Repository navigation
Conversation
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.
Closes #470
Adds
contracts/docs/contracts-proposals-storage.md: the storage layout of theproposalscontract (DataKey,Proposal,ProposalStatusand the transitions the code actually permits, vote tracking, the event structs instorage.rs) and the typed client it uses to callgroup_treasury. Style follows the existingcontracts/docs/*.mdfiles (overview → keys → types → interface → gaps,File:linecitations inline).What the doc covers
DataKeyvariant with its storage type and value type, plus which function writes it.ProposalStatusvalues, with a transition table saying which transitions the code allows, which it refuses, and which test pins each one. Includes the two boundary asymmetries:finalize_proposalacceptsnow == expires_atwhilefinalize_expired_proposalrefuses it, andApprovedis declared but no code path ever assigns it.DataKey::Vote(u64, Address) -> boolentry is the double-vote guard, alongside the aggregateyes_votes/no_votescounters thatfinalize_proposalactually reads.#[contractclient]trait, how the contract ID comes fromProposal.treasuryand is handed toTreasuryClient::new, and the three ordered calls (is_member,balance,withdraw) with the guard each one feeds.One thing to flag
treasury_interface_client.rsis a single comment line —// Intentionally left empty - this file was generated automatically.— and is not declared in the module tree, so it is never compiled. The typed client the issue asks about is generated by the#[contractclient(name = "TreasuryClient")]attribute on the trait intreasury_interface.rs. The doc documents that file as the empty placeholder it is and points at the macro instead, rather than describing a mechanism that does not exist in it.Acceptance criteria → evidence
ProposalData Structurestorage.rs:3-9(DataKey),storage.rs:22-39(Proposal); writes atlib.rs:46,lib.rs:93-95,lib.rs:96-98,lib.rs:133,lib.rs:140-142,lib.rs:176-178,lib.rs:204-206,lib.rs:225-227,lib.rs:280-282; reads atlib.rs:42,lib.rs:73-77,lib.rs:130,lib.rs:298-303ProposalStatusvaluesProposalStatusand Permitted Transitionsstorage.rs:11-20; assignments atlib.rs:86,lib.rs:171,lib.rs:173,lib.rs:203,lib.rs:224,lib.rs:279;Approvedreferenced only atstorage.rs:15,lib.rs:241,lib.rs:254lib.rs:66,lib.rs:69,lib.rs:121-123,lib.rs:125-127,lib.rs:162,lib.rs:166,lib.rs:170,lib.rs:173,lib.rs:195,lib.rs:199,lib.rs:221,lib.rs:250,lib.rs:253; tests:create_then_vote_then_pass_then_execute_happy_path,finalize_with_more_no_votes_rejects,finalize_with_a_tie_rejects,finalize_with_zero_votes_rejects,finalize_before_expiry_panics,finalize_twice_panics,finalize_expired_success,finalize_expired_when_passed_panics,finalize_expired_before_expiry_panics,execute_when_rejected_panics,execute_when_still_active_panics,vote_after_expiry_panics,double_vote_panics,execute_withdraw_pending_panics,execute_withdraw_already_executed_panics,execute_withdraw_non_member_panics,execute_withdraw_reduces_balance(test.rs:150-473)storage.rs:8;lib.rs:129-133(key + duplicate guard),lib.rs:135-139(counters),lib.rs:170-174(tally reads counters only), events atlib.rs:144-151treasury_interface_client.rscross-contract mechanismlib.rs:19-22module list); generated client fromtreasury_interface.rs:4-9; contract ID fromProposal.treasury(lib.rs:87) intoTreasuryClient::new(lib.rs:258-259); calls atlib.rs:261,lib.rs:266,lib.rs:272; treasury side atgroup_treasury/src/lib.rs:126,:175,:205,require_adminat:15/:180; nested-call auth noted intest.rs:78-81; constructor shape confirmed insoroban-sdk-macros-22.0.11/src/derive_client.rs(derive_client_type)env.storage().instance()(grep output below); persistent storage appears only in the test mock token (test.rs:28-53)test_snapshots/test/create_then_vote_then_pass_then_execute_happy_path.1.jsonshows the instance entry atlive_until_ledger_seq = 4095, ledger defaultsmin_persistent_entry_ttl 4096,min_temp_entry_ttl 16,max_entry_ttl 6312000Commands run and output
Every storage access in the contract resolves to
.instance()at the following line (the multi-lineenv.storage()calls above continue on the next line):lib.rs:47-49,74-77,93-95,96-98,140-142,176-178,204-206,225-227,280-282,299-302.Build and test verification
Toolchain:
cargo 1.98.1,rustc 1.98.1(contracts/rust-toolchain.toml: stable,wasm32-unknown-unknown). Dependencies are not vendored, so--offlinecannot resolve them; the run below used the network.Docs only — no Rust, config,
Cargo.tomlorCargo.lockfile is touched. Diff is the single new markdown file.Retargeted to
dev— the previous PR (#605) was auto-closed because contributor PRs must merge intodev, notmain.