Gnosis-Safe

呼叫“safeSdk.executeTransaction()”時出錯

  • January 10, 2022

我有一個有 1 個所有者和 1 個門檻的保險箱。我正在嘗試進行簡單的令牌轉移交易,但出現錯誤。

// Able to create and sign transaction off-chain successfully

{
   "signatures": {}, // here signature is present
   "data": {
       "to": "0x213C77a6d109c300a3851DE1e42553Ad47f8187e",
       "value": "1000",
       "data": "0x", // Notice here data is not null
       "operation": 0,
       "baseGas": 0,
       "gasPrice": 0,
       "gasToken": "0x0000000000000000000000000000000000000000",
       "refundReceiver": "0x0000000000000000000000000000000000000000",
       "nonce": 3,
       "safeTxGas": 0
   }
}

在此之後,成功地向 gnosis 伺服器提出事務,現在當我再次獲取事務以執行它時,該data欄位為空。

{
   "safe": "0x3C0574fb0FC4F6FFd765724DEC593017b636797a",
   "to": "0x213C77a6d109c300a3851DE1e42553Ad47f8187e",
   "value": "1000",
   "data": null, // Here data is null, I am not able to get it
   "operation": 0,
   "gasToken": "0x0000000000000000000000000000000000000000",
   "safeTxGas": 0,
   "baseGas": 0,
   "gasPrice": "0",
   "refundReceiver": "0x0000000000000000000000000000000000000000",
   "nonce": 0,
   "executionDate": null,
   "submissionDate": "2022-01-04T11:55:15.816271Z",
   "modified": "2022-01-04T11:55:15.837756Z",
   "blockNumber": null,
   "transactionHash": null,
   "safeTxHash": "0x38aaff98405aba4cd7ad988ea711c6db4f3a75a118f168f6b9e2cd44638e00ef",
   "executor": null,
   "isExecuted": false,
   "isSuccessful": null,
   "ethGasPrice": null,
   "gasUsed": null,
   "fee": null,
   "origin": null,
   "dataDecoded": null,
   "confirmationsRequired": null,
   "confirmations": [
       {
           "owner": "0x213C77a6d109c300a3851DE1e42553Ad47f8187e",
           "submissionDate": "2022-01-04T11:55:15.837756Z",
           "transactionHash": null,
           "signature": "0x705868eb79f838f303553e95e79d7fe84c38a6433b4d432c66569f0c6db8066d608f4b816e70e7ff614056222db9ad7f1fe7fa0bb354c1db6c9db4b0376dc47c1f",
           "signatureType": "ETH_SIGN"
       }
   ],
   "signatures": null
}

將此多重簽名交易轉換為安全交易後,以下執行交易功能會出錯 -

const executeTxResponse = await safeSdk.executeTransaction(safeTransaction)

TypeError: Cannot read properties of null (reading 'length')
   at ABICoder.formatParam (index.js?8fce:247)
   at eval (index.js?8fce:99)
   at Array.map (<anonymous>)
   at ABICoder.encodeParameters (index.js?8fce:93)
   at eval (index.js?7bbc:450)
   at Array.map (<anonymous>)
   at Object._encodeMethodABI (index.js?7bbc:449)
   at Object._processExecuteArguments (index.js?7bbc:713)
   at Object._executeMethod (index.js?7bbc:732)
   at GnosisSafeContract_V1_3_0_Web3.getTransactionHash (GnosisSafeContractWeb3.js?528e:34)
   at Safe.getTransactionHash (Safe.js?3512:232)
   at Safe.executeTransaction (Safe.js?3512:420)
   at _callee13$ (safe.js?273a:280)
   at tryCatch (runtime.js?2d8a:45)
   at Generator.invoke [as _invoke] (runtime.js?2d8a:274)
   at Generator.prototype.<computed> [as next] (runtime.js?2d8a:97)
   at asyncGeneratorStep (asyncToGenerator.js?d70f:3)
   at _next (asyncToGenerator.js?d70f:25)

我只是遵循本指南並執行此處提到的操作。如果有人可以幫助我解決這個問題,將不勝感激。

這是 sdk/service 組合的目前缺點(參見https://github.com/gnosis/safe-core-sdk/issues/125)。最好是在轉換 tx 時添加一個備份:data: transaction.data || "0x"

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