Skip to content

Commit c7b5375

Browse files
committed
feat(launchpad): Add DAO Proposal Single contract address in nft-launchpad contract config
1 parent 918b2c0 commit c7b5375

File tree

6 files changed

+122
-56
lines changed

6 files changed

+122
-56
lines changed

packages/networks/features.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ const zodCosmWasmNFTLaunchpad = z.object({
5858
launchpadEndpoint: z.string(),
5959
codeId: z.number(),
6060
nftTr721CodeId: z.number(),
61+
daoProposalSingleContractAddress: z.string(),
6162
});
6263

6364
export type CosmWasmNFTLaunchpad = z.infer<typeof zodCosmWasmNFTLaunchpad>;

packages/networks/teritori-testnet/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const cosmwasmNftLaunchpadFeature: CosmWasmNFTLaunchpad = {
3939
nftTr721CodeId: 60,
4040
codeId: 71,
4141
defaultMintDenom: "utori",
42+
daoProposalSingleContractAddress: "",
4243
};
4344

4445
const rakkiFeature: CosmWasmRakki = {

packages/scripts/network-setup/deployNftLaunchpad.ts

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,35 @@ const instantiateNftLaunchpad = async (
8282
}
8383
let nftCodeId = featureObject.nftTr721CodeId;
8484
if (!nftCodeId) {
85+
console.error("No NFT TR721 code ID found. Deploying NFT TR721 ...");
8586
nftCodeId = await deployNftTr721({
8687
opts,
8788
networkId: network.id,
8889
deployerWallet,
8990
});
9091
}
92+
93+
let daoProposalSingleContractAddress =
94+
featureObject.daoProposalSingleContractAddress;
95+
if (!daoProposalSingleContractAddress) {
96+
console.error(
97+
"No DAO Proposal Single contract address found. Instantiating DAO Proposal Single...",
98+
);
99+
daoProposalSingleContractAddress = await instantiateDaoProposalSingle(
100+
opts,
101+
deployerWallet,
102+
launchpadAdmin,
103+
network,
104+
);
105+
}
106+
91107
const instantiateMsg: NftLaunchpadInstantiateMsg = {
92108
config: {
93109
name: "Teritori NFT Launchpad",
94110
owner: deployerAddr,
95111
admin: launchpadAdmin,
96112
nft_code_id: nftCodeId,
113+
dao_proposal_single_contract_addr: daoProposalSingleContractAddress,
97114
},
98115
};
99116
return await instantiateContract(
@@ -107,6 +124,68 @@ const instantiateNftLaunchpad = async (
107124
);
108125
};
109126

127+
const instantiateDaoProposalSingle = async (
128+
opts: DeployOpts,
129+
deployerWallet: string,
130+
adminAddr: string,
131+
network: CosmosNetworkInfo,
132+
) => {
133+
let codeId = network.daoProposalSingleCodeId;
134+
if (!codeId) {
135+
console.error(
136+
"No DAO Proposal Single code ID. Deploying DAO Proposal Single...",
137+
);
138+
codeId = deployDaoProposalSingle({
139+
opts,
140+
networkId: network.id,
141+
deployerWallet,
142+
});
143+
}
144+
return await instantiateContract(
145+
opts,
146+
deployerWallet,
147+
network,
148+
codeId,
149+
adminAddr,
150+
"Teritori DAO Proposal Single",
151+
{},
152+
);
153+
};
154+
155+
const deployDaoProposalSingle = async ({
156+
opts,
157+
networkId,
158+
deployerWallet,
159+
}: {
160+
networkId: string;
161+
deployerWallet: string;
162+
opts: DeployOpts;
163+
}) => {
164+
const { network } = await initDeploy({
165+
opts,
166+
networkId,
167+
wallet: deployerWallet,
168+
});
169+
const cosmwasmLaunchpadFeature = cloneDeep(
170+
getNetworkFeature(networkId, NetworkFeature.CosmWasmNFTLaunchpad),
171+
);
172+
if (!cosmwasmLaunchpadFeature) {
173+
console.error(`Cosmwasm Launchpad feature not found on ${networkId}`);
174+
process.exit(1);
175+
}
176+
const daoProposalSingleFilePath = path.join(
177+
__dirname,
178+
"dao_proposal_single.wasm",
179+
);
180+
const daoProposalSingleCodeId = await storeWASM(
181+
opts,
182+
deployerWallet,
183+
network,
184+
daoProposalSingleFilePath,
185+
);
186+
return daoProposalSingleCodeId;
187+
};
188+
110189
const deployNftTr721 = async ({
111190
opts,
112191
networkId,

rust/cw-contracts/nft-launchpad/config-mainnet.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"supported_networks": ["teritori"],
55
"owner": "",
66
"deployer": "",
7-
"nft_code_id": 0
7+
"nft_code_id": 0,
8+
"dao_proposal_single_contract_addr": ""
89
}
910
}

rust/cw-contracts/nft-launchpad/config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"supported_networks": ["teritori-testnet"],
55
"owner": "tori1llmym9upcpwnz7qte856ghlp5437ezz2gg7z0q",
66
"admin": "tori1kjvyqf4mttwrhfuq5gfj9xgxx9jdt92xnxzf770x853567ymx8cscrnw05",
7-
"nft_code_id": 60
7+
"nft_code_id": 60,
8+
"dao_proposal_single_contract_addr": ""
89
}
910
}

rust/cw-contracts/nft-launchpad/src/contract.rs

Lines changed: 37 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ impl NftLaunchpad {
133133
merkle_root: String,
134134
) -> Result<Response, ContractError> {
135135
let storage = ctx.deps.storage;
136+
let config = self.config.load(ctx.deps.storage)?;
137+
136138

137139
let mut collection = self
138140
.collections
@@ -155,72 +157,51 @@ impl NftLaunchpad {
155157
// Update collection
156158
self.collections.save(storage, collection_id, &collection)?;
157159

158-
Ok(Response::new()
159-
.add_attribute("action", "update_merkle_root")
160-
.add_attribute("merkle_root", merkle_root))
161-
}
162160

163-
#[msg(exec)]
164-
pub fn deploy_collection(
165-
&self,
166-
ctx: ExecCtx,
167-
collection_id: String,
168-
) -> Result<Response, ContractError> {
169-
let sender = ctx.info.sender.to_string();
170-
let config = self.config.load(ctx.deps.storage)?;
171161

172-
// Only allow launchpad_admin to deploy
173-
if sender != config.admin {
174-
return Err(ContractError::WrongDeployer);
175-
}
162+
// TODO:
163+
// MAKE THE PROPOSAL
176164

177-
let collection = self
178-
.collections
179-
.load(ctx.deps.storage, collection_id.to_owned())
180-
.map_err(|_| ContractError::CollectionNotFound)?;
181165

182-
// Do not allow to deploy collection if merkle root is not set
183-
if collection.metadatas_merkle_root.is_none() {
184-
return Err(ContractError::MerkleRootMissing);
185-
}
166+
167+
// verify proposal_id exists using DA0 contract
168+
169+
// vote yes to this proposal
186170

187-
let nft_code_id = config.nft_code_id;
188-
189-
// NOTE: cannot use wasm_instantiate because we need to specify admin
190-
let instantiate_msg = WasmMsg::Instantiate {
191-
admin: Some(sender.clone()),
192-
code_id: nft_code_id,
193-
msg: to_json_binary(&Tr721InstantiateMsg {
194-
admin: sender.clone(),
195-
name: collection.name.clone(),
196-
symbol: collection.symbol.clone(),
197-
minter: sender,
198-
launchpad_contract: "launchpad_contract".to_string(),
199-
mint_info: Tr721MintInfo {
200-
metadatas_merkle_root: collection.metadatas_merkle_root.unwrap(),
201-
tokens_count: collection.tokens_count,
202-
royalty_address: collection.royalty_address,
203-
royalty_percentage: collection.royalty_percentage,
204-
},
205-
mint_periods: collection.mint_periods,
171+
// emit "project_id"
172+
173+
// with indexer, listen to vote_approve_project and trigger UpdateApprovedProject
174+
175+
let proposal_contract_addr = config.dao_proposal_single_contract_addr;
176+
177+
let proposal_msg = WasmMsg::Execute {
178+
contract_addr: proposal_contract_addr.to_string(),
179+
msg: to_json_binary(&dao_contracts::msg::ExecuteMsg::Propose {
180+
title: format!("Approve Merkle Root Update for {}", collection_id),
181+
description: format!(
182+
"Update the Merkle root for collection {} to {}.",
183+
collection_id, merkle_root
184+
),
185+
msgs: vec![cosmwasm_std::CosmosMsg::Wasm(WasmMsg::Execute {
186+
contract_addr: ctx.env.contract.address.to_string(),
187+
msg: to_json_binary(&Self::msg().approve_merkle_root_update {
188+
collection_id: collection_id.clone(),
189+
})?,
190+
funds: vec![],
191+
})],
206192
})?,
207193
funds: vec![],
208-
label: format!(
209-
"TR721 codeId:{} collectionId:{} symbol:{}",
210-
nft_code_id, collection_id, collection.symbol
211-
),
212194
};
213195

214-
// Update instantiating collection id
215-
self.instantiating_collection_id
216-
.save(ctx.deps.storage, &collection_id)?;
217196

218-
let submessage = SubMsg::reply_on_success(instantiate_msg, INSTANTIATE_REPLY_ID);
219197

220198
Ok(Response::new()
221-
.add_submessage(submessage)
222-
.add_attribute("action", "collection_deployed")
223-
.add_attribute("collection_id", collection_id))
199+
// TODO:
200+
// .add_message(makeProposalMsg)
201+
.add_attribute("action", "update_merkle_root")
202+
.add_attribute("merkle_root", merkle_root))
203+
// TODO:
204+
// .add_attribute("proposal_id", proposal_id))
224205
}
225206

226207
#[msg(query)]
@@ -274,6 +255,7 @@ pub struct Config {
274255
pub nft_code_id: u64,
275256
pub admin: Addr,
276257
pub owner: Addr,
258+
pub dao_proposal_single_contract_addr: Addr,
277259
}
278260

279261
#[cw_serde]
@@ -282,6 +264,7 @@ pub struct ConfigChanges {
282264
pub nft_code_id: Option<u64>,
283265
pub admin: Option<String>,
284266
pub owner: Option<String>,
267+
pub dao_proposal_single_contract_addr: Option<Addr>,
285268
}
286269

287270
#[cw_serde]

0 commit comments

Comments
 (0)