Description
The Governance contract defines proposal storage and vote execution flows, but it still needs a public proposal-creation entrypoint so proposals can be created on-chain without test-only storage seeding.
User Story
As a Protocol User,
I want to create a proposal through the contract,
so that governance state begins from an on-chain action rather than direct storage writes.
Requirements and Context
- Files:
contracts/governance/src/lib.rs, contracts/governance/src/types.rs, contracts/governance/src/test.rs
- Add
create_proposal(env: Env, proposer: Address, metadata_hash: BytesN<32>, end_time: u64) -> u32
- Require
proposer.require_auth()
- Generate and persist a new proposal ID with zeroed vote counters and
executed = false
- Add any additional storage key needed for proposal counting
Suggested Implementation
// IN FUNCTION: create_proposal(env: Env, proposer: Address, metadata_hash: BytesN<32>, end_time: u64) -> u32
// 1. proposer.require_auth();
// 2. let proposal_id = next stored counter value;
// 3. let proposal = Proposal { ... };
// 4. env.storage().persistent().set(&DataKey::Proposal(proposal_id), &proposal);
// 5. return proposal_id;
Acceptance Criteria
Submission Guidelines
- Branch:
feat/create-proposal
- Depends on:
[Governance] Define proposal schema
- PR:
feat(governance): add create_proposal entrypoint
Description
The Governance contract defines proposal storage and vote execution flows, but it still needs a public proposal-creation entrypoint so proposals can be created on-chain without test-only storage seeding.
User Story
As a Protocol User,
I want to create a proposal through the contract,
so that governance state begins from an on-chain action rather than direct storage writes.
Requirements and Context
contracts/governance/src/lib.rs,contracts/governance/src/types.rs,contracts/governance/src/test.rscreate_proposal(env: Env, proposer: Address, metadata_hash: BytesN<32>, end_time: u64) -> u32proposer.require_auth()executed = falseSuggested Implementation
Acceptance Criteria
Submission Guidelines
feat/create-proposal[Governance] Define proposal schemafeat(governance): add create_proposal entrypoint