diff --git a/Cargo.toml b/Cargo.toml index 606b72e5..b7e7da2a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,21 +14,21 @@ incremental = false overflow-checks = true [workspace.dependencies] -cosmwasm-std = "1.4.0" -cw2 = "1.1.1" +cosmwasm-std = "2.0.4" +cw2 = "2.0.0" schemars = "0.8.15" serde = { version = "1.0.188", default-features = false } serde-json-wasm = "1.0.0" -cw-storage-plus = "1.1.0" -cosmwasm-schema = { version = "1.4.0", default-features = false } -base64 = "0.21.4" +cw-storage-plus = "2.0.0" +cosmwasm-schema = { version = "2.0.4", default-features = false } +base64 = "0.21.7" prost = "0.12.3" prost-types = "0.12.1" cosmos-sdk-proto = { version = "0.20.0", default-features = false } bech32 = "0.9.1" thiserror = "1.0.49" -protobuf = { version = "3.3.0" } +protobuf = "~3.3.0" hex = "0.4.3" serde_json = { version = "1.0.87" } -tendermint-proto = "0.34" +tendermint-proto = "0.34.1" speedate = "0.13.0" \ No newline at end of file diff --git a/contracts/ibc_transfer/.cargo/config b/contracts/ibc_transfer/.cargo/config index 7ab58a79..ddb87ef6 100644 --- a/contracts/ibc_transfer/.cargo/config +++ b/contracts/ibc_transfer/.cargo/config @@ -1,6 +1,6 @@ [alias] wasm = "build --release --target wasm32-unknown-unknown" wasm-debug = "build --target wasm32-unknown-unknown" -unit-test = "test --lib --features backtraces" +unit-test = "test --lib" integration-test = "test --test integration" schema = "run --bin ibc_transfer_schema" diff --git a/contracts/ibc_transfer/Cargo.toml b/contracts/ibc_transfer/Cargo.toml index d26fa6da..e53f6dae 100644 --- a/contracts/ibc_transfer/Cargo.toml +++ b/contracts/ibc_transfer/Cargo.toml @@ -15,8 +15,6 @@ crate-type = ["cdylib", "rlib"] [features] # for quicker tests, cargo test --lib -# for more explicit tests, cargo test --features=backtraces -backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] diff --git a/contracts/ibc_transfer/src/contract.rs b/contracts/ibc_transfer/src/contract.rs index 2c9ab62e..46ddeb0c 100644 --- a/contracts/ibc_transfer/src/contract.rs +++ b/contracts/ibc_transfer/src/contract.rs @@ -1,11 +1,13 @@ use cosmwasm_std::{ - coin, entry_point, from_json, Binary, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Reply, - Response, StdError, StdResult, SubMsg, + coin, entry_point, Binary, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Reply, Response, + StdError, StdResult, SubMsg, }; use cw2::set_contract_version; +use neutron_sdk::interchain_txs::helpers::decode_message_response; +use neutron_sdk::proto_types::neutron::transfer::MsgTransferResponse; use neutron_sdk::{ bindings::{ - msg::{IbcFee, MsgIbcTransferResponse, NeutronMsg}, + msg::{IbcFee, NeutronMsg}, query::NeutronQuery, }, query::min_ibc_fee::query_min_ibc_fee, @@ -112,12 +114,14 @@ fn msg_with_sudo_callback>, T>( // and process this payload when an acknowledgement for the SubmitTx message is received in Sudo handler fn prepare_sudo_payload(mut deps: DepsMut, _env: Env, msg: Reply) -> StdResult { let payload = read_reply_payload(deps.storage, msg.id)?; - let resp: MsgIbcTransferResponse = from_json( - msg.result + let resp: MsgTransferResponse = decode_message_response( + &msg.result .into_result() .map_err(StdError::generic_err)? - .data - .ok_or_else(|| StdError::generic_err("no result"))?, + .msg_responses[0] // msg_responses must have exactly one Msg response: https://github.com/neutron-org/neutron/blob/28b1d2ce968aaf1866e92d5286487f079eba3370/wasmbinding/message_plugin.go#L307 + .clone() + .value + .to_vec(), ) .map_err(|e| StdError::generic_err(format!("failed to parse response: {:?}", e)))?; let seq_id = resp.sequence_id; diff --git a/contracts/ibc_transfer/src/state.rs b/contracts/ibc_transfer/src/state.rs index cdd2a315..63221f0e 100644 --- a/contracts/ibc_transfer/src/state.rs +++ b/contracts/ibc_transfer/src/state.rs @@ -34,7 +34,7 @@ pub fn save_reply_payload(store: &mut dyn Storage, payload: SudoPayload) -> StdR pub fn read_reply_payload(store: &dyn Storage, id: u64) -> StdResult { let data = REPLY_QUEUE_ID.load(store, id)?; - from_json(Binary(data)) + from_json(Binary::new(data)) } /// SUDO_PAYLOAD - tmp storage for sudo handler payloads @@ -59,5 +59,5 @@ pub fn read_sudo_payload( seq_id: u64, ) -> StdResult { let data = SUDO_PAYLOAD.load(store, (channel_id, seq_id))?; - from_json(Binary(data)) + from_json(Binary::new(data)) } diff --git a/contracts/neutron_interchain_queries/.cargo/config b/contracts/neutron_interchain_queries/.cargo/config index a746caf0..9e2d5edb 100644 --- a/contracts/neutron_interchain_queries/.cargo/config +++ b/contracts/neutron_interchain_queries/.cargo/config @@ -1,6 +1,6 @@ [alias] wasm = "build --release --target wasm32-unknown-unknown" wasm-debug = "build --target wasm32-unknown-unknown" -unit-test = "test --lib --features backtraces" +unit-test = "test --lib" integration-test = "test --test integration" schema = "run --bin neutron_interchain_queries_schema" diff --git a/contracts/neutron_interchain_queries/Cargo.toml b/contracts/neutron_interchain_queries/Cargo.toml index 56e1fbae..5682a1a8 100644 --- a/contracts/neutron_interchain_queries/Cargo.toml +++ b/contracts/neutron_interchain_queries/Cargo.toml @@ -14,8 +14,6 @@ exclude = [ crate-type = ["cdylib", "rlib"] [features] -# for more explicit tests, cargo test --features=backtraces -backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] @@ -32,4 +30,3 @@ cosmwasm-schema = { workspace = true } [dev-dependencies] base64 = { workspace = true } - diff --git a/contracts/neutron_interchain_queries/src/testing/mock_querier.rs b/contracts/neutron_interchain_queries/src/testing/mock_querier.rs index b82c8b94..4d19d376 100644 --- a/contracts/neutron_interchain_queries/src/testing/mock_querier.rs +++ b/contracts/neutron_interchain_queries/src/testing/mock_querier.rs @@ -89,7 +89,7 @@ impl WasmMockQuerier { validators: &[Validator], delegations: &[FullDelegation], ) { - self.base.update_staking(denom, validators, delegations); + self.base.staking.update(denom, validators, delegations); } pub fn add_query_response(&mut self, query_id: u64, response: Binary) { diff --git a/contracts/neutron_interchain_queries/src/testing/tests.rs b/contracts/neutron_interchain_queries/src/testing/tests.rs index 55f55829..1dbda130 100644 --- a/contracts/neutron_interchain_queries/src/testing/tests.rs +++ b/contracts/neutron_interchain_queries/src/testing/tests.rs @@ -15,10 +15,10 @@ use cosmos_sdk_proto::cosmos::slashing::v1beta1::ValidatorSigningInfo as CosmosV use cosmos_sdk_proto::cosmos::staking::v1beta1::Validator as CosmosValidator; use cosmos_sdk_proto::traits::Message; use cosmos_sdk_proto::Any; -use cosmwasm_std::testing::{mock_env, mock_info, MockApi, MockStorage}; +use cosmwasm_std::testing::{message_info, mock_env, MockApi, MockStorage}; use cosmwasm_std::{ - from_json, to_json_binary, Addr, Binary, Coin, Decimal, Delegation, Env, MessageInfo, - OwnedDeps, StdError, Uint128, + from_json, to_json_binary, Addr, Binary, Coin, Decimal, Env, MessageInfo, OwnedDeps, StdError, + Uint128, }; use neutron_sdk::bindings::query::{ NeutronQuery, QueryRegisteredQueryResponse, QueryRegisteredQueryResultResponse, @@ -35,8 +35,8 @@ use neutron_sdk::interchain_queries::v047::helpers::{ create_total_denom_key, create_validator_key, }; use neutron_sdk::interchain_queries::v047::types::{ - Balances, FeePool, GovernmentProposal, Proposal, SigningInfo, StakingValidator, TallyResult, - TotalSupply, Validator, ValidatorSigningInfo, RECIPIENT_FIELD, STAKING_PARAMS_KEY, + Balances, FeePool, GovernmentProposal, Proposal, SigningInfo, StakingValidator, StdDelegation, + TallyResult, TotalSupply, Validator, ValidatorSigningInfo, RECIPIENT_FIELD, STAKING_PARAMS_KEY, }; use neutron_sdk::interchain_queries::v047::queries::{ @@ -96,8 +96,8 @@ fn build_interchain_query_bank_total_denom_value(denom: String, amount: String) StorageValue { storage_prefix: "".to_string(), - key: Binary(bank_total_key), - value: Binary(amount), + key: Binary::new(bank_total_key), + value: Binary::new(amount), } } @@ -112,8 +112,8 @@ fn build_interchain_query_distribution_fee_pool_response(denom: String, amount: let s = StorageValue { storage_prefix: "".to_string(), - key: Binary(fee_pool_key), - value: Binary(fee_pool.encode_to_vec()), + key: Binary::new(fee_pool_key), + value: Binary::new(fee_pool.encode_to_vec()), }; Binary::from( to_string(&QueryRegisteredQueryResultResponse { @@ -151,8 +151,8 @@ fn build_interchain_query_staking_validator_value(validator: String) -> StorageV StorageValue { storage_prefix: "".to_string(), - key: Binary(validator_key), - value: Binary(validator.encode_to_vec()), + key: Binary::new(validator_key), + value: Binary::new(validator.encode_to_vec()), } } @@ -174,8 +174,8 @@ fn build_interchain_query_validator_signing_info_value( StorageValue { storage_prefix: "".to_string(), - key: Binary(validator_key), - value: Binary(validator.encode_to_vec()), + key: Binary::new(validator_key), + value: Binary::new(validator.encode_to_vec()), } } @@ -207,8 +207,8 @@ fn build_interchain_query_gov_proposal_value(proposal_id: u64) -> StorageValue { StorageValue { storage_prefix: "".to_string(), - key: Binary(proposal_key), - value: Binary(proposal.encode_to_vec()), + key: Binary::new(proposal_key), + value: Binary::new(proposal.encode_to_vec()), } } @@ -223,8 +223,8 @@ fn build_interchain_query_balances_response(addr: Addr, balances: Vec) -> .unwrap(); StorageValue { storage_prefix: "".to_string(), - key: Binary(balance_key), - value: Binary(c.amount.to_string().into_bytes()), + key: Binary::new(balance_key), + value: Binary::new(c.amount.to_string().into_bytes()), } }) .collect(); @@ -270,7 +270,12 @@ fn test_query_balance() { denoms: vec!["uosmo".to_string()], }; - let keys = register_query(&mut deps, mock_env(), mock_info("", &[]), msg); + let keys = register_query( + &mut deps, + mock_env(), + message_info(&Addr::unchecked(""), &[]), + msg, + ); let registered_query = build_registered_query_response(1, QueryParam::Keys(keys.0), QueryType::KV, 987); @@ -308,7 +313,12 @@ fn test_query_balances() { denoms: vec!["uosmo".to_string(), "uatom".to_string()], }; - let keys = register_query(&mut deps, mock_env(), mock_info("", &[]), msg); + let keys = register_query( + &mut deps, + mock_env(), + message_info(&Addr::unchecked(""), &[]), + msg, + ); let registered_query = build_registered_query_response(1, QueryParam::Keys(keys.0), QueryType::KV, 987); @@ -353,7 +363,12 @@ fn test_bank_total_supply_query() { denoms: denoms.clone(), }; - let keys = register_query(&mut deps, mock_env(), mock_info("", &[]), msg); + let keys = register_query( + &mut deps, + mock_env(), + message_info(&Addr::unchecked(""), &[]), + msg, + ); let registered_query = build_registered_query_response(1, QueryParam::Keys(keys.0), QueryType::KV, 987); @@ -404,7 +419,12 @@ fn test_distribution_fee_pool_query() { update_period: 10, }; - let keys = register_query(&mut deps, mock_env(), mock_info("", &[]), msg); + let keys = register_query( + &mut deps, + mock_env(), + message_info(&Addr::unchecked(""), &[]), + msg, + ); let registered_query = build_registered_query_response(1, QueryParam::Keys(keys.0), QueryType::KV, 987); @@ -443,7 +463,12 @@ fn test_gov_proposals_query() { update_period: 10, }; - let keys = register_query(&mut deps, mock_env(), mock_info("", &[]), msg); + let keys = register_query( + &mut deps, + mock_env(), + message_info(&Addr::unchecked(""), &[]), + msg, + ); let registered_query = build_registered_query_response(1, QueryParam::Keys(keys.0), QueryType::KV, 987); @@ -553,7 +578,12 @@ fn test_staking_validators_query() { validators: validators.clone(), }; - let keys = register_query(&mut deps, mock_env(), mock_info("", &[]), msg); + let keys = register_query( + &mut deps, + mock_env(), + message_info(&Addr::unchecked(""), &[]), + msg, + ); let registered_query = build_registered_query_response(1, QueryParam::Keys(keys.0), QueryType::KV, 987); @@ -656,7 +686,12 @@ fn test_validators_signing_infos_query() { validators: validators.clone().into_iter().map(|(v, _)| v).collect(), }; - let keys = register_query(&mut deps, mock_env(), mock_info("", &[]), msg); + let keys = register_query( + &mut deps, + mock_env(), + message_info(&Addr::unchecked(""), &[]), + msg, + ); let registered_query = build_registered_query_response(1, QueryParam::Keys(keys.0), QueryType::KV, 987); @@ -725,7 +760,12 @@ fn test_query_delegator_delegations() { ], }; - let keys = register_query(&mut deps, mock_env(), mock_info("", &[]), msg); + let keys = register_query( + &mut deps, + mock_env(), + message_info(&Addr::unchecked(""), &[]), + msg, + ); let delegations_response = QueryRegisteredQueryResultResponse { result: InterchainQueryResult { @@ -812,17 +852,17 @@ fn test_query_delegator_delegations() { DelegatorDelegationsResponse { last_submitted_local_height: 987, delegations: vec![ - Delegation { + StdDelegation { delegator: Addr::unchecked("osmo1yz54ncxj9csp7un3xled03q6thrrhy9cztkfzs"), validator: "osmovaloper1r2u5q6t6w0wssrk6l66n3t2q3dw2uqny4gj2e3".to_string(), amount: Coin::new(5177628u128, "uatom".to_string()), }, - Delegation { + StdDelegation { delegator: Addr::unchecked("osmo1yz54ncxj9csp7un3xled03q6thrrhy9cztkfzs"), validator: "osmovaloper1ej2es5fjztqjcd4pwa0zyvaevtjd2y5w37wr9t".to_string(), amount: Coin::new(29620221u128, "uatom".to_string()), }, - Delegation { + StdDelegation { delegator: Addr::unchecked("osmo1yz54ncxj9csp7un3xled03q6thrrhy9cztkfzs"), validator: "osmovaloper1lzhlnpahvznwfv4jmay2tgaha5kmz5qxwmj9we".to_string(), amount: Coin::new(219920u128, "uatom".to_string()), @@ -845,7 +885,13 @@ fn test_sudo_tx_query_result_callback() { recipient: watched_addr.clone(), min_height: None, }; - execute(deps.as_mut(), env.clone(), mock_info("", &[]), msg).unwrap(); + execute( + deps.as_mut(), + env.clone(), + message_info(&Addr::unchecked(""), &[]), + msg, + ) + .unwrap(); let registered_query = build_registered_query_response( 1, QueryParam::TransactionsFilter( @@ -969,7 +1015,13 @@ fn test_sudo_tx_query_result_min_height_callback() { recipient: watched_addr.clone(), min_height: Some(100000), }; - execute(deps.as_mut(), env.clone(), mock_info("", &[]), msg).unwrap(); + execute( + deps.as_mut(), + env.clone(), + message_info(&Addr::unchecked(""), &[]), + msg, + ) + .unwrap(); let registered_query = build_registered_query_response( 1, QueryParam::TransactionsFilter( diff --git a/contracts/neutron_interchain_txs/.cargo/config b/contracts/neutron_interchain_txs/.cargo/config index ba76f006..fe066df6 100644 --- a/contracts/neutron_interchain_txs/.cargo/config +++ b/contracts/neutron_interchain_txs/.cargo/config @@ -1,6 +1,6 @@ [alias] wasm = "build --release --target wasm32-unknown-unknown" wasm-debug = "build --target wasm32-unknown-unknown" -unit-test = "test --lib --features backtraces" +unit-test = "test --lib" integration-test = "test --test integration" schema = "run --bin neutron_interchain_txs_schema" diff --git a/contracts/neutron_interchain_txs/Cargo.toml b/contracts/neutron_interchain_txs/Cargo.toml index caa21a52..9c320018 100644 --- a/contracts/neutron_interchain_txs/Cargo.toml +++ b/contracts/neutron_interchain_txs/Cargo.toml @@ -14,8 +14,6 @@ exclude = [ crate-type = ["cdylib", "rlib"] [features] -# for more explicit tests, cargo test --features=backtraces -backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] @@ -29,4 +27,3 @@ cosmos-sdk-proto = { workspace = true } neutron-sdk = { path = "../../packages/neutron-sdk", default-features = false } prost-types = { workspace = true } cosmwasm-schema = { workspace = true } - diff --git a/contracts/neutron_interchain_txs/src/contract.rs b/contracts/neutron_interchain_txs/src/contract.rs index 6518ada0..662325b1 100644 --- a/contracts/neutron_interchain_txs/src/contract.rs +++ b/contracts/neutron_interchain_txs/src/contract.rs @@ -13,9 +13,10 @@ use serde::{Deserialize, Serialize}; use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; use neutron_sdk::bindings::msg::IbcFee; +use neutron_sdk::proto_types::neutron::interchaintxs::v1::MsgSubmitTxResponse; use neutron_sdk::{ bindings::{ - msg::{MsgSubmitTxResponse, NeutronMsg}, + msg::NeutronMsg, query::{NeutronQuery, QueryInterchainAccountAddressResponse}, types::ProtobufAny, }, @@ -615,13 +616,14 @@ fn sudo_error(deps: DepsMut, request: RequestPacket, details: String) -> StdResu // and process this payload when an acknowledgement for the SubmitTx message is received in Sudo handler fn prepare_sudo_payload(mut deps: DepsMut, _env: Env, msg: Reply) -> StdResult { let payload = read_reply_payload(deps.storage)?; - let resp: MsgSubmitTxResponse = serde_json_wasm::from_slice( - msg.result + let resp: MsgSubmitTxResponse = decode_message_response( + &msg.result .into_result() .map_err(StdError::generic_err)? - .data - .ok_or_else(|| StdError::generic_err("no result"))? - .as_slice(), + .msg_responses[0] // msg_responses must have exactly one Msg response: https://github.com/neutron-org/neutron/blob/28b1d2ce968aaf1866e92d5286487f079eba3370/wasmbinding/message_plugin.go#L443 + .clone() + .value + .to_vec(), ) .map_err(|e| StdError::generic_err(format!("failed to parse response: {:?}", e)))?; deps.api diff --git a/contracts/neutron_interchain_txs/src/storage.rs b/contracts/neutron_interchain_txs/src/storage.rs index ea4687d1..aec9b710 100644 --- a/contracts/neutron_interchain_txs/src/storage.rs +++ b/contracts/neutron_interchain_txs/src/storage.rs @@ -43,7 +43,7 @@ pub fn save_reply_payload(store: &mut dyn Storage, payload: SudoPayload) -> StdR pub fn read_reply_payload(store: &dyn Storage) -> StdResult { let data = REPLY_ID_STORAGE.load(store)?; - from_json(Binary(data)) + from_json(Binary::new(data)) } pub fn add_error_to_queue(store: &mut dyn Storage, error_msg: String) -> Option<()> { @@ -69,7 +69,7 @@ pub fn read_sudo_payload( seq_id: u64, ) -> StdResult { let data = SUDO_PAYLOAD.load(store, (channel_id, seq_id))?; - from_json(Binary(data)) + from_json(Binary::new(data)) } pub fn save_sudo_payload( diff --git a/packages/neutron-sdk/schema/neutron_msg.json b/packages/neutron-sdk/schema/neutron_msg.json index c667340d..6a23b3f2 100644 --- a/packages/neutron-sdk/schema/neutron_msg.json +++ b/packages/neutron-sdk/schema/neutron_msg.json @@ -629,7 +629,8 @@ "additionalProperties": false }, { - "description": "Proposal to upgrade IBC client", + "description": "Depreacteed Proposal to upgrade IBC client", + "deprecated": true, "type": "object", "required": [ "upgrade_proposal" @@ -642,7 +643,8 @@ "additionalProperties": false }, { - "description": "Proposal to update IBC client", + "description": "Deprecated. Proposal to update IBC client", + "deprecated": true, "type": "object", "required": [ "client_update_proposal" @@ -816,6 +818,7 @@ }, "ClientUpdateProposal": { "description": "ClientUpdateProposal defines the struct for client update proposal.", + "deprecated": true, "type": "object", "required": [ "description", @@ -1628,6 +1631,7 @@ }, "UpgradeProposal": { "description": "UpgradeProposal defines the struct for IBC upgrade proposal.", + "deprecated": true, "type": "object", "required": [ "description", diff --git a/packages/neutron-sdk/schema/neutron_query.json b/packages/neutron-sdk/schema/neutron_query.json index af319ba5..1a8f4cd4 100644 --- a/packages/neutron-sdk/schema/neutron_query.json +++ b/packages/neutron-sdk/schema/neutron_query.json @@ -244,6 +244,30 @@ } }, "additionalProperties": false + }, + { + "type": "object", + "required": [ + "market_map" + ], + "properties": { + "market_map": { + "$ref": "#/definitions/MarketMapQuery" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "oracle" + ], + "properties": { + "oracle": { + "$ref": "#/definitions/OracleQuery" + } + }, + "additionalProperties": false } ], "definitions": { @@ -251,6 +275,21 @@ "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec. See also .", "type": "string" }, + "CurrencyPair": { + "type": "object", + "required": [ + "Base", + "Quote" + ], + "properties": { + "Base": { + "type": "string" + }, + "Quote": { + "type": "string" + } + } + }, "DexQuery": { "oneOf": [ { @@ -872,6 +911,67 @@ } ] }, + "MarketMapQuery": { + "oneOf": [ + { + "description": "Parameters queries the parameters of the module.", + "type": "object", + "required": [ + "params" + ], + "properties": { + "params": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "last_updated" + ], + "properties": { + "last_updated": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "market_map" + ], + "properties": { + "market_map": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "market" + ], + "properties": { + "market": { + "type": "object", + "required": [ + "currency_pair" + ], + "properties": { + "currency_pair": { + "$ref": "#/definitions/CurrencyPair" + } + } + } + }, + "additionalProperties": false + } + ] + }, "MultiHopRoute": { "type": "object", "required": [ @@ -886,6 +986,65 @@ } } }, + "OracleQuery": { + "oneOf": [ + { + "type": "object", + "required": [ + "get_all_currency_pairs" + ], + "properties": { + "get_all_currency_pairs": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "get_price" + ], + "properties": { + "get_price": { + "type": "object", + "required": [ + "currency_pair" + ], + "properties": { + "currency_pair": { + "$ref": "#/definitions/CurrencyPair" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "get_prices" + ], + "properties": { + "get_prices": { + "type": "object", + "required": [ + "currency_pair_ids" + ], + "properties": { + "currency_pair_ids": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + }, + "additionalProperties": false + } + ] + }, "PageRequest": { "type": "object", "required": [ diff --git a/packages/neutron-sdk/src/bindings/types.rs b/packages/neutron-sdk/src/bindings/types.rs index 01d95c80..2dec2b2b 100644 --- a/packages/neutron-sdk/src/bindings/types.rs +++ b/packages/neutron-sdk/src/bindings/types.rs @@ -204,7 +204,7 @@ impl KVKey { Some(KVKey { path: split[0].to_string(), - key: Binary(decode_hex(split[1])?), + key: Binary::new(decode_hex(split[1])?), }) } } diff --git a/packages/neutron-sdk/src/interchain_queries/v045/helpers.rs b/packages/neutron-sdk/src/interchain_queries/v045/helpers.rs index f8960862..9306c743 100644 --- a/packages/neutron-sdk/src/interchain_queries/v045/helpers.rs +++ b/packages/neutron-sdk/src/interchain_queries/v045/helpers.rs @@ -59,7 +59,7 @@ pub fn create_balances_query_keys(addr: String, denoms: Vec) -> NeutronR let kv_key = KVKey { path: BANK_STORE_KEY.to_string(), - key: Binary(balance_key), + key: Binary::new(balance_key), }; kv_keys.push(kv_key) @@ -242,7 +242,7 @@ pub fn create_gov_proposal_keys(proposals_ids: Vec) -> NeutronResult, + pub delegations: Vec, pub last_submitted_local_height: u64, } diff --git a/packages/neutron-sdk/src/interchain_queries/v045/register_queries.rs b/packages/neutron-sdk/src/interchain_queries/v045/register_queries.rs index 0169b8d2..d379e5a8 100644 --- a/packages/neutron-sdk/src/interchain_queries/v045/register_queries.rs +++ b/packages/neutron-sdk/src/interchain_queries/v045/register_queries.rs @@ -67,7 +67,7 @@ pub fn new_register_bank_total_supply_query_msg( let kv_key = KVKey { path: BANK_STORE_KEY.to_string(), - key: Binary(supply_key), + key: Binary::new(supply_key), }; kv_keys.push(kv_key) @@ -86,7 +86,7 @@ pub fn new_register_distribution_fee_pool_query_msg( ) -> NeutronResult { let kv_key = KVKey { path: DISTRIBUTION_STORE_KEY.to_string(), - key: Binary(create_fee_pool_key()?), + key: Binary::new(create_fee_pool_key()?), }; NeutronMsg::register_interchain_query( @@ -177,7 +177,7 @@ pub fn new_register_staking_validators_query_msg( let kv_key = KVKey { path: STAKING_STORE_KEY.to_string(), - key: Binary(create_validator_key(&val_addr)?), + key: Binary::new(create_validator_key(&val_addr)?), }; kv_keys.push(kv_key) @@ -203,7 +203,7 @@ pub fn new_register_validators_signing_infos_query_msg( let kv_key = KVKey { path: SLASHING_STORE_KEY.to_string(), - key: Binary(create_validator_signing_info_key(&valcons_addr)?), + key: Binary::new(create_validator_signing_info_key(&valcons_addr)?), }; kv_keys.push(kv_key) @@ -235,7 +235,7 @@ pub fn new_register_delegator_delegations_query_msg( // create KV key to get BondDenom from staking module params keys.push(KVKey { path: PARAMS_STORE_KEY.to_string(), - key: Binary(create_params_store_key(STAKING_STORE_KEY, KEY_BOND_DENOM)), + key: Binary::new(create_params_store_key(STAKING_STORE_KEY, KEY_BOND_DENOM)), }); for v in validators { @@ -244,13 +244,13 @@ pub fn new_register_delegator_delegations_query_msg( // create delegation key to get delegation structure keys.push(KVKey { path: STAKING_STORE_KEY.to_string(), - key: Binary(create_delegation_key(&delegator_addr, &val_addr)?), + key: Binary::new(create_delegation_key(&delegator_addr, &val_addr)?), }); // create validator key to get validator structure keys.push(KVKey { path: STAKING_STORE_KEY.to_string(), - key: Binary(create_validator_key(&val_addr)?), + key: Binary::new(create_validator_key(&val_addr)?), }) } @@ -280,7 +280,7 @@ pub fn new_register_delegator_unbonding_delegations_query_msg( // create unbonding delegation key to get unbonding delegation structure keys.push(KVKey { path: STAKING_STORE_KEY.to_string(), - key: Binary(create_unbonding_delegation_key(&delegator_addr, &val_addr)?), + key: Binary::new(create_unbonding_delegation_key(&delegator_addr, &val_addr)?), }) } @@ -311,7 +311,7 @@ pub fn new_register_wasm_contract_store_query_msg( let kv_key = KVKey { path: WASM_STORE_KEY.to_string(), - key: Binary(wasm_key), + key: Binary::new(wasm_key), }; NeutronMsg::register_interchain_query( diff --git a/packages/neutron-sdk/src/interchain_queries/v045/testing.rs b/packages/neutron-sdk/src/interchain_queries/v045/testing.rs index 0fdba3a3..c4f01543 100644 --- a/packages/neutron-sdk/src/interchain_queries/v045/testing.rs +++ b/packages/neutron-sdk/src/interchain_queries/v045/testing.rs @@ -10,9 +10,9 @@ use crate::interchain_queries::v045::helpers::{ use crate::interchain_queries::v045::types::BALANCES_PREFIX; use crate::interchain_queries::v045::types::{ Balances, Delegations, FeePool, GovernmentProposal, GovernmentProposalVotes, Proposal, - ProposalVote, SigningInfo, StakingValidator, TallyResult, TotalSupply, UnbondingDelegations, - UnbondingEntry, UnbondingResponse, Validator as ContractValidator, ValidatorSigningInfo, - WeightedVoteOption, DECIMAL_PLACES, KEY_BOND_DENOM, STAKING_STORE_KEY, + ProposalVote, SigningInfo, StakingValidator, StdDelegation, TallyResult, TotalSupply, + UnbondingDelegations, UnbondingEntry, UnbondingResponse, Validator as ContractValidator, + ValidatorSigningInfo, WeightedVoteOption, DECIMAL_PLACES, KEY_BOND_DENOM, STAKING_STORE_KEY, }; use crate::{NeutronError, NeutronResult}; use base64::prelude::*; @@ -28,10 +28,7 @@ use cosmos_sdk_proto::cosmos::staking::v1beta1::{ Commission, CommissionRates, Delegation, Description, Validator, }; use cosmos_sdk_proto::traits::Message; -use cosmwasm_std::{ - to_json_binary, Addr, Binary, Coin as StdCoin, Decimal, Delegation as StdDelegation, Timestamp, - Uint128, -}; +use cosmwasm_std::{to_json_binary, Addr, Binary, Coin as StdCoin, Decimal, Timestamp, Uint128}; use hex; use std::ops::Mul; use std::str::FromStr; @@ -88,8 +85,8 @@ fn test_balance_reconstruct() { }; let s = StorageValue { storage_prefix: "".to_string(), - key: Binary(balance_key), - value: Binary(balance_amount.encode_to_vec()), + key: Binary::new(balance_key), + value: Binary::new(balance_amount.encode_to_vec()), }; st_values.push(s); } @@ -142,8 +139,8 @@ fn test_bank_total_supply_reconstruct() { let denom_key = create_total_denom_key(case.denom.as_str()).unwrap(); let s = StorageValue { storage_prefix: "".to_string(), - key: Binary(denom_key), - value: Binary(case.amount.as_str().as_bytes().to_vec()), + key: Binary::new(denom_key), + value: Binary::new(case.amount.as_str().as_bytes().to_vec()), }; st_values.push(s); } @@ -362,8 +359,8 @@ fn test_staking_validators_reconstruct() { let validator_key = create_validator_key(&val_addr).unwrap(); let s = StorageValue { storage_prefix: "".to_string(), - key: Binary(validator_key), - value: Binary(validator.encode_to_vec()), + key: Binary::new(validator_key), + value: Binary::new(validator.encode_to_vec()), }; st_values.push(s); } @@ -485,8 +482,8 @@ fn test_validators_signing_infos_reconstruct() { let signing_info_key = create_validator_signing_info_key(&val_addr).unwrap(); let s = StorageValue { storage_prefix: "".to_string(), - key: Binary(signing_info_key), - value: Binary(info.encode_to_vec()), + key: Binary::new(signing_info_key), + value: Binary::new(info.encode_to_vec()), }; st_values.push(s); } @@ -668,8 +665,8 @@ fn test_government_proposals_reconstruct() { let proposal_key = create_gov_proposal_key(proposal.proposal_id).unwrap(); let s = StorageValue { storage_prefix: "".to_string(), - key: Binary(proposal_key), - value: Binary(proposal.encode_to_vec()), + key: Binary::new(proposal_key), + value: Binary::new(proposal.encode_to_vec()), }; st_values.push(s); } @@ -767,8 +764,8 @@ fn test_proposal_votes_reconstruct() { let proposal_key = create_gov_proposal_votes_key(votes.proposal_id).unwrap(); let s = StorageValue { storage_prefix: "".to_string(), - key: Binary(proposal_key), - value: Binary(votes.encode_to_vec()), + key: Binary::new(proposal_key), + value: Binary::new(votes.encode_to_vec()), }; st_values.push(s); } @@ -821,8 +818,8 @@ fn test_fee_pool_reconstruct() { let st_value = StorageValue { storage_prefix: "".to_string(), - key: Binary(fee_pool_key), - value: Binary(fee_pool.encode_to_vec()), + key: Binary::new(fee_pool_key), + value: Binary::new(fee_pool.encode_to_vec()), }; let fee_pool_coins = FeePool::reconstruct(&[st_value]).unwrap(); @@ -966,7 +963,7 @@ fn test_delegations_reconstruct() { // prepare storage values let mut st_values: Vec = vec![StorageValue { storage_prefix: STAKING_STORE_KEY.to_string(), - key: Binary(create_params_store_key(STAKING_STORE_KEY, KEY_BOND_DENOM)), + key: Binary::new(create_params_store_key(STAKING_STORE_KEY, KEY_BOND_DENOM)), value: { if ts.stake_denom.is_empty() { return Default::default(); @@ -981,14 +978,14 @@ fn test_delegations_reconstruct() { st_values.push(StorageValue { storage_prefix: STAKING_STORE_KEY.to_string(), - key: Binary(create_delegation_key(&delegator_addr, &val_addr).unwrap()), + key: Binary::new(create_delegation_key(&delegator_addr, &val_addr).unwrap()), value: Binary::from(d.encode_to_vec()), }); if let Some(v) = ts.validators.get(i) { st_values.push(StorageValue { storage_prefix: STAKING_STORE_KEY.to_string(), - key: Binary(create_validator_key(&val_addr).unwrap()), + key: Binary::new(create_validator_key(&val_addr).unwrap()), value: Binary::from(v.encode_to_vec()), }); } @@ -1056,7 +1053,7 @@ fn test_bank_total_supply_reconstruct_from_hex() { let s = StorageValue { storage_prefix: String::default(), // not used in reconstruct - key: Binary(create_total_denom_key("stake").unwrap()), + key: Binary::new(create_total_denom_key("stake").unwrap()), value: Binary::from_base64(base64_input.as_str()).unwrap(), }; let total_supply = TotalSupply::reconstruct(&[s]).unwrap(); @@ -1417,7 +1414,7 @@ fn test_delegations_reconstruct_overflow() { // prepare storage values let mut st_values: Vec = vec![StorageValue { storage_prefix: STAKING_STORE_KEY.to_string(), - key: Binary(create_params_store_key(STAKING_STORE_KEY, KEY_BOND_DENOM)), + key: Binary::new(create_params_store_key(STAKING_STORE_KEY, KEY_BOND_DENOM)), value: { if ts.stake_denom.is_empty() { return Default::default(); @@ -1432,14 +1429,14 @@ fn test_delegations_reconstruct_overflow() { st_values.push(StorageValue { storage_prefix: STAKING_STORE_KEY.to_string(), - key: Binary(create_delegation_key(&delegator_addr, &val_addr).unwrap()), + key: Binary::new(create_delegation_key(&delegator_addr, &val_addr).unwrap()), value: Binary::from(d.encode_to_vec()), }); if let Some(v) = ts.validators.get(i) { st_values.push(StorageValue { storage_prefix: STAKING_STORE_KEY.to_string(), - key: Binary(create_validator_key(&val_addr).unwrap()), + key: Binary::new(create_validator_key(&val_addr).unwrap()), value: Binary::from(v.encode_to_vec()), }); } diff --git a/packages/neutron-sdk/src/interchain_queries/v045/types.rs b/packages/neutron-sdk/src/interchain_queries/v045/types.rs index 4b6c2655..68e29be8 100644 --- a/packages/neutron-sdk/src/interchain_queries/v045/types.rs +++ b/packages/neutron-sdk/src/interchain_queries/v045/types.rs @@ -440,18 +440,29 @@ impl KVReconstruct for GovernmentProposalVotes { } } +/// Delegation is basic (cheap to query) data about a delegation. +/// +/// Instances are created in the querier. +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +pub struct StdDelegation { + pub delegator: Addr, + /// A validator address (e.g. cosmosvaloper1...) + pub validator: String, + /// How much we have locked in the delegation + pub amount: Coin, +} + #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] /// A structure that can be reconstructed from **StorageValues**'s for the **Delegator Delegation Interchain Query**. /// Contains delegations which some delegator has on remote chain. pub struct Delegations { - pub delegations: Vec, + pub delegations: Vec, } impl KVReconstruct for Delegations { fn reconstruct(storage_values: &[StorageValue]) -> NeutronResult { // We are taking 2 items chunks from starage_value to calculate one delegation - let mut delegations: Vec = - Vec::with_capacity(storage_values.len() / 2); + let mut delegations: Vec = Vec::with_capacity(storage_values.len() / 2); if storage_values.is_empty() { return Err(NeutronError::InvalidQueryResultFormat( @@ -479,7 +490,7 @@ impl KVReconstruct for Delegations { } let delegation_sdk: Delegation = Delegation::decode(chunk[0].value.as_slice())?; - let mut delegation_std = cosmwasm_std::Delegation { + let mut delegation_std = StdDelegation { delegator: Addr::unchecked(delegation_sdk.delegator_address.as_str()), validator: delegation_sdk.validator_address, amount: Default::default(), diff --git a/packages/neutron-sdk/src/interchain_queries/v047/queries.rs b/packages/neutron-sdk/src/interchain_queries/v047/queries.rs index f3324b29..8bc2000b 100644 --- a/packages/neutron-sdk/src/interchain_queries/v047/queries.rs +++ b/packages/neutron-sdk/src/interchain_queries/v047/queries.rs @@ -11,7 +11,7 @@ use crate::{ interchain_queries::{ queries::{check_query_type, get_registered_query, query_kv_result}, types::QueryType, - v047::types::Balances, + v047::types::{Balances, StdDelegation}, }, NeutronResult, }; @@ -50,7 +50,7 @@ pub fn query_balance( #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] #[serde(rename_all = "snake_case")] pub struct DelegatorDelegationsResponse { - pub delegations: Vec, + pub delegations: Vec, pub last_submitted_local_height: u64, } diff --git a/packages/neutron-sdk/src/interchain_queries/v047/register_queries.rs b/packages/neutron-sdk/src/interchain_queries/v047/register_queries.rs index 7de756b2..547ba091 100644 --- a/packages/neutron-sdk/src/interchain_queries/v047/register_queries.rs +++ b/packages/neutron-sdk/src/interchain_queries/v047/register_queries.rs @@ -35,7 +35,7 @@ pub fn new_register_delegator_delegations_query_msg( // create KV key to get Staking Params from staking module keys.push(KVKey { path: STAKING_STORE_KEY.to_string(), - key: Binary(vec![STAKING_PARAMS_KEY]), + key: Binary::new(vec![STAKING_PARAMS_KEY]), }); for v in validators { @@ -44,13 +44,13 @@ pub fn new_register_delegator_delegations_query_msg( // create delegation key to get delegation structure keys.push(KVKey { path: STAKING_STORE_KEY.to_string(), - key: Binary(create_delegation_key(&delegator_addr, &val_addr)?), + key: Binary::new(create_delegation_key(&delegator_addr, &val_addr)?), }); // create validator key to get validator structure keys.push(KVKey { path: STAKING_STORE_KEY.to_string(), - key: Binary(create_validator_key(&val_addr)?), + key: Binary::new(create_validator_key(&val_addr)?), }) } diff --git a/packages/neutron-sdk/src/interchain_queries/v047/testing.rs b/packages/neutron-sdk/src/interchain_queries/v047/testing.rs index 3d22e7b2..8f754cc1 100644 --- a/packages/neutron-sdk/src/interchain_queries/v047/testing.rs +++ b/packages/neutron-sdk/src/interchain_queries/v047/testing.rs @@ -10,9 +10,9 @@ use crate::interchain_queries::v047::helpers::{ }; use crate::interchain_queries::v047::types::{ Balances, Delegations, FeePool, GovernmentProposal, Proposal, SigningInfo, StakingValidator, - TallyResult, TotalSupply, UnbondingDelegations, UnbondingEntry, UnbondingResponse, - Validator as ContractValidator, ValidatorSigningInfo, DECIMAL_PLACES, STAKING_PARAMS_KEY, - STAKING_STORE_KEY, + StdDelegation, TallyResult, TotalSupply, UnbondingDelegations, UnbondingEntry, + UnbondingResponse, Validator as ContractValidator, ValidatorSigningInfo, DECIMAL_PLACES, + STAKING_PARAMS_KEY, STAKING_STORE_KEY, }; use crate::{NeutronError, NeutronResult}; use base64::prelude::*; @@ -27,9 +27,7 @@ use cosmos_sdk_proto::cosmos::staking::v1beta1::{ Commission, CommissionRates, Delegation, Description, Params, Validator, }; use cosmos_sdk_proto::traits::Message; -use cosmwasm_std::{ - Addr, Binary, Coin as StdCoin, Decimal, Delegation as StdDelegation, Timestamp, Uint128, -}; +use cosmwasm_std::{Addr, Binary, Coin as StdCoin, Decimal, Timestamp, Uint128}; use hex; use std::ops::Mul; use std::str::FromStr; @@ -81,8 +79,8 @@ fn test_balance_reconstruct() { let s = StorageValue { storage_prefix: "".to_string(), - key: Binary(balance_key), - value: Binary(coin.1.clone().into_bytes()), + key: Binary::new(balance_key), + value: Binary::new(coin.1.clone().into_bytes()), }; st_values.push(s); } @@ -140,8 +138,8 @@ fn test_bank_total_supply_reconstruct() { let denom_key = create_total_denom_key(case.denom.as_str()).unwrap(); let s = StorageValue { storage_prefix: "".to_string(), - key: Binary(denom_key), - value: Binary(case.amount.as_str().as_bytes().to_vec()), + key: Binary::new(denom_key), + value: Binary::new(case.amount.as_str().as_bytes().to_vec()), }; st_values.push(s); } @@ -360,8 +358,8 @@ fn test_staking_validators_reconstruct() { let validator_key = create_validator_key(&val_addr).unwrap(); let s = StorageValue { storage_prefix: "".to_string(), - key: Binary(validator_key), - value: Binary(validator.encode_to_vec()), + key: Binary::new(validator_key), + value: Binary::new(validator.encode_to_vec()), }; st_values.push(s); } @@ -483,8 +481,8 @@ fn test_validators_signing_infos_reconstruct() { let signing_info_key = create_validator_signing_info_key(&val_addr).unwrap(); let s = StorageValue { storage_prefix: "".to_string(), - key: Binary(signing_info_key), - value: Binary(info.encode_to_vec()), + key: Binary::new(signing_info_key), + value: Binary::new(info.encode_to_vec()), }; st_values.push(s); } @@ -666,8 +664,8 @@ fn test_government_proposals_reconstruct() { let proposal_key = create_gov_proposal_key(proposal.proposal_id).unwrap(); let s = StorageValue { storage_prefix: "".to_string(), - key: Binary(proposal_key), - value: Binary(proposal.encode_to_vec()), + key: Binary::new(proposal_key), + value: Binary::new(proposal.encode_to_vec()), }; st_values.push(s); } @@ -720,8 +718,8 @@ fn test_fee_pool_reconstruct() { let st_value = StorageValue { storage_prefix: "".to_string(), - key: Binary(fee_pool_key), - value: Binary(fee_pool.encode_to_vec()), + key: Binary::new(fee_pool_key), + value: Binary::new(fee_pool.encode_to_vec()), }; let fee_pool_coins = FeePool::reconstruct(&[st_value]).unwrap(); @@ -893,7 +891,7 @@ fn test_delegations_reconstruct() { // prepare storage values let mut st_values: Vec = vec![StorageValue { storage_prefix: STAKING_STORE_KEY.to_string(), - key: Binary(vec![STAKING_PARAMS_KEY]), + key: Binary::new(vec![STAKING_PARAMS_KEY]), value: { if ts.staking_params.bond_denom.is_empty() { return Default::default(); @@ -908,14 +906,14 @@ fn test_delegations_reconstruct() { st_values.push(StorageValue { storage_prefix: STAKING_STORE_KEY.to_string(), - key: Binary(create_delegation_key(&delegator_addr, &val_addr).unwrap()), + key: Binary::new(create_delegation_key(&delegator_addr, &val_addr).unwrap()), value: Binary::from(d.encode_to_vec()), }); if let Some(v) = ts.validators.get(i) { st_values.push(StorageValue { storage_prefix: STAKING_STORE_KEY.to_string(), - key: Binary(create_validator_key(&val_addr).unwrap()), + key: Binary::new(create_validator_key(&val_addr).unwrap()), value: Binary::from(v.encode_to_vec()), }); } @@ -935,7 +933,7 @@ fn test_balance_reconstruct_from_hex() { let s = StorageValue { storage_prefix: String::default(), // not used in reconstruct - key: Binary(create_account_denom_balance_key("addr", "uatom").unwrap()), + key: Binary::new(create_account_denom_balance_key("addr", "uatom").unwrap()), value: Binary::from_base64(base64_input.as_str()).unwrap(), }; let bank_balances = Balances::reconstruct(&[s]).unwrap(); @@ -951,7 +949,7 @@ fn test_balance_reconstruct_from_hex() { fn test_balance_reconstruct_from_empty_value() { let s = StorageValue { storage_prefix: String::default(), // not used in reconstruct - key: Binary(create_account_denom_balance_key("addr", "uatom").unwrap()), + key: Binary::new(create_account_denom_balance_key("addr", "uatom").unwrap()), value: Binary::from(vec![]), }; let bank_balances = Balances::reconstruct(&[s]).unwrap(); @@ -970,7 +968,7 @@ fn test_bank_total_supply_reconstruct_from_hex() { let s = StorageValue { storage_prefix: String::default(), // not used in reconstruct - key: Binary(create_total_denom_key("stake").unwrap()), + key: Binary::new(create_total_denom_key("stake").unwrap()), value: Binary::from_base64(base64_input.as_str()).unwrap(), }; let total_supply = TotalSupply::reconstruct(&[s]).unwrap(); @@ -1033,7 +1031,7 @@ fn test_delegations_reconstruct_overflow() { // prepare storage values let mut st_values: Vec = vec![StorageValue { storage_prefix: STAKING_STORE_KEY.to_string(), - key: Binary(create_params_store_key(STAKING_STORE_KEY, KEY_BOND_DENOM)), + key: Binary::new(create_params_store_key(STAKING_STORE_KEY, KEY_BOND_DENOM)), value: { if ts.staking_params.bond_denom.is_empty() { return Default::default(); @@ -1048,14 +1046,14 @@ fn test_delegations_reconstruct_overflow() { st_values.push(StorageValue { storage_prefix: STAKING_STORE_KEY.to_string(), - key: Binary(create_delegation_key(&delegator_addr, &val_addr).unwrap()), + key: Binary::new(create_delegation_key(&delegator_addr, &val_addr).unwrap()), value: Binary::from(d.encode_to_vec()), }); if let Some(v) = ts.validators.get(i) { st_values.push(StorageValue { storage_prefix: STAKING_STORE_KEY.to_string(), - key: Binary(create_validator_key(&val_addr).unwrap()), + key: Binary::new(create_validator_key(&val_addr).unwrap()), value: Binary::from(v.encode_to_vec()), }); } diff --git a/packages/neutron-sdk/src/interchain_queries/v047/types.rs b/packages/neutron-sdk/src/interchain_queries/v047/types.rs index b32f8f65..38e3a00a 100644 --- a/packages/neutron-sdk/src/interchain_queries/v047/types.rs +++ b/packages/neutron-sdk/src/interchain_queries/v047/types.rs @@ -54,14 +54,13 @@ impl KVReconstruct for Balances { /// A structure that can be reconstructed from **StorageValues**'s for the **Delegator Delegation Interchain Query**. /// Contains delegations which some delegator has on remote chain. pub struct Delegations { - pub delegations: Vec, + pub delegations: Vec, } impl KVReconstruct for Delegations { fn reconstruct(storage_values: &[StorageValue]) -> NeutronResult { // We are taking 2 items chunks from starage_value to calculate one delegation - let mut delegations: Vec = - Vec::with_capacity(storage_values.len() / 2); + let mut delegations: Vec = Vec::with_capacity(storage_values.len() / 2); if storage_values.is_empty() { return Err(NeutronError::InvalidQueryResultFormat( @@ -89,7 +88,7 @@ impl KVReconstruct for Delegations { } let delegation_sdk: Delegation = Delegation::decode(chunk[0].value.as_slice())?; - let mut delegation_std = cosmwasm_std::Delegation { + let mut delegation_std = StdDelegation { delegator: Addr::unchecked(delegation_sdk.delegator_address.as_str()), validator: delegation_sdk.validator_address, amount: Default::default(), diff --git a/packages/neutron-sdk/src/stargate/aux.rs b/packages/neutron-sdk/src/stargate/aux.rs index 132310e6..24c8431a 100644 --- a/packages/neutron-sdk/src/stargate/aux.rs +++ b/packages/neutron-sdk/src/stargate/aux.rs @@ -16,6 +16,7 @@ where Req: prost::Message, Res: DeserializeOwned, { + #[allow(deprecated)] deps.querier.query(&QueryRequest::Stargate { path: path.to_string(), data: req.encode_to_vec().into(), @@ -28,6 +29,7 @@ where /// * **path** is an RPC request path. See Msg service definitions in neutron modules' proto files /// for additional info. pub fn create_stargate_msg(path: &str, req: Req) -> CosmosMsg { + #[allow(deprecated)] CosmosMsg::Stargate:: { type_url: path.to_string(), value: Binary::from(req.encode_to_vec()),