-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Any easy way to validate a function signature? #1101
Comments
You need a bit more for a signature, but you could glue boiler plate around it, but you could use something like |
@ricmoo I tried this before. The problem is that it doesn’t verify that the types
are valid when I create the fragments. It will create a fragment out of
invalid types.
…On Tue, Oct 13, 2020 at 4:58 PM Richard Moore ***@***.***> wrote:
See: https://docs.ethers.io/v5/api/utils/abi/fragments/
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1101 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAC4SBFTAG4GOOBJXNHG4RDSKS5NTANCNFSM4SPUDXJA>
.
|
@ricmoo Heres an example: It does not seem to do any type checking on the parameters. |
Hmmm. It shouldn’t have done that, but now I realize I can’t change that in a backwards compatible way. It will be corrected in v6. In the meantime, I should be able to get something together to help you verify signatures. I’m almost done EIP-712 and have 2 other things to get to, but there is something I wanted to get around to adjacent to what you are trying to solve. :) |
@ricmoo Hey, have you had a chance to work on this? No big deal if not, just wondering. |
Yes! I have something locally that I think will do exactly what you want. And be generally useful for now and the future... Just running a bit more testing on it first. Basically, it will allow you to compute the default values for a given set of parameters. So, you can use it like this: // Works:
const fragment = ethers.utils.FunctionFragment.from("transfer(uint32 num1,address from,bool isTrue)");
console.log(ethers.utils.defaultAbiCoder.getDefaultValue(fragment.inputs));
/*
[ 0,
'0x0000000000000000000000000000000000000000',
false,
num1: 0,
from: '0x0000000000000000000000000000000000000000',
isTrue: false ]
*/
// Throws an Error:
const fragment = ethers.utils.FunctionFragment.from("transfer(uAint8 num1,addressed to)");
console.log(ethers.utils.defaultAbiCoder.getDefaultValue(fragment.inputs)); The CI system seems down right now, but let me know what you think and I'll try to get this out as soon as possible. :) |
The above functionality has been added in 5.0.22. Try it out and let me know if you have any problems. Thanks! :) |
@ricmoo Amazing! This is exactly what I was hoping for. Works great. Thank you so much for releasing this patch, it will be very useful to me and most likely many others! |
For example:
uint32 num1,address from,bool isTrue
should validate to true while
uAint8 num1,addressed to
should be false.
The only thing Ive found that does validation is the Abicoder encode function, however I have to provide values for it to work.
Thanks!
The text was updated successfully, but these errors were encountered: