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

fix: encoding ints/uints #854

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

janndriessen
Copy link
Collaborator

Summary of Changes

  • Fixes the ABI encoding of int and uint which was not taking the bits parameter into account

Test Data or Screenshots

  • Fixes and updates tests in ABIEncoderTest
By submitting this pull request, you are confirming the following:
  • I have reviewed the Contribution Guidelines.
  • I have performed a self-review of my own code.
  • I have updated my repository to match the develop branch.
  • I have included test data or screenshots that prove my fix is effective or that my feature works.
  • I have checked that all tests work and swiftlint is not throwing any errors/warnings.

// This one shouldn't have data offset
hexData = ABIEncoder.encode(types: [.array(type: .uint(bits: 8), length: 4)], values: [[1, 2, 3, 4]])?.toHexString()
// First 32 bytes are the first value from the array
XCTAssertEqual(hexData?[0..<64], "0000000000000000000000000000000000000000000000000000000000000001")
XCTAssertEqual(hexData, "0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000004")
// XCTAssertEqual(hexData?[0..<32], "0000000000000000000000000000000000000000000000000000000000000001")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Wasn't sure about this line. @JeneaVranceanu @yaroslavyaroslav

Is it actually needed or could it be deleted? Because of the bug fix of uint bits this hex string is now signficantly shorter.

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.

1 participant