gnosis-safe – Fixing Error in safeSdk.executeTransaction() with Gnosis Safe Core SDK

gnosisgnosis-safesafe-core-sdk

I have a safe with 1 owner and 1 threshold. I am trying to do a simple token transfer transaction but getting an error.

// 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
    }
}

After this, proposing the transaction to the gnosis server successfully, now when I fetch the transaction again in order to execute it, the data field comes as null.

{
    "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
}

After converting this multisig transaction into the safe transaction, the below execute transaction function gives an error –

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)

I am simply following this guide and doing what is mentioned here. Would be grateful if someone could help me in resolving this.

Best Answer

This is a current shortcoming of the sdk/service combination (see https://github.com/gnosis/safe-core-sdk/issues/125). The best is to add a fallback when converting the tx: data: transaction.data || "0x"

Related Topic