question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Any easy way to validate a function signature?

See original GitHub issue

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!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
slavik0329commented, Dec 2, 2020

@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!

1reaction
ricmoocommented, Nov 23, 2020

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. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there a way to check a function's signature in Python?
You can use: import inspect len(inspect.getargspec(foo_func)[0]). This won't acknowledge variable-length parameters, like: def foo(a, b, *args, ...
Read more >
Python - Get Function Signature - GeeksforGeeks
We can get function Signature with the help of signature() Function. It takes callable as a parameter and returns the annotation.
Read more >
MATLAB validateFunctionSignaturesJSON - MathWorks
This MATLAB function displays validation messages for the functionSignatures.json file in the current folder.
Read more >
How to Validate Digital Signatures | Kofax Power PDF
Simple Steps for Validating Time Stamps. Some digital signatures have an additional timestamp element added to them to demonstrate the exact date and...
Read more >
Javascript Functions & Parameters and Best Coding Practises ...
In this video, I teach you all about javascript functions and their parameters/ arguments. I also show you how you can protect your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found