Skip to content

feat(contract): add creator registration status, treasury address view, key balance helper, and duplicate registration rejection#33

Merged
Chucks1093 merged 1 commit into
accesslayerorg:mainfrom
Akanimoh12:feat/issue-28-29-30-31-contract-view-helpers
Mar 26, 2026
Merged

feat(contract): add creator registration status, treasury address view, key balance helper, and duplicate registration rejection#33
Chucks1093 merged 1 commit into
accesslayerorg:mainfrom
Akanimoh12:feat/issue-28-29-30-31-contract-view-helpers

Conversation

@Akanimoh12

Copy link
Copy Markdown
Contributor

Summary

This PR adds four contract improvements covering read-only view methods, a shared helper for safe key balance reads, and duplicate creator registration rejection with focused tests.

Closes #28, Closes #29, Closes #30, Closes #31


Issue #28 — Read-only creator registration status method

  • Added is_creator_registered(env, creator) -> bool contract method that returns whether a CreatorProfile exists for the given address.
  • No state mutation; safe for indexers and read-only callers.
  • Tests cover: unregistered address returns false, registered returns true, read-only idempotency, and independent creator lookups.

Issue #29 — Read-only protocol treasury address method

  • Added DataKey::TreasuryAddress storage variant.
  • Added set_treasury_address(env, admin, treasury) admin-only setter.
  • Added get_treasury_address(env) -> Option<Address> read-only view method returning the current treasury routing target, or None if unconfigured.
  • Tests cover: unset returns None, configured returns correct address, read-only idempotency, and updates after reconfiguration.

Issue #30 — Safe key balance read helper

  • Added read_key_balance(env, creator) -> u32 public shared helper that reads a creator's key supply, returning 0 for unregistered creators.
  • Refactored get_total_key_supply to delegate to read_key_balance, eliminating duplicated read logic.
  • Missing-balance behavior is now consistent across the contract.
  • All existing key supply tests continue to pass.

Issue #31 — Duplicate registration rejection tests

  • Added a guard in register_creator that panics with "creator already registered" when the creator address already has a stored profile.
  • Tests cover: duplicate registration with same handle panics, duplicate with different handle panics, and distinct addresses register independently.

Verification

All three CI checks pass locally:

cargo fmt --all -- --check   ✓
cargo clippy --workspace --all-targets -- -D warnings   ✓
cargo test --workspace   ✓  (45 tests, 0 failures)

Files changed

…w, key balance helper, and duplicate registration rejection

- Add is_creator_registered read-only view method (accesslayerorg#28)
- Add get_treasury_address and set_treasury_address methods (accesslayerorg#29)
- Add read_key_balance shared helper for safe key balance reads (accesslayerorg#30)
- Add duplicate creator registration rejection with tests (accesslayerorg#31)
- Refactor get_total_key_supply to use read_key_balance helper
@drips-wave

drips-wave Bot commented Mar 26, 2026

Copy link
Copy Markdown

@Akanimoh12 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! 🚀

Learn more about application limits

@Chucks1093 Chucks1093 merged commit 7bc6806 into accesslayerorg:main Mar 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants