Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

bug: safe sdk having trouble with value-less write transactions #346

Closed
1 task done
razgraf opened this issue Jun 16, 2023 · 1 comment
Closed
1 task done

bug: safe sdk having trouble with value-less write transactions #346

razgraf opened this issue Jun 16, 2023 · 1 comment

Comments

@razgraf
Copy link

razgraf commented Jun 16, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Using prepareWriteContract without an explicit value will work fine with most connectors except within a Safe environment.

Note: I wasn't sure if I should publish this here, but figured it's best to keep it close to where the Safe SDK is being used.

Expected Behavior

prepareWriteContract should count the optional value parameter (or {value: undefined}) as a non-payable transaction and proceed with the setup (e.g. simulateContract, ...) without trying to make use of that param.

Steps To Reproduce

While walletClients provided by regular connectors like Metamask will work fine and process the transaction flow, within Safe the transaction will fail with the following error:

Screenshot 2023-06-15 at 23 37 11

As you can see, it attempts to convert undefined to what probably is an ethers.BigNumber instance used by the Safe SDK.

A quick fix was to explicitly attribute 0n to the value argument (no ETH passing through) in prepareWriteContract.

Link to Minimal Reproducible Example (CodeSandbox, StackBlitz, etc.)

No response

Anything else?

Side-note: I imagine the Safe integration needs to be revisited in light of the viem update, as well as due to other issues such as wevm/wagmi#2461

H/T @gavriliumircea

@jxom
Copy link
Member

jxom commented Jun 25, 2023

Should be fixed in @wagmi/connectors@2.5.0 (the safe sdk viem upgrade)!

@jxom jxom closed this as completed Jun 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants