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

utf-8 valid char not supported in string in Native #94

Open
julianzamt opened this issue Oct 24, 2023 · 4 comments
Open

utf-8 valid char not supported in string in Native #94

julianzamt opened this issue Oct 24, 2023 · 4 comments
Labels
Backlog Stuff to be done in the future Bug This is an item that causes unwanted behavior

Comments

@julianzamt
Copy link

Describe the bug
Passing Chévere as a string param in Native throws with:
panicked at \'called Result::unwrap()on anErr value: Custom { kind: InvalidData, error: "invalid utf-8 sequence of 1 bytes from index 2" }\'

In Anchor the same string works fine.

To Reproduce
Anchor test, works fine:
image

Native test, fails:
image

Expected behavior
To allow any utf-8 char in a string in native.

Platform version:

  • CLI Version [e.g. v0.1.0]
  • GenService Version v0.8

Extension (mark with an X the extension):

  • Solana Native [x]
  • Solana Anchor [ ]
@julianzamt julianzamt added Bug This is an item that causes unwanted behavior Triage This item needs to be prioritize labels Oct 24, 2023
@julianzamt
Copy link
Author

After further research, the issue is originated in a bug in the borsh-js 1.0.0 library, which serializes a non ascii char in one single byte instead of following utf-8.

To solve this issue, we need to change the current library.
Anchor uses borsh-js 0.7.0
Another library that has been tested on works fine is borsh-ts 5.1.8

Both libraries have been tested and work fine.

Because both solutions have different serdes syntax code than borsh 1.0.0, this fix will require to change client code generation, and probably the ts-config.ts generated file (both make use of ts classes to define the schema)

@gagdiez
Copy link

gagdiez commented Nov 21, 2023

@julianzamt borsh-js developer here, indeed this is a bug from our library, will see to get the patch expedited, please check if this solves the problem on your side:
near/borsh-js#76

@gagdiez
Copy link

gagdiez commented Nov 24, 2023

@julianzamt it should be fixed now with version v2.0

@julianzamt
Copy link
Author

@julianzamt it should be fixed now with version v2.0

Thanks! I'll be checking this asap

@JazielGuerrero JazielGuerrero added Backlog Stuff to be done in the future and removed Triage This item needs to be prioritize labels Dec 4, 2023
@JazielGuerrero JazielGuerrero removed their assignment Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backlog Stuff to be done in the future Bug This is an item that causes unwanted behavior
Projects
None yet
Development

No branches or pull requests

3 participants