Repository navigation
feat(creator-keys): add get_protocol_status view for #792 - #1084
Merged
Merged
Conversation
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)
|
@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! 🚀 |
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
Closes #792
The server needs to read the global trading paused state (and related protocol config) from the contract to back the
GET /protocol/statusendpoint. This PR adds aget_protocol_status()read-only view function that returns all required fields in a single RPC call.Changes
ProtocolStatusstruct (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.get_protocol_status(env: Env) -> ProtocolStatusview onCreatorKeysContract(no auth required):GLOBAL_TRADING_PAUSED,FEE_CONFIG(protocol bps),TREASURY_ADDRESS,LOCKUP_DURATION_SECS, and the newMIN_INVESTMENT_AMOUNTkey from persistent storage.false,DEFAULT_PROTOCOL_FEE_BPS(100),None,DEFAULT_LOCKUP_DURATION_SECS(86_400), and0respectively — so the function never panics regardless of storage state.bump_persistent_ttl(extend_ttlon an absent key is a no-op), so actively polled config never expires.DataKey::MinInvestmentAmountvariant (appended at the end of the enum, preserving ABI discriminant stability) and itsconstants::storage::MIN_INVESTMENT_AMOUNTalias. No setter is added in this PR; the field reads0until a setter lands, per the issue scope.Acceptance Criteria
global_trading_pausedreturned correctly when set; defaults tofalsewhen unsetprotocol_fee_bpsandtreasury_addressreturned correctlylockup_duration_secondsandmin_investment_amountreturned correctlyTest plan
Per the assignment, no tests were run locally. Reviewers should verify:
cargo build -p creator-keys --target wasm32v1-nonecompilesget_protocol_status