Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
98c55e0
wip
ozgunozerk Feb 1, 2026
ba57bed
wip
ozgunozerk Feb 2, 2026
8173627
base implementations are done
ozgunozerk Feb 2, 2026
185d0e6
inline docs
ozgunozerk Feb 5, 2026
a13014a
quorum and get_votes integration
ozgunozerk Feb 5, 2026
79b1b44
fmt
ozgunozerk Feb 5, 2026
c21e74e
quorum extracted
ozgunozerk Feb 6, 2026
2abca20
Merge branch 'main' into governance-base-contract
ozgunozerk Feb 6, 2026
6b54744
suggestions
ozgunozerk Feb 10, 2026
a229f74
fmt
ozgunozerk Feb 10, 2026
4858385
suggestions
ozgunozerk Feb 10, 2026
289006c
blacklist instead of whitelist states for cancel
ozgunozerk Feb 10, 2026
9af9fdf
state inline docs
ozgunozerk Feb 10, 2026
537cbd1
also comment trait method
ozgunozerk Feb 10, 2026
fcc80d4
Merge branch 'main' into governance-base-contract
ozgunozerk Feb 12, 2026
25c5287
Update packages/governance/src/governor/mod.rs
ozgunozerk Feb 16, 2026
5483c45
Update packages/governance/src/governor/storage.rs
ozgunozerk Feb 16, 2026
efb640b
Update packages/governance/src/governor/mod.rs
ozgunozerk Feb 16, 2026
d8aa73f
suggestions
ozgunozerk Feb 16, 2026
98d4372
pending vs active state
ozgunozerk Feb 16, 2026
7994a9a
quorum and counting
ozgunozerk Feb 17, 2026
0b58ae2
suggestions
ozgunozerk Feb 20, 2026
7fe4fd5
Merge branch 'counting' into governance-base-contract
ozgunozerk Feb 20, 2026
5186a4d
merge quorum/counting into governor, and tests
ozgunozerk Feb 20, 2026
cacf3ba
Merge branch 'main' into governance-base-contract
ozgunozerk Feb 20, 2026
d9e6227
example contract
ozgunozerk Feb 20, 2026
99a676d
suggestions
ozgunozerk Feb 24, 2026
5e14335
suggestion
ozgunozerk Feb 24, 2026
cf2321a
suggestions
ozgunozerk Feb 25, 2026
aec779f
fmt
ozgunozerk Feb 25, 2026
2de0f1b
queue logic better integration
ozgunozerk Feb 25, 2026
8b8aa63
fix comments
ozgunozerk Feb 25, 2026
e85ef37
Merge branch 'main' into governance-base-contract
ozgunozerk Feb 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ members = [
"examples/fungible-blocklist",
"examples/fungible-capped",
"examples/fungible-merkle-airdrop",
"examples/fungible-governor",
"examples/fungible-votes",
"examples/fee-forwarder-permissioned",
"examples/fee-forwarder-permissionless",
Expand Down
21 changes: 21 additions & 0 deletions examples/fungible-governor/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "fungible-governor-example"
edition.workspace = true
license.workspace = true
repository.workspace = true
publish = false
version.workspace = true

[lib]
crate-type = ["cdylib"]
doctest = false

[dependencies]
soroban-sdk = { workspace = true }
stellar-access = { workspace = true }
stellar-governance = { workspace = true }
stellar-macros = { workspace = true }
stellar-tokens = { workspace = true }

[dev-dependencies]
soroban-sdk = { workspace = true, features = ["testutils"] }
68 changes: 68 additions & 0 deletions examples/fungible-governor/src/governor.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
use soroban_sdk::{contract, contractimpl, Address, BytesN, Env, String, Symbol, Val, Vec};
use stellar_governance::governor::{
storage::{self, set_token_contract},
Governor, ProposalState,
};

#[contract]
pub struct GovernorContract;

#[contractimpl]
impl GovernorContract {
pub fn __constructor(
e: &Env,
token_contract: Address,
voting_delay: u32,
voting_period: u32,
proposal_threshold: u128,
quorum: u128,
) {
storage::set_name(e, String::from_str(e, "ExampleGovernor"));
storage::set_version(e, String::from_str(e, "1.0.0"));
set_token_contract(e, &token_contract);
storage::set_voting_delay(e, voting_delay);
storage::set_voting_period(e, voting_period);
storage::set_proposal_threshold(e, proposal_threshold);
storage::set_quorum(e, quorum);
}
}

#[contractimpl(contracttrait)]
impl Governor for GovernorContract {
fn execute(
e: &Env,
targets: Vec<Address>,
functions: Vec<Symbol>,
args: Vec<Vec<Val>>,
description_hash: BytesN<32>,
executor: Address,
) -> BytesN<32> {
// Open execution: any account can trigger a succeeded proposal,
// as long as they authenticate themselves as `executor`.
executor.require_auth();
Comment thread
ozgunozerk marked this conversation as resolved.
storage::execute(
e,
targets,
functions,
args,
&description_hash,
Self::proposal_needs_queuing(e),
)
}

fn cancel(
e: &Env,
targets: Vec<Address>,
functions: Vec<Symbol>,
args: Vec<Vec<Val>>,
description_hash: BytesN<32>,
operator: Address,
) -> BytesN<32> {
// Restricted cancellation: only the original proposer can cancel.
let proposal_id = storage::hash_proposal(e, &targets, &functions, &args, &description_hash);
let proposer = storage::get_proposal_proposer(e, &proposal_id);
assert!(operator == proposer);
operator.require_auth();
storage::cancel(e, targets, functions, args, &description_hash)
}
}
10 changes: 10 additions & 0 deletions examples/fungible-governor/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#![no_std]

mod governor;
mod token;

#[cfg(test)]
mod test;

pub use governor::*;
pub use token::*;
Loading
Loading