Skip to content

refactor: use semantically correct ICRC-3 types for attribute values#3770

Open
sea-snake wants to merge 7 commits intosea-snake/icrc3-attributesfrom
sea-snake/icrc3-text-types
Open

refactor: use semantically correct ICRC-3 types for attribute values#3770
sea-snake wants to merge 7 commits intosea-snake/icrc3-attributesfrom
sea-snake/icrc3-text-types

Conversation

@sea-snake
Copy link
Copy Markdown
Contributor

@sea-snake sea-snake commented Apr 10, 2026

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_attributes to use the appropriate ICRC-3 Value type for each entry:

Key Before After Reason
Attribute values (email, name, verified_email) Blob Text Human-readable strings
implicit:origin Blob Text URL string
implicit:issued_at_timestamp_ns Blob (string bytes) Nat Numeric value
implicit:nonce Blob Blob (unchanged) Raw 32 bytes

Test app (auth.ts, index.html, index.tsx)

  • Added optional icrc3Nonce parameter (base64 input field) so an app-supplied nonce can be used instead of a random one.

Tests

  • Updated unit tests in icrc3_attribute_message_tests to use Icrc3Value::Text and verify decoded values.
  • Updated integration test assertions for implicit:origin (Text) and implicit:issued_at_timestamp_ns (Nat).
  • Updated e2e test helper from decodeIcrc3BlobEntries to decodeIcrc3TextEntries to extract Text variant entries.
  • Added e2e verification of all implicit entries: implicit:origin is Text, implicit:nonce is a 32-byte Blob, and implicit:issued_at_timestamp_ns is a Nat > 0.
  • Added "with app-supplied nonce" e2e test that passes a known nonce and verifies it appears byte-for-byte in the decoded ICRC-3 map.

← Previous: #3768
Next: #3771

- 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)
@sea-snake sea-snake requested a review from a team as a code owner April 10, 2026 13:14
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