Ethers.js

Gnosis safe-core-sdk:EthersAdapter 提供空對象

  • January 10, 2022

我正在嘗試在我們的 Dapp 上使用 safe-core-sdk,但是即使簽名者從提供者那裡獲得的 EthersAdapter 實例創建工作正常,它也總是給出空對象在此處輸入圖像描述

使用的庫:ether.js ^5.5.2,“bnc-onboard”:“^1.35.4”,

在下面附上控制台螢幕截圖和程式碼

 const safeService = new SafeServiceClient(transactionServiceUrl);
       const onboard = initOnboard({
           address: setAddress,
           network: setNetwork,
           balance: setBalance,
           wallet: wallet => {
               setWallet(wallet);

               if (wallet.provider) {
                   console.info(`${wallet.name} is connected`);

                   const ethersProvider = new Web3Provider(wallet.provider);
                   console.log(ethersProvider.getSigner());
                   // signerAddress(ethersProvider.getSigner());
                   const ethersAdapter = new EthersAdapter({
                       ethers: ethers,
                       signer: ethersProvider.getSigner(0),
                   });
                   console.log(ethersAdapter);
                   setEthersAdaptor(ethersAdapter);
                   // provider = ethersProvider;
                   setProvider(ethersProvider);

                   window.localStorage.setItem("selectedWallet", wallet.name);
               } else {
                   // provider = null;

                   setProvider(false);
                   setWallet({});
               }
           },
       });

如果你擴展它,你能看到 EthersAdapter 類中的方法嗎?

在此處輸入圖像描述

引用自:https://ethereum.stackexchange.com/questions/118520