Skip to content

Commit

Permalink
Merge branch 'main' into fix/empty-metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
NeverHappened committed Jul 5, 2024
2 parents 607c53d + 5c64652 commit ac20438
Show file tree
Hide file tree
Showing 52 changed files with 477 additions and 351 deletions.
282 changes: 191 additions & 91 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ neutron-sdk = { package = "neutron-sdk", git = "https://github.com/neutron-org/n
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 = [
cosmwasm-std = { version = "2.0.4", features = [
"stargate",
"staking",
"cosmwasm_1_1",
"cosmwasm_1_2",
] }
cw2 = "1.1.1"
cw-storage-plus = "1.1.0"
cw2 = "2.0.0"
cw-storage-plus = "2.0.0"
schemars = "0.8.15"
serde = { version = "1.0.189", default-features = false }
cosmwasm-schema = { version = "1.4.1", default-features = false }
cosmwasm-schema = { version = "2.0.4", default-features = false }
serde-json-wasm = "1.0.0"
base64 = "0.21.4"
base64 = "0.21.7"
thiserror = "1.0.49"
2 changes: 1 addition & 1 deletion contracts/before-send-hook/.cargo/config
Original file line number Diff line number Diff line change
@@ -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 --example schema"
10 changes: 4 additions & 6 deletions contracts/before-send-hook/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,13 @@ overflow-checks = true

[features]
# for quicker tests, cargo test --lib
# for more explicit tests, cargo test --features=backtraces
backtraces = ["cosmwasm-std/backtraces"]
library = []

[dependencies]
cosmwasm-std = "1.3.1"
cosmwasm-std = { workspace = true }
serde = { version = "1.0.180", default-features = false, features = ["derive"] }
schemars = "0.8.12"
cw-storage-plus = "1.1.0"
schemars = { workspace = true }
cw-storage-plus = { workspace = true }

[dev-dependencies]
cosmwasm-schema = { version = "1.3.1", default-features = false }
cosmwasm-schema = { workspace = true }
2 changes: 1 addition & 1 deletion contracts/client_updater/.cargo/config
Original file line number Diff line number Diff line change
@@ -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 --example client_updater-schema"
2 changes: 0 additions & 2 deletions contracts/client_updater/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,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]
Expand Down
2 changes: 1 addition & 1 deletion contracts/dex/.cargo/config
Original file line number Diff line number Diff line change
@@ -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 --example schema"
10 changes: 4 additions & 6 deletions contracts/dex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,14 @@ overflow-checks = true

[features]
# for quicker tests, cargo test --lib
# for more explicit tests, cargo test --features=backtraces
backtraces = ["cosmwasm-std/backtraces"]
library = []

[dependencies]
cosmwasm-std = "1.3.1"
cw2 = "1.1.0"
schemars = "0.8.10"
cosmwasm-std = { workspace = true }
cw2 = { workspace = true }
schemars = { workspace = true }
serde = { version = "1.0.180", default-features = false, features = ["derive"] }
neutron-sdk = { workspace = true }

[dev-dependencies]
cosmwasm-schema = { version = "1.3.1", default-features = false }
cosmwasm-schema = { workspace = true }
2 changes: 1 addition & 1 deletion contracts/dex_stargate/.cargo/config
Original file line number Diff line number Diff line change
@@ -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 --example schema"
10 changes: 4 additions & 6 deletions contracts/dex_stargate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,17 @@ overflow-checks = true

[features]
# for quicker tests, cargo test --lib
# for more explicit tests, cargo test --features=backtraces
backtraces = ["cosmwasm-std/backtraces"]
library = []

[dependencies]
neutron-sdk = { workspace = true }
cosmwasm-std = { version = "1.4.0", features = ["stargate"] }
cw2 = "1.1.1"
schemars = "0.8.15"
cosmwasm-std = { workspace = true, features = ["stargate"] }
cw2 = { workspace = true }
schemars = { workspace = true }
serde = { version = "1.0.188", default-features = false, features = ["derive"] }
prost = "0.12.3"
prost-types = "0.12.3"
cosmos-sdk-proto = { version = "0.20.0", default-features = false }

[dev-dependencies]
cosmwasm-schema = { version = "1.3.1", default-features = false }
cosmwasm-schema = { workspace = true }
2 changes: 1 addition & 1 deletion contracts/echo/.cargo/config
Original file line number Diff line number Diff line change
@@ -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 --example echo-schema"
2 changes: 0 additions & 2 deletions contracts/echo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,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]
Expand Down
2 changes: 1 addition & 1 deletion contracts/ibc_transfer/.cargo/config
Original file line number Diff line number Diff line change
@@ -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 --example ibc_transfer-schema"
2 changes: 0 additions & 2 deletions contracts/ibc_transfer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,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]
Expand Down
20 changes: 8 additions & 12 deletions contracts/ibc_transfer/schema/execute_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
],
"properties": {
"amount": {
"type": "integer",
"format": "uint128",
"minimum": 0.0
"$ref": "#/definitions/Uint128"
},
"channel": {
"type": "string"
Expand Down Expand Up @@ -60,22 +58,16 @@
],
"properties": {
"ack_fee": {
"type": "integer",
"format": "uint128",
"minimum": 0.0
"$ref": "#/definitions/Uint128"
},
"denom": {
"type": "string"
},
"recv_fee": {
"type": "integer",
"format": "uint128",
"minimum": 0.0
"$ref": "#/definitions/Uint128"
},
"timeout_fee": {
"type": "integer",
"format": "uint128",
"minimum": 0.0
"$ref": "#/definitions/Uint128"
}
}
}
Expand Down Expand Up @@ -147,6 +139,10 @@
"enabled_infinite_loop",
"disabled"
]
},
"Uint128": {
"description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```",
"type": "string"
}
}
}
42 changes: 22 additions & 20 deletions contracts/ibc_transfer/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use cosmwasm_std::{
coin, entry_point, Binary, Coin, CosmosMsg, Deps, DepsMut, Env, MessageInfo, Reply, Response,
StdError, StdResult, SubMsg,
StdError, StdResult, SubMsg, Uint128,
};
use cw2::set_contract_version;
use neutron_sdk::bindings::msg::MsgIbcTransferResponse;
use neutron_sdk::interchain_txs::helpers::decode_message_response;
use neutron_sdk::proto_types::neutron::transfer::MsgTransferResponse;
use neutron_sdk::{
bindings::msg::{IbcFee, NeutronMsg},
sudo::msg::{RequestPacket, RequestPacketTimeoutHeight, TransferSudoMsg},
Expand Down Expand Up @@ -49,13 +50,13 @@ pub enum ExecuteMsg {
channel: String,
to: String,
denom: String,
amount: u128,
amount: Uint128,
timeout_height: Option<u64>,
},
SetFees {
recv_fee: u128,
ack_fee: u128,
timeout_fee: u128,
recv_fee: Uint128,
ack_fee: Uint128,
timeout_fee: Uint128,
denom: String,
},
ResubmitFailure {
Expand Down Expand Up @@ -153,13 +154,14 @@ fn msg_with_sudo_callback<C: Into<CosmosMsg<T>>, T>(

fn prepare_sudo_payload(mut deps: DepsMut, _env: Env, msg: Reply) -> StdResult<Response> {
let payload = read_reply_payload(deps.storage, msg.id)?;
let resp: MsgIbcTransferResponse = serde_json_wasm::from_slice(
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"))?
.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#L307
.clone()
.value
.to_vec(),
)
.map_err(|e| StdError::generic_err(format!("failed to parse response: {:?}", e)))?;
let seq_id = resp.sequence_id;
Expand All @@ -179,19 +181,19 @@ pub fn reply(deps: DepsMut, env: Env, msg: Reply) -> StdResult<Response> {
}
}

fn get_fee_item(denom: String, amount: u128) -> Vec<Coin> {
if amount == 0 {
fn get_fee_item(denom: String, amount: Uint128) -> Vec<Coin> {
if amount == Uint128::new(0) {
vec![]
} else {
vec![coin(amount, denom)]
vec![coin(amount.u128(), denom)]
}
}

fn execute_set_fees(
deps: DepsMut,
recv_fee: u128,
ack_fee: u128,
timeout_fee: u128,
recv_fee: Uint128,
ack_fee: Uint128,
timeout_fee: Uint128,
denom: String,
) -> StdResult<Response<NeutronMsg>> {
let fee = IbcFee {
Expand All @@ -211,11 +213,11 @@ fn execute_send(
channel: String,
to: String,
denom: String,
amount: u128,
amount: Uint128,
timeout_height: Option<u64>,
) -> StdResult<Response<NeutronMsg>> {
let fee = IBC_FEE.load(deps.storage)?;
let coin1 = coin(amount, denom.clone());
let coin1 = coin(amount.u128(), denom.clone());
let msg1 = NeutronMsg::IbcTransfer {
source_port: "transfer".to_string(),
source_channel: channel.clone(),
Expand All @@ -230,7 +232,7 @@ fn execute_send(
fee: fee.clone(),
memo: "".to_string(),
};
let coin2 = coin(2 * amount, denom);
let coin2 = coin(2 * amount.u128(), denom);
let msg2 = NeutronMsg::IbcTransfer {
source_port: "transfer".to_string(),
source_channel: channel,
Expand Down
4 changes: 2 additions & 2 deletions contracts/ibc_transfer/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub fn save_reply_payload(store: &mut dyn Storage, payload: SudoPayload) -> StdR

pub fn read_reply_payload(store: &dyn Storage, id: u64) -> StdResult<SudoPayload> {
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
Expand All @@ -64,7 +64,7 @@ pub fn read_sudo_payload(
seq_id: u64,
) -> StdResult<SudoPayload> {
let data = SUDO_PAYLOAD.load(store, (channel_id, seq_id))?;
from_json(Binary(data))
from_json(Binary::new(data))
}

/// Used only in integration tests framework to simulate failures.
Expand Down
2 changes: 1 addition & 1 deletion contracts/marketmap/.cargo/config
Original file line number Diff line number Diff line change
@@ -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 --example schema"
10 changes: 4 additions & 6 deletions contracts/marketmap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,14 @@ overflow-checks = true

[features]
# for quicker tests, cargo test --lib
# for more explicit tests, cargo test --features=backtraces
backtraces = ["cosmwasm-std/backtraces"]
library = []

[dependencies]
cosmwasm-std = "1.3.1"
cw2 = "1.1.0"
schemars = "0.8.10"
cosmwasm-std = { workspace = true }
cw2 = { workspace = true }
schemars = { workspace = true }
serde = { version = "1.0.180", default-features = false, features = ["derive"] }
neutron-sdk = { workspace = true }

[dev-dependencies]
cosmwasm-schema = { version = "1.3.1", default-features = false }
cosmwasm-schema = { workspace = true }
2 changes: 1 addition & 1 deletion contracts/msg_receiver/.cargo/config
Original file line number Diff line number Diff line change
@@ -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 --example msg_receiver-schema"
2 changes: 0 additions & 2 deletions contracts/msg_receiver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,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]
Expand Down
2 changes: 1 addition & 1 deletion contracts/neutron_interchain_queries/.cargo/config
Original file line number Diff line number Diff line change
@@ -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 --example neutron_interchain_queries-schema"
2 changes: 0 additions & 2 deletions contracts/neutron_interchain_queries/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ exclude = [
crate-type = ["cdylib", "rlib"]

[features]
# for more explicit tests, cargo test --features=backtraces
backtraces = ["cosmwasm-std/backtraces"]
library = []

[dependencies]
Expand Down
Loading

0 comments on commit ac20438

Please sign in to comment.