feat(governance): v0.0.28 origin-chain-governance pallet scaffold (Phase 5.1 Foundation Treasury CHN-4)
Phase 5.1 GOVERNANCE pallet scaffold canonical. Reemplaza placeholder GovernanceConfig stub en existing origin-chain-governance crate con real FRAME pallet. AI-Driven Human-Guarded canonical CHN-4 — 5 AI advisor agents ADVISE only, humans-only vote canonical non-negotiable. ## Pallet surface canonical - Pallet<T> + Config trait + RuntimeEvent - Proposal struct (11 fields content-addressed via BLAKE2-256) - ProposalStatus enum (Voting + Approved + Rejected + Withdrawn) - Proposals<StorageMap<ProposalId, Proposal>> per-proposal O(1) - Votes<StorageDoubleMap<ProposalId, AccountId, VoteStance>> double-vote prevention - Events ProposalSubmitted + VoteCast + ProposalFinalized - Errors 8 variants (ProposalNotFound + AlreadyVoted + VotingPeriodClosed/Open + StakeInsufficient + ProposalAlreadyFinalized + AdvisorMayNotVote + ProposalIdCollision) - Scaffold dispatchables submit_proposal + cast_vote + finalize_proposal - Helper derive_proposal_id via BLAKE2-256 hash (Inmutable #16 byte-determinism) - sp_api::decl_runtime_apis! GovernanceApi declaration (query_proposal + query_vote) ## Types canonical updated - origin-chain-types/src/governance.rs: added scale derives a ProposalId + VoteStance + Vote (Encode + Decode + DecodeWithMemTracking + MaxEncodedLen + TypeInfo) para FRAME-compatibility canonical ## Files - EDIT: crates/origin-chain-governance/Cargo.toml (stub → FRAME pallet deps canonical) - REPLACE: crates/origin-chain-governance/src/lib.rs (placeholder → ~360 LOC scaffold) - EDIT: crates/origin-chain-types/src/governance.rs (scale derives canonical) - EDIT: CHANGELOG.md (v0.0.28 entry) ## Verification - cargo test -p origin-chain-governance — 5 tests verde, 0 failures (pallet_compiles + derive_proposal_id deterministic + different + status variants + re-export) 🏛️ Phase 5.1 scaffold canonical. Wire pattern v0.0.29 next. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
dc1c2e7cd1
commit
1bde93921e
5 files changed
+453
-24
No files matched your search
Generated
+8
@@ -2212,7 +2212,15 @@ dependencies = [
|
||||
name = "origin-chain-governance"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"frame-support",
|
||||
"frame-system",
|
||||
"origin-chain-types",
|
||||
"parity-scale-codec",
|
||||
"scale-info",
|
||||
"sp-api",
|
||||
"sp-core",
|
||||
"sp-io",
|
||||
"sp-runtime",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
Reference in new issue
Block a user