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: add support for encoding bytes1 to bytes32 + fix incorrect encoding uintN #427

Merged
merged 5 commits into from
Apr 28, 2024

Conversation

CJ42
Copy link
Collaborator

@CJ42 CJ42 commented Apr 25, 2024

What kind of change does this PR introduce (bug fix, feature, docs update, ...)?

⭐ Feature
🐛 Bug Fix

What is the current behaviour (you can also link to an open issue here)?

Bug

When encoding uintN in tuples and the valueContent is Number, these are always encoded to a uint256 as a 32 bytes long value because of the following line in the code:

case 'Number': {
return {
type: 'uint256',
encode: (value: string) => {
let parsedValue: number;
try {
parsedValue = Number.parseInt(value, 10);
} catch (error: any) {
throw new Error(error);
}
return padLeft(numberToHex(parsedValue), 64);
},
decode: (value) => Number(hexToNumber(value)),
};
}

Missing Feature

Additionally, there is only support for few bytesN types, like bytes2, bytes4, bytes8, etc...

What is the new behaviour (if this is a feature change)?

This the padding for the encoding of uintN and bytesN + add support for multiple bytesN

@CJ42 CJ42 force-pushed the fix/tuple-encoding-number branch from ba31885 to 1db6f2f Compare April 25, 2024 12:34
@CJ42 CJ42 marked this pull request as ready for review April 25, 2024 17:11
@CJ42 CJ42 merged commit a218ef3 into develop Apr 28, 2024
2 checks passed
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.

2 participants