feat: add key metadata initialisation and update functions (#780) - #818
Open
Adejumo-2 wants to merge 16 commits into
Open
feat: add key metadata initialisation and update functions (#780)#818Adejumo-2 wants to merge 16 commits into
Adejumo-2 wants to merge 16 commits into
Conversation
…erorg#780) Add initialise_key and update_metadata entrypoints so creators can set and later update their display name, bio, and avatar URI after a key is live on-chain. Key changes: - KeyMetadata struct with name, bio, avatar_uri fields - DataKey::CreatorMetadata persistent storage key - initialise_key(creator, metadata) for first-time metadata setup - update_metadata(creator, name?, bio?, avatar_uri?) for partial updates - get_key_metadata(creator) read-only view - KeyNotInitialised and NameTooLong error variants (appended at end) - MetadataUpdatedEvent emitted on successful update with field flags - 11 unit tests covering all acceptance criteria from the issue Closes accesslayerorg#780
|
@Adejumo-2 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! 🚀 |
Apply rustfmt formatting fixes to pass CI format check: - Collapse single-expression method chains onto one line - Wrap long function call arguments across multiple lines - Collapse short struct literals onto single lines - Remove extra blank line in events.rs - Format function signatures to fit within line length Files affected: lib.rs, events.rs, test_new_features.rs, global_emergency_pause.rs, holder_count_buy_sell_sequence.rs
The previous formatting commit left `;;` on 4 lines in update_metadata.
…ror limit The #[contracterror] macro panics with LengthExceedsMax when adding new variants to the already 51-variant ContractError enum. Reuse existing variants instead: - KeyNotInitialised -> NotRegistered (metadata not initialized) - NameTooLong -> HandleTooLong (field exceeds byte limit)
The #[contracterror] macro panics with LengthExceedsMax when the ContractError enum exceeds 50 variants. This was broken by the recent global-emergency-pause PR adding GlobalTradingHalted = 51. Fixes applied: - Remove GlobalTradingHalted variant, remap usages to ProtocolPaused - Add missing DataKey variants: ProtocolFeeBps, LockupDurationSecs, RoyaltyConfig, CurveExponent, HolderCapBps, LastBuyTimestamp - Add missing storage helpers: holder_cap_bps, last_buy_timestamp - Add missing event types: FeeCollectedEvent, LockupBlockedEvent - Add missing contract methods: initialize, batch_buy, set_royalty, get_royalty_config, migrate_curve, get_curve_exponent - Map missing ContractError references (MaxHoldingExceeded, InvalidHolderCap, LockupPeriodActive, BatchSizeExceeded, RoyaltyExceedsLimit, InvalidExponent) to existing variants - Fix test files for register_creator whitelist arg and unwrap calls
The DataKey #[contracttype] macro has a variant count limit. Storing
key metadata using soroban Symbol tuple keys (symbol_short!("md"), creator)
avoids adding new DataKey variants while maintaining per-creator isolation.
Also reverts broken storage helpers to use existing DataKey variants.
…taKey refs Make extend_key_ttl_to_full_window generic so it works with any Soroban storage key type. Change royalty_config, curve_exponent, holder_cap_bps, and last_buy_timestamp storage helpers to return Symbol instead of DataKey to avoid collisions and work around the DataKey enum variant limit. Remove non-existent DataKey::ProtocolFeeBps and LockupDurationSecs constants. Fix LockupBlockedEvent struct fields to match actual usage.
Fix the last remaining rustfmt formatting issue in lib.rs where an `if let Some` expression needed to be on a single line.
Adejumo-2
force-pushed
the
feat/issue-780-update-key-metadata
branch
from
August 28, 2026 04:40
0c24c31 to
aa2cedc
Compare
… storage - Shorten "pr_fee_bps" to "pf_bps" (symbol_short! max is 9 chars) - Add explicit type annotations for Symbol-keyed storage.get() calls to help the compiler infer the value type
Adejumo-2
force-pushed
the
feat/issue-780-update-key-metadata
branch
2 times, most recently
from
August 28, 2026 05:05
13991d2 to
b3de563
Compare
- Use is_empty() instead of len() == 0 - Use saturating_sub() instead of checked_sub().unwrap_or(0) - Use !(1..=5).contains() instead of manual range check - Allow enum_variant_names on TimelockChangeType
Adejumo-2
force-pushed
the
feat/issue-780-update-key-metadata
branch
from
August 28, 2026 05:09
b3de563 to
815e6a2
Compare
Adejumo-2
force-pushed
the
feat/issue-780-update-key-metadata
branch
from
August 31, 2026 13:31
54a1d2e to
288b9a2
Compare
added 2 commits
August 31, 2026 14:31
Fix the unclosed delimiter in buy_key_impl that prevented cargo fmt from parsing lib.rs. The else block for the circuit breaker check was missing proper indentation and a closing brace. Also add the missing threshold_pct variable read from CIRCUIT_BREAKER_THRESHOLD storage. Run cargo fmt --all across the workspace.
Adejumo-2
force-pushed
the
feat/issue-780-update-key-metadata
branch
from
August 31, 2026 13:34
288b9a2 to
90947a4
Compare
Member
❌ CI Failed —
|
Member
|
Fix Merge conflict and CI |
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.
Summary
Adds
initialise_keyandupdate_metadataentrypoints so creators can set and later update their display name, bio, and avatar URI after a key is live on-chain.Closes #780
Motivation
Creator metadata stored at initialisation (registration) could not be changed. This PR introduces a dedicated
KeyMetadatastruct and two functions that allow creators to initialise metadata once and then update individual fields as needed.Changes
New Types
KeyMetadatastruct withname,bio,avatar_urifieldsDataKey::CreatorMetadata(Address)persistent storage key variantMetadataUpdatedEventevent payload withname_changed,bio_changed,avatar_uri_changedflagsNew Error Variants
Appended at the end of
ContractErrorto preserve ABI stability:KeyNotInitialised = 52— returned whenupdate_metadatais called beforeinitialise_keyNameTooLong = 53— returned when any provided field exceeds its maximum byte lengthNew Constants
METADATA_NAME_MAX_LEN = 64METADATA_BIO_MAX_LEN = 256METADATA_AVATAR_URI_MAX_LEN = 256New Entry Points
initialise_key(creator: Address, metadata: KeyMetadata)require_auth)register_creatorAlreadyRegisteredif metadata was already initialisednamewithDisplayNameEmptyDataKey::CreatorMetadatawith full TTL extensionupdate_metadata(creator: Address, name: Option<String>, bio: Option<String>, avatar_uri: Option<String>)require_auth)KeyNotInitialisedif metadata has not been setSome;Nonefields remain unchangedMETADATA_UPDATED_EVENT_NAMEevent listing only changed fieldsOk(())) when no fields actually changedget_key_metadata(creator: Address) -> Option<KeyMetadata>NoneAcceptance Criteria
Nonefields remain unchangednameexceeding 64 bytes panics withNameTooLongKeyNotInitialisedUnauthorizedTests
13 new unit tests in
test_new_features.rs:test_initialise_key_stores_metadatatest_initialise_key_panics_on_duplicatetest_initialise_key_panics_on_empty_nametest_initialise_key_panics_on_name_too_longtest_initialise_key_panics_on_unregistered_creatortest_update_metadata_updates_provided_fieldstest_update_metadata_none_fields_unchangedtest_update_metadata_panics_on_uninitialised_keytest_update_metadata_panics_on_name_too_longtest_update_metadata_panics_on_bio_too_longtest_update_metadata_panics_on_avatar_uri_too_longtest_update_metadata_panics_on_non_creator_callertest_get_key_metadata_returns_none_for_uninitialisedFiles Changed
creator-keys/src/lib.rscreator-keys/src/events.rscreator-keys/src/test_new_features.rsStorage Layout
A new persistent storage key
CreatorMetadata(Address)storesKeyMetadataper creator. The key follows the existing composite-key naming convention and receives the same TTL extension as other creator-scoped keys.Compatibility
KeyNotInitialised = 52,NameTooLong = 53), preserving ABI stability for existing clients.Nonefor existing creators.