Skip to content

feat(creator-keys): add get_protocol_status view for #792 - #1084

Merged
Chucks1093 merged 1 commit into
accesslayerorg:mainfrom
cold-13:feat/792-protocol-status
Oct 18, 2026
Merged

Chucks1093 merged 1 commit into
accesslayerorg:mainfrom
cold-13:feat/792-protocol-status

Conversation

@cold-13

@cold-13 cold-13 commented Oct 18, 2026

Copy link
Copy Markdown

Summary

Closes #792

The server needs to read the global trading paused state (and related protocol config) from the contract to back the GET /protocol/status endpoint. This PR adds a get_protocol_status() read-only view function that returns all required fields in a single RPC call.

Changes

  • New ProtocolStatus struct (contracttype): global_trading_paused (bool), protocol_fee_bps (u32), treasury_address (Option<Address>), lockup_duration_seconds (u64), min_investment_amount (i128). Fields are append-only per the repo's XDR field-stability convention.
  • New get_protocol_status(env: Env) -> ProtocolStatus view on CreatorKeysContract (no auth required):
    • Reads GLOBAL_TRADING_PAUSED, FEE_CONFIG (protocol bps), TREASURY_ADDRESS, LOCKUP_DURATION_SECS, and the new MIN_INVESTMENT_AMOUNT key from persistent storage.
    • Falls back to documented defaults for unset entries: false, DEFAULT_PROTOCOL_FEE_BPS (100), None, DEFAULT_LOCKUP_DURATION_SECS (86_400), and 0 respectively — so the function never panics regardless of storage state.
    • Bumps the TTL of every persistent entry it reads via bump_persistent_ttl (extend_ttl on an absent key is a no-op), so actively polled config never expires.
  • New DataKey::MinInvestmentAmount variant (appended at the end of the enum, preserving ABI discriminant stability) and its constants::storage::MIN_INVESTMENT_AMOUNT alias. No setter is added in this PR; the field reads 0 until a setter lands, per the issue scope.

Acceptance Criteria

  • global_trading_paused returned correctly when set; defaults to false when unset
  • protocol_fee_bps and treasury_address returned correctly
  • lockup_duration_seconds and min_investment_amount returned correctly
  • TTL bumped on all read entries
  • Function never panics regardless of storage state

Test plan

Per the assignment, no tests were run locally. Reviewers should verify:

  • cargo build -p creator-keys --target wasm32v1-none compiles
  • The new view compiles into the generated client as get_protocol_status
  • Defaults and TTL-bump behaviour match the acceptance criteria above

Add a read-only get_protocol_status() view returning an aggregated
ProtocolStatus struct (global_trading_paused, protocol_fee_bps,
treasury_address, lockup_duration_seconds, min_investment_amount) so
the server can back GET /protocol/status in a single RPC call.

- Unset config entries fall back to documented defaults so the view
  never panics regardless of storage state
- TTLs of all read persistent entries are bumped on every call
- New MinInvestmentAmount DataKey appended to the enum (ABI-safe)
@drips-wave

drips-wave Bot commented Oct 18, 2026

Copy link
Copy Markdown

@cold-13 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 bb4b3dd into accesslayerorg:main Oct 18, 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

Development

Successfully merging this pull request may close these issues.

Add a protocol status function exposing the global trading paused state as a readable contract entry

3 participants