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

[bcs] Add documentation for BCS #817

Merged
merged 1 commit into from
Feb 12, 2025
Merged

[bcs] Add documentation for BCS #817

merged 1 commit into from
Feb 12, 2025

Conversation

gregnazario
Copy link
Collaborator

Description

BCS docs for how to serialize in multiple languages.

This is a first pass, will need to make updates to finish the last ones, but some of this was generated with AI to shorten the coding time

Checklist

  • If any existing pages were renamed or removed:
    • Were redirects added to next.config.mjs?
    • Did you update any relative links that pointed to the renamed / removed pages?
  • Do all Lints pass?
    • Have you ran pnpm fmt?
    • Have you ran pnpm lint?

@gregnazario gregnazario requested a review from a team as a code owner February 12, 2025 02:57
Copy link

vercel bot commented Feb 12, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
developer-docs-nextra ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 12, 2025 2:59am

// Serialize
let val: u256 = 10000000000000000;
let bytes: vector<u8> = bcs::to_bytes(&val);
assert!(bytes == vector[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x9c, 0x4f, 0x2c, 0x68, 0x00, 0x00]);
Copy link
Contributor

Choose a reason for hiding this comment

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

The u256 bytes vector contains 34 bytes but the specification requires exactly 32 bytes. Please remove the trailing 0x00, 0x00 from the vector to match both the specification and the examples in other languages.

Spotted by Graphite Reviewer

Is this helpful? React 👍 or 👎 to let us know.

@gregnazario gregnazario merged commit 7a7095e into main Feb 12, 2025
5 of 6 checks passed
@gregnazario gregnazario deleted the add-bcs-docs branch February 12, 2025 03:50
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