8000 Governance | pre voting by FloppyDisck · Pull Request #133 · securesecrets/shade · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Governance | pre voting #133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Nov 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion contracts/governance/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ debug-print = ["cosmwasm-std/debug-print"]
cosmwasm-schema = { git = "https://github.com/enigmampc/SecretNetwork", tag = "v1.0.4-debug-print" }
cosmwasm-std = { git = "https://github.com/enigmampc/SecretNetwork", tag = "v1.0.4-debug-print" }
cosmwasm-storage = { git = "https://github.com/enigmampc/SecretNetwork", tag = "v1.0.4-debug-print" }
secret-toolkit = { git = "https://github.com/enigmampc/secret-toolkit", branch = "debug-print"}
# TODO: Update when secret-toolkit accepts the branch
secret-toolkit = { git = "https://github.com/FloppyDisck/secret-toolkit", branch = "snip20-batch-transactions"}
shade-protocol = { version = "0.1.0", path = "../../packages/shade_protocol" }
schemars = "0.7"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
Expand Down
33 changes: 23 additions & 10 deletions contracts/governance/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ use shade_protocol::{
},
};
use crate::{
state::{config_w, total_proposals_w},
state::{config_w, admin_commands_list_w, supported_contracts_list_w},
proposal_state::total_proposals_w,
handle,
query
};
use crate::state::{admin_commands_list_w, supported_contracts_list_w};
use crate::handle::try_disable_staker;
use secret_toolkit::snip20::register_receive_msg;

pub fn init<S: Storage, A: Api, Q: Querier>(
deps: &mut Extern<S, A, Q>,
Expand All @@ -25,7 +25,10 @@ pub fn init<S: Storage, A: Api, Q: Querier>(
Some(admin) => { admin }
},
staker: msg.staker,
proposal_deadline: msg.proposal_deadline,
funding_token: msg.funding_token.clone(),
funding_amount: msg.funding_amount,
funding_deadline: msg.funding_deadline,
voting_deadline: msg.voting_deadline,
minimum_votes: msg.quorum
};

Expand All @@ -39,7 +42,13 @@ pub fn init<S: Storage, A: Api, Q: Querier>(
supported_contracts_list_w(&mut deps.storage).save(&vec![])?;

Ok(InitResponse {
messages: vec![],
messages: vec![register_receive_msg(
env.contract_code_hash,
None,
256,
msg.funding_token.code_hash,
msg.funding_token.address,
)?],
log: vec![]
})
}
Expand All @@ -55,13 +64,17 @@ pub fn handle<S: Storage, A: Api, Q: Querier>(
} => handle::try_create_proposal(deps, &env, target_contract,
Binary::from(proposal.as_bytes()), description),

HandleMsg::Receive {sender, amount, msg
} => handle::try_fund_proposal(deps, &env, sender, amount, msg),

// Self interactions
// Config
HandleMsg::UpdateConfig { admin, staker, proposal_deadline,
minimum_votes } =>
handle::try_update_config(deps, &env, admin, staker, proposal_deadline, minimum_votes),
funding_amount, funding_deadline, minimum_votes } =>
handle::try_update_config(deps, &env, admin, staker, proposal_deadline,
funding_amount, funding_deadline, minimum_votes),

HandleMsg::DisableStaker {} => try_disable_staker(deps, &env),
HandleMsg::DisableStaker {} => handle::try_disable_staker(deps, &env),

// Supported contract
HandleMsg::AddSupportedContract { name, contract
Expand Down Expand Up @@ -102,7 +115,7 @@ pub fn query<S: Storage, A: Api, Q: Querier>(
msg: QueryMsg,
) -> StdResult<Binary> {
match msg {
QueryMsg::GetProposals { total, start
QueryMsg::GetProposals { total, start, status
} => to_binary(&query::proposals(deps, total, start)?),

QueryMsg::GetProposal { proposal_id } => to_binary(
Expand All @@ -124,4 +137,4 @@ pub fn query<S: Storage, A: Api, Q: Querier>(
QueryMsg::GetAdminCommand { name
} => to_binary(&query::admin_command(deps, name)?),
}
}
}
Loading
0