Skip to content

Commit

Permalink
ModuleInstantiateInfo callback to accept ownership of new NFT contract
Browse files Browse the repository at this point in the history
Ownship transfer process is two steps now, so the DAO needs to accept
the ownership transfer.
  • Loading branch information
JakeHartnell committed Sep 28, 2023
1 parent f13d8d4 commit ac38d6e
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions contracts/voting/dao-voting-cw721-staked/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use cw721::{Cw721QueryMsg, Cw721ReceiveMsg, NumTokensResponse};
use cw_storage_plus::Bound;
use cw_utils::{parse_reply_execute_data, parse_reply_instantiate_data, Duration};
use dao_hooks::nft_stake::{stake_nft_hook_msgs, unstake_nft_hook_msgs};
use dao_interface::state::ModuleInstantiateCallback;
use dao_interface::{nft::NftFactoryCallback, voting::IsActiveResponse};
use dao_voting::duration::validate_duration;
use dao_voting::threshold::{
Expand Down Expand Up @@ -719,7 +720,7 @@ pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> Result<Response, ContractE
// Query the total supply of the NFT contract
let nft_supply: NumTokensResponse = deps
.querier
.query_wasm_smart(collection_addr, &Cw721QueryMsg::NumTokens {})?;
.query_wasm_smart(collection_addr.clone(), &Cw721QueryMsg::NumTokens {})?;

// Check greater than zero
if nft_supply.count == 0 {
Expand All @@ -737,7 +738,22 @@ pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> Result<Response, ContractE
)?;
}

Ok(Response::new())
// On setup success, have the DAO complete the second part of
// ownership transfer by accepting ownership in a
// ModuleInstantiateCallback.
let callback = to_binary(&ModuleInstantiateCallback {
msgs: vec![CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: collection_addr.to_string(),
msg: to_binary(
&&cw721_base::msg::ExecuteMsg::<Empty, Empty>::UpdateOwnership(
cw721_base::Action::AcceptOwnership {},
),
)?,
funds: vec![],
})],
})?;

Ok(Response::new().set_data(callback))
}
FACTORY_EXECUTE_REPLY_ID => {
// Parse reply data
Expand Down

0 comments on commit ac38d6e

Please sign in to comment.