From bfe2120931f53e672ad07fa4a5cca8edbb9c8bb1 Mon Sep 17 00:00:00 2001 From: Abhishek-1857 Date: Wed, 8 May 2024 17:21:09 +0530 Subject: [PATCH] submessages issues wip --- Cargo.lock | 8 ++++ packages/controllers/src/replies.rs | 8 ++-- packages/dao-interface/src/msg.rs | 39 ++++---------------- packages/dao-interface/src/query.rs | 8 ++-- packages/dao-pre-propose-base/src/execute.rs | 6 ++- packages/dao-voting/src/pre_propose.rs | 8 +--- 6 files changed, 32 insertions(+), 45 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 370eed9..e438423 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -603,6 +603,7 @@ dependencies = [ "cw-denom", "cw-ownable", "cw-vesting", + "dao-interface", "schemars 0.8.16", "secret-cosmwasm-std", "secret-cw2", @@ -652,6 +653,7 @@ name = "cw-token-swap" version = "2.4.0" dependencies = [ "cosmwasm-schema 1.1.11", + "dao-interface", "schemars 0.8.16", "secret-cosmwasm-std", "secret-cw2", @@ -701,6 +703,7 @@ dependencies = [ "cw-paginate-storage 2.4.0", "cw-stake-tracker", "cw-wormhole", + "dao-interface", "schemars 0.8.16", "secret-cosmwasm-std", "secret-cw2", @@ -2600,6 +2603,7 @@ version = "1.0.0" dependencies = [ "base64 0.21.5", "cosmwasm-schema 1.1.11", + "dao-interface", "getrandom", "rand", "schemars 0.8.16", @@ -2624,6 +2628,7 @@ dependencies = [ "cw-utils 0.13.4", "cw20-stake", "dao-hooks", + "dao-interface", "dao-voting 2.4.0", "hex", "query_auth 0.1.0", @@ -2654,6 +2659,7 @@ dependencies = [ "cw-ownable", "cw20 0.13.4", "dao-hooks", + "dao-interface", "query_auth 0.1.0", "schemars 0.8.16", "secret-cosmwasm-std", @@ -2678,6 +2684,7 @@ version = "2.4.0" dependencies = [ "cosmwasm-schema 1.1.11", "cw-ownable", + "dao-interface", "query_auth 0.1.0", "schemars 0.8.16", "secret-cosmwasm-std", @@ -2729,6 +2736,7 @@ dependencies = [ "cosmwasm-schema 1.1.11", "cw-ownable", "cw4", + "dao-interface", "dao-snip721-extensions", "dao-voting-snip721-staked", "schemars 0.8.16", diff --git a/packages/controllers/src/replies.rs b/packages/controllers/src/replies.rs index 55499d3..97da14a 100644 --- a/packages/controllers/src/replies.rs +++ b/packages/controllers/src/replies.rs @@ -19,10 +19,10 @@ pub enum ReplyError { #[cw_serde] pub enum ReplyEvent { - VotingModuleInstantiate { code_hash: String }, - ProposalModuleInstantiate { code_hash: String }, - PreProposalModuleInstantiate { code_hash: String }, - Snip20ModuleInstantiate { code_hash: String }, + VotingModuleInstantiate {}, + ProposalModuleInstantiate {}, + PreProposalModuleInstantiate {}, + Snip20ModuleInstantiate {}, Snip20ModuleCreateViewingKey {}, FailedPreProposeModuleHook {}, FailedVoteHook { idx: u64 }, diff --git a/packages/dao-interface/src/msg.rs b/packages/dao-interface/src/msg.rs index f3ac3b1..1cc3bdd 100644 --- a/packages/dao-interface/src/msg.rs +++ b/packages/dao-interface/src/msg.rs @@ -71,36 +71,6 @@ pub struct Snip20ReceiveMsg { pub msg: Option, } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")] -pub enum Snip721ReceiveMsg { - /// ReceiveNft may be a HandleMsg variant of any contract that wants to implement a receiver - /// interface. BatchReceiveNft, which is more informative and more efficient, is preferred over - /// ReceiveNft. Please read above regarding why ReceiveNft, which follows CW-721 standard has an - /// inaccurately named `sender` field - ReceiveNft { - /// previous owner of sent token - sender: Addr, - /// token that was sent - token_id: String, - /// optional message to control receiving logic - msg: Option, - }, - /// BatchReceiveNft may be a HandleMsg variant of any contract that wants to implement a receiver - /// interface. BatchReceiveNft, which is more informative and more efficient, is preferred over - /// ReceiveNft. - BatchReceiveNft { - /// address that sent the tokens. There is no ReceiveNft field equivalent to this - sender: Addr, - /// previous owner of sent tokens. This is equivalent to the ReceiveNft `sender` field - from: Addr, - /// tokens that were sent - token_ids: Vec, - /// optional message to control receiving logic - msg: Option, - }, -} - #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] #[serde(rename_all = "snake_case")] pub enum ExecuteMsg { @@ -120,7 +90,14 @@ pub enum ExecuteMsg { /// Executed when the contract receives a cw721 token. Depending /// on the contract's configuration the contract will /// automatically add the token to its treasury. - ReceiveNft(Snip721ReceiveMsg), + ReceiveNft { + /// previous owner of sent token + sender: Addr, + /// token that was sent + token_id: String, + /// optional message to control receiving logic + msg: Option, + }, /// Removes an item from the governance contract's item map. RemoveItem { key: String }, /// Adds an item to the governance contract's item map. If the diff --git a/packages/dao-interface/src/query.rs b/packages/dao-interface/src/query.rs index 5afd3f9..e91dba4 100644 --- a/packages/dao-interface/src/query.rs +++ b/packages/dao-interface/src/query.rs @@ -4,7 +4,7 @@ use secret_cw2::ContractVersion; use secret_utils::Expiration; use serde::{Deserialize, Serialize}; -use crate::state::{Config, ProposalModule, VotingModuleInfo}; +use crate::state::{Config, ProposalModule}; /// Relevant state for the governance module. Returned by the /// `DumpState` query. @@ -22,8 +22,10 @@ pub struct DumpStateResponse { /// The governance modules associated with the governance /// contract. pub proposal_modules: Vec, - /// The voting module associated with the governance contract. - pub voting_module: VotingModuleInfo, + /// The voting module address associated with the governance contract. + pub voting_module_address: Addr, + /// The voting module code hash associated with the governance contract. + pub voting_module_code_hash: String, /// The number of active proposal modules. pub active_proposal_module_count: u32, /// The total number of proposal modules. diff --git a/packages/dao-pre-propose-base/src/execute.rs b/packages/dao-pre-propose-base/src/execute.rs index 1b93bc6..ca72cff 100644 --- a/packages/dao-pre-propose-base/src/execute.rs +++ b/packages/dao-pre-propose-base/src/execute.rs @@ -34,7 +34,7 @@ where pub fn instantiate( &self, deps: DepsMut, - _env: Env, + env: Env, info: MessageInfo, msg: InstantiateMsg, ) -> Result { @@ -87,6 +87,10 @@ where "open_proposal_submission", config.open_proposal_submission.to_string(), ) + .set_data(to_binary(&AnyContractInfo { + addr: env.contract.address, + code_hash: env.contract.code_hash, + })?) .add_attribute("dao", dao_info.addr.to_string())) } diff --git a/packages/dao-voting/src/pre_propose.rs b/packages/dao-voting/src/pre_propose.rs index a86495a..968cfdb 100644 --- a/packages/dao-voting/src/pre_propose.rs +++ b/packages/dao-voting/src/pre_propose.rs @@ -49,12 +49,8 @@ impl PreProposeInfo { Ok(match self { Self::AnyoneMayPropose {} => (ProposalCreationPolicy::Anyone {}, vec![]), Self::ModuleMayPropose { info } => { - let reply_id = reply_id.add_event( - store, - ReplyEvent::PreProposalModuleInstantiate { - code_hash: info.clone().code_hash, - }, - ); + let reply_id = + reply_id.add_event(store, ReplyEvent::PreProposalModuleInstantiate {}); ( // Anyone can propose will be set until instantiation succeeds, then // `ModuleMayPropose` will be set. This ensures that we fail open