diff --git a/contracts/external/cw-abc/src/commands.rs b/contracts/external/cw-abc/src/commands.rs index c661ccfb8..447597bd1 100644 --- a/contracts/external/cw-abc/src/commands.rs +++ b/contracts/external/cw-abc/src/commands.rs @@ -140,8 +140,8 @@ pub fn execute_sell( // Execute burn on the cw-tokenfactory-issuer contract CosmosMsg::::Wasm(WasmMsg::Execute { contract_addr: issuer_addr.to_string(), - msg: to_binary(&IssuerExecuteMsg::Mint { - to_address: info.sender.to_string(), + msg: to_binary(&IssuerExecuteMsg::Burn { + from_address: info.sender.to_string(), amount: burn_amount, })?, funds: vec![], @@ -178,8 +178,8 @@ pub fn execute_sell( }; Ok(Response::::new() - .add_messages(burn_msgs) .add_message(msg_send) + .add_messages(burn_msgs) .add_attribute("action", "burn") .add_attribute("from", burner) .add_attribute("amount", burn_amount) diff --git a/contracts/external/cw-abc/src/contract.rs b/contracts/external/cw-abc/src/contract.rs index 4a7c489d7..e9ce64d4d 100644 --- a/contracts/external/cw-abc/src/contract.rs +++ b/contracts/external/cw-abc/src/contract.rs @@ -244,6 +244,17 @@ pub fn reply( funds: vec![], }); + // Grant an allowance to burn + msgs.push(WasmMsg::Execute { + contract_addr: issuer_addr.clone(), + msg: to_binary(&IssuerExecuteMsg::SetBurnerAllowance { + address: env.contract.address.to_string(), + // TODO let this be capped + allowance: Uint128::MAX, + })?, + funds: vec![], + }); + // TODO fix metadata // // If metadata, set it by calling the contract // if let Some(metadata) = token_info.metadata { diff --git a/contracts/external/cw-abc/src/test_tube/integration_tests.rs b/contracts/external/cw-abc/src/test_tube/integration_tests.rs index 8a3b7fe25..54b1d1c4c 100644 --- a/contracts/external/cw-abc/src/test_tube/integration_tests.rs +++ b/contracts/external/cw-abc/src/test_tube/integration_tests.rs @@ -1,22 +1,57 @@ -use crate::msg::ExecuteMsg; +use crate::msg::{ + CommonsPhaseConfigResponse, CurveInfoResponse, DenomResponse, ExecuteMsg, QueryMsg, +}; use super::test_env::{TestEnv, TestEnvBuilder}; use cosmwasm_std::coins; -use osmosis_test_tube::OsmosisTestApp; +use cw_tokenfactory_issuer::msg::QueryMsg as IssuerQueryMsg; +use osmosis_test_tube::{Account, OsmosisTestApp}; #[test] fn test_happy_path() { let app = OsmosisTestApp::new(); - let env = TestEnvBuilder::new(); - let TestEnv { abc, accounts, .. } = env.default_setup(&app); + let builder = TestEnvBuilder::new(); + let env = builder.default_setup(&app); + let TestEnv { + ref abc, + ref accounts, + ref tf_issuer, + .. + } = env; // Buy tokens abc.execute(&ExecuteMsg::Buy {}, &coins(1000000, "uosmo"), &accounts[0]) .unwrap(); - // TODO query curve + // Query denom + let denom = tf_issuer + .query::(&IssuerQueryMsg::Denom {}) + .unwrap() + .denom; + println!("Denom {:?}", denom); - // TODO burn + // Query balances + let balances = env.bank().query_all_balances( + &osmosis_test_tube::osmosis_std::types::cosmos::bank::v1beta1::QueryAllBalancesRequest { + address: accounts[0].address(), + pagination: None, + }, + ).unwrap(); + println!("{:?}", balances); + + // Query curve + let curve_info: CurveInfoResponse = abc.query(&QueryMsg::CurveInfo {}).unwrap(); + println!("Curve {:?}", curve_info); + + let phase: CommonsPhaseConfigResponse = abc.query(&QueryMsg::PhaseConfig {}).unwrap(); + println!("Phase {:?}", phase); + + // Burn + abc.execute(&ExecuteMsg::Burn {}, &coins(900000, denom), &accounts[0]) + .unwrap(); + + let curve_info: CurveInfoResponse = abc.query(&QueryMsg::CurveInfo {}).unwrap(); + println!("Curve {:?}", curve_info); }