diff --git a/Cargo.lock b/Cargo.lock index ec8fb742..2421ddf4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ "cw-storage-plus 1.2.0", "cw-utils 0.16.0", "cw2 0.16.0", - "injective-cosmwasm 0.2.18", + "injective-cosmwasm 0.2.21", "injective-math 0.2.4", "injective-protobuf", "protobuf", @@ -774,7 +774,7 @@ dependencies = [ "cosmwasm-std", "cw-storage-plus 1.2.0", "cw2 0.16.0", - "injective-cosmwasm 0.2.18", + "injective-cosmwasm 0.2.21", "schemars", "serde 1.0.194", "thiserror", @@ -1519,36 +1519,36 @@ dependencies = [ [[package]] name = "injective-cosmwasm" version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53b6f08b14a23696948d51ba6a050382cbc6e23522efec3ca607a5b1a317de0c" dependencies = [ - "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus 1.2.0", "ethereum-types", "hex", - "injective-math 0.2.4", + "injective-math 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "schemars", "serde 1.0.194", - "serde-json-wasm 1.0.0", "serde_repr", - "serde_test", "subtle-encoding", "tiny-keccak", ] [[package]] name = "injective-cosmwasm" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53b6f08b14a23696948d51ba6a050382cbc6e23522efec3ca607a5b1a317de0c" +version = "0.2.21" dependencies = [ + "cosmwasm-schema", "cosmwasm-std", "cw-storage-plus 1.2.0", "ethereum-types", "hex", - "injective-math 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "injective-math 0.2.4", "schemars", "serde 1.0.194", + "serde-json-wasm 1.0.0", "serde_repr", + "serde_test", "subtle-encoding", "tiny-keccak", ] @@ -1560,7 +1560,7 @@ dependencies = [ "cosmwasm-std", "cw-storage-plus 1.2.0", "cw2 0.16.0", - "injective-cosmwasm 0.2.18", + "injective-cosmwasm 0.2.21", "injective-math 0.2.4", "injective-std 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "injective-test-tube", @@ -1652,7 +1652,7 @@ dependencies = [ "cosmrs", "cosmwasm-std", "hex", - "injective-cosmwasm 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", + "injective-cosmwasm 0.2.18", "injective-std 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "prost 0.11.9", "serde 1.0.194", @@ -1669,7 +1669,7 @@ dependencies = [ "base64 0.13.1", "cosmwasm-std", "cw-multi-test", - "injective-cosmwasm 0.2.18", + "injective-cosmwasm 0.2.21", "injective-math 0.2.4", "rand 0.4.6", "secp256k1", diff --git a/contracts/atomic-order-example/Cargo.toml b/contracts/atomic-order-example/Cargo.toml index 8a75b928..199174b4 100644 --- a/contracts/atomic-order-example/Cargo.toml +++ b/contracts/atomic-order-example/Cargo.toml @@ -34,7 +34,7 @@ cosmwasm-storage = { version = "1.5.0", features = [ "iterator" ] } cw-storage-plus = { version = "1.2.0" } cw-utils = { version = "0.16.0" } cw2 = { version = "0.16.0" } -injective-cosmwasm = { version = "0.2.18", path = "../../packages/injective-cosmwasm" } +injective-cosmwasm = { version = "0.2.21", path = "../../packages/injective-cosmwasm" } injective-math = { version = "0.2.4", path = "../../packages/injective-math" } injective-protobuf = { version = "0.2.2", path = "../../packages/injective-protobuf" } protobuf = { version = "2.28.0", features = [ "with-bytes" ] } diff --git a/contracts/dummy/Cargo.toml b/contracts/dummy/Cargo.toml index d5586880..29b6389b 100644 --- a/contracts/dummy/Cargo.toml +++ b/contracts/dummy/Cargo.toml @@ -32,7 +32,7 @@ optimize = """docker run --rm -v "$(pwd)":/code \ cosmwasm-std = { version = "1.5.0", features = [ "abort", "cosmwasm_1_2", "cosmwasm_1_3", "cosmwasm_1_4", "iterator", "stargate" ] } cw-storage-plus = { version = "1.2.0" } cw2 = { version = "0.16.0" } -injective-cosmwasm = { version = "0.2.18", path = "../../packages/injective-cosmwasm" } +injective-cosmwasm = { version = "0.2.21", path = "../../packages/injective-cosmwasm" } schemars = "0.8.8" serde = { version = "1.0.136", default-features = false, features = [ "derive" ] } thiserror = { version = "1.0.30" } diff --git a/packages/injective-cosmwasm/Cargo.toml b/packages/injective-cosmwasm/Cargo.toml index 4ba81d20..3275b07d 100644 --- a/packages/injective-cosmwasm/Cargo.toml +++ b/packages/injective-cosmwasm/Cargo.toml @@ -6,7 +6,7 @@ license = "Apache-2.0" name = "injective-cosmwasm" readme = "README.md" repository = "https://github.com/InjectiveLabs/cw-injective/tree/dev/packages/injective-cosmwasm" -version = "0.2.18" +version = "0.2.21" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] diff --git a/packages/injective-cosmwasm/src/exchange_mock_querier.rs b/packages/injective-cosmwasm/src/exchange_mock_querier.rs index 42081c72..738ddea6 100644 --- a/packages/injective-cosmwasm/src/exchange_mock_querier.rs +++ b/packages/injective-cosmwasm/src/exchange_mock_querier.rs @@ -4,7 +4,7 @@ use std::str::FromStr; use cosmwasm_std::testing::{MockApi, MockStorage}; use cosmwasm_std::{ from_json, to_json_binary, Addr, AllBalanceResponse, BalanceResponse, BankQuery, Binary, Coin, ContractResult, OwnedDeps, Querier, QuerierResult, - QueryRequest, SystemError, SystemResult, Uint128, WasmQuery, + QueryRequest, SupplyResponse, SystemError, SystemResult, Uint128, WasmQuery, }; use injective_math::FPDecimal; @@ -18,6 +18,7 @@ use crate::oracle::{ types::{OracleHistoryOptions, OracleType, PriceState, PythPriceState}, volatility::TradeHistoryOptions, }; + use crate::tokenfactory::response::{TokenFactoryCreateDenomFeeResponse, TokenFactoryDenomSupplyResponse}; use crate::wasmx::response::QueryContractRegistrationInfoResponse; use crate::{ @@ -254,6 +255,14 @@ fn default_token_factory_denom_total_supply_handler() -> QuerierResult { SystemResult::Ok(ContractResult::from(to_json_binary(&response))) } +fn default_bank_total_supply_handler() -> QuerierResult { + let response = SupplyResponse::new(Coin { + denom: "inj".to_string(), + amount: Uint128::from(1000u128), + }); + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) +} + fn default_token_factory_denom_creation_fee_handler() -> QuerierResult { let response = TokenFactoryCreateDenomFeeResponse { fee: vec![Coin::new(10, "inj")], @@ -495,6 +504,7 @@ pub struct WasmMockQuerier { pub token_factory_denom_creation_fee_handler: Option>, pub balance_query_handler: Option>, pub all_balances_query_handler: Option>, + pub total_supply_handler: Option>, pub registered_contract_info_query_handler: Option>, pub spot_market_orderbook_response_handler: Option>, pub derivative_market_orderbook_response_handler: Option>, @@ -533,6 +543,10 @@ impl WasmMockQuerier { Some(handler) => handler.handle(address.to_string()), None => default_all_balances_bank_query_handler(), }, + BankQuery::Supply { denom } => match &self.total_supply_handler { + Some(handler) => handler.handle(denom.to_string()), + None => default_bank_total_supply_handler(), + }, _ => panic!("unsupported"), }, QueryRequest::Custom(query) => match query.query_data.clone() { @@ -753,6 +767,7 @@ impl WasmMockQuerier { spot_market_orderbook_response_handler: None, derivative_market_orderbook_response_handler: None, market_atomic_execution_fee_multiplier_response_handler: None, + total_supply_handler: None, } } } @@ -781,8 +796,8 @@ impl TestDeposit { pub mod handlers { use cosmwasm_std::{ - to_json_binary, AllBalanceResponse, BalanceResponse, Binary, Coin, ContractResult, QuerierResult, StdResult, SystemError, SystemResult, - Uint128, + to_json_binary, AllBalanceResponse, BalanceResponse, Binary, Coin, ContractResult, QuerierResult, StdResult, SupplyResponse, SystemError, + SystemResult, Uint128, }; use std::collections::HashMap; @@ -1180,6 +1195,19 @@ pub mod handlers { })) } + pub fn create_bank_supply_handler(supply: Uint128) -> Option> { + struct Temp { + supply: Uint128, + } + impl HandlesDenomSupplyQuery for Temp { + fn handle(&self, denom: String) -> QuerierResult { + let response = SupplyResponse::new(Coin { denom, amount: self.supply }); + SystemResult::Ok(ContractResult::from(to_json_binary(&response))) + } + } + Some(Box::new(Temp { supply })) + } + pub fn create_denom_supply_handler(supply: Uint128) -> Option> { struct Temp { supply: Uint128, diff --git a/packages/injective-cosmwasm/src/query.rs b/packages/injective-cosmwasm/src/query.rs index 5b8378c3..3a4b8066 100644 --- a/packages/injective-cosmwasm/src/query.rs +++ b/packages/injective-cosmwasm/src/query.rs @@ -101,6 +101,7 @@ pub enum InjectiveQuery { PerpetualMarketFunding { market_id: MarketId, }, + // Make sure you are aware of the potential to run out of gas when using this query MarketVolatility { market_id: MarketId, trade_history_options: TradeHistoryOptions, diff --git a/packages/injective-testing/Cargo.toml b/packages/injective-testing/Cargo.toml index ef6d1d6f..739c71ca 100644 --- a/packages/injective-testing/Cargo.toml +++ b/packages/injective-testing/Cargo.toml @@ -12,7 +12,7 @@ anyhow = { version = "1.0.66" } base64 = { version = "0.13.1" } cosmwasm-std = { version = "1.5.0", features = [ "abort", "cosmwasm_1_2", "cosmwasm_1_3", "cosmwasm_1_4", "iterator", "stargate" ] } cw-multi-test = { version = "0.16.2" } -injective-cosmwasm = { version = "0.2.18", path = "../injective-cosmwasm" } +injective-cosmwasm = { version = "0.2.21", path = "../injective-cosmwasm" } injective-math = { version = "0.2.4", path = "../injective-math" } rand = { version = "0.4.6" } secp256k1 = { version = "0.6.2" }