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

fixed parsing of ABIs with tuples + wrong gas info when transactionOptions created from json #379

Merged
merged 4 commits into from
Oct 29, 2021

Conversation

izakpavel
Copy link
Contributor

related to the issues #358 (#358)
and #353 #353

@BaldyAsh BaldyAsh merged commit 4ad1217 into web3swift-team:develop Oct 29, 2021
subpointer = subpointer + consumedUnwrapped
}
else {
subpointer = consumedUnwrapped // need to go by nextElementPointer
Copy link
Collaborator

Choose a reason for hiding this comment

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

Breaks decoding of arrays that contain any type that is not static.
That would be string, dynamicBytes, array and tuple that contain non-static types.

@izakpavel Could you please explain what you meant by this comment?

// need to go by nextElementPointer

Thanks!

Copy link
Collaborator

@JeneaVranceanu JeneaVranceanu Mar 12, 2022

Choose a reason for hiding this comment

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

Here is an example with values that I'm working with.
What I'm doing is encoding two arrays and using that result as an argument for the decoding function.

This is the first array to be encoded.
ABI.Element.ParameterType is array(bytes(32)):

[0] - 0xdf30dba06db6a30e65354d9a64c609861f089545ca58c6b4dbe31a5f338cb0e3
[1] - 0x4b80742d0000000082ac000022300fd00e3402df12db7a0a054fae50f0bf91d7
[2] - 0x027545a85de73f6a6ec5ce14736fa7eb00000000000000000000000000000002

This is the second array to encoded.
ABI.Element.ParameterType is array(dynamicBytes) even though in this specific example all values are 32 bytes long:

[0] - 0x0000000000000000000000000000000000000000000000000000000000000003
[1] - 0x00000000000000000000000000000000000000000000000000000000000003fe
[2] - 0x22300fd00e3402df12db7a0a054fae50f0bf91d7000000000000000000000000

And this is how they are decoded:
Array with bytes(32):

[0] - 0xdf30dba06db6a30e65354d9a64c609861f089545ca58c6b4dbe31a5f338cb0e3
[1] - 0x4b80742d0000000082ac000022300fd00e3402df12db7a0a054fae50f0bf91d7
[2] - 0x027545a85de73f6a6ec5ce14736fa7eb00000000000000000000000000000002

Array with dynamicBytes:

[0] - 0x0000000000000000000000000000000000000000000000000000000000000003
[1] - 0x00000000000000000000000000000000000000000000000000000000000003fe
[2] - 0x00000000000000000000000000000000000000000000000000000000000003fe

Copy link
Collaborator

Choose a reason for hiding this comment

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

@BaldyAsh Please, take a look at this issue. It feels like reverting line 144 back to

subpointer = subpointer + consumedUnwrapped

would fix the issue.

Note: tested the suggestion above in a fork of web3swift and it does indeed fix the issue.
I'll test later with array(tuple) type as @izakpavel had issues with it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

array(tuple) does break indeed if line 144 is reverted to its previous logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants