feat(json-abi): add full_signature #480
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
I’m working on a ABI fragments database so we can fill in function and event data for contracts that haven’t been verified, but we having a matching ABI fragment for from another contract.
We’re going to have each row be unique based on the
full_signature
, which includes the name of each param, for events, whether the param is indexed or not, and for functions, the state mutabilityIn
ethers.js
, there is a fragmentFormatTypes.full
that can generate the full signature for you.https://docs.ethers.org/v5/api/utils/abi/fragments/#fragments--output-formats
some maximally illustrative examples:
function batchSwapExactIn(tuple(address pool, uint256 tokenInParam, uint256 tokenOutParam, uint256 maxPrice)[] swaps, address tokenIn, address tokenOut, uint256 totalAmountIn, uint256 minTotalAmountOut) payable returns (uint256 totalAmountOut)
event SetupDirectDebit(address indexed debtor, address indexed receiver, tuple(uint256 amount, uint256 startTime, uint256 interval) info)
Solution
I've added a
.full_signature()
function to theFunction
andEvent
structsPR Checklist
Notes
Functions already have
signature_full
that includes the output types. This is pretty close tofull_signature
as a name. Are we fine with that or do we need to think of a different name forfull_signature
?I thought about trying to overload some of the functions instead of making additional functions prepended with
full_
, but I don’t think it’d make it any cleaner.