Skip to content

Commit

Permalink
submessages issues wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhishek-1857 committed May 8, 2024
1 parent b187fe4 commit bfe2120
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 45 deletions.
8 changes: 8 additions & 0 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions packages/controllers/src/replies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
39 changes: 8 additions & 31 deletions packages/dao-interface/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,36 +71,6 @@ pub struct Snip20ReceiveMsg {
pub msg: Option<Binary>,
}

#[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<Binary>,
},
/// 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<String>,
/// optional message to control receiving logic
msg: Option<Binary>,
},
}

#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
Expand All @@ -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<Binary>,
},
/// 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
Expand Down
8 changes: 5 additions & 3 deletions packages/dao-interface/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -22,8 +22,10 @@ pub struct DumpStateResponse {
/// The governance modules associated with the governance
/// contract.
pub proposal_modules: Vec<ProposalModule>,
/// 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.
Expand Down
6 changes: 5 additions & 1 deletion packages/dao-pre-propose-base/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ where
pub fn instantiate(
&self,
deps: DepsMut,
_env: Env,
env: Env,
info: MessageInfo,
msg: InstantiateMsg<InstantiateExt>,
) -> Result<Response, PreProposeError> {
Expand Down Expand Up @@ -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()))
}

Expand Down
8 changes: 2 additions & 6 deletions packages/dao-voting/src/pre_propose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bfe2120

Please sign in to comment.