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: incorrect JSON serialization on FieldElement #74

Closed
xJonathanLEI opened this issue Feb 24, 2022 · 1 comment · Fixed by #75
Closed

Bug: incorrect JSON serialization on FieldElement #74

xJonathanLEI opened this issue Feb 24, 2022 · 1 comment · Fixed by #75
Assignees
Labels
bug Something isn't working

Comments

@xJonathanLEI
Copy link
Owner

xJonathanLEI commented Feb 24, 2022

So when working on #62 I found out about a critical bug on the FieldElement type that's basically breaking all contract deployments and calls. This code doesn't work:

let num = FieldElement::from_hex_be("0x1").unwrap();
let text = serde_json::to_string(&num).unwrap();
assert_eq!(text, "\"1\"");

Fails with:

thread 'tests::test_json_ser' panicked at 'assertion failed: `(left == right)`
  left: `"\"0\""`,
 right: `"\"1\""`', starknet-ff/src/lib.rs:450:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@xJonathanLEI xJonathanLEI added the bug Something isn't working label Feb 24, 2022
@xJonathanLEI xJonathanLEI self-assigned this Feb 24, 2022
@xJonathanLEI
Copy link
Owner Author

Looks like checked_rem on crypto_bigint::U256 is causing the issue. It's returning 0 for the operation.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant