diff --git a/Cargo.lock b/Cargo.lock index 1bc337b..02031c6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -397,7 +397,7 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "osmo-bindings" -version = "0.4.1" +version = "0.5.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -407,7 +407,7 @@ dependencies = [ [[package]] name = "osmo-bindings-test" -version = "0.4.1" +version = "0.5.0" dependencies = [ "anyhow", "cosmwasm-std", @@ -421,7 +421,7 @@ dependencies = [ [[package]] name = "osmo-reflect" -version = "0.4.1" +version = "0.5.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", diff --git a/contracts/reflect/Cargo.toml b/contracts/reflect/Cargo.toml index 59a794e..9269e07 100644 --- a/contracts/reflect/Cargo.toml +++ b/contracts/reflect/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "osmo-reflect" -version = "0.4.1" +version = "0.5.0" authors = ["Ethan Frey "] edition = "2018" description = "Reflect messages to use for test cases - based on cw-mask" @@ -19,7 +19,7 @@ backtraces = ["cosmwasm-std/backtraces"] [dependencies] cosmwasm-std = { version = "1.0.0-beta6", features = ["staking", "stargate"] } cosmwasm-storage = "1.0.0-beta6" -osmo-bindings = { version = "0.4.1", path = "../../packages/bindings" } +osmo-bindings = { version = "0.5.0", path = "../../packages/bindings" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = "1.0" diff --git a/contracts/reflect/src/contract.rs b/contracts/reflect/src/contract.rs index eb74844..45948ab 100644 --- a/contracts/reflect/src/contract.rs +++ b/contracts/reflect/src/contract.rs @@ -161,7 +161,7 @@ mod tests { }; use cosmwasm_std::{ coin, coins, from_binary, AllBalanceResponse, BankMsg, BankQuery, Binary, Coin, Event, - StakingMsg, StdError, SubMsgExecutionResponse, Uint128, + StakingMsg, StdError, SubMsgExecutionResponse, }; use cosmwasm_std::{OwnedDeps, SubMsgResult, SystemError}; use std::marker::PhantomData; @@ -277,12 +277,6 @@ mod tests { amount: coins(1, "token"), } .into(), - OsmosisMsg::MintTokens { - sub_denom: "bonus".to_string(), - amount: Uint128::new(123456789), - recipient: "creator".to_string(), - } - .into(), StakingMsg::Delegate { validator: String::from("validator"), amount: coin(100, "ustake"), diff --git a/packages/bindings-test/Cargo.toml b/packages/bindings-test/Cargo.toml index f59cc99..941ec32 100644 --- a/packages/bindings-test/Cargo.toml +++ b/packages/bindings-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "osmo-bindings-test" -version = "0.4.1" +version = "0.5.0" authors = ["Ethan Frey "] edition = "2018" description = "Multitest (and other test helpers) support for Osmosis-specific contracts" @@ -9,7 +9,7 @@ homepage = "https://osmosis.zone" license = "Apache-2.0" [dependencies] -osmo-bindings = { version = "0.4.1", path = "../bindings" } +osmo-bindings = { version = "0.5.0", path = "../bindings" } cosmwasm-std = { version = "1.0.0-beta6" } schemars = "0.8" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/packages/bindings-test/src/multitest.rs b/packages/bindings-test/src/multitest.rs index 0b4b6f6..8832e48 100644 --- a/packages/bindings-test/src/multitest.rs +++ b/packages/bindings-test/src/multitest.rs @@ -18,8 +18,8 @@ use cw_multi_test::{ use cw_storage_plus::Map; use osmo_bindings::{ - EstimatePriceResponse, FullDenomResponse, OsmosisMsg, OsmosisQuery, PoolStateResponse, - SpotPriceResponse, SwapAmount, SwapAmountWithLimit, + EstimatePriceResponse, OsmosisMsg, OsmosisQuery, PoolStateResponse, SpotPriceResponse, + SwapAmount, SwapAmountWithLimit, }; pub const POOLS: Map = Map::new("pools"); @@ -174,11 +174,6 @@ pub struct OsmosisModule {} pub const BLOCK_TIME: u64 = 5; impl OsmosisModule { - fn build_denom(&self, contract: &Addr, sub_denom: &str) -> String { - // TODO: validation assertion on sub_denom - format!("cw/{}/{}", contract, sub_denom) - } - /// Used to mock out the response for TgradeQuery::ValidatorVotes pub fn set_pool(&self, storage: &mut dyn Storage, pool_id: u64, pool: &Pool) -> StdResult<()> { POOLS.save(storage, pool_id, pool) @@ -204,24 +199,6 @@ impl Module for OsmosisModule { QueryC: CustomQuery + DeserializeOwned + 'static, { match msg { - OsmosisMsg::MintTokens { - sub_denom, - amount, - recipient, - } => { - let denom = self.build_denom(&sender, &sub_denom); - let mint = BankSudo::Mint { - to_address: recipient, - amount: coins(amount.u128(), &denom), - }; - router.sudo(api, storage, block, mint.into())?; - - let data = Some(to_binary(&FullDenomResponse { denom })?); - Ok(AppResponse { - data, - events: vec![], - }) - } OsmosisMsg::Swap { first, route, @@ -284,22 +261,13 @@ impl Module for OsmosisModule { fn query( &self, - api: &dyn Api, + _api: &dyn Api, storage: &dyn Storage, _querier: &dyn Querier, _block: &BlockInfo, request: OsmosisQuery, ) -> anyhow::Result { match request { - OsmosisQuery::FullDenom { - contract, - sub_denom, - } => { - let contract = api.addr_validate(&contract)?; - let denom = self.build_denom(&contract, &sub_denom); - let res = FullDenomResponse { denom }; - Ok(to_binary(&res)?) - } OsmosisQuery::PoolState { id } => { let pool = POOLS.load(storage, id)?; let res = pool.into_response(id); @@ -314,7 +282,7 @@ impl Module for OsmosisModule { Ok(to_binary(&SpotPriceResponse { price })?) } OsmosisQuery::EstimateSwap { - contract: _sender, + sender: _sender, first, route, amount, @@ -425,53 +393,6 @@ mod tests { use cw_multi_test::Executor; use osmo_bindings::Swap; - #[test] - fn mint_token() { - let contract = Addr::unchecked("govner"); - let rcpt = Addr::unchecked("townies"); - let sub_denom = "fundz"; - - let mut app = OsmosisApp::new(); - - // no tokens - let start = app.wrap().query_all_balances(rcpt.as_str()).unwrap(); - assert_eq!(start, vec![]); - - // let's find the mapping - let FullDenomResponse { denom } = app - .wrap() - .query( - &OsmosisQuery::FullDenom { - contract: contract.to_string(), - sub_denom: sub_denom.to_string(), - } - .into(), - ) - .unwrap(); - assert_ne!(denom, sub_denom); - assert!(denom.len() > 10); - - // prepare to mint - let amount = Uint128::new(1234567); - let msg = OsmosisMsg::MintTokens { - sub_denom: sub_denom.to_string(), - amount, - recipient: rcpt.to_string(), - }; - - // simulate contract calling - app.execute(contract, msg.into()).unwrap(); - - // we got tokens! - let end = app.wrap().query_balance(rcpt.as_str(), &denom).unwrap(); - let expected = Coin { denom, amount }; - assert_eq!(end, expected); - - // but no minting of unprefixed version - let empty = app.wrap().query_balance(rcpt.as_str(), sub_denom).unwrap(); - assert_eq!(empty.amount, Uint128::zero()); - } - #[test] fn query_pool() { let coin_a = coin(6_000_000u128, "osmo"); diff --git a/packages/bindings/Cargo.toml b/packages/bindings/Cargo.toml index c9b9409..df68e04 100644 --- a/packages/bindings/Cargo.toml +++ b/packages/bindings/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "osmo-bindings" -version = "0.4.1" +version = "0.5.0" authors = ["Ethan Frey "] edition = "2018" description = "Bindings for CustomMsg and CustomQuery for the Osmosis blockchain" diff --git a/packages/bindings/examples/schema.rs b/packages/bindings/examples/schema.rs index 2c9b055..3817e37 100644 --- a/packages/bindings/examples/schema.rs +++ b/packages/bindings/examples/schema.rs @@ -4,8 +4,7 @@ use std::fs::create_dir_all; use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; use osmo_bindings::{ - EstimatePriceResponse, FullDenomResponse, OsmosisMsg, OsmosisQuery, PoolStateResponse, - SpotPriceResponse, + EstimatePriceResponse, OsmosisMsg, OsmosisQuery, PoolStateResponse, SpotPriceResponse, }; fn main() { @@ -16,7 +15,6 @@ fn main() { export_schema(&schema_for!(OsmosisMsg), &out_dir); export_schema(&schema_for!(OsmosisQuery), &out_dir); - export_schema(&schema_for!(FullDenomResponse), &out_dir); export_schema(&schema_for!(PoolStateResponse), &out_dir); export_schema(&schema_for!(SpotPriceResponse), &out_dir); export_schema(&schema_for!(EstimatePriceResponse), &out_dir); diff --git a/packages/bindings/src/lib.rs b/packages/bindings/src/lib.rs index 52f0333..dd4fac9 100644 --- a/packages/bindings/src/lib.rs +++ b/packages/bindings/src/lib.rs @@ -3,9 +3,7 @@ mod query; mod types; pub use msg::OsmosisMsg; -pub use query::{ - EstimatePriceResponse, FullDenomResponse, OsmosisQuery, PoolStateResponse, SpotPriceResponse, -}; +pub use query::{EstimatePriceResponse, OsmosisQuery, PoolStateResponse, SpotPriceResponse}; pub use types::{Step, Swap, SwapAmount, SwapAmountWithLimit}; // This is a signal, such that any contract that imports these helpers will only run on the diff --git a/packages/bindings/src/msg.rs b/packages/bindings/src/msg.rs index d7b6f7c..7c753a3 100644 --- a/packages/bindings/src/msg.rs +++ b/packages/bindings/src/msg.rs @@ -3,23 +3,12 @@ use serde::{Deserialize, Serialize}; use crate::types::SwapAmountWithLimit; use crate::{Step, Swap}; -use cosmwasm_std::{CosmosMsg, CustomMsg, Uint128}; +use cosmwasm_std::{CosmosMsg, CustomMsg}; #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] #[serde(rename_all = "snake_case")] /// A number of Custom messages that can call into the Osmosis bindings pub enum OsmosisMsg { - /// Contracts can mint native tokens that have an auto-generated denom - /// namespaced under the contract's address. A contract may create any number - /// of independent sub-denoms. - /// Returns FullDenomResponse in the data field of the Response - MintTokens { - /// Must be 2-32 alphanumeric characters - /// FIXME: revisit actual requirements in SDK - sub_denom: String, - amount: Uint128, - recipient: String, - }, /// Swap over one or more pools /// Returns EstimatePriceResponse in the data field of the Response Swap { diff --git a/packages/bindings/src/query.rs b/packages/bindings/src/query.rs index 0a42b3c..43655a4 100644 --- a/packages/bindings/src/query.rs +++ b/packages/bindings/src/query.rs @@ -7,11 +7,6 @@ use cosmwasm_std::{Coin, CustomQuery, Decimal, Uint128}; #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] #[serde(rename_all = "snake_case")] pub enum OsmosisQuery { - /// Given a sub-denom minted by a contract via `OsmosisMsg::MintTokens`, - /// returns the full denom as used by `BankMsg::Send`. - /// You may call `FullDenom { contract: env.contract.address, sub_denom }` to find the denom issued - /// by the current contract. - FullDenom { contract: String, sub_denom: String }, /// For a given pool ID, list all tokens traded on it with current liquidity (spot). /// As well as the total number of LP shares and their denom PoolState { id: u64 }, @@ -25,7 +20,7 @@ pub enum OsmosisQuery { /// Warning: this can easily be manipulated via sandwich attacks, do not use as price oracle. /// We will add TWAP for more robust price feed. EstimateSwap { - contract: String, + sender: String, first: Swap, route: Vec, amount: SwapAmount, @@ -52,7 +47,7 @@ impl OsmosisQuery { amount: SwapAmount, ) -> Self { OsmosisQuery::EstimateSwap { - contract: contract.into(), + sender: contract.into(), first: Swap::new(pool_id, denom_in, denom_out), amount, route: vec![], @@ -60,11 +55,6 @@ impl OsmosisQuery { } } -#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -pub struct FullDenomResponse { - pub denom: String, -} - #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] pub struct PoolStateResponse { /// The various assets that be swapped. Including current liquidity.