Repository navigation
Feat/1037 key discovery registry - #1058
Open
Bolajiomo99 wants to merge 2 commits into
Open
Bolajiomo99 wants to merge 2 commits into
Bolajiomo99 wants to merge 2 commits into
Conversation
|
@Bolajiomo99 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! 🚀 |
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
This PR introduces the
key-discovery-registrycontract, a new on-chain discovery index for creator keys. It tracks keys deployed through the creator-keys factory, records per-key trade volume over rolling windows, and exposes sorted discovery views ("trending" and "new keys").Key features:
register_key(caller, key_id, creator)records deployment metadata (key_id,creator,deploy_timestamp). Only the admin or an authorisedregistrarmay call this. Re-registering the same key is rejected.record_volume(caller, key_id, amount)appends a positive volume entry for a registered key. Entries older than 48 hours are pruned on write. Only the admin or an authorisedrecordermay call this.get_trending(limit)returns top keys by 24h volume (descending), ties broken by earlier deployment; keys with zero 24h volume are omitted.get_new_keys(since_timestamp, limit)returns keys deployed at/aftersince_timestamp, newest-first.prune(key_id)removes records older than 48h (callable by anyone). Read-only helpers:get_volume_24h,get_volume_entries,get_key_info,get_registered_count.initialise(admin)(one-time),set_registrar(registrar, allowed),set_recorder(recorder, allowed). All admin operations require auth.key_reg(key_id)withKeyInfopayload;vol_rec(key_id)withVolumeEntrypayload.The crate is added to the workspace. Unit tests cover registration/auth, volume windows/pruning, trending ordering, and new-keys filtering.
closes #1037
Testing
cargo fmt --all -- --checkcargo clippy -p key-discovery-registry --all-targets -- -D warningscargo test -p key-discovery-registryChecklist
key-discovery-registry/src/test.rscovering success and failure paths (unauthorised, duplicate registration, non-positive amount, unregistered key, pruning, trending, new keys). Nocreator-keysbehavior changed, so no newcreator-keystests required.cargo fmt --all -- --check,cargo clippy --workspace --all-targets -- -D warnings, andcargo test --workspace(all workspace tests pass; unrelated snapshot artifacts modified during workspace test run were reverted to keep scope clean)docs/storage-key-invariants.md. New contract uses instance/persistent storage under its own DataKey namespace (Admin,Initialised,Registrar,Recorder,KeyInfo,KeyIndex,Volume). No existing storage keys are modified.(EVENT_NAME, key_id)as topic and the corresponding struct as payload (KeyInfoforkey_reg,VolumeEntryforvol_rec). Order/meanings align with existing Soroban event conventions.key-discovery-registrycontract, workspace member addition, and its tests. No unrelated formatting, generated artifacts, or unnecessary dependency changes.