diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e1cb78b..2bc01b0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,7 @@ on: inputs: toolchain: description: 'Default Rust Toolchain' - default: "1.68.2" + default: "1.73.0" required: true type: string target: @@ -31,7 +31,7 @@ on: type: string env: - TOOLCHAIN: ${{ inputs.toolchain || '1.68.2' }} + TOOLCHAIN: ${{ inputs.toolchain || '1.73.0' }} TARGET: ${{ inputs.target || 'wasm32-unknown-unknown' }} REF: ${{ github.event_name == 'push' && github.ref || inputs.branch || 'main' }} ID: ${{ inputs.id || 'scheduled' }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 84b4f80..18a4d9a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,7 +15,7 @@ jobs: fetch-depth: 1 - uses: actions-rs/toolchain@v1 with: - toolchain: 1.68.2 + toolchain: 1.73.0 components: clippy profile: minimal override: true @@ -31,7 +31,7 @@ jobs: fetch-depth: 1 - uses: actions-rs/toolchain@v1 with: - toolchain: 1.68.2 + toolchain: 1.73.0 components: rustfmt profile: minimal override: true @@ -49,7 +49,7 @@ jobs: fetch-depth: 1 - uses: actions-rs/toolchain@v1 with: - toolchain: 1.68.2 + toolchain: 1.73.0 profile: minimal - run: cargo fetch --verbose - run: cargo build diff --git a/Cargo.lock b/Cargo.lock index 7d06595..de2bf33 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -48,9 +48,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" [[package]] name = "balance-tracker" @@ -131,9 +131,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" dependencies = [ "serde", ] @@ -146,9 +146,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.35" +version = "0.4.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eaf5903dcbc0a39312feb77df2ff4c76387d591b9fc7b04a238dcf8bb62639a" +checksum = "8a0d04d43504c61aa6c7531f1871dd0d418d91130162063b789da00fd7057a5e" dependencies = [ "num-traits", ] @@ -189,8 +189,8 @@ version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32560304ab4c365791fd307282f76637213d8083c1a98490c35159cd67852237" dependencies = [ - "prost 0.12.3", - "prost-types 0.12.3", + "prost 0.12.4", + "prost-types 0.12.4", "tendermint-proto 0.34.1", ] @@ -392,9 +392,9 @@ dependencies = [ [[package]] name = "der" -version = "0.7.8" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" dependencies = [ "const-oid", "zeroize", @@ -441,8 +441,8 @@ dependencies = [ "cosmwasm-std", "cw2", "neutron-sdk", - "prost 0.12.3", - "prost-types 0.12.3", + "prost 0.12.4", + "prost-types 0.12.4", "schemars", "serde", ] @@ -576,9 +576,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" dependencies = [ "cfg-if", "libc", @@ -649,15 +649,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" -dependencies = [ - "either", -] - [[package]] name = "itertools" version = "0.12.1" @@ -669,9 +660,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "k256" @@ -719,15 +710,15 @@ dependencies = [ [[package]] name = "neutron-sdk" -version = "0.9.0" -source = "git+https://github.com/neutron-org/neutron-sdk.git?branch=main#8645132d09229f717d13bcc5fd74b0886c0c9c31" +version = "0.10.0" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/proposal-votes#2dfca1734dfc4cfba478b3067417648733d66cd9" dependencies = [ "bech32", "cosmos-sdk-proto 0.20.0", "cosmwasm-schema", "cosmwasm-std", - "prost 0.12.3", - "prost-types 0.12.3", + "prost 0.12.4", + "prost-types 0.12.4", "protobuf", "schemars", "serde", @@ -749,7 +740,7 @@ dependencies = [ "cw-storage-plus", "cw2", "neutron-sdk", - "prost 0.12.3", + "prost 0.12.4", "schemars", "serde", "serde-json-wasm 1.0.1", @@ -765,8 +756,8 @@ dependencies = [ "cw-storage-plus", "cw2", "neutron-sdk", - "prost 0.12.3", - "prost-types 0.12.3", + "prost 0.12.4", + "prost-types 0.12.4", "schemars", "serde", "serde-json-wasm 1.0.1", @@ -897,12 +888,12 @@ dependencies = [ [[package]] name = "prost" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146c289cda302b98a28d40c8b3b90498d6e526dd24ac2ecea73e4e491685b94a" +checksum = "d0f5d036824e4761737860779c906171497f6d55681139d8312388f8fe398922" dependencies = [ "bytes", - "prost-derive 0.12.3", + "prost-derive 0.12.4", ] [[package]] @@ -920,15 +911,15 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efb6c9a1dd1def8e2124d17e83a20af56f1570d6c2d2bd9e266ccb768df3840e" +checksum = "19de2de2a00075bf566bee3bd4db014b11587e84184d3f7a791bc17f1a8e9e48" dependencies = [ "anyhow", - "itertools 0.11.0", + "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] @@ -942,11 +933,11 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "193898f59edcf43c26227dcd4c8427f00d99d61e95dcde58dabd49fa291d470e" +checksum = "3235c33eb02c1f1e212abdbe34c78b264b038fb58ca612664343271e36e55ffe" dependencies = [ - "prost 0.12.3", + "prost 0.12.4", ] [[package]] @@ -1017,9 +1008,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47" [[package]] name = "ryu" @@ -1124,7 +1115,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] @@ -1140,9 +1131,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.114" +version = "1.0.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" +checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" dependencies = [ "itoa", "ryu", @@ -1244,7 +1235,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] @@ -1275,9 +1266,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.53" +version = "2.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7383cd0e49fff4b6b90ca5670bfd3e9d6a733b3f90c686605aa7eec8c4996032" +checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" dependencies = [ "proc-macro2", "quote", @@ -1312,8 +1303,8 @@ dependencies = [ "flex-error", "num-derive", "num-traits", - "prost 0.12.3", - "prost-types 0.12.3", + "prost 0.12.4", + "prost-types 0.12.4", "serde", "serde_bytes", "subtle-encoding", @@ -1337,7 +1328,7 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.53", + "syn 2.0.58", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index f57b145..238d598 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,9 +13,9 @@ incremental = false overflow-checks = true [workspace.dependencies] -neutron-sdk = { git = "https://github.com/neutron-org/neutron-sdk.git", branch = "main" } -prost = "0.12.1" -prost-types = "0.12.1" +neutron-sdk = { package = "neutron-sdk", git = "https://github.com/neutron-org/neutron-sdk", branch = "feat/proposal-votes" } +prost = "0.12.4" +prost-types = "0.12.4" cosmos-sdk-proto = { version = "0.20.0", default-features = false } cosmwasm-std = { version = "1.4.1", features = [ "stargate", diff --git a/artifacts/checksums.txt b/artifacts/checksums.txt deleted file mode 100644 index e1cbbeb..0000000 --- a/artifacts/checksums.txt +++ /dev/null @@ -1,15 +0,0 @@ -0c52b85da277055d45075144d7566d40490519486e93601793e7f298e0b80a99 balance_tracker.wasm -9fc5cc70b25d3faa19199bb83b148274794d7df96e4a16f60a53781410b11da2 before_send_hook_test.wasm -0e145a43d5bce9e04ae8db21f2dcc5c897fa7ae65c3cdbcfc846e3e34b2dd793 client_updater.wasm -8f514402615c949263062772b3481a4919777577ff3841128949e53561d0cc61 dex.wasm -4ebb637e1085f24a7a8a023c7955020fc6db340248361d7f7b2b16c17691d7ea dex_stargate.wasm -cbaf8c3e0f063ed8f5fb8be6dc846196cba26455c8d2b1e4cf60ddce06e68d94 echo.wasm -8d05f93af63df857f0e69c1023b3c1fbbfabc0459a6a4249367588874f795030 ibc_transfer.wasm -ebe171cfafe79343f84e0f49e412fec174ddc8a0753d7ec9749bd81e0bf17f55 msg_receiver.wasm -3efca7bfbab65ff18fdf3ac12626939b2a605a6717eeef404d0eec25c864df57 neutron_interchain_queries.wasm -53508475d18898aaac829a55fa38b8fe31870583ede740d6b175a025ccecd6d1 neutron_interchain_txs.wasm -da2a1e14f3658c69846f7f9773c9eb39bc4dd243946bd22ca47079b314b3ebbb neutron_price_feed_mock.wasm -8b7e9946dc8c86729fdecbebd51fd8eeb360da48c1ce5cb9be52319584c376f9 neutron_validators_test.wasm -14d4dce209e210f20bce9fb835194a1d53fe1a99a5ee78f916e51d41d0679bf6 reflect.wasm -3a720c4ee3de2f9d1bb66d20582f14168084c40c00d8a9240d2c6a26750894c8 stargate_querier.wasm -f49da4ab5ee960686c942408a348cd9125fa6d1b93ad328a6e938374e6e0df7d tokenfactory.wasm diff --git a/contracts/dex_stargate/Cargo.toml b/contracts/dex_stargate/Cargo.toml index 861d71b..c22c7d5 100644 --- a/contracts/dex_stargate/Cargo.toml +++ b/contracts/dex_stargate/Cargo.toml @@ -39,7 +39,7 @@ cw2 = "1.1.1" schemars = "0.8.15" serde = { version = "1.0.188", default-features = false, features = ["derive"] } prost = "0.12.3" -prost-types = "0.12.1" +prost-types = "0.12.3" cosmos-sdk-proto = { version = "0.20.0", default-features = false } [dev-dependencies] diff --git a/contracts/neutron_interchain_queries/Cargo.toml b/contracts/neutron_interchain_queries/Cargo.toml index fe642f7..f9af084 100644 --- a/contracts/neutron_interchain_queries/Cargo.toml +++ b/contracts/neutron_interchain_queries/Cargo.toml @@ -21,7 +21,7 @@ backtraces = ["cosmwasm-std/backtraces"] library = [] [dependencies] -cosmwasm-std = { workspace = true } +cosmwasm-std = { workspace = true, features = ["stargate", "staking"] } cw2 = { workspace = true } schemars = { workspace = true } serde = { workspace = true } diff --git a/contracts/neutron_interchain_queries/schema/execute_msg.json b/contracts/neutron_interchain_queries/schema/execute_msg.json index c365623..cdc5e0e 100644 --- a/contracts/neutron_interchain_queries/schema/execute_msg.json +++ b/contracts/neutron_interchain_queries/schema/execute_msg.json @@ -163,6 +163,48 @@ }, "additionalProperties": false }, + { + "type": "object", + "required": [ + "register_government_proposal_votes_query" + ], + "properties": { + "register_government_proposal_votes_query": { + "type": "object", + "required": [ + "connection_id", + "proposals_ids", + "update_period", + "voters" + ], + "properties": { + "connection_id": { + "type": "string" + }, + "proposals_ids": { + "type": "array", + "items": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "update_period": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "voters": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + }, + "additionalProperties": false + }, { "type": "object", "required": [ diff --git a/contracts/neutron_interchain_queries/schema/query_msg.json b/contracts/neutron_interchain_queries/schema/query_msg.json index 858f554..8deb564 100644 --- a/contracts/neutron_interchain_queries/schema/query_msg.json +++ b/contracts/neutron_interchain_queries/schema/query_msg.json @@ -134,6 +134,28 @@ }, "additionalProperties": false }, + { + "type": "object", + "required": [ + "government_proposal_votes" + ], + "properties": { + "government_proposal_votes": { + "type": "object", + "required": [ + "query_id" + ], + "properties": { + "query_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, { "type": "object", "required": [ diff --git a/contracts/neutron_interchain_queries/src/contract.rs b/contracts/neutron_interchain_queries/src/contract.rs index 121ce21..47135ba 100644 --- a/contracts/neutron_interchain_queries/src/contract.rs +++ b/contracts/neutron_interchain_queries/src/contract.rs @@ -37,17 +37,20 @@ use neutron_sdk::interchain_queries::types::{ }; use neutron_sdk::interchain_queries::v047::queries::{ query_balance, query_bank_total, query_delegations, query_distribution_fee_pool, - query_government_proposals, query_staking_validators, query_unbonding_delegations, - query_validators_signing_infos, + query_government_proposal_votes, query_government_proposals, query_staking_validators, + query_unbonding_delegations, query_validators_signing_infos, }; -use neutron_sdk::interchain_queries::v047::register_queries::new_register_validators_signing_infos_query_msg; use neutron_sdk::interchain_queries::v047::register_queries::{ new_register_balance_query_msg, new_register_bank_total_supply_query_msg, new_register_delegator_delegations_query_msg, new_register_delegator_unbonding_delegations_query_msg, - new_register_distribution_fee_pool_query_msg, new_register_gov_proposal_query_msg, + new_register_distribution_fee_pool_query_msg, new_register_gov_proposals_query_msg, new_register_staking_validators_query_msg, new_register_transfers_query_msg, }; +use neutron_sdk::interchain_queries::v047::register_queries::{ + new_register_gov_proposals_voters_votes_query_msg, + new_register_validators_signing_infos_query_msg, +}; use neutron_sdk::interchain_queries::v047::types::{COSMOS_SDK_TRANSFER_MSG_URL, RECIPIENT_FIELD}; use neutron_sdk::sudo::msg::SudoMsg; use neutron_sdk::{NeutronError, NeutronResult}; @@ -100,6 +103,18 @@ pub fn execute( proposals_ids, update_period, } => register_gov_proposal_query(connection_id, proposals_ids, update_period), + ExecuteMsg::RegisterGovernmentProposalVotesQuery { + connection_id, + proposals_ids, + voters, + update_period, + } => register_gov_proposal_votes_query( + deps, + connection_id, + proposals_ids, + voters, + update_period, + ), ExecuteMsg::RegisterStakingValidatorsQuery { connection_id, validators, @@ -189,7 +204,27 @@ pub fn register_gov_proposal_query( proposals_ids: Vec, update_period: u64, ) -> NeutronResult> { - let msg = new_register_gov_proposal_query_msg(connection_id, proposals_ids, update_period)?; + let msg = new_register_gov_proposals_query_msg(connection_id, proposals_ids, update_period)?; + + Ok(Response::new().add_message(msg)) +} + +pub fn register_gov_proposal_votes_query( + deps: DepsMut, + connection_id: String, + proposals_ids: Vec, + voters: Vec, + update_period: u64, +) -> NeutronResult> { + deps.api + .debug("WASMDEBUG: register_gov_proposal_votes_query"); + + let msg = new_register_gov_proposals_voters_votes_query_msg( + connection_id, + proposals_ids, + voters, + update_period, + )?; Ok(Response::new().add_message(msg)) } @@ -341,6 +376,9 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> NeutronResult QueryMsg::GovernmentProposals { query_id } => Ok(to_json_binary( &query_government_proposals(deps, env, query_id)?, )?), + QueryMsg::GovernmentProposalVotes { query_id } => Ok(to_json_binary( + &query_government_proposal_votes(deps, env, query_id)?, + )?), QueryMsg::GetDelegations { query_id } => { Ok(to_json_binary(&query_delegations(deps, env, query_id)?)?) } diff --git a/contracts/neutron_interchain_queries/src/msg.rs b/contracts/neutron_interchain_queries/src/msg.rs index 70ff045..06366b5 100644 --- a/contracts/neutron_interchain_queries/src/msg.rs +++ b/contracts/neutron_interchain_queries/src/msg.rs @@ -34,6 +34,12 @@ pub enum ExecuteMsg { proposals_ids: Vec, update_period: u64, }, + RegisterGovernmentProposalVotesQuery { + connection_id: String, + proposals_ids: Vec, + voters: Vec, + update_period: u64, + }, RegisterTransfersQuery { connection_id: String, update_period: u64, @@ -97,6 +103,7 @@ pub enum QueryMsg { StakingValidators { query_id: u64 }, ValidatorsSigningInfos { query_id: u64 }, GovernmentProposals { query_id: u64 }, + GovernmentProposalVotes { query_id: u64 }, GetDelegations { query_id: u64 }, GetUnbondingDelegations { query_id: u64 }, GetRegisteredQuery { query_id: u64 }, diff --git a/contracts/neutron_interchain_queries/src/testing/tests.rs b/contracts/neutron_interchain_queries/src/testing/tests.rs index 5ec57d2..4e1eeda 100644 --- a/contracts/neutron_interchain_queries/src/testing/tests.rs +++ b/contracts/neutron_interchain_queries/src/testing/tests.rs @@ -21,7 +21,8 @@ use base64::prelude::*; use cosmos_sdk_proto::cosmos::base::v1beta1::{Coin as CosmosCoin, DecCoin as CosmosDecCoin}; use cosmos_sdk_proto::cosmos::distribution::v1beta1::FeePool as CosmosFeePool; use cosmos_sdk_proto::cosmos::gov::v1beta1::{ - Proposal as CosmosProposal, TallyResult as CosmosTallyResult, + Proposal as CosmosProposal, TallyResult as CosmosTallyResult, Vote, + WeightedVoteOption as CosmosWeightedVoteOption, }; use cosmos_sdk_proto::cosmos::slashing::v1beta1::ValidatorSigningInfo as CosmosValidatorSigningInfo; use cosmos_sdk_proto::cosmos::staking::v1beta1::Validator as CosmosValidator; @@ -43,15 +44,17 @@ use neutron_sdk::interchain_queries::types::{ }; use neutron_sdk::interchain_queries::v047::helpers::{ create_account_denom_balance_key, create_fee_pool_key, create_gov_proposal_key, - create_total_denom_key, create_validator_key, create_validator_signing_info_key, + create_gov_proposal_votes_key, create_total_denom_key, create_validator_key, + create_validator_signing_info_key, }; use neutron_sdk::interchain_queries::v047::queries::{ BalanceResponse, DelegatorDelegationsResponse, FeePoolResponse, ProposalResponse, - TotalSupplyResponse, ValidatorResponse, ValidatorSigningInfoResponse, + ProposalVotesResponse, TotalSupplyResponse, ValidatorResponse, ValidatorSigningInfoResponse, }; use neutron_sdk::interchain_queries::v047::types::{ - Balances, FeePool, GovernmentProposal, Proposal, SigningInfo, StakingValidator, TallyResult, - TotalSupply, Validator, ValidatorSigningInfo, DECIMAL_PLACES, RECIPIENT_FIELD, + Balances, FeePool, GovernmentProposal, GovernmentProposalVotes, Proposal, ProposalVote, + SigningInfo, StakingValidator, TallyResult, TotalSupply, Validator, ValidatorSigningInfo, + WeightedVoteOption, DECIMAL_PLACES, RECIPIENT_FIELD, }; use neutron_sdk::NeutronError; use prost::Message as ProstMessage; @@ -227,6 +230,27 @@ fn build_interchain_query_gov_proposal_value(proposal_id: u64) -> StorageValue { } } +#[allow(deprecated)] +fn build_interchain_query_gov_proposal_votes_value(proposal_id: u64) -> StorageValue { + let votes_key = create_gov_proposal_votes_key(proposal_id).unwrap(); + + let vote = Vote { + proposal_id, + voter: "cosmos1yz54ncxj9csp7un3xled03q6thrrhy9cztkfzs".to_string(), + option: 0, + options: vec![CosmosWeightedVoteOption { + weight: "1000000000000000000".to_string(), + option: 1, + }], + }; + + StorageValue { + storage_prefix: "".to_string(), + key: Binary(votes_key), + value: Binary(vote.encode_to_vec()), + } +} + fn build_interchain_query_balance_response(addr: Addr, denom: String, amount: String) -> Binary { let converted_addr_bytes = decode_and_convert(addr.as_str()).unwrap(); @@ -454,10 +478,10 @@ fn test_gov_proposals_query() { voting_end_time: None, voting_start_time: None, final_tally_result: Some(TallyResult { - abstain: "0".to_string(), - yes: "0".to_string(), - no: "0".to_string(), - no_with_veto: "0".to_string(), + abstain: Uint128::zero(), + yes: Uint128::zero(), + no: Uint128::zero(), + no_with_veto: Uint128::zero(), }), }, Proposal { @@ -473,10 +497,10 @@ fn test_gov_proposals_query() { voting_end_time: None, voting_start_time: None, final_tally_result: Some(TallyResult { - abstain: "0".to_string(), - yes: "0".to_string(), - no: "0".to_string(), - no_with_veto: "0".to_string(), + abstain: Uint128::zero(), + yes: Uint128::zero(), + no: Uint128::zero(), + no_with_veto: Uint128::zero(), }), }, Proposal { @@ -492,10 +516,10 @@ fn test_gov_proposals_query() { voting_end_time: None, voting_start_time: None, final_tally_result: Some(TallyResult { - abstain: "0".to_string(), - yes: "0".to_string(), - no: "0".to_string(), - no_with_veto: "0".to_string(), + abstain: Uint128::zero(), + yes: Uint128::zero(), + no: Uint128::zero(), + no_with_veto: Uint128::zero(), }), }, ] @@ -504,6 +528,86 @@ fn test_gov_proposals_query() { ) } +#[test] +fn test_gov_proposal_votes_query() { + let mut deps = dependencies(&[]); + + let proposals_ids = vec![1, 2, 3]; + + let msg = ExecuteMsg::RegisterGovernmentProposalVotesQuery { + connection_id: "connection".to_string(), + proposals_ids: proposals_ids.clone(), + voters: vec![ + "osmo1yz54ncxj9csp7un3xled03q6thrrhy9cztkfzs".to_string(), + "osmo1yz54ncxj9csp7un3xled03q6thrrhy9cztkfzs".to_string(), + "osmo1yz54ncxj9csp7un3xled03q6thrrhy9cztkfzs".to_string(), + ], + update_period: 10, + }; + + let keys = register_query(&mut deps, mock_env(), mock_info("", &[]), msg); + + let registered_query = + build_registered_query_response(1, QueryParam::Keys(keys.0), QueryType::KV, 325); + + let mut kv_results: Vec = vec![]; + + for id in proposals_ids { + let value = build_interchain_query_gov_proposal_votes_value(id); + kv_results.push(value); + } + + let proposals_votes_response = QueryRegisteredQueryResultResponse { + result: InterchainQueryResult { + kv_results, + height: 0, + revision: 0, + }, + }; + + deps.querier.add_registered_queries(1, registered_query); + deps.querier + .add_query_response(1, to_json_binary(&proposals_votes_response).unwrap()); + + let government_proposal_votes = QueryMsg::GovernmentProposalVotes { query_id: 1 }; + let resp: ProposalVotesResponse = + from_json(query(deps.as_ref(), mock_env(), government_proposal_votes).unwrap()).unwrap(); + assert_eq!( + resp, + ProposalVotesResponse { + last_submitted_local_height: 325, + votes: GovernmentProposalVotes { + proposal_votes: vec![ + ProposalVote { + proposal_id: 1, + voter: "cosmos1yz54ncxj9csp7un3xled03q6thrrhy9cztkfzs".to_string(), + options: vec![WeightedVoteOption { + weight: "1000000000000000000".to_string(), + option: 1, + }], + }, + ProposalVote { + proposal_id: 2, + voter: "cosmos1yz54ncxj9csp7un3xled03q6thrrhy9cztkfzs".to_string(), + options: vec![WeightedVoteOption { + weight: "1000000000000000000".to_string(), + option: 1, + }], + }, + ProposalVote { + proposal_id: 3, + voter: "cosmos1yz54ncxj9csp7un3xled03q6thrrhy9cztkfzs".to_string(), + options: vec![WeightedVoteOption { + weight: "1000000000000000000".to_string(), + option: 1, + }], + } + ] + } + } + ) +} + #[test] fn test_staking_validators_query() { let mut deps = dependencies(&[]); diff --git a/contracts/stargate_querier/Cargo.toml b/contracts/stargate_querier/Cargo.toml index d25b4cf..58a43c8 100644 --- a/contracts/stargate_querier/Cargo.toml +++ b/contracts/stargate_querier/Cargo.toml @@ -31,7 +31,7 @@ neutron-sdk = { workspace = true } # These dependencies are slightly outdated because of osmosis-std osmosis-std = "0.19.2" -prost = "0.11" +prost = "=0.11" cosmos-sdk-proto = { version = "0.19.0", default-features = false } [dev-dependencies]