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

feat!: v1 encoding and encoding improvements #1780

Merged
merged 36 commits into from
Feb 23, 2024

Conversation

danielbate
Copy link
Contributor

@danielbate danielbate commented Feb 20, 2024

Following the process set out in #1672, this PR introduces encoding support following the v1 specification. Currently this is just unit tested as v1 encode has not yet been supported in contract calls.

This PR also introduces multiple version support through getEncodingStrategy. There is alot of room for improvement within getCoderV1 however this will be refactored, as discussed in #1672.

This PR lays the foundations for #1739 and #1749, once those have been unblocked by the Sway encoding PRs.

Breaking Change
As we would like towards a more functional approach, and given abi-coder is subject to a lot of change at the moment, I have moved the package to the correct naming conventions for classes and functions.

@danielbate danielbate added feat Issue is a feature mainnet labels Feb 20, 2024
@danielbate danielbate self-assigned this Feb 20, 2024
Copy link
Member

@arboleya arboleya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This kind of renaming will likely turn this PR into a breaking change, no?

@danielbate danielbate changed the title feat: v1 encoding and encoding improvements feat!: v1 encoding and encoding improvements Feb 20, 2024
@danielbate danielbate marked this pull request as ready for review February 20, 2024 16:37
Torres-ssf
Torres-ssf previously approved these changes Feb 22, 2024
nedsalk
nedsalk previously approved these changes Feb 22, 2024
Copy link
Contributor

@nedsalk nedsalk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Dhaiwat10
Dhaiwat10 previously approved these changes Feb 22, 2024
Copy link
Member

@Dhaiwat10 Dhaiwat10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a huge fan of your work sir @danielbate 👏🏻

arboleya

This comment was marked as resolved.

Copy link
Contributor

Coverage Report:

Lines Branches Functions Statements
79.45%(-0.56%) 70.28%(-0.77%) 77.91%(-0.09%) 79.52%(-0.55%)
Changed Files:
Ok File (✨=New File) Lines Branches Functions Statements
🔴 ✨ packages/abi-coder/src/AbiCoder.ts 75%
(+75%)
100%
(+100%)
66.66%
(+66.66%)
75%
(+75%)
🔴 ✨ packages/abi-coder/src/FunctionFragment.ts 73.52%
(+73.52%)
70.96%
(+70.96%)
81.81%
(+81.81%)
74.66%
(+74.66%)
🔴 ✨ packages/abi-coder/src/Interface.ts 61.76%
(+61.76%)
50%
(+50%)
76.47%
(+76.47%)
61.11%
(+61.11%)
🔴 ✨ packages/abi-coder/src/ResolvedAbiType.ts 98.57%
(+98.57%)
100%
(+100%)
94.73%
(+94.73%)
98.66%
(+98.66%)
✨ packages/abi-coder/src/encoding/coders/AbstractCoder.ts 100%
(+100%)
100%
(+100%)
100%
(+100%)
100%
(+100%)
✨ packages/abi-coder/src/encoding/coders/v0/ArrayCoder.ts 100%
(+100%)
100%
(+100%)
100%
(+100%)
100%
(+100%)
✨ packages/abi-coder/src/encoding/coders/v0/B256Coder.ts 100%
(+100%)
100%
(+100%)
100%
(+100%)
100%
(+100%)
✨ packages/abi-coder/src/encoding/coders/v0/B512Coder.ts 100%
(+100%)
100%
(+100%)
100%
(+100%)
100%
(+100%)
✨ packages/abi-coder/src/encoding/coders/v0/BooleanCoder.ts 100%
(+100%)
100%
(+100%)
100%
(+100%)
100%
(+100%)
✨ packages/abi-coder/src/encoding/coders/v0/ByteCoder.ts 100%
(+100%)
100%
(+100%)
100%
(+100%)
100%
(+100%)
✨ packages/abi-coder/src/encoding/coders/v0/EnumCoder.ts 100%
(+100%)
100%
(+100%)
100%
(+100%)
100%
(+100%)
✨ packages/abi-coder/src/encoding/coders/v0/NumberCoder.ts 100%
(+100%)
100%
(+100%)
100%
(+100%)
100%
(+100%)
🔴 ✨ packages/abi-coder/src/encoding/coders/v0/OptionCoder.ts 91.66%
(+91.66%)
87.5%
(+87.5%)
100%
(+100%)
91.66%
(+91.66%)
✨ packages/abi-coder/src/encoding/coders/v0/RawSliceCoder.ts 100%
(+100%)
100%
(+100%)
100%
(+100%)
100%
(+100%)
✨ packages/abi-coder/src/encoding/coders/v0/StdStringCoder.ts 100%
(+100%)
100%
(+100%)
100%
(+100%)
100%
(+100%)
✨ packages/abi-coder/src/encoding/coders/v0/StringCoder.ts 100%
(+100%)
100%
(+100%)
100%
(+100%)
100%
(+100%)
✨ packages/abi-coder/src/encoding/coders/v0/StructCoder.ts 100%
(+100%)
100%
(+100%)
100%
(+100%)
100%
(+100%)
✨ packages/abi-coder/src/encoding/coders/v0/TupleCoder.ts 100%
(+100%)
100%
(+100%)
100%
(+100%)
100%
(+100%)
✨ packages/abi-coder/src/encoding/coders/v0/U64Coder.ts 100%
(+100%)
100%
(+100%)
100%
(+100%)
100%
(+100%)
✨ packages/abi-coder/src/encoding/coders/v0/VecCoder.ts 100%
(+100%)
100%
(+100%)
100%
(+100%)
100%
(+100%)
✨ packages/abi-coder/src/encoding/coders/v1/BooleanCoder.ts 100%
(+100%)
100%
(+100%)
100%
(+100%)
100%
(+100%)
🔴 ✨ packages/abi-coder/src/encoding/coders/v1/ByteCoder.ts 93.75%
(+93.75%)
83.33%
(+83.33%)
100%
(+100%)
93.75%
(+93.75%)
🔴 ✨ packages/abi-coder/src/encoding/coders/v1/EnumCoder.ts 78.04%
(+78.04%)
68.75%
(+68.75%)
100%
(+100%)
78.04%
(+78.04%)
✨ packages/abi-coder/src/encoding/coders/v1/NumberCoder.ts 100%
(+100%)
100%
(+100%)
100%
(+100%)
100%
(+100%)
🔴 ✨ packages/abi-coder/src/encoding/coders/v1/RawSliceCoder.ts 94.44%
(+94.44%)
83.33%
(+83.33%)
100%
(+100%)
94.44%
(+94.44%)
✨ packages/abi-coder/src/encoding/coders/v1/StdStringCoder.ts 100%
(+100%)
100%
(+100%)
100%
(+100%)
100%
(+100%)
✨ packages/abi-coder/src/encoding/coders/v1/StrSliceCoder.ts 100%
(+100%)
100%
(+100%)
100%
(+100%)
100%
(+100%)
✨ packages/abi-coder/src/encoding/coders/v1/StringCoder.ts 100%
(+100%)
100%
(+100%)
100%
(+100%)
100%
(+100%)
🔴 ✨ packages/abi-coder/src/encoding/coders/v1/StructCoder.ts 95%
(+95%)
83.33%
(+83.33%)
100%
(+100%)
95%
(+95%)
✨ packages/abi-coder/src/encoding/coders/v1/TupleCoder.ts 100%
(+100%)
100%
(+100%)
100%
(+100%)
100%
(+100%)
✨ packages/abi-coder/src/encoding/coders/v1/VecCoder.ts 100%
(+100%)
100%
(+100%)
100%
(+100%)
100%
(+100%)
✨ packages/abi-coder/src/encoding/strategies/getCoderForEncoding.ts 100%
(+100%)
100%
(+100%)
100%
(+100%)
100%
(+100%)
🔴 ✨ packages/abi-coder/src/encoding/strategies/getCoderV0.ts 90%
(+90%)
84.37%
(+84.37%)
100%
(+100%)
90.19%
(+90.19%)
🔴 ✨ packages/abi-coder/src/encoding/strategies/getCoderV1.ts 2%
(+2%)
0%
(+0%)
0%
(+0%)
1.96%
(+1.96%)
✨ packages/abi-coder/src/encoding/strategies/getCoders.ts 100%
(+100%)
100%
(+100%)
100%
(+100%)
100%
(+100%)
🔴 ✨ packages/abi-coder/src/utils/constants.ts 97.29%
(+97.29%)
100%
(+100%)
0%
(+0%)
97.29%
(+97.29%)
🔴 ✨ packages/abi-coder/src/utils/utilities.ts 96.72%
(+96.72%)
91.3%
(+91.3%)
93.33%
(+93.33%)
96.87%
(+96.87%)

@arboleya arboleya enabled auto-merge (squash) February 23, 2024 17:42
@arboleya arboleya merged commit 1918470 into master Feb 23, 2024
12 of 13 checks passed
@arboleya arboleya deleted the db/feat/v1-encoding-improvements branch February 23, 2024 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Issue is a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants