Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

callStatic: "Error: call cannot override value" #847

Closed
crazyrabbitLTC opened this issue May 22, 2020 · 3 comments
Closed

callStatic: "Error: call cannot override value" #847

crazyrabbitLTC opened this issue May 22, 2020 · 3 comments
Labels
enhancement New feature or improvement. fixed/complete This Bug is fixed or Enhancement is complete and published.

Comments

@crazyrabbitLTC
Copy link

Before doing a transaction, I am trying to use "callStatic" to simulate a transaction/call in order to check if the transaction/call will revert, and if yes- grab the Revert reason to display to the user.

      const tempOverride = { value: ethers.utils.parseEther(value) }
      await writeContract.callStatic[methodName](...methodParams, tempOverride)

If I have a payable function, and I attempt to try callStatic with my method name, params and the override with my value, I get the following error:

Error:  Error: call cannot override value
    at ethers.umd.js:9394
    at Array.forEach (<anonymous>)
    at ethers.umd.js:9392
    at async sendTx (sendTx.ts:34)
    at async handleRunMethod (Reducer.tsx:235)
instrument.ts:129 Tx will revert. Message:  undefined 

Am I wrong in thinking I should be able to use callStatic with a value on a payable function? This might be related to my other issue:

#845

@ricmoo
Copy link
Member

ricmoo commented May 23, 2020

Yes, you are correct. I will relax this check too. I'm looking at that function in general and contemplating a larger refactor overall...

I'll look into this now too. :)

@ricmoo ricmoo added enhancement New feature or improvement. on-deck This Enhancement or Bug is currently being worked on. labels May 23, 2020
@ricmoo
Copy link
Member

ricmoo commented May 30, 2020

This should be fixed now in 5.0.0-beta.189. The Contract has been fairly refactored and should allow value for calls.

Please try it out and let me know if you have any further issue. Thanks! :)

edit: part of the response was for another similar issue and I didn't read close enough which I was responding to; I've updated the above explanation.

@ricmoo ricmoo added fixed/complete This Bug is fixed or Enhancement is complete and published. and removed on-deck This Enhancement or Bug is currently being worked on. labels May 30, 2020
@crazyrabbitLTC
Copy link
Author

Seems to work! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement. fixed/complete This Bug is fixed or Enhancement is complete and published.
Projects
None yet
Development

No branches or pull requests

2 participants