Skip to content

feat(stellar): integrate on-chain metadata resolver for wraith-names - #150

Open
OTimileyin wants to merge 2 commits into
wraith-protocol:mainfrom
OTimileyin:main
Open

feat(stellar): integrate on-chain metadata resolver for wraith-names#150
OTimileyin wants to merge 2 commits into
wraith-protocol:mainfrom
OTimileyin:main

Conversation

@OTimileyin

Copy link
Copy Markdown

Closes #119

Summary

Add optional on-chain metadata resolver for wraith-names, allowing name
owners to attach text records and content hashes to their .wraith names,
similar to ENS text records. The feature is opt-in, owner-gated, and avoids
the resolution hot path.

Changes

New: src/metadata.rs

  • MetadataEntry struct with text_records: Map<String, String> and
    content_hash: BytesN<32>
  • MetadataError enum with 5 dedicated error codes (101–105):
    MetadataKeyTooLong, MetadataValueTooLong, MetadataRecordTooLong,
    MetadataTotalTooLong, MetadataNotFound
  • Validation functions with per-record (key ≤ 64B, value ≤ 256B) and total
    (≤ 1024B) size limits
  • Unit tests for validation logic

Modified: src/lib.rs

  • DataKey::Metadata(BytesN<32>) storage key variant for per-name metadata
  • 5 new NamesError variants (50–54) for metadata error propagation
  • set_metadata(env, owner, name, metadata) — owner-gated setter with full
    validation
  • get_metadata(env, name) — public reader, returns NameNotFound or
    MetadataNotFound
  • Metadata cleanup on release() — metadata is removed when a name is
    released
  • MetadataUpdated event emission on metadata changes

Hot path untouched

  • resolve() and name_of() remain completely unchanged — no metadata
    lookups added to the resolution path

Tests

  • test_set_and_get_metadata — happy path with avatar + twitter records
  • test_set_metadata_not_owner — non-owner rejected with NotOwner
  • test_set_metadata_key_too_long — 65B key → MetadataKeyTooLong
  • test_set_metadata_value_too_long — 257B value → MetadataValueTooLong
  • test_set_metadata_total_too_long — 5 records × 210B → MetadataTotalTooLong
  • test_get_metadata_not_found — name exists, no metadata → MetadataNotFound
  • test_get_metadata_unregistered_name — name doesn't exist → NameNotFound
  • test_metadata_cleaned_on_release — metadata removed when name is released
  • test_hot_path_unchanged_after_metadataresolve() and name_of() work
    identically before/after metadata
  • 3 existing metadata.rs module tests for isolated validation

All 17 wraith-names tests pass, cargo fmt clean, zero warnings.

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