refactor: use semantically correct ICRC-3 types for attribute values#3770
Open
sea-snake wants to merge 7 commits intosea-snake/icrc3-attributesfrom
Open
refactor: use semantically correct ICRC-3 types for attribute values#3770sea-snake wants to merge 7 commits intosea-snake/icrc3-attributesfrom
sea-snake wants to merge 7 commits intosea-snake/icrc3-attributesfrom
Conversation
- Attribute values (email, name, verified_email): Blob → Text - implicit:origin: Blob → Text - implicit:issued_at_timestamp_ns: Blob (string bytes) → Nat - implicit:nonce: stays Blob (raw 32 bytes)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The ICRC-3 attribute message encoded all values as
Blob, even for human-readable strings and numeric timestamps. Using the semantically correct ICRC-3 Value types makes the encoded message more self-describing and easier to decode on the client side.Changes
Backend (
attributes.rs)Updated
prepare_icrc3_attributesto use the appropriate ICRC-3 Value type for each entry:BlobTextimplicit:originBlobTextimplicit:issued_at_timestamp_nsBlob(string bytes)Natimplicit:nonceBlobBlob(unchanged)Test app (
auth.ts,index.html,index.tsx)icrc3Nonceparameter (base64 input field) so an app-supplied nonce can be used instead of a random one.Tests
icrc3_attribute_message_teststo useIcrc3Value::Textand verify decoded values.implicit:origin(Text) andimplicit:issued_at_timestamp_ns(Nat).decodeIcrc3BlobEntriestodecodeIcrc3TextEntriesto extractTextvariant entries.implicit:originisText,implicit:nonceis a 32-byteBlob, andimplicit:issued_at_timestamp_nsis aNat> 0.