From c247ed5c1ec771ed9e086dfb182d8b2fffbaaeab Mon Sep 17 00:00:00 2001 From: swelf Date: Thu, 1 Aug 2024 17:39:17 +0300 Subject: [PATCH 1/7] method register_transfers_query now accepts list of recepients --- Cargo.lock | 4 +-- Cargo.toml | 2 +- .../src/contract.rs | 33 +++++++++++++++---- .../neutron_interchain_queries/src/msg.rs | 2 +- .../src/testing/tests.rs | 4 +-- 5 files changed, 33 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 416ce3c..35c9d9a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -822,8 +822,8 @@ dependencies = [ [[package]] name = "neutron-sdk" -version = "0.10.0" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=main#039d33c22590bf481a9a716c0842c2930829fffd" +version = "0.11.0" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/icq-params-gov-gated#29785255db777fec917225ec866d1c4be1d5512c" dependencies = [ "bech32", "cosmos-sdk-proto 0.20.0", diff --git a/Cargo.toml b/Cargo.toml index b9be99c..5500202 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ incremental = false overflow-checks = true [workspace.dependencies] -neutron-sdk = { package = "neutron-sdk", git = "https://github.com/neutron-org/neutron-sdk", branch = "main" } +neutron-sdk = { package = "neutron-sdk", git = "https://github.com/neutron-org/neutron-sdk", branch = "feat/icq-params-gov-gated" } prost = "0.12.4" prost-types = "0.12.4" cosmos-sdk-proto = { version = "0.20.0", default-features = false } diff --git a/contracts/neutron_interchain_queries/src/contract.rs b/contracts/neutron_interchain_queries/src/contract.rs index 169e321..ca7619a 100644 --- a/contracts/neutron_interchain_queries/src/contract.rs +++ b/contracts/neutron_interchain_queries/src/contract.rs @@ -35,6 +35,7 @@ use neutron_sdk::interchain_queries::get_registered_query; use neutron_sdk::interchain_queries::types::{ QueryPayload, TransactionFilterItem, TransactionFilterOp, TransactionFilterValue, }; +use neutron_sdk::interchain_queries::v045::types::HEIGHT_FIELD; use neutron_sdk::interchain_queries::v047::queries::{ query_balance, query_bank_total, query_delegations, query_distribution_fee_pool, query_government_proposal_votes, query_government_proposals, query_staking_validators, @@ -45,7 +46,7 @@ use neutron_sdk::interchain_queries::v047::register_queries::{ new_register_delegator_delegations_query_msg, new_register_delegator_unbonding_delegations_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, + new_register_staking_validators_query_msg, }; use neutron_sdk::interchain_queries::v047::register_queries::{ new_register_gov_proposals_voters_votes_query_msg, @@ -144,10 +145,10 @@ pub fn execute( } => register_validators_signing_infos_query(connection_id, validators, update_period), ExecuteMsg::RegisterTransfersQuery { connection_id, - recipient, + recipients, update_period, min_height, - } => register_transfers_query(connection_id, recipient, update_period, min_height), + } => register_transfers_query(connection_id, recipients, update_period, min_height), ExecuteMsg::UpdateInterchainQuery { query_id, new_keys, @@ -284,12 +285,32 @@ pub fn register_validators_signing_infos_query( pub fn register_transfers_query( connection_id: String, - recipient: String, + recipients: Vec, update_period: u64, min_height: Option, ) -> NeutronResult> { - let msg = - new_register_transfers_query_msg(connection_id, recipient, update_period, min_height)?; + let mut query_data: Vec = recipients + .into_iter() + .map(|r| TransactionFilterItem { + field: RECIPIENT_FIELD.to_string(), + op: TransactionFilterOp::Eq, + value: TransactionFilterValue::String(r), + }) + .collect(); + + if let Some(min_height) = min_height { + query_data.push(TransactionFilterItem { + field: HEIGHT_FIELD.to_string(), + op: TransactionFilterOp::Gte, + value: TransactionFilterValue::Int(min_height), + }) + } + + let msg = NeutronMsg::register_interchain_query( + QueryPayload::TX(query_data), + connection_id, + update_period, + )?; Ok(Response::new().add_message(msg)) } diff --git a/contracts/neutron_interchain_queries/src/msg.rs b/contracts/neutron_interchain_queries/src/msg.rs index ddc0971..311a181 100644 --- a/contracts/neutron_interchain_queries/src/msg.rs +++ b/contracts/neutron_interchain_queries/src/msg.rs @@ -43,7 +43,7 @@ pub enum ExecuteMsg { RegisterTransfersQuery { connection_id: String, update_period: u64, - recipient: String, + recipients: Vec, min_height: Option, }, RegisterDelegatorDelegationsQuery { diff --git a/contracts/neutron_interchain_queries/src/testing/tests.rs b/contracts/neutron_interchain_queries/src/testing/tests.rs index 04b0902..d0ee479 100644 --- a/contracts/neutron_interchain_queries/src/testing/tests.rs +++ b/contracts/neutron_interchain_queries/src/testing/tests.rs @@ -1000,7 +1000,7 @@ fn test_sudo_tx_query_result_callback() { let msg = ExecuteMsg::RegisterTransfersQuery { connection_id: "connection".to_string(), update_period: 1u64, - recipient: watched_addr.clone(), + recipients: vec![watched_addr.clone()], min_height: None, }; execute( @@ -1104,7 +1104,7 @@ fn test_sudo_tx_query_result_min_height_callback() { let msg = ExecuteMsg::RegisterTransfersQuery { connection_id: "connection".to_string(), update_period: 1u64, - recipient: watched_addr.clone(), + recipients: vec![watched_addr.clone()], min_height: Some(100000), }; execute( From 3e78f1328616db76919c49de2eb0db499b38fec7 Mon Sep 17 00:00:00 2001 From: swelf Date: Mon, 5 Aug 2024 18:47:27 +0300 Subject: [PATCH 2/7] bumper rust version in toolchain --- .github/workflows/build.yml | 4 ++-- .github/workflows/tests.yml | 6 +++--- rust-toolchain.toml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2bc01b0..fca0ead 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,7 @@ on: inputs: toolchain: description: 'Default Rust Toolchain' - default: "1.73.0" + default: "1.78.0" required: true type: string target: @@ -31,7 +31,7 @@ on: type: string env: - TOOLCHAIN: ${{ inputs.toolchain || '1.73.0' }} + TOOLCHAIN: ${{ inputs.toolchain || '1.78.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 18a4d9a..e683412 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.73.0 + toolchain: 1.78.0 components: clippy profile: minimal override: true @@ -31,7 +31,7 @@ jobs: fetch-depth: 1 - uses: actions-rs/toolchain@v1 with: - toolchain: 1.73.0 + toolchain: 1.78.0 components: rustfmt profile: minimal override: true @@ -49,7 +49,7 @@ jobs: fetch-depth: 1 - uses: actions-rs/toolchain@v1 with: - toolchain: 1.73.0 + toolchain: 1.78.0 profile: minimal - run: cargo fetch --verbose - run: cargo build diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 8142c30..5198580 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.73.0" +channel = "1.78.0" From 0c0b34ff47da67f15b082e23ad3a4bedb7b054c3 Mon Sep 17 00:00:00 2001 From: swelf Date: Mon, 5 Aug 2024 19:04:11 +0300 Subject: [PATCH 3/7] lint --- contracts/neutron_interchain_txs/src/contract.rs | 4 ++-- contracts/neutron_validator_test/src/contract.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contracts/neutron_interchain_txs/src/contract.rs b/contracts/neutron_interchain_txs/src/contract.rs index 20ff287..efc4660 100644 --- a/contracts/neutron_interchain_txs/src/contract.rs +++ b/contracts/neutron_interchain_txs/src/contract.rs @@ -346,7 +346,7 @@ fn execute_undelegate( amount: amount.to_string(), }), }; - let mut buf = Vec::new(); + let mut buf = Vec::with_capacity(delegate_msg.encoded_len()); buf.reserve(delegate_msg.encoded_len()); if let Err(e) = delegate_msg.encode(&mut buf) { @@ -403,7 +403,7 @@ fn do_delegate( amount: info.amount.to_string(), }), }; - let mut buf = Vec::new(); + let mut buf = Vec::with_capacity(delegate_msg.encoded_len()); buf.reserve(delegate_msg.encoded_len()); if let Err(e) = delegate_msg.encode(&mut buf) { diff --git a/contracts/neutron_validator_test/src/contract.rs b/contracts/neutron_validator_test/src/contract.rs index 9288521..31ee097 100644 --- a/contracts/neutron_validator_test/src/contract.rs +++ b/contracts/neutron_validator_test/src/contract.rs @@ -350,7 +350,7 @@ fn execute_undelegate( amount: amount.to_string(), }), }; - let mut buf = Vec::new(); + let mut buf = Vec::with_capacity(delegate_msg.encoded_len()); buf.reserve(delegate_msg.encoded_len()); if let Err(e) = delegate_msg.encode(&mut buf) { From 8f6917d3275128f106f705fc54d905a7cfd60a28 Mon Sep 17 00:00:00 2001 From: swelf Date: Mon, 5 Aug 2024 19:13:23 +0300 Subject: [PATCH 4/7] build --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5458820..382b781 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ compile: --mount type=volume,source="$(notdir $(CURDIR))_cache",target=/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ --platform linux/amd64 \ - cosmwasm/workspace-optimizer:0.15.0 + cosmwasm/workspace-optimizer:0.16.0 check_contracts: @cargo install cosmwasm-check --locked From 11295ccf93aa8eedb84f10694b39acef386cb25f Mon Sep 17 00:00:00 2001 From: swelf Date: Mon, 5 Aug 2024 19:23:56 +0300 Subject: [PATCH 5/7] scheme --- .../neutron_interchain_queries/schema/execute_msg.json | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/contracts/neutron_interchain_queries/schema/execute_msg.json b/contracts/neutron_interchain_queries/schema/execute_msg.json index cc7022e..742347b 100644 --- a/contracts/neutron_interchain_queries/schema/execute_msg.json +++ b/contracts/neutron_interchain_queries/schema/execute_msg.json @@ -218,7 +218,7 @@ "type": "object", "required": [ "connection_id", - "recipient", + "recipients", "update_period" ], "properties": { @@ -233,8 +233,11 @@ "format": "uint64", "minimum": 0.0 }, - "recipient": { - "type": "string" + "recipients": { + "type": "array", + "items": { + "type": "string" + } }, "update_period": { "type": "integer", From 5c5e413976254084bafb833dcd12c5f868f786d7 Mon Sep 17 00:00:00 2001 From: swelf Date: Fri, 30 Aug 2024 12:58:17 +0300 Subject: [PATCH 6/7] updated sdk --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index c3f7277..ce7f99a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1131,7 +1131,7 @@ dependencies = [ [[package]] name = "neutron-sdk" version = "0.11.0" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/icq-params-gov-gated#a47ca5f461de2a021b912bd7f4851782f8dcebd0" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/icq-params-gov-gated#a11018a9152bb0065868145266f35e283ac36b8e" dependencies = [ "bech32 0.9.1", "chrono", From ffc721ca7637e0d186b5ee16b30239b4a286aad2 Mon Sep 17 00:00:00 2001 From: swelf Date: Mon, 2 Sep 2024 13:36:48 +0300 Subject: [PATCH 7/7] bumbed neutron-sdk version --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ce7f99a..ea31203 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1131,7 +1131,7 @@ dependencies = [ [[package]] name = "neutron-sdk" version = "0.11.0" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/icq-params-gov-gated#a11018a9152bb0065868145266f35e283ac36b8e" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=main#e0e697a5c8f2960da1c1e6f4a5fd42b1c0dfb5b7" dependencies = [ "bech32 0.9.1", "chrono", @@ -1155,7 +1155,7 @@ dependencies = [ [[package]] name = "neutron-std-derive" version = "0.20.1" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/icq-params-gov-gated#a47ca5f461de2a021b912bd7f4851782f8dcebd0" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=main#e0e697a5c8f2960da1c1e6f4a5fd42b1c0dfb5b7" dependencies = [ "itertools 0.10.5", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 4a6767e..dc9f388 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ incremental = false overflow-checks = true [workspace.dependencies] -neutron-sdk = { package = "neutron-sdk", git = "https://github.com/neutron-org/neutron-sdk", branch = "feat/icq-params-gov-gated" } +neutron-sdk = { package = "neutron-sdk", git = "https://github.com/neutron-org/neutron-sdk", branch = "main" } prost = "0.12.4" prost-types = "0.12.4" cosmos-sdk-proto = { version = "0.20.0", default-features = false }