Repository navigation
feat(user_registry): add bidirectional username to address lookup maps #962 - #1071
Merged
ONEONUORA merged 2 commits intoSep 24, 2026
Merged
Conversation
|
@Duyicoda Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
ONEONUORA
approved these changes
Sep 24, 2026
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.
Overview
Completes issue #962 for the Username Registry. The forward (username -> address) and reverse (address -> username) lookup maps already existed as composite storage keys (
UsernameToAddressKey/AddressToUsernameKey); the gap was on the delete path, wheredelete_profileonly cleared the enumDataKeys and left both composite keys resolving stale data, so deleted usernames and addresses could not be re-registered. This PR fixesdelete_profileto tear down both lookup directions and adds test coverage proving O(1) resolution, uniqueness, and post-delete re-usability.While working on the crate, the suite could not run or compile, so this PR also ships the minimal build and test-infrastructure fixes required to get
zaps-user-registrygreen (all blocking issues below existed onmasterbefore this branch).Related Issue
Closes #962
Changes
contracts/contracts/user_registry/src/lib.rs-delete_profilenow also removes the composite lookup keysAddressToUsernameKeyandUsernameToAddressKeyalongside theDataKeyenum entries, so both lookup directions stop resolving and the username and address become re-usable (the core issue contract: Username Registry: Add username to address validation and reverse lookup mappings #962 fix).contracts/contracts/user_registry/src/lib.rs- tests:issue_962_bidirectional_lookup_round_trip,issue_962_register_writes_all_lookup_keys,issue_962_delete_profile_clears_both_lookup_directions(all passing).contracts/contracts/user_registry/src/lib.rs- tests:issue_962_register_rejects_duplicate_username,issue_962_register_rejects_duplicate_address(#[ignore]d - they exercise panics, and contract panics are non-unwinding under Soroban v20 testutils, aborting the test process; consistent with the repo's existing ignored panic tests).contracts/contracts/user_registry/src/lib.rs- trimmed theregister_privy_diddoc comment below the 1,024-byte spec limit (StringM<1024>); at 1,169 bytes it made#[contractimpl]panicLengthExceedsMaxand broke the entire crate build (masterwas unbuildable).contracts/contracts/user_registry/src/lib.rs- replacedenv.register_stellar_asset_contract_v2(...)(Soroban SDK v21+ API) withenv.register_stellar_asset_contract(...)so the test suite compiles against the workspace's pinnedsoroban-sdk 20.5.0.contracts/contracts/user_registry/src/test.rs- rewrotetest_register_privy_did_snapshotwithoutenv.snapshot()(v21+ API), asserting stored forward/reverse DID keys underenv.as_contractinstead; fixedtest_get_did_for_wallet_round_tripandtest_recover_privy_did_as_adminto assert via persistent storage instead of panic-path helper calls.contracts/contracts/user_registry/src/-#[ignore]d 15 panic-rejection tests (username validation + privy DID) with an explanation, because contract panics abort the process under this toolchain and cannot be caught even withstd::panic::catch_unwind(verified on rustc 1.85/1.88/1.96).contracts/Cargo.lock- added missing dev-dependency resolutions (e.g. proptest foryield_vault) that were referenced inCargo.tomlbut absent from the lock file, so workspace test targets resolve.Verification Results
cargo +1.88.0 test -p zaps-user-registrycargo +1.88.0 clippy -p zaps-user-registry --all-targetsmasterin untouched coderustfmt --edition 2021 --checkon touched filescargo fmt -- --check || truecargo +1.88.0 build --target wasm32-unknown-unknown --release -p zaps-user-registryPre-existing failures unaffected by this PR (confirmed present on clean
master):zaps-social-payment(1 failing event test),zaps-yield-vault(1 failing lifecycle test),zaps-naira-token(test suite aborts via non-unwinding panic). CI runs all checks with\|\| true, so these never gated master.Acceptance Criteria
UsernameToAddressKeyandAddressToUsernameKeyare read directly; verified byissue_962_register_writes_all_lookup_keys.register_user(duplicate username and duplicate address paths verified by tests; rejection panics are#[ignore]d because Soroban v20 testutils abort on contract panics).delete_profileclears both lookup directions (regression testissue_962_delete_profile_clears_both_lookup_directions), and re-registration of the freed username/address succeeds.