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

add fillInputData option argument to formatTransaction on call function in rpc_method_wrappers #6378

Closed
wants to merge 2 commits into from

Conversation

moshmage
Copy link
Contributor

@moshmage moshmage commented Aug 24, 2023

Description

The fillInputData option on formatTransaction call that was introduced with this change left eth_call method unchanged. In my case, 4.1.0 + hardhat was unable to call a simple ERC20.name() returning unkown function selector (even if the contract had a fallback).

Adding this argument to the function call when call() is made fixed it on my side.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

@moshmage moshmage changed the title add fillInputData option argument to on call function on rpc_method_wrappers add fillInputData option argument to formatTransaction on call function in rpc_method_wrappers Aug 24, 2023
@luu-alex
Copy link
Contributor

Hey there @moshmage . As well I have a pr that addresses different issues related to that change, but i'll merge this branch with mines. Thanks a ton for opening this PR and if there are any other issues you are facing, feel free to open another issue/pr

@luu-alex luu-alex closed this Sep 2, 2023
@luu-alex
Copy link
Contributor

luu-alex commented Sep 5, 2023

Hey there @moshmage do you have an code snippet you can share of how your using this code? it'll help me out a ton :)

@moshmage
Copy link
Contributor Author

moshmage commented Sep 5, 2023

Hey there @moshmage do you have an code snippet you can share of how your using this code? it'll help me out a ton :)

sure @luu-alex -- head over to https://github.com/moshmage/dappkit/blob/3.x.x/test/models/base-model.spec.ts#L59 (where it fails the test): the await model.contract.methods.name().call() is calling the web3js implementation (.contract.methods = new web3.eth.Contract(abi, address).methods). This will only fail on a hardhat local chain (I tested it against a ganache fork of ethereum and it went smoothly). you can check the contract here https://github.com/moshmage/dappkit/blob/3.x.x/contracts/token/ERC20/ERC20.sol#L41 (excuse the mess, in the process of cleaning up ^^')

You can read how to set-up a dev-env on https://github.com/moshmage/dappkit/blob/3.x.x/how-to/contributing/readme.md

ps: The way I got to the "fill input data was" that I just echoed out the json params that web3js@1.x.x was doing against the current version and noticed that the 1.x.x call had data and input, and not just one - after adding the fillInputData: true to a local-fork of web3js the tests went by smoothly as well.

@luu-alex
Copy link
Contributor

luu-alex commented Sep 5, 2023

Thanks alot this is really helpful!

We are actually trying to get away from using the default call to be both data and input, we made the default to be only filling input in the eth_call and I think the error you are running into is due to hardhat could only be accepting data.

I'll be adding to the PR so that you can use a flag when creating your contract to include in your method calls to either send data, input or both. Does this solution work for you?

@moshmage
Copy link
Contributor Author

moshmage commented Sep 5, 2023

Thanks alot this is really helpful!

We are actually trying to get away from using the default call to be both data and input, we made the default to be only filling input in the eth_call and I think the error you are running into is due to hardhat could only be accepting data.

I'll be adding to the PR so that you can use a flag when creating your contract to include in your method calls to either send data, input or both. Does this solution work for you?

Being fair to hardhat, the only place where input is documented is on geth execution-apis documentation repo here -- everywhere else, input is not even mentioned (including eth.org oficial docs)

That said, as long as web3js plays ball with hardhat it'll be cool by me;

But I'm afraid that this change will add a "we will deal with any and all edge-cases" precedent and I don't wanna be the cause for it :P

Wouldn't it be better if we go to the handleRevert route and have it on the Web3Config, instead of "per contract" basis -- that way userland can simply turn the option on and be done with it - no need to understand the underlyings of the Contract class ^^

@luu-alex
Copy link
Contributor

luu-alex commented Sep 6, 2023

I understand, i'm not too sure why the geth documentation and eth official docs are different but we have been trying hard to follow the geth repo as much as possible.

I think your suggestion is great! It will be included as a web3config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Data is missing from methods.myMethod
3 participants