Skip to content

Commit

Permalink
Merge branch 'main' of github.com:neutron-org/neutron-sdk into feat/i…
Browse files Browse the repository at this point in the history
…mprove-balances-query
  • Loading branch information
sotnikov-s committed May 30, 2024
2 parents 0f396a9 + 4fc7cfd commit 9e0b30c
Show file tree
Hide file tree
Showing 46 changed files with 4,401 additions and 195 deletions.
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Changelog

## 0.10.0

Bindings for [Neutron Dex module](https://docs.neutron.org/neutron/modules/dex/overview/) is added.

### Added

* feat: cw dex bindings by @swelf19 in https://github.com/neutron-org/neutron-sdk/pull/120

## 0.9.0

Now Neutron-SDK supports ICQ and ICTX helpers for different version of Cosmos-SDK and specifically 0.9.0 release
introduces ICQ and ICTX helpers for Cosmos SDK 0.47.

So if your contract requires interaction with remote chain that uses Cosmos SDK 0.47 you should use helpers from `v047`
packages.

### Added

* ICQ helpers for Cosmos SDK 0.47 by @pr0n00gler in https://github.com/neutron-org/neutron-sdk/pull/133
* Feat: missing tokenfactory bindings by @pr0n00gler in https://github.com/neutron-org/neutron-sdk/pull/128
* Add grpc option `IncludePoolData` to `QueryUserDeposits` by @sotnikov-s
in https://github.com/neutron-org/neutron-sdk/pull/127
* Add query for validators signing infos and unbonding delegations query by @albertandrejev
in https://github.com/neutron-org/neutron-sdk/pull/122

### Fixed

* NTRN-201 fix potential overflow during delegations reconstruct by @quasisamurai
in https://github.com/neutron-org/neutron-sdk/pull/132

### Changed

* Remove usage of deprecated `data` field in Neutron SDK ICTX helper for SDK 0.47 chains & update SDK 0.45 helper to
backw compat NTRN-223 by @quasisamurai in https://github.com/neutron-org/neutron-sdk/pull/134
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
resolver = "2"
members = ["contracts/*", "packages/*"]
members = ["contracts/*", "packages/*", "proto-build"]

[profile.release]
opt-level = 3
Expand Down Expand Up @@ -29,5 +29,6 @@ bech32 = "0.9.1"
thiserror = "1.0.49"
protobuf = { version = "3.3.0" }
hex = "0.4.3"
serde_json = { version = "1.0.87" }
tendermint-proto = "0.34"
speedate = "0.13.0"
speedate = "0.13.0"
48 changes: 48 additions & 0 deletions MIGRATING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Migrating

This guide explains what is needed to upgrade contracts when migrating over releases of`neutron-sdk`. Note that you can
also view the
[complete CHANGELOG](./CHANGELOG.md) to understand the differences.

## 0.9.0 -> 0.10.0

* Update`neutron-sdk`dependencies in Cargo.toml:

```
[dependencies]
neutron-sdk = "0.10.0"
# ...
```

## 0.8.0 -> 0.9.0

* Update`neutron-sdk`dependencies in Cargo.toml:

```
[dependencies]
neutron-sdk = "0.9.0"
# ...
```

* If you want to use ICQ helpers compatible with Cosmos SDK 0.47, you must use helpers from v047 package now (you don't
need to change the code otherwise):

```diff
-use neutron_sdk::interchain_queries::v045::queries::{...}
+use neutron_sdk::interchain_queries::v047::queries::{...}

-use neutron_sdk::interchain_queries::v045::register_queries::{...}
+use neutron_sdk::interchain_queries::v047::register_queries::{...}

-use neutron_sdk::interchain_queries::v045::types::{...};
+use neutron_sdk::interchain_queries::v047::types::{...};
```

* Helper for Interchain transactions module `decode_acknowledgement_response` has been moved
from `neutron_sdk::interchain_txs::helpers` package to respective packages for different Cosmos SDK version (`v045`
and `v047` respectively):

```diff
-use neutron_sdk::interchain_txs::helpers::decode_acknowledgement_response;
+use neutron_sdk::interchain_txs::v047::helpers::decode_acknowledgement_response;
```
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@ check_contracts:
@cargo install cosmwasm-check
@cosmwasm-check --available-capabilities iterator,staking,stargate,neutron artifacts/*.wasm

build: schema clippy test fmt doc compile check_contracts
build: schema clippy test fmt doc compile check_contracts

build-proto:
@cargo run --bin proto-build $(revision)
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ make test
make schema
```

### Generating proto files

Neutron proto files represented as generated Rust code is a part of the Neutron SDK. In case Neutron
proto files have changed there's a command for Rust generated code rebuild. To rebuild the files,
run the following command using the respective Neutron revision (tag) as an argument, e.g.:
```sh
make build-proto revision=v3.0.3
```

### Production

For production builds, run the following:
Expand Down
22 changes: 12 additions & 10 deletions contracts/neutron_interchain_queries/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use cosmwasm_std::{
StdResult, Uint128,
};
use cw2::set_contract_version;
use neutron_sdk::interchain_queries::v045::register_queries::new_register_validators_signing_infos_query_msg;
use neutron_sdk::interchain_queries::v047::register_queries::new_register_validators_signing_infos_query_msg;

use crate::msg::{
Cw20BalanceResponse, ExecuteMsg, GetRecipientTxsResponse, InstantiateMsg, MigrateMsg, QueryMsg,
Expand All @@ -15,20 +15,22 @@ use crate::state::{Transfer, RECIPIENT_TXS, TRANSFERS};
use neutron_sdk::bindings::msg::NeutronMsg;
use neutron_sdk::bindings::query::{NeutronQuery, QueryRegisteredQueryResponse};
use neutron_sdk::bindings::types::{Height, KVKey};
use neutron_sdk::interchain_queries::v045::queries::{
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,
};
use neutron_sdk::interchain_queries::{
check_query_type, get_registered_query, query_kv_result,
v045::{
new_register_balances_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_staking_validators_query_msg, new_register_transfers_query_msg,
register_queries::new_register_wasm_contract_store_query_msg,
v047::{
register_queries::{
new_register_balances_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_proposals_query_msg,
new_register_staking_validators_query_msg, new_register_transfers_query_msg,
new_register_wasm_contract_store_query_msg,
},
types::{COSMOS_SDK_TRANSFER_MSG_URL, RECIPIENT_FIELD},
},
};
Expand Down Expand Up @@ -176,7 +178,7 @@ pub fn register_gov_proposal_query(
proposals_ids: Vec<u64>,
update_period: u64,
) -> NeutronResult<Response<NeutronMsg>> {
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))
}
Expand Down
86 changes: 42 additions & 44 deletions contracts/neutron_interchain_queries/src/testing/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ use neutron_sdk::interchain_queries::helpers::decode_and_convert;
use neutron_sdk::interchain_queries::types::{
QueryType, TransactionFilterItem, TransactionFilterOp, TransactionFilterValue,
};
use neutron_sdk::interchain_queries::v045::helpers::{
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,
};
use neutron_sdk::interchain_queries::v045::types::{
use neutron_sdk::interchain_queries::v047::types::{
Balances, FeePool, GovernmentProposal, Proposal, SigningInfo, StakingValidator, TallyResult,
TotalSupply, Validator, ValidatorSigningInfo, RECIPIENT_FIELD,
TotalSupply, Validator, ValidatorSigningInfo, RECIPIENT_FIELD, STAKING_PARAMS_KEY,
};

use neutron_sdk::interchain_queries::v045::queries::{
use neutron_sdk::interchain_queries::v047::queries::{
BalanceResponse, DelegatorDelegationsResponse, FeePoolResponse, ProposalResponse,
TotalSupplyResponse, ValidatorResponse, ValidatorSigningInfoResponse,
};
Expand Down Expand Up @@ -215,14 +215,12 @@ fn build_interchain_query_gov_proposal_value(proposal_id: u64) -> StorageValue {
fn build_interchain_query_balance_response(addr: Addr, denom: String, amount: String) -> Binary {
let converted_addr_bytes = decode_and_convert(addr.as_str()).unwrap();

let balance_key = create_account_denom_balance_key(converted_addr_bytes, &denom).unwrap();

let balance_amount = CosmosCoin { denom, amount };
let balance_key = create_account_denom_balance_key(converted_addr_bytes, denom).unwrap();

let s = StorageValue {
storage_prefix: "".to_string(),
key: Binary(balance_key),
value: Binary(balance_amount.encode_to_vec()),
value: Binary(amount.into_bytes()),
};
Binary::from(
to_string(&QueryRegisteredQueryResultResponse {
Expand Down Expand Up @@ -288,7 +286,7 @@ fn test_query_balance() {
last_submitted_local_height: 987,
balances: Balances {
coins: vec![Coin::new(8278104u128, "uosmo")]
}
},
}
)
}
Expand Down Expand Up @@ -340,9 +338,9 @@ fn test_bank_total_supply_query() {
supply: TotalSupply {
coins: vec![
Coin::new(8278104u128, "uosmo"),
Coin::new(8278104u128, "uatom")
Coin::new(8278104u128, "uatom"),
]
}
},
}
);
}
Expand Down Expand Up @@ -378,7 +376,7 @@ fn test_distribution_fee_pool_query() {
last_submitted_local_height: 987,
pool: FeePool {
coins: vec![Coin::new(8278104u128, "uosmo")]
}
},
}
)
}
Expand Down Expand Up @@ -441,11 +439,11 @@ 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 {
proposal_id: 2,
Expand All @@ -460,11 +458,11 @@ 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 {
proposal_id: 3,
Expand All @@ -479,14 +477,14 @@ 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(),
}),
},
]
}
},
}
)
}
Expand Down Expand Up @@ -578,9 +576,9 @@ fn test_staking_validators_query() {
max_rate: None,
max_change_rate: None,
update_time: None,
}
},
]
}
},
}
)
}
Expand Down Expand Up @@ -646,7 +644,7 @@ fn test_validators_signing_infos_query() {
index_offset: 20,
jailed_until: None,
tombstoned: false,
missed_blocks_counter: 13
missed_blocks_counter: 13,
},
ValidatorSigningInfo {
address: "cosmosvaloper1sjllsnramtg3ewxqwwrwjxfgc4n4ef9u2lcnj0".to_string(),
Expand All @@ -655,9 +653,9 @@ fn test_validators_signing_infos_query() {
jailed_until: Some(1203981203),
tombstoned: false,
missed_blocks_counter: 13,
}
},
]
}
},
}
)
}
Expand All @@ -684,12 +682,12 @@ fn test_query_delegator_delegations() {
// response for `RegisterDelegatorDelegationsQuery` with necessary KV values to test reconstruction logic.
// The values are taken from osmosis network
kv_results: vec![
// params value of staking module for key 'staking/BondDenom'
// value: uosmo
// params value of staking module for key 'staking/params'
// value: Params
StorageValue {
storage_prefix: "params".to_string(),
key: Binary::from(BASE64_STANDARD.decode("c3Rha2luZy9Cb25kRGVub20=").unwrap()),
value: Binary::from(BASE64_STANDARD.decode("InVvc21vIg==").unwrap()),
storage_prefix: "staking".to_string(),
key: Binary::from([STAKING_PARAMS_KEY]),
value: Binary::from(BASE64_STANDARD.decode("CgQIgN9uEGQYByCQTioFdWF0b20yATA6FC0xMDAwMDAwMDAwMDAwMDAwMDAwQhMxMDAwMDAwMDAwMDAwMDAwMDAwShMxMDAwMDAwMDAwMDAwMDAwMDAw").unwrap()),
},
// delegation
// from: osmo1yz54ncxj9csp7un3xled03q6thrrhy9cztkfzs
Expand Down Expand Up @@ -741,7 +739,7 @@ fn test_query_delegator_delegations() {
storage_prefix: "staking".to_string(),
key: Binary::from(decode_hex("2114f8aff987b760a6e4b2b2df48a5a3b7ed2db15006").unwrap()),
value: Binary::from(BASE64_STANDARD.decode("CjJvc21vdmFsb3BlcjFsemhsbnBhaHZ6bndmdjRqbWF5MnRnYWhhNWttejVxeHdtajl3ZRJDCh0vY29zbW9zLmNyeXB0by5lZDI1NTE5LlB1YktleRIiCiBPXCnkQvO+pU6oGbp4ZiJBBZ7RNoLYtXYFOEdpXGH+uSADKg0zMjAxNDM4ODk4NDc2Mh8zMjAxNDM4ODk4NDc2MDAwMDAwMDAwMDAwMDAwMDAwOp8CCgtDaXRhZGVsLm9uZRIQRUJCMDNFQjRCQjRDRkNBNxoTaHR0cHM6Ly9jaXRhZGVsLm9uZSroAUNpdGFkZWwub25lIGlzIGEgbXVsdGktYXNzZXQgbm9uLWN1c3RvZGlhbCBzdGFraW5nIHBsYXRmb3JtIHRoYXQgbGV0cyBhbnlvbmUgYmVjb21lIGEgcGFydCBvZiBkZWNlbnRyYWxpemVkIGluZnJhc3RydWN0dXJlIGFuZCBlYXJuIHBhc3NpdmUgaW5jb21lLiBTdGFrZSB3aXRoIG91ciBub2RlcyBvciBhbnkgb3RoZXIgdmFsaWRhdG9yIGFjcm9zcyBtdWx0aXBsZSBuZXR3b3JrcyBpbiBhIGZldyBjbGlja3NKAFJECjoKETUwMDAwMDAwMDAwMDAwMDAwEhIyMDAwMDAwMDAwMDAwMDAwMDAaETMwMDAwMDAwMDAwMDAwMDAwEgYIkKKzhgZaATE=").unwrap()),
}
},
],
height: 0,
revision: 0,
Expand All @@ -767,18 +765,18 @@ fn test_query_delegator_delegations() {
Delegation {
delegator: Addr::unchecked("osmo1yz54ncxj9csp7un3xled03q6thrrhy9cztkfzs"),
validator: "osmovaloper1r2u5q6t6w0wssrk6l66n3t2q3dw2uqny4gj2e3".to_string(),
amount: Coin::new(5177628u128, "uosmo".to_string())
amount: Coin::new(5177628u128, "uatom".to_string()),
},
Delegation {
delegator: Addr::unchecked("osmo1yz54ncxj9csp7un3xled03q6thrrhy9cztkfzs"),
validator: "osmovaloper1ej2es5fjztqjcd4pwa0zyvaevtjd2y5w37wr9t".to_string(),
amount: Coin::new(29620221u128, "uosmo".to_string())
amount: Coin::new(29620221u128, "uatom".to_string()),
},
Delegation {
delegator: Addr::unchecked("osmo1yz54ncxj9csp7un3xled03q6thrrhy9cztkfzs"),
validator: "osmovaloper1lzhlnpahvznwfv4jmay2tgaha5kmz5qxwmj9we".to_string(),
amount: Coin::new(219920u128, "uosmo".to_string())
}
amount: Coin::new(219920u128, "uatom".to_string()),
},
],
}
)
Expand Down
Loading

0 comments on commit 9e0b30c

Please # to comment.