Skip to content

Commit

Permalink
saving so can branch
Browse files Browse the repository at this point in the history
  • Loading branch information
humanalgorithm committed Aug 22, 2023
1 parent 7da1754 commit 7cf1e64
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 83 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ open-edition-minter = { version = "3.1.0", path = "contracts/minters/open-editi
whitelist-immutable = { version = "3.1.0", path = "contracts/whitelists/whitelist-immutable" }
sg-whitelist-flex = { version = "3.1.0", path = "contracts/whitelists/whitelist-flex" }
ethereum-verify = { version = "3.1.0", path = "packages/ethereum-verify" }
burn-to-mint = { version = "3.1.0", path = "packages/burn-to-mint" }
burn-to-mint = { version = "3.1.0", path = "packages/burn-to-mint" }
sg-eth-airdrop = { version = "3.1.0", path = "contracts/sg-eth-airdrop" }
test-suite = { version = "3.1.0", path = "test-suite" }
semver = "1"
Expand Down
1 change: 1 addition & 0 deletions contracts/minters/base-minter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ sg721-base = { workspace = true, features = ["library"] }
sg-std = { workspace = true }
thiserror = { workspace = true }
url = { workspace = true }
burn-to-mint = { workspace = true }
29 changes: 3 additions & 26 deletions contracts/minters/base-minter/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,32 +129,9 @@ pub fn call_burn_to_mint(
let execute_mint_msg = ExecuteMsg::Mint {
token_uri: token_uri_msg.token_uri,
};
Ok(Response::new())
}

pub fn execute_burn_to_mint(
info: MessageInfo,
env: Env,
msg: Cw721ReceiveMsg,
) -> Result<Response, ContractError> {
let mut res = Response::new();
let burn_msg = cw721::Cw721ExecuteMsg::Burn {
token_id: msg.token_id,
};
let cosmos_burn_msg = CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: info.sender.to_string(),
msg: to_binary(&burn_msg)?,
funds: vec![],
});
res = res.add_message(cosmos_burn_msg);

let cosmos_mint_msg = CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: env.contract.address.to_string(),
msg: to_binary(&execute_mint_msg.into())?,
funds: vec![],
});
let res = res.add_message(cosmos_mint_msg);
Ok(res)
let res = burn_to_mint::generate_burn_mint_response(info, env, msg, execute_mint_msg)
.map_err(|_| ContractError::BurnToMintError {});
res
}

pub fn execute_mint_sender(
Expand Down
3 changes: 3 additions & 0 deletions contracts/minters/base-minter/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,7 @@ pub enum ContractError {

#[error("InvalidStartTradingTime {0} < {1}")]
InvalidStartTradingTime(Timestamp, Timestamp),

#[error("Burn to Mint Error")]
BurnToMintError {},
}
1 change: 1 addition & 0 deletions contracts/minters/open-edition-minter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ thiserror = { workspace = true }
url = { workspace = true }
open-edition-factory = { workspace = true, features = ["library"] }
semver = {workspace = true }
burn-to-mint = { workspace = true }
25 changes: 5 additions & 20 deletions contracts/minters/open-edition-minter/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ pub fn execute(
execute_update_per_address_limit(deps, env, info, per_address_limit)
}
ExecuteMsg::MintTo { recipient } => execute_mint_to(deps, env, info, recipient),
ExecuteMsg::ReceiveNft(msg) => execute_burn_to_mint(deps, env, info, msg),
ExecuteMsg::ReceiveNft(msg) => call_burn_to_mint(deps, env, info, msg),
}
}

Expand Down Expand Up @@ -680,31 +680,16 @@ pub fn execute_update_per_address_limit(
.add_attribute("limit", per_address_limit.to_string()))
}

pub fn execute_burn_to_mint(
pub fn call_burn_to_mint(
_deps: DepsMut,
env: Env,
info: MessageInfo,
msg: Cw721ReceiveMsg,
) -> Result<Response, ContractError> {
let mut res = Response::new();
let burn_msg = cw721::Cw721ExecuteMsg::Burn {
token_id: msg.token_id,
};
let cosmos_burn_msg = CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: info.sender.to_string(),
msg: to_binary(&burn_msg)?,
funds: vec![],
});
res = res.add_message(cosmos_burn_msg);

let execute_mint_msg = ExecuteMsg::Mint {};
let cosmos_mint_msg = CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: env.contract.address.to_string(),
msg: to_binary(&execute_mint_msg)?,
funds: vec![],
});
let res = res.add_message(cosmos_mint_msg);
Ok(res)
let res = burn_to_mint::generate_burn_mint_response(info, env, msg, execute_mint_msg)
.map_err(|_| ContractError::BurnToMintError {});
res
}

// if admin_no_fee => no fee,
Expand Down
3 changes: 3 additions & 0 deletions contracts/minters/open-edition-minter/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,7 @@ pub enum ContractError {

#[error("Expected fungible token, received nonfungible")]
IncorrectFungibility {},

#[error("Burn to Mint Error")]
BurnToMintError {},
}
3 changes: 2 additions & 1 deletion contracts/minters/vending-minter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ sg-whitelist = { workspace = true, features = ["library"] }
thiserror = { workspace = true }
url = { workspace = true }
vending-factory = { workspace = true, features = ["library"] }
semver = {workspace = true }
semver = { workspace = true }
burn-to-mint = { workspace = true }
25 changes: 5 additions & 20 deletions contracts/minters/vending-minter/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,35 +245,20 @@ pub fn execute(
execute_update_discount_price(deps, env, info, price)
}
ExecuteMsg::RemoveDiscountPrice {} => execute_remove_discount_price(deps, info),
ExecuteMsg::ReceiveNft(msg) => execute_burn_to_mint(deps, env, info, msg),
ExecuteMsg::ReceiveNft(msg) => call_burn_to_mint(deps, env, info, msg),
}
}

pub fn execute_burn_to_mint(
pub fn call_burn_to_mint(
_deps: DepsMut,
env: Env,
info: MessageInfo,
msg: Cw721ReceiveMsg,
) -> Result<Response, ContractError> {
let mut res = Response::new();
let burn_msg = cw721::Cw721ExecuteMsg::Burn {
token_id: msg.token_id,
};
let cosmos_burn_msg = CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: info.sender.to_string(),
msg: to_binary(&burn_msg)?,
funds: vec![],
});
res = res.add_message(cosmos_burn_msg);

let execute_mint_msg = ExecuteMsg::Mint {};
let cosmos_mint_msg = CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: env.contract.address.to_string(),
msg: to_binary(&execute_mint_msg)?,
funds: vec![],
});
let res = res.add_message(cosmos_mint_msg);
Ok(res)
let res = burn_to_mint::generate_burn_mint_response(info, env, msg, execute_mint_msg)
.map_err(|_| ContractError::BurnToMintError {});
res
}

pub fn execute_update_discount_price(
Expand Down
3 changes: 3 additions & 0 deletions contracts/minters/vending-minter/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,7 @@ pub enum ContractError {

#[error("Expected fungible token, received nonfungible")]
IncorrectFungibility {},

#[error("Burn to Mint Error")]
BurnToMintError {},
}
2 changes: 1 addition & 1 deletion packages/burn-to-mint/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "burn-to-mint"
authors = ["Michael Scotto <m@noreply.publicawsome.com>"]
authors = ["Michael Scotto <m@publicawsome.com>"]
description = "Burn to mint utility functions"
version = { workspace = true }
edition = { workspace = true }
Expand Down
17 changes: 3 additions & 14 deletions packages/burn-to-mint/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
use cosmwasm_schema::cw_serde;
use cosmwasm_std::StdError;
use std::env;

// use crate::error::ContractError;
// use crate::msg::{ConfigResponse, ExecuteMsg, TokenUriMsg};
// use crate::state::{increment_token_index, Config, COLLECTION_ADDRESS, CONFIG, STATUS};
pub mod msg;

use msg::TokenUriMsg;

#[cfg(not(feature = "library"))]
use cosmwasm_std::{from_binary, to_binary, CosmosMsg, DepsMut, Env, MessageInfo, WasmMsg};
use cosmwasm_std::{to_binary, CosmosMsg, Env, MessageInfo, WasmMsg};

use cw721::Cw721ReceiveMsg;
use serde::Serialize;
use sg_std::Response;

#[cw_serde]
pub struct BurnToMint();

pub fn execute_burn_to_mint<T>(
pub fn generate_burn_mint_response<T: Serialize>(
info: MessageInfo,
env: Env,
msg: Cw721ReceiveMsg,
Expand All @@ -35,7 +25,6 @@ pub fn execute_burn_to_mint<T>(
});
res = res.add_message(cosmos_burn_msg);
let execute_msg = to_binary(&execute_mint_msg)?;
// let execute_mint_msg = to_binary(&execute_mint_msg)?;
let cosmos_mint_msg = CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: env.contract.address.to_string(),
msg: to_binary(&execute_msg)?,
Expand Down

0 comments on commit 7cf1e64

Please sign in to comment.