web3-onboard: [Bug]: Gnosis Safe provider does not pick gas limit nor reports errors

Current Behavior

When using the Gnosis Safe provider, the app does not pick the predefined gas limit for the transaction nor it throws an error when the execution of the transaction fails. It didn’t use to be the case a few months ago.

Expected Behavior

I expect the Safe App to pick the predefined gas limit I have computed for that transaction and to throw an error whenever the transaction execution fails.

Steps To Reproduce

  1. I’m using:
"@web3-onboard/react": "2.3.2",
"@web3-onboard/gnosis": "^2.1.2",
  1. Go to https://gnosis-safe.io/ and create a safe for your app.
  2. Then connect using the @web3-onboard/gnosis provider.
  3. Start a transaction.
  4. Notice the gas limit is not being picked up by the value you have computed before sending the transaction to the provider.

What package is effected by this issue?

@web3-onboard/gnosis

Is this a build or a runtime issue?

Runtime

Package Version

2

Node Version

No response

What browsers are you seeing the problem on?

Chrome

Relevant log output

No response

Anything else?

The Safe App does report in the console the errors, however those are not surfaced to the application. I’m using ethers@^5.7.0 and calling await transaction.wait() but the promise never resolves nor rejects.

Sanity Check

  • If this is a build issue, I have included my build config. If this is a runtime issue, I have included reproduction steps and/or a Minimal, Reproducible Example.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 36 (34 by maintainers)

Most upvoted comments

Hey @Adamj1232, here is a summary of what we are doing to generate the transaction (simplified React code, it won’t work if you copy paste because of lifecycles):

// 1. We get a contract instance using Ethers and the provider obtained from @web3-onboard
const [{ wallet}] = useConnectWallet();
const connectedWalletProvider = new ethers.providers.Web3Provider(
    wallet.provider
);
const signer = connectedWalletProvider.getSigner();
const contractInstance = new ethers.Contract(
    contractAddress,
    abi,
    signer
);

// 2. We populate the transaction setting a gas limit explicitly
const populatedTransaction = contractInstance.populateTransaction.someFunction(
    someArg1,
    someArg2,
    {
      gasLimit: 400000,
    }
);

// 3. We send the populated transaction via the signer and wait on it
const transaction = await signer.sendTransaction(populatedTransaction);
await transaction.wait();

After running that, see the gas limit is not being set to the amount specified:

Screenshot 2022-10-14 at 11 04 24

Then, about the transaction failure not being reported. If I execute the same transaction but set the gas limit low enough to force the transaction to fail, I see these errors in the console but the transaction.wait() call never resolves:

Screenshot 2022-10-14 at 12 17 43

You can see the transaction failed on MetaMask:

Screenshot 2022-10-14 at 12 18 24

And here is the transaction on explorer.

While trying this, I have also found that if I set the Nonce value on the Advanced Parameters dialog, the transaction prompt I’m getting on the wallet does not use it but rather uses the next available one:

Screenshot 2022-10-14 at 11 25 50 Screenshot 2022-10-14 at 11 26 47

I (somewhat) understand you, but I can say the same thing: dApp estimations on gas prices and gas limits are also way too often wrong. Especially for smart contract wallets

@mikhailxyz Agreed too, OpenSea being one of them as an example. The difference is that you are leaving place for dApp to make their own judgements and go for your recommendations or stick with theirs. As of right now, dApps are forced to follow your recommendations, which fall short for our business as an example. Hope this conversation makes you reconsider this topic or at least start a conversation about it internally. Thank you again for your help here 😁

@mikhailxyz thank you for chiming in! I am trying to catch the 803 event(or the error message more closely related to the error occurring) from the Safe to pass along through the provider. The error seems to always be converted to Error: Transaction was rejected even if the transaction was canceled in the wallet or there was a gas error. Do you know if there is way to get the intrinsic gas too low error message from the Safe so it can be passed through the Web3-Onboard package? It seems in this case the MetaMask error is being caught by the Safe and not passed. Screen Shot 2022-10-21 at 10 25 24 AM

I’m not sure what’s the problem here, the error happened after the “transaction was rejected” error that was returned by the SDK. So why would an error happening later be passed? Perhaps I do not understand the problem very well.

Apologies sent, the wrong screenshot. The error occurs before the SDK return the Transaction was rejected after the intrinsic gas too low error but that verbiage isn’t passed along with the error object. Screen Shot 2022-10-21 at 10 43 15 AM Code producing err for context. Happens both with SDK.txs.send and using the bare with eth_sendTransaction

eth_sendTransaction: async ({baseRequest, txs}) => {
  try {
    const transactionHash = await appsSdk.txs.send({txs})
    return transactionHash
  } catch (e) {
    console.log(e)
  }
}

We’ll check this. Agree the error message could be improved

@enzoferey Thanks for raising this issue! We’ll take a look this week and see what the issue is!