Skip to content

Commit

Permalink
Testing min_quorum param
Browse files Browse the repository at this point in the history
  • Loading branch information
nalnir committed Oct 4, 2023
1 parent 298037f commit ac73575
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 30 deletions.
46 changes: 23 additions & 23 deletions dao/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 10,13 @@ use crate::proposal::{
for_votes_win,
get_proposal,
get_voted,
// min_quorum_met,
set_executed,
set_min_vote_power,
set_voted,
votes_counts,
Proposal,
VotesCount,
// min_quorum_met
};
use crate::storage::core::CoreState;

Expand Down Expand Up @@ -45,7 45,7 @@ pub trait DaoContractTrait {
fn vote(env: Env, from: Address, prop_id: u32, power: u32, vote: u32);
fn get_votes(env: Env, prop_id: u32) -> VotesCount;
fn have_voted(env: Env, prop_id: u32, vote: Address) -> bool;
// fn execute(env: Env, prop_id: u32) -> Vec<Val>;
fn execute(env: Env, prop_id: u32) -> Vec<Val>;
}

#[contract]
Expand Down Expand Up @@ -153,33 153,33 @@ impl DaoContractTrait for DaoContract {
}
}

// fn execute(env: Env, prop_id: u32) -> Vec<Val> {
// let proposal = get_proposal(&env, prop_id);
// // 1. Check deadline
// check_min_duration(&env, &proposal);
fn execute(env: Env, prop_id: u32) -> Vec<Val> {
let proposal = get_proposal(&env, prop_id);
// 1. Check deadline
check_min_duration(&env, &proposal);

// // 2. Check if min quorum is met
// min_quorum_met(&env, prop_id);
// 2. Check if min quorum is met
// min_quorum_met(&env, prop_id);

// // 3. Check if "for" votes beat "against" votes
// for_votes_win(&env, prop_id);
// 3. Check if "for" votes beat "against" votes
for_votes_win(&env, prop_id);

// // 4. Check if executed
// executed(&env, prop_id);
// 4. Check if executed
executed(&env, prop_id);

// // 5. Execute
// let mut exec_results: Vec<Val> = Vec::new(&env);
// for instruct in proposal.instr {
// let res: Val = env.invoke_contract(&instruct.c_id, &instruct.fun_name, instruct.args);
// exec_results.push_front(res);
// }
// 5. Execute
let mut exec_results: Vec<Val> = Vec::new(&env);
// for instruct in proposal.instr {
// let res: Val = env.invoke_contract(&instruct.c_id, &instruct.fun_name, instruct.args);
// exec_results.push_front(res);
// }

// // 6. Set executed to true
// set_executed(&env, prop_id);
// 6. Set executed to true
set_executed(&env, prop_id);

// // 7. Return results
// exec_results
// }
// 7. Return results
exec_results
}

fn get_votes(env: Env, prop_id: u32) -> VotesCount {
votes_counts(&env, prop_id)
Expand Down
7 changes: 4 additions & 3 deletions dao/src/proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 30,10 @@ pub struct ProposalInstr {
pub struct Proposal {
pub end_time: u64,
// instrunctions will be executed in sequence
pub url: String, // pub instr: Vec<ProposalInstr>,
// pub min_quorum: i128,
// pub instr: Vec<ProposalInstr>,
pub url: String,
// pub instr: Vec<ProposalInstr>,
// pub min_quorum: i128,
pub min_quo: u64,
}

#[contracttype]
Expand Down
8 changes: 4 additions & 4 deletions deployer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 30,7 @@ impl Deployer {
mod test;

// soroban contract install --wasm ../dao/target/wasm32-unknown-unknown/release/governance.wasm
// dao-wasm-hash -> ee1c29af589ee186ca7ea23ed79baaa90ed3f511a74912c1376eb408035adcb2
// dao-wasm-hash -> f850e236ebe99e38a4043ea6e8b9533022ce7bcbd07b2e7fd1a8449670433941

// soroban contract install --wasm ../token/target/wasm32-unknown-unknown/release/soroban_token_contract.wasm
// token-wasm-hash -> cf2318b87338b80ce75d0276244f9be3a131d74656a7fecd1d92da0eb8ab09e3
Expand All @@ -39,19 39,19 @@ mod test;
// --wasm target/wasm32-unknown-unknown/release/soroban_deployer_contract.wasm \
// --source juico \
// --network futurenet
// deployer_contract_id -> CBLEY56J52CQVKH73BRCEWWMTLXM5JDHO55OGOW5CGJEHO6CZ6YTUQGG
// deployer_contract_id -> CC77VGFNAWBQX3HZGF2WNJY2WESGZP3I3RV7YWO5HK5W4APSX37AZK2C

// soroban contract deploy \
// --wasm target/wasm32-unknown-unknown/release/governance.wasm \
// --source juico \
// --network futurenet
// dao_contract_id -> CBTKPVZAJXD5ZPK5HMTKS22HUOMIFY52FKXA6H54J7S4WUOQSB7GDNKX
// dao_contract_id -> CC6CIJRZ3AVR4BRNOZJWIXVY6S7NWYAOBZ2KMDZ5FTVEJ53L2DBUAW6B

// soroban contract deploy \
// --wasm target/wasm32-unknown-unknown/release/soroban_token_contract.wasm \
// --source juico \
// --network futurenet
// token_contract_id -> CCQNGCPYYJXIGOY4KEWVN6QGKN7N2EFJIRNKUJDVEPTT5ANKITGXBNE3
// token_contract_id -> CC7KV5EAMCGAKSSBBFQ74GAF3ZCHPEIAMQTI5EJ45VUQH32LZ5JIIY23

// ------------------------------------ FOR RESTORATION ------------------------------------

Expand Down

0 comments on commit ac73575

Please sign in to comment.