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

🐛 [BUG] - encodeBytes32String() is padding on the left instead of right side #840

Closed
ifavo opened this issue May 2, 2024 · 0 comments · Fixed by #846
Closed

🐛 [BUG] - encodeBytes32String() is padding on the left instead of right side #840

ifavo opened this issue May 2, 2024 · 0 comments · Fixed by #846
Assignees

Comments

@ifavo
Copy link
Contributor

ifavo commented May 2, 2024

Description

When using encodeBytes32String('1') is behaving different than ethers' version.
The result is padded with zero's to the left instead of the right.

  • For example encoding 1 results with the vechain sdk to: 0x0000000000000000000000000000000000000000000000000000000000000031
  • ethers does encode 1 to: 0x3100000000000000000000000000000000000000000000000000000000000000

I would expect both functions to generate identical outputs.

Reproduction URL

https://www.val.town/v/ifavo/encodeBytes32String

Reproduction steps

import { dataUtils } from "npm:@vechain/sdk-core";
import * as ethers from "npm:ethers";

const data = "1";
console.log("dataUtils.encodeBytes32String:", dataUtils.encodeBytes32String(data));
console.log("ethers.encodeBytes32String:", ethers.encodeBytes32String(data));

Screenshots

![DESCRIPTION](LINK.png)

Logs

No response

OS

No response

@ifavo ifavo changed the title 🐛 [BUG] - dataUtils.encodeBytes32String() is left instead of right padding 🐛 [BUG] - encodeBytes32String() is padding on the left instead of right side May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants