Skip to content

Commit

Permalink
Merge pull request #60 from neutron-org/feat/new_transaction_filter
Browse files Browse the repository at this point in the history
Feat/new transaction filter
  • Loading branch information
zavgorodnii authored Nov 19, 2022
2 parents 9a67728 + 57baaa3 commit 17f469b
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 10 deletions.
8 changes: 4 additions & 4 deletions artifacts/checksums.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
f43a8d9f57d10567c106dc75ce3112e712d3760c86c197e90674d07f83e02c5c ibc_transfer.wasm
f6f463813fbfc0a586f8db4ced7a5935c7651a1a202d846fb1fbf511195e73f5 neutron_interchain_queries.wasm
c3439930acd1251a66e3e1cb45ff3670ad35cdf6c9db747c60912f156a2206ac neutron_interchain_txs.wasm
c2829bea69560d444a66f9785935e9fd8a09becf9f321363a8bcc1e531dfcb6e neutron_validators_test.wasm
4d2a9f1b9d6e8181c3ecca744ae5e42667cfe9e4c2dccca1ae08a14235e18508 ibc_transfer.wasm
cbf63b17bd81dcce44a3ba3d5b4e61ec6f1da8e3a1f90041d518ac4397b326bd neutron_interchain_queries.wasm
a34dcff26a3709f5382d526ade65d41384e376eda7a28c07c588f4301554debe neutron_interchain_txs.wasm
e0746b2fc07dfa19ff2dc19b031874ff059118ed551f49128babbca64bae53cb neutron_validators_test.wasm
2e7a0f168de97eebf4080df6f9fe23987fc96ac5852f29ca6c489dee7b10e6dd reflect.wasm
Binary file modified artifacts/ibc_transfer.wasm
Binary file not shown.
Binary file modified artifacts/neutron_interchain_queries.wasm
Binary file not shown.
Binary file modified artifacts/neutron_interchain_txs.wasm
Binary file not shown.
Binary file modified artifacts/neutron_validators_test.wasm
Binary file not shown.
6 changes: 6 additions & 0 deletions contracts/neutron_interchain_queries/schema/execute_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@
"$ref": "#/definitions/KVKey"
}
},
"new_recipient": {
"type": [
"string",
"null"
]
},
"new_update_period": {
"type": [
"integer",
Expand Down
15 changes: 13 additions & 2 deletions contracts/neutron_interchain_queries/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ pub fn execute(
query_id,
new_keys,
new_update_period,
} => update_interchain_query(query_id, new_keys, new_update_period),
new_recipient,
} => update_interchain_query(query_id, new_keys, new_update_period, new_recipient),
ExecuteMsg::RemoveInterchainQuery { query_id } => remove_interchain_query(query_id),
ExecuteMsg::IntegrationTestsSetKvQueryMock {} => set_kv_query_mock(deps),
ExecuteMsg::IntegrationTestsUnsetKvQueryMock {} => unset_kv_query_mock(deps),
Expand Down Expand Up @@ -277,8 +278,18 @@ pub fn update_interchain_query(
query_id: u64,
new_keys: Option<Vec<KVKey>>,
new_update_period: Option<u64>,
new_recipient: Option<String>,
) -> NeutronResult<Response<NeutronMsg>> {
let update_msg = NeutronMsg::update_interchain_query(query_id, new_keys, new_update_period);
let new_filter = new_recipient.map(|recipient| {
vec![TransactionFilterItem {
field: RECIPIENT_FIELD.to_string(),
op: TransactionFilterOp::Eq,
value: TransactionFilterValue::String(recipient),
}]
});

let update_msg =
NeutronMsg::update_interchain_query(query_id, new_keys, new_update_period, new_filter)?;
Ok(Response::new().add_message(update_msg))
}

Expand Down
1 change: 1 addition & 0 deletions contracts/neutron_interchain_queries/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pub enum ExecuteMsg {
query_id: u64,
new_keys: Option<Vec<KVKey>>,
new_update_period: Option<u64>,
new_recipient: Option<String>,
},
RemoveInterchainQuery {
query_id: u64,
Expand Down
7 changes: 7 additions & 0 deletions packages/neutron-sdk/schema/neutron_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@
"$ref": "#/definitions/KVKey"
}
},
"new_transactions_filter": {
"description": "*new_transactions_filter** is a new transactions filter of the query",
"type": [
"string",
"null"
]
},
"new_update_period": {
"description": "*new_update_period** is a new update period of the query",
"type": [
Expand Down
27 changes: 23 additions & 4 deletions packages/neutron-sdk/src/bindings/msg.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
bindings::types::{KVKey, ProtobufAny},
interchain_queries::types::{QueryPayload, QueryType, MAX_TX_FILTERS},
interchain_queries::types::{QueryPayload, QueryType, TransactionFilterItem, MAX_TX_FILTERS},
sudo::msg::RequestPacketTimeoutHeight,
NeutronError, NeutronResult,
};
Expand Down Expand Up @@ -80,6 +80,9 @@ pub enum NeutronMsg {

/// **new_update_period** is a new update period of the query
new_update_period: Option<u64>,

/// **new_transactions_filter** is a new transactions filter of the query
new_transactions_filter: Option<String>,
},

/// RemoveInterchainQuery removes as interchain query
Expand Down Expand Up @@ -195,12 +198,28 @@ impl NeutronMsg {
query_id: u64,
new_keys: Option<Vec<KVKey>>,
new_update_period: Option<u64>,
) -> Self {
NeutronMsg::UpdateInterchainQuery {
new_transactions_filter: Option<Vec<TransactionFilterItem>>,
) -> NeutronResult<Self> {
Ok(NeutronMsg::UpdateInterchainQuery {
query_id,
new_keys,
new_update_period,
}
new_transactions_filter: match new_transactions_filter {
Some(filters) => {
if filters.len() > MAX_TX_FILTERS {
return Err(NeutronError::TooManyTransactionFilters {
max: MAX_TX_FILTERS,
});
} else {
Some(
to_string(&filters)
.map_err(|e| StdError::generic_err(e.to_string()))?,
)
}
}
None => None,
},
})
}

/// Basic helper to define a remove interchain query message:
Expand Down

0 comments on commit 17f469b

Please sign in to comment.