-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Internal improvement: Move selector computation from codec
into abi-utils
#5465
Conversation
This makes sense! Good call. |
More specifically the reason it came up is because I'm planning a substantial Codec breakage to deal with this internal function pointers problem. :P Btw, you may notice I added the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a question about the regex type matching, but otherwise looks good!
packages/abi-utils/lib/signature.ts
Outdated
const tupleMatch = parameter.type.match(/tuple(.*)/); | ||
if (tupleMatch === null) { | ||
//does not start with "tuple" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment says does not start with tuple
but the regex doesn't use ^
. Is that correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops! Good catch. This code will work anyway, because there's no other place that tuple
can occur, but I should change it to not rely on that, thanks.
Putting the label back on at @gnidan's insistence. |
This PR moves code for computing signatures and selectors from
codec
intoabi-utils
. Note that we continue to re-export these functions from Codec, in order to avoid a breaking change. I also added a few tests of these functions inabi-utils
-- not property-based, sorry, I couldn't figure out a good way to do that. On top of that, I expanded theabi-utils
README to cover this new functionality.Since this PR is mostly just moving code around and not changing it, there's not a lot to say here about the code itself. However, I wanted to record why I'm doing this.
Basically, it comes back to the abi-to-sol problem. I want to be able to make breakiing changes to Codec without a repeat of the problem that caused last time (see #5396 for an explanation). This is the only code from Codec that abi-to-sol uses. Moving it to abi-utils will of course not get rid of the problem, but it reduces it, since it means that the problem will only come up when we break abi-utils rather than when we break codec. Since we break abi-utils hardly ever, and break codec somewhat frequently, this acts as a stopgap to allow us to avoid problems until we figure out a better solution.