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

Custom ABIs #60

Open
LesterLyu opened this issue Sep 13, 2023 · 3 comments
Open

Custom ABIs #60

LesterLyu opened this issue Sep 13, 2023 · 3 comments

Comments

@LesterLyu
Copy link

Is there any way to add custom ABIs via config, the ABIs from 4byte.directory may not always correct.

@zemse
Copy link
Owner

zemse commented Sep 13, 2023

If you just add interfaces in your contracts folder, that should be used and given more preference than 4bytes dir. You can also turn off usage of 4bytes using this config.

@LesterLyu
Copy link
Author

LesterLyu commented Sep 14, 2023

I have the interfaces defined in the contracts folder, but it still prefers to pick from the 4bytes dir in a special case.

Assuming the interface is function someFunction(bytes calldata data) and the data is only 10 bytes.
The function call is below in yul:

let contractAddress := `some address`
// 4 bytes sighash + 32 bytes data size + 10 bytes data
// If do the function call in solidity, the insize will be 4 + 32 + 32, but including the ending zeros is not necessary and consumes more gas
let insize := 46 
pop(call(gas(), contractAddress, 0, 0, insize, 0, 0))

If insize is 4 + 32 + 32, it will pick the interfaces from the contract folder.

@zemse
Copy link
Owner

zemse commented Sep 14, 2023

Hmm, interesting. I'm using ethers.js ABI decoder which expects the calldata to be adhering to the ABI spec. If you are not passing the zeros for the last value, it works in solidity because it doesn't check calldata length. Solidity also accepts more bytes in calldata than needed but ethers would throw an exception for these both cases.

Maybe it could be fine to fill missing bytes by not requiring exact calldata length to reflect the behaviour of solidity, I can try patching it on my side.

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

No branches or pull requests

2 participants