Skip to content

Commit

Permalink
chore: add mocked bank supply
Browse files Browse the repository at this point in the history
  • Loading branch information
gorgos committed Jan 25, 2024
1 parent 424abf4 commit be2ceea
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 19 deletions.
26 changes: 13 additions & 13 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion contracts/atomic-order-example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.20", 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" ] }
Expand Down
2 changes: 1 addition & 1 deletion contracts/dummy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.20", path = "../../packages/injective-cosmwasm" }
schemars = "0.8.8"
serde = { version = "1.0.136", default-features = false, features = [ "derive" ] }
thiserror = { version = "1.0.30" }
2 changes: 1 addition & 1 deletion packages/injective-cosmwasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.20"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
Expand Down
10 changes: 8 additions & 2 deletions packages/injective-cosmwasm/src/exchange_mock_querier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ fn default_pyth_price_response_handler() -> QuerierResult {
SystemResult::Ok(ContractResult::from(to_json_binary(&response)))
}

fn default_token_factory_denom_total_supply_handler() -> QuerierResult {
fn default_total_supply_handler() -> QuerierResult {
let response = TokenFactoryDenomSupplyResponse {
total_supply: Uint128::from(1000u128),
};
Expand Down Expand Up @@ -495,6 +495,7 @@ pub struct WasmMockQuerier {
pub token_factory_denom_creation_fee_handler: Option<Box<dyn HandlesFeeQuery>>,
pub balance_query_handler: Option<Box<dyn HandlesBankBalanceQuery>>,
pub all_balances_query_handler: Option<Box<dyn HandlesBankAllBalancesQuery>>,
pub total_supply_handler: Option<Box<dyn HandlesDenomSupplyQuery>>,
pub registered_contract_info_query_handler: Option<Box<dyn HandlesByAddressQuery>>,
pub spot_market_orderbook_response_handler: Option<Box<dyn HandlesPriceLevelsQuery>>,
pub derivative_market_orderbook_response_handler: Option<Box<dyn HandlesDerivativePriceLevelsQuery>>,
Expand Down Expand Up @@ -533,6 +534,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_total_supply_handler(),
},
_ => panic!("unsupported"),
},
QueryRequest::Custom(query) => match query.query_data.clone() {
Expand Down Expand Up @@ -679,7 +684,7 @@ impl WasmMockQuerier {
},
InjectiveQuery::TokenFactoryDenomTotalSupply { denom } => match &self.token_factory_denom_total_supply_handler {
Some(handler) => handler.handle(denom),
None => default_token_factory_denom_total_supply_handler(),
None => default_total_supply_handler(),
},
InjectiveQuery::TokenFactoryDenomCreationFee {} => match &self.token_factory_denom_creation_fee_handler {
Some(handler) => handler.handle(),
Expand Down Expand Up @@ -753,6 +758,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,
}
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/injective-cosmwasm/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/injective-testing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.20", path = "../injective-cosmwasm" }
injective-math = { version = "0.2.4", path = "../injective-math" }
rand = { version = "0.4.6" }
secp256k1 = { version = "0.6.2" }
Expand Down

0 comments on commit be2ceea

Please sign in to comment.