Skip to content

Commit 4deb42e

Browse files
author
hard-nett
committed
dev: update config entrypoint, update infusion base_uri
1 parent 7c06cfb commit 4deb42e

File tree

12 files changed

+2832
-349
lines changed

12 files changed

+2832
-349
lines changed

Cargo.lock

+343-289
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
| | | | | \
1414
| ~ ~ ~ ~ |` )
1515
| /
16-
\ 595 /
16+
\ 600 /
1717
\ /
1818
\ _____ /
1919
|--//''`\--|

contracts/cw-infuser/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cw-infuser"
3-
version = "0.1.0"
3+
version = "0.2.1"
44
authors = ["hard-nett <hardnettt@proton.me>"]
55
edition = "2021"
66

contracts/cw-infuser/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11

2+
## Current Infusion Minters
3+
`stargaze-1`:
4+
- stars1333zgwvcxe04apsg98mccpc2fg7ft5xwl9ewkey2fwgf70zghsrse5nglu
5+
- stars1zkdqlly53sdafh6dhcpuapxxc3llxyqw4v9ekk9x553mc4mv0xlqkyvg3l
26
## Instantiate
7+
8+
39
```json
410
{
511
"admin": "stars1x7krclfpvt3d50ae4cvukckz4fe46g5gx393y2cjtdpar3aw6r3q3g8pd0",

contracts/cw-infuser/src/contract.rs

+101-41
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use crate::error::ContractError;
22
use crate::msg::{ExecuteMsg, InfusionsResponse, InstantiateMsg, MigrateMsg, QueryMsg};
33
use crate::state::{
44
Bundle, Config, InfusedCollection, Infusion, InfusionParamState, InfusionState, NFTCollection,
5-
TokenPositionMapping, CONFIG, INFUSION, INFUSION_ID, INFUSION_INFO, MINTABLE_NUM_TOKENS,
6-
MINTABLE_TOKEN_POSITIONS, NFT,
5+
TokenPositionMapping, UpdatingConfig, CONFIG, INFUSION, INFUSION_ID, INFUSION_INFO,
6+
MINTABLE_NUM_TOKENS, MINTABLE_TOKEN_POSITIONS, NFT,
77
};
88
use cosmwasm_schema::serde::Serialize;
99
#[cfg(not(feature = "library"))]
@@ -120,8 +120,12 @@ pub fn execute(
120120
infusion_id,
121121
bundle,
122122
} => execute_infuse_bundle(deps, env, info, infusion_id, bundle),
123-
ExecuteMsg::UpdateConfig {} => update_config(deps, info),
123+
ExecuteMsg::UpdateConfig { config } => update_config(deps, info, config),
124124
ExecuteMsg::EndInfusion { id } => execute_end_infusion(deps, info, id),
125+
ExecuteMsg::UpdateInfusionBaseUri {
126+
infusion_id,
127+
base_uri,
128+
} => update_infused_base_uri(deps, info, infusion_id, base_uri),
125129
}
126130
}
127131

@@ -147,15 +151,20 @@ pub fn reply(_deps: DepsMut, _env: Env, msg: Reply) -> Result<Response, Contract
147151
}
148152
}
149153

150-
/// Update the configuration of the app
151-
fn update_config(deps: DepsMut, msg: MessageInfo) -> Result<Response, ContractError> {
152-
let config = CONFIG.load(deps.storage)?;
153-
// Only the admin should be able to call this
154-
if config.contract_owner != msg.sender {
154+
/// Update the baseuri used for infused collection metadata
155+
fn update_infused_base_uri(
156+
deps: DepsMut,
157+
msg: MessageInfo,
158+
id: u64,
159+
base_uri: String,
160+
) -> Result<Response, ContractError> {
161+
let key = INFUSION_ID.load(deps.storage, id)?;
162+
let mut infusion = INFUSION.load(deps.storage, key.clone())?;
163+
if infusion.owner != msg.sender {
155164
return Err(ContractError::Admin(AdminError::NotAdmin {}));
156165
}
157-
158-
// todo: update configs
166+
infusion.infused_collection.base_uri = base_uri;
167+
INFUSION.save(deps.storage, key, &infusion)?;
159168

160169
Ok(Response::new())
161170
}
@@ -279,6 +288,7 @@ pub fn execute_create_infusion(
279288
max: cfg.max_per_bundle,
280289
});
281290
}
291+
282292
unique.push(col.addr.clone());
283293
}
284294
}
@@ -475,7 +485,7 @@ fn execute_infuse_bundle(
475485
}
476486
}
477487

478-
// check lens
488+
// // check lens
479489
if bundle.is_empty() {
480490
return Err(ContractError::EmptyBundle);
481491
}
@@ -565,49 +575,51 @@ fn check_bundles(
565575
elig_col: Vec<NFTCollection>,
566576
sent: &Vec<Coin>,
567577
) -> Result<(), ContractError> {
568-
// verify correct # of nft's provided & are accepted nfts
569-
// verify that the bundle is included in infusions
570578
for c in &elig_col {
571579
let elig = bundle
572580
.iter()
573581
.filter(|b| b.addr == c.addr)
574582
.collect::<Vec<_>>();
575583

584+
let elig_len: u64 = elig.len() as u64;
576585
if let Some(ps) = c.payment_substitute.clone() {
577-
if !sent
578-
.iter()
579-
.any(|coin| coin.denom == ps.denom && coin.amount >= ps.amount)
580-
{
581-
let mut havea = 0u128;
582-
let mut haved = String::new();
583-
for coin in sent {
584-
if coin.denom == ps.denom {
585-
havea = coin.amount.into();
586-
haved = coin.denom.clone();
587-
break;
586+
if elig_len == 0u64 {
587+
if !sent
588+
.iter()
589+
.any(|coin| coin.denom == ps.denom && coin.amount >= ps.amount)
590+
{
591+
let mut havea = 0u128;
592+
let mut haved = String::new();
593+
for coin in sent {
594+
if coin.denom == ps.denom {
595+
havea = coin.amount.into();
596+
haved = coin.denom.clone();
597+
break;
598+
}
588599
}
600+
return Err(ContractError::PaymentSubstituteNotProvided {
601+
col: c.addr.to_string(),
602+
haved,
603+
havea: havea.to_string(),
604+
wantd: ps.denom,
605+
wanta: ps.amount.to_string(),
606+
});
589607
}
590-
return Err(ContractError::PaymentSubstituteNotProvided {
591-
col: c.addr.to_string(),
592-
haved,
593-
havea: havea.to_string(),
594-
wantd: ps.denom,
595-
wanta: ps.amount.to_string(),
596-
});
597608
}
598609
} else if elig.is_empty() {
599610
return Err(ContractError::CollectionNotEligible {
600611
col: c.addr.to_string(),
601612
});
602-
// ensure minimum is met
603-
} else if elig.len() as u64 != c.min_req {
604-
return Err(ContractError::BundleNotAccepted {
605-
have: elig.len() as u64,
606-
want: c.min_req,
607-
});
608-
} else if c.max_req.is_some_and(|a| elig.len() as u64 > a) {
613+
} else if let Some(max) = c.max_req {
614+
if elig_len > max {
615+
return Err(ContractError::BundleNotAccepted {
616+
have: elig_len,
617+
want: c.min_req,
618+
});
619+
}
620+
} else if elig_len != c.min_req {
609621
return Err(ContractError::BundleNotAccepted {
610-
have: elig.len() as u64,
622+
have: elig_len,
611623
want: c.min_req,
612624
});
613625
}
@@ -788,6 +800,54 @@ fn random_mintable_token_mapping(
788800
Ok(TokenPositionMapping { position, token_id })
789801
}
790802

803+
/// Update the configuration of the app
804+
fn update_config(
805+
deps: DepsMut,
806+
msg: MessageInfo,
807+
uc: UpdatingConfig,
808+
) -> Result<Response, ContractError> {
809+
let mut config = CONFIG.load(deps.storage)?;
810+
// Only the admin should be able to call this
811+
if config.contract_owner != msg.sender {
812+
return Err(ContractError::Admin(AdminError::NotAdmin {}));
813+
}
814+
815+
if let Some(owner) = uc.contract_owner {
816+
config.contract_owner = deps.api.addr_validate(&owner)?;
817+
}
818+
819+
if let Some(of) = uc.owner_fee {
820+
config.owner_fee = of;
821+
}
822+
823+
if let Some(cf) = uc.min_creation_fee {
824+
config.min_creation_fee = Some(cf);
825+
}
826+
827+
if let Some(mif) = uc.min_infusion_fee {
828+
config.min_infusion_fee = Some(mif);
829+
}
830+
831+
if let Some(mi) = uc.max_infusions {
832+
config.max_infusions = mi;
833+
}
834+
835+
if let Some(mpb) = uc.min_per_bundle {
836+
config.min_per_bundle = mpb;
837+
}
838+
839+
if let Some(mb) = uc.max_bundles {
840+
config.max_bundles = mb;
841+
}
842+
843+
if let Some(ci) = uc.code_id {
844+
config.code_id = ci;
845+
}
846+
847+
CONFIG.save(deps.storage, &config)?;
848+
Ok(Response::new())
849+
}
850+
791851
// source: https://github.com/public-awesome/launchpad/blob/main/contracts/minters/vending-minter/src/contract.rs#L1371
792852
#[cfg_attr(not(feature = "library"), entry_point)]
793853
pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> StdResult<Response> {
@@ -799,10 +859,10 @@ pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> StdResult<Response
799859
let version: Version = current_version
800860
.version
801861
.parse()
802-
.map_err(|_| StdError::generic_err("Invalid contract version"))?;
862+
.map_err(|_| StdError::generic_err("Invalid current contract version"))?;
803863
let new_version: Version = CONTRACT_VERSION
804864
.parse()
805-
.map_err(|_| StdError::generic_err("Invalid contract version"))?;
865+
.map_err(|_| StdError::generic_err("Invalid new contract version"))?;
806866

807867
if version > new_version {
808868
return Err(StdError::generic_err("Cannot upgrade to a previous contract version").into());

contracts/cw-infuser/src/msg.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ pub struct InstantiateMsg {
2727
#[cw_serde]
2828
#[derive(cw_orch::ExecuteFns)]
2929
pub enum ExecuteMsg {
30-
UpdateConfig {},
30+
UpdateConfig {
31+
config: UpdatingConfig,
32+
},
33+
UpdateInfusionBaseUri {
34+
infusion_id: u64,
35+
base_uri: String,
36+
},
3137
CreateInfusion {
3238
infusions: Vec<Infusion>,
3339
},
@@ -37,7 +43,7 @@ pub enum ExecuteMsg {
3743
},
3844
EndInfusion {
3945
id: u64,
40-
}
46+
},
4147
}
4248

4349
#[cw_serde]

contracts/cw-infuser/src/state.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ pub const INFUSION_INFO: Map<&Addr, InfusionInfo> = Map::new("infusion_info");
1515
pub const MINTABLE_TOKEN_POSITIONS: Map<u32, u32> = Map::new("mt");
1616
pub const MINTABLE_NUM_TOKENS: Map<String, u32> = Map::new("mnt");
1717

18+
#[cosmwasm_schema::cw_serde]
19+
pub struct UpdatingConfig {
20+
pub contract_owner: Option<String>,
21+
pub owner_fee: Option<u64>,
22+
pub min_creation_fee: Option<Coin>,
23+
pub min_infusion_fee: Option<Coin>,
24+
pub max_infusions: Option<u64>,
25+
pub min_per_bundle: Option<u64>,
26+
pub max_bundles: Option<u64>,
27+
pub code_id: Option<u64>,
28+
}
29+
1830
#[cosmwasm_schema::cw_serde]
1931
pub struct Config {
2032
// Default at 0.
@@ -39,7 +51,7 @@ pub struct Config {
3951
/// code hash of cw721. used for instantitate2 during infusion creation.
4052
pub code_hash: HexBinary,
4153
}
42-
54+
4355
#[cosmwasm_schema::cw_serde]
4456
pub struct Infusion {
4557
/// Optional description of this infusion

scripts/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ cw-orch-clone-testing = "0.6.4"
1414
cw721 = "0.18.0"
1515
dotenv = "0.15.0"
1616
env_logger = { version = "0.11.3", default-features = false }
17-
cw-infuser = {version = "0.1.0", path = "../contracts/cw-infuser" }
17+
cw-infuser = {version = "0.2.1", path = "../contracts/cw-infuser" }
1818
sg721 = "^3.3"
1919
sg721-base = "^3.3"
2020
clap = "4.5.23"

scripts/README.md

+17-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11

22

3-
## Testnet collection
43

5-
Open Edition Minter Contract Address: stars15wjw88mhscwqc2rn255clz57wavcwqa9vwexjqpx3ksudapq3lfs4lzz2y
6-
SG721 Contract Address: stars18vng693zqjgwd08p3ypzy26h8f7d7yjweahn5hxq2xnuu837emuslfzn5w
7-
Transaction Hash: C251E4142002A548E38625222AE227C7E5C2336C6821BF39503CFB558C31B80A
4+
### UPDATING COLLECTION INFO
5+
```json
6+
{
7+
"update_collection_info": {
8+
"collection_info": {
9+
"description": "Infused Collection: Achieving peace of mind through alignment of intentions and actions. Art designed by the legendary Jinxto \u003c3",
10+
"image": "ipfs://QmRxSCKLTDPwjBy4HieLLkZE5vLCACRLAfBthu3iHMGu2w",
11+
"external_link": "https://infuse.permissionless.money",
12+
"explicit_content": null,
13+
"royalty_info": {
14+
"payment_address": "stars1a5hezc5p5qgy8hx365dh5zzps4ckee9c6dv6k5",
15+
"share": "0.06"
16+
},
17+
}
18+
}
19+
}
20+
```

0 commit comments

Comments
 (0)