Skip to content

Commit

Permalink
Fixups, burning tokens still doesn't work
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeHartnell committed Sep 1, 2023
1 parent 0e39a50 commit f2f40b2
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 9 deletions.
6 changes: 3 additions & 3 deletions contracts/external/cw-abc/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ pub fn execute_sell(
// Execute burn on the cw-tokenfactory-issuer contract
CosmosMsg::<TokenFactoryMsg>::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![],
Expand Down Expand Up @@ -178,8 +178,8 @@ pub fn execute_sell(
};

Ok(Response::<TokenFactoryMsg>::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)
Expand Down
11 changes: 11 additions & 0 deletions contracts/external/cw-abc/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
47 changes: 41 additions & 6 deletions contracts/external/cw-abc/src/test_tube/integration_tests.rs
Original file line number Diff line number Diff line change
@@ -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::<DenomResponse>(&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);
}

0 comments on commit f2f40b2

Please sign in to comment.