Skip to content

Commit

Permalink
commit error
Browse files Browse the repository at this point in the history
  • Loading branch information
humanalgorithm committed Aug 19, 2023
1 parent 79f13a8 commit 7da1754
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 7 deletions.
24 changes: 24 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +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" }
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
22 changes: 15 additions & 7 deletions contracts/minters/base-minter/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,27 @@ pub fn execute(
ExecuteMsg::UpdateStartTradingTime(time) => {
execute_update_start_trading_time(deps, env, info, time)
}
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 token_uri_msg: TokenUriMsg = from_binary(&msg.msg)?;
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 {
Expand All @@ -136,13 +148,9 @@ pub fn execute_burn_to_mint(
});
res = res.add_message(cosmos_burn_msg);

let token_uri_msg: TokenUriMsg = from_binary(&msg.msg)?;
let execute_mint_msg = ExecuteMsg::Mint {
token_uri: token_uri_msg.token_uri,
};
let cosmos_mint_msg = CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: env.contract.address.to_string(),
msg: to_binary(&execute_mint_msg)?,
msg: to_binary(&execute_mint_msg.into())?,
funds: vec![],
});
let res = res.add_message(cosmos_mint_msg);
Expand Down
40 changes: 40 additions & 0 deletions packages/burn-to-mint/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[package]
name = "burn-to-mint"
authors = ["Michael Scotto <m@noreply.publicawsome.com>"]
description = "Burn to mint utility functions"
version = { workspace = true }
edition = { workspace = true }
homepage = { workspace = true }
repository = { workspace = true }
license = { workspace = true }

exclude = [
# Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication.
"contract.wasm",
"hash.txt",
]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
crate-type = ["cdylib", "rlib"]

[dependencies]
cosmwasm-schema = { workspace = true }
cosmwasm-std = { workspace = true, features = ["staking"] }
base-factory = { workspace = true }
cw2 = { workspace = true }
cw721 = { workspace = true }
cw721-base = { workspace = true, features = ["library"] }
cw-storage-plus = { workspace = true }
cw-utils = { workspace = true }
schemars = { workspace = true }
serde = { workspace = true }
sg1 = { workspace = true }
sg2 = { workspace = true }
sg4 = { workspace = true }
sg721 = { workspace = true }
sg721-base = { workspace = true, features = ["library"] }
sg-std = { workspace = true }
thiserror = { workspace = true }
url = { workspace = true }
46 changes: 46 additions & 0 deletions packages/burn-to-mint/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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 cw721::Cw721ReceiveMsg;
use sg_std::Response;

#[cw_serde]
pub struct BurnToMint();

pub fn execute_burn_to_mint<T>(
info: MessageInfo,
env: Env,
msg: Cw721ReceiveMsg,
execute_mint_msg: T,
) -> Result<Response, StdError> {
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_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)?,
funds: vec![],
});
let res = res.add_message(cosmos_mint_msg);
Ok(res)
}
6 changes: 6 additions & 0 deletions packages/burn-to-mint/src/msg.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use cosmwasm_schema::cw_serde;

#[cw_serde]
pub struct TokenUriMsg {
pub token_uri: String,
}

0 comments on commit 7da1754

Please sign in to comment.