diff --git a/Cargo.lock b/Cargo.lock index e7d969a..471b11b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -154,12 +154,11 @@ checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" [[package]] name = "cosmwasm-crypto" -version = "1.5.5" +version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd50718a2b6830ce9eb5d465de5a018a12e71729d66b70807ce97e6dd14f931d" +checksum = "c7a339f6b59ff7ad4ae05a70512a4f3c19bf8fcc845d46bfef90f4ec0810f72c" dependencies = [ "digest 0.10.7", - "ecdsa", "ed25519-zebra", "k256", "rand_core 0.6.4", @@ -168,18 +167,18 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.5.5" +version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "242e98e7a231c122e08f300d9db3262d1007b51758a8732cd6210b3e9faa4f3a" +checksum = "7d3bfea6af94a83880fb05478135ed0c256d9a2fcde58c595a10d64dcb9c925d" dependencies = [ "syn 1.0.109", ] [[package]] name = "cosmwasm-schema" -version = "1.5.5" +version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7879036156092ad1c22fe0d7316efc5a5eceec2bc3906462a2560215f2a2f929" +checksum = "101d0739564bd34cba9b84bf73665f0822487ae3b29b2dd59930608ed3aafd43" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -190,9 +189,9 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.5.5" +version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bb57855fbfc83327f8445ae0d413b1a05ac0d68c396ab4d122b2abd7bb82cb6" +checksum = "cf4be75f60158478da2c5d319ed59295bca1687ad50c18215a0485aa91a995ea" dependencies = [ "proc-macro2", "quote", @@ -201,9 +200,9 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.5.5" +version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78c1556156fdf892a55cced6115968b961eaaadd6f724a2c2cb7d1e168e32dd3" +checksum = "ded932165de44cd0717979c34fc3b84d8e8066b8dde4f5bd78f96a643b090f90" dependencies = [ "base64 0.21.7", "bech32", @@ -280,9 +279,8 @@ dependencies = [ [[package]] name = "cw-address-like" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "451a4691083a88a3c0630a8a88799e9d4cd6679b7ce8ff22b8da2873ff31d380" +version = "2.0.4" +source = "git+https://github.com/CyberHoward/cw-plus-plus?branch=bump/cosmwasm-2.0#c33ce107e25fdb68daff42cb201e382d02619022" dependencies = [ "cosmwasm-std", ] @@ -377,9 +375,8 @@ dependencies = [ [[package]] name = "cw-ownable" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "093dfb4520c48b5848274dd88ea99e280a04bc08729603341c7fb0d758c74321" +version = "0.6.0" +source = "git+https://github.com/CyberHoward/cw-plus-plus?branch=bump/cosmwasm-2.0#c33ce107e25fdb68daff42cb201e382d02619022" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -392,9 +389,8 @@ dependencies = [ [[package]] name = "cw-ownable-derive" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d3bf2e0f341bb6cc100d7d441d31cf713fbd3ce0c511f91e79f14b40a889af" +version = "0.6.0" +source = "git+https://github.com/CyberHoward/cw-plus-plus?branch=bump/cosmwasm-2.0#c33ce107e25fdb68daff42cb201e382d02619022" dependencies = [ "proc-macro2", "quote", @@ -403,9 +399,9 @@ dependencies = [ [[package]] name = "cw-storage-plus" -version = "1.2.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5ff29294ee99373e2cd5fd21786a3c0ced99a52fec2ca347d565489c61b723c" +checksum = "f13360e9007f51998d42b1bc6b7fa0141f74feae61ed5fd1e5b0a89eec7b5de1" dependencies = [ "cosmwasm-std", "schemars", @@ -414,24 +410,22 @@ dependencies = [ [[package]] name = "cw-utils" -version = "1.0.3" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c4a657e5caacc3a0d00ee96ca8618745d050b8f757c709babafb81208d4239c" +checksum = "07dfee7f12f802431a856984a32bce1cb7da1e6c006b5409e3981035ce562dec" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw2", "schemars", - "semver", "serde", "thiserror", ] [[package]] name = "cw2" -version = "1.1.2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6c120b24fbbf5c3bedebb97f2cc85fbfa1c3287e09223428e7e597b5293c1fa" +checksum = "b04852cd38f044c0751259d5f78255d07590d136b8a86d4e09efdd7666bd6d27" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -444,9 +438,9 @@ dependencies = [ [[package]] name = "cw20" -version = "1.1.2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "526e39bb20534e25a1cd0386727f0038f4da294e5e535729ba3ef54055246abd" +checksum = "a42212b6bf29bbdda693743697c621894723f35d3db0d5df930be22903d0e27c" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -757,8 +751,7 @@ dependencies = [ [[package]] name = "ibc-client-cw" version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14bf49f8f43c3fea593d7c2413e061f8df607de45e6f7d76de5346a456f6addd" +source = "git+https://github.com/cosmos/ibc-rs?rev=1ca03717ab074da605ace9ad75247dfa8fb03f86#1ca03717ab074da605ace9ad75247dfa8fb03f86" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -773,8 +766,7 @@ dependencies = [ [[package]] name = "ibc-client-tendermint" version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "804dcd81f62608c453e72f669b2df986eb49d4b4381deac2a70bd33ee94cef7f" +source = "git+https://github.com/cosmos/ibc-rs?rev=1ca03717ab074da605ace9ad75247dfa8fb03f86#1ca03717ab074da605ace9ad75247dfa8fb03f86" dependencies = [ "derive_more", "ibc-client-tendermint-types", @@ -791,8 +783,7 @@ dependencies = [ [[package]] name = "ibc-client-tendermint-types" version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54b41444137be02cabc484079443f447d23e746fabd9ac6fd5d99faac0b30a5f" +source = "git+https://github.com/cosmos/ibc-rs?rev=1ca03717ab074da605ace9ad75247dfa8fb03f86#1ca03717ab074da605ace9ad75247dfa8fb03f86" dependencies = [ "displaydoc", "ibc-core-client-types", @@ -809,8 +800,7 @@ dependencies = [ [[package]] name = "ibc-client-wasm-types" version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcc05b707ee957b1272877606379647ae1e5897316a3406b6a93e1885ee99e68" +source = "git+https://github.com/cosmos/ibc-rs?rev=1ca03717ab074da605ace9ad75247dfa8fb03f86#1ca03717ab074da605ace9ad75247dfa8fb03f86" dependencies = [ "base64 0.21.7", "cosmwasm-schema", @@ -825,8 +815,7 @@ dependencies = [ [[package]] name = "ibc-core" version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cb69c4ee05d367fa321acf67ec00d3e9f8ecfef013accdb05889db32ff2de3f" +source = "git+https://github.com/cosmos/ibc-rs?rev=1ca03717ab074da605ace9ad75247dfa8fb03f86#1ca03717ab074da605ace9ad75247dfa8fb03f86" dependencies = [ "ibc-core-channel", "ibc-core-client", @@ -842,8 +831,7 @@ dependencies = [ [[package]] name = "ibc-core-channel" version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5dcc1c14a92f01e556d72d834f842bb655043a7e122ebb8aabdb5e9df600aa8" +source = "git+https://github.com/cosmos/ibc-rs?rev=1ca03717ab074da605ace9ad75247dfa8fb03f86#1ca03717ab074da605ace9ad75247dfa8fb03f86" dependencies = [ "ibc-core-channel-types", "ibc-core-client", @@ -858,8 +846,7 @@ dependencies = [ [[package]] name = "ibc-core-channel-types" version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c2744ad32ae7360caefb80f495800f883f5e5687cfbd74ff82a444b59a47af7" +source = "git+https://github.com/cosmos/ibc-rs?rev=1ca03717ab074da605ace9ad75247dfa8fb03f86#1ca03717ab074da605ace9ad75247dfa8fb03f86" dependencies = [ "derive_more", "displaydoc", @@ -879,8 +866,7 @@ dependencies = [ [[package]] name = "ibc-core-client" version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80071ac73dd4f3436bf1aef03c9b1715a4db0914f738904c281449dc05a0a9cf" +source = "git+https://github.com/cosmos/ibc-rs?rev=1ca03717ab074da605ace9ad75247dfa8fb03f86#1ca03717ab074da605ace9ad75247dfa8fb03f86" dependencies = [ "ibc-core-client-context", "ibc-core-client-types", @@ -893,8 +879,7 @@ dependencies = [ [[package]] name = "ibc-core-client-context" version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e9f751b62cad4195be5347646151020fd27c2924f10d82d6301a675fac544dd" +source = "git+https://github.com/cosmos/ibc-rs?rev=1ca03717ab074da605ace9ad75247dfa8fb03f86#1ca03717ab074da605ace9ad75247dfa8fb03f86" dependencies = [ "derive_more", "displaydoc", @@ -910,8 +895,7 @@ dependencies = [ [[package]] name = "ibc-core-client-types" version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "423e9e9a70b78fabc94c51dae76800459e126f891ae0987e88ac5e12c36e24de" +source = "git+https://github.com/cosmos/ibc-rs?rev=1ca03717ab074da605ace9ad75247dfa8fb03f86#1ca03717ab074da605ace9ad75247dfa8fb03f86" dependencies = [ "derive_more", "displaydoc", @@ -928,8 +912,7 @@ dependencies = [ [[package]] name = "ibc-core-commitment-types" version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1b323c91e58ea7b573e01b8e76d13f146c97c245ada0aab3070576d54288f30" +source = "git+https://github.com/cosmos/ibc-rs?rev=1ca03717ab074da605ace9ad75247dfa8fb03f86#1ca03717ab074da605ace9ad75247dfa8fb03f86" dependencies = [ "derive_more", "displaydoc", @@ -944,8 +927,7 @@ dependencies = [ [[package]] name = "ibc-core-connection" version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31271364789ccfc12c25afa21b47274d7e07bf49b1f728fd66cfa6c29daaf4a" +source = "git+https://github.com/cosmos/ibc-rs?rev=1ca03717ab074da605ace9ad75247dfa8fb03f86#1ca03717ab074da605ace9ad75247dfa8fb03f86" dependencies = [ "ibc-core-client", "ibc-core-connection-types", @@ -957,8 +939,7 @@ dependencies = [ [[package]] name = "ibc-core-connection-types" version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52d302a36925469589a911dab66654f390b87e98608d07515e47f5c7e51dffe7" +source = "git+https://github.com/cosmos/ibc-rs?rev=1ca03717ab074da605ace9ad75247dfa8fb03f86#1ca03717ab074da605ace9ad75247dfa8fb03f86" dependencies = [ "derive_more", "displaydoc", @@ -976,8 +957,7 @@ dependencies = [ [[package]] name = "ibc-core-handler" version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4523b9f77d3a1a391a3d63737760be44b23bc9b09ed297883a34654383b9b0e2" +source = "git+https://github.com/cosmos/ibc-rs?rev=1ca03717ab074da605ace9ad75247dfa8fb03f86#1ca03717ab074da605ace9ad75247dfa8fb03f86" dependencies = [ "ibc-core-channel", "ibc-core-client", @@ -992,8 +972,7 @@ dependencies = [ [[package]] name = "ibc-core-handler-types" version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b229a92aa8b06ab9ccde6e1b3dad597deb97cb40e3bb6a631799b4cd2ad124" +source = "git+https://github.com/cosmos/ibc-rs?rev=1ca03717ab074da605ace9ad75247dfa8fb03f86#1ca03717ab074da605ace9ad75247dfa8fb03f86" dependencies = [ "derive_more", "displaydoc", @@ -1014,8 +993,7 @@ dependencies = [ [[package]] name = "ibc-core-host" version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ed7421f285225b78f3d020df6126b61f94b9eb370a83e42fbd4e9c8b04162fa" +source = "git+https://github.com/cosmos/ibc-rs?rev=1ca03717ab074da605ace9ad75247dfa8fb03f86#1ca03717ab074da605ace9ad75247dfa8fb03f86" dependencies = [ "derive_more", "displaydoc", @@ -1033,8 +1011,7 @@ dependencies = [ [[package]] name = "ibc-core-host-types" version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "939178939d33e5af1aca19608b019233d753f3734b828d66f40152b382f3db53" +source = "git+https://github.com/cosmos/ibc-rs?rev=1ca03717ab074da605ace9ad75247dfa8fb03f86#1ca03717ab074da605ace9ad75247dfa8fb03f86" dependencies = [ "derive_more", "displaydoc", @@ -1046,8 +1023,7 @@ dependencies = [ [[package]] name = "ibc-core-router" version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "328e6db6d3aa7126278c46c3dff779aa961952a63d031d3ddf4c202f4a3faad4" +source = "git+https://github.com/cosmos/ibc-rs?rev=1ca03717ab074da605ace9ad75247dfa8fb03f86#1ca03717ab074da605ace9ad75247dfa8fb03f86" dependencies = [ "derive_more", "displaydoc", @@ -1061,8 +1037,7 @@ dependencies = [ [[package]] name = "ibc-core-router-types" version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4175b57087b28759364572683b335ec4fe63a6f938f1a5d0c383a6297a032155" +source = "git+https://github.com/cosmos/ibc-rs?rev=1ca03717ab074da605ace9ad75247dfa8fb03f86#1ca03717ab074da605ace9ad75247dfa8fb03f86" dependencies = [ "derive_more", "displaydoc", @@ -1078,8 +1053,7 @@ dependencies = [ [[package]] name = "ibc-derive" version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d961d2194fd5229961835d2eb78091906ef8afbaaa55bce7ad41bf3ead8aa9" +source = "git+https://github.com/cosmos/ibc-rs?rev=1ca03717ab074da605ace9ad75247dfa8fb03f86#1ca03717ab074da605ace9ad75247dfa8fb03f86" dependencies = [ "proc-macro2", "quote", @@ -1089,8 +1063,7 @@ dependencies = [ [[package]] name = "ibc-primitives" version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b3340c4908f1a1a36863270ac976e0295fbd1911cbc4609ab406967fd8ccc04" +source = "git+https://github.com/cosmos/ibc-rs?rev=1ca03717ab074da605ace9ad75247dfa8fb03f86#1ca03717ab074da605ace9ad75247dfa8fb03f86" dependencies = [ "derive_more", "displaydoc", @@ -1104,9 +1077,9 @@ dependencies = [ [[package]] name = "ibc-proto" -version = "0.44.0" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66080040d5a4800d52966d55b055400f86b79c34b854b935bef03c87aacda62a" +checksum = "7002e679ad26dc29bd27dfa490bb689d121d03c1512bed9f646f75028165644d" dependencies = [ "base64 0.22.1", "bytes", @@ -1166,9 +1139,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "k256" -version = "0.13.1" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" +checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" dependencies = [ "cfg-if", "ecdsa", @@ -1399,9 +1372,9 @@ dependencies = [ [[package]] name = "serde-json-wasm" -version = "0.5.2" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e9213a07d53faa0b8dd81e767a54a8188a242fdb9be99ab75ec576a774bfdd7" +checksum = "f05da0d153dd4595bdffd5099dc0e9ce425b205ee648eb93437ff7302af8c9a5" dependencies = [ "serde", ] diff --git a/Cargo.toml b/Cargo.toml index 0690ef2..ac5cecd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,29 +28,29 @@ rpath = false overflow-checks = true [workspace.dependencies] -cosmwasm-schema = "1.5.5" -cosmwasm-std = { version = "1.5.5", features = [ +cosmwasm-schema = "2.0" +cosmwasm-std = { version = "2.0", features = [ # Enable this if you only deploy to chains that have CosmWasm 1.4 or higher - "cosmwasm_1_4", + "cosmwasm_2_0", "stargate", ] } -cw-storage-plus = "1.2.0" -cw2 = "1.1.2" -cw20 = "1.1.2" -cw20-ics20 = "1.1.2" +cw-storage-plus = "2.0" +cw2 = "2.0" +cw20 = "2.0" schemars = "0.8.16" serde = { version = "1.0.197", default-features = false, features = ["derive"] } thiserror = { version = "1.0.58" } -cw-ownable = "0.5.1" -ibc-core-host = { version = "0.53.0", default-features = false, features = ["schema"] } -ibc-client-cw = { version = "0.53.0", default-features = false } -ibc-client-tendermint = { version = "0.53.0", default-features = false, features = ["schema"] } +# TODO: Remove this once cw-ownable is published with cw-plus-plus +cw-ownable = { git = "https://github.com/CyberHoward/cw-plus-plus", branch = "bump/cosmwasm-2.0" } +ibc-core-host = { git = "https://github.com/cosmos/ibc-rs", rev = "1ca03717ab074da605ace9ad75247dfa8fb03f86", default-features = false, features = ["schema"] } +ibc-client-cw = { git = "https://github.com/cosmos/ibc-rs", rev = "1ca03717ab074da605ace9ad75247dfa8fb03f86", default-features = false } +ibc-client-tendermint = { git = "https://github.com/cosmos/ibc-rs", rev = "1ca03717ab074da605ace9ad75247dfa8fb03f86", default-features = false, features = ["schema"] } cw-ibc-lite-shared = { version = "0.1.0", path = "./packages/shared/" } cw-ibc-lite-derive = { version = "0.1.0", path = "./packages/derive/" } cw-ibc-lite-ics02-client = { version = "0.1.0", path = "./contracts/ics02-client/", default-features = false } cw-ibc-lite-ics26-router = { version = "0.1.0", path = "./contracts/ics26-router/", default-features = false } sha2 = "0.10.8" -ibc-proto = { version = "0.44.0", default-features = false } +ibc-proto = { version = "0.45.0", default-features = false } derive_more = { version = "0.99.17", default-features = false, features = [ "from", "into", "display", "try_into" ] } proc-macro2 = "1.0" quote = "1.0" diff --git a/contracts/ics02-client/src/helpers.rs b/contracts/ics02-client/src/helpers.rs index a0dcc1d..b2096e4 100644 --- a/contracts/ics02-client/src/helpers.rs +++ b/contracts/ics02-client/src/helpers.rs @@ -145,8 +145,12 @@ impl Ics02ClientCode { let creator_cannonical = api.addr_canonicalize(env.contract.address.as_str())?; let contract_addr = api.addr_humanize( - &instantiate2_address(&code_info.checksum, &creator_cannonical, salt.as_bytes()) - .map_err(|e| StdError::generic_err(e.to_string()))?, + &instantiate2_address( + code_info.checksum.as_slice(), + &creator_cannonical, + salt.as_bytes(), + ) + .map_err(|e| StdError::generic_err(e.to_string()))?, )?; let instantiate_msg = WasmMsg::Instantiate2 { diff --git a/contracts/ics20-transfer/src/contract.rs b/contracts/ics20-transfer/src/contract.rs index 5c12bd7..30bd90d 100644 --- a/contracts/ics20-transfer/src/contract.rs +++ b/contracts/ics20-transfer/src/contract.rs @@ -58,7 +58,7 @@ pub fn execute( pub fn reply(deps: DepsMut, env: Env, msg: Reply) -> Result { match msg.id { keys::reply::ON_RECV_PACKET_CW20_TRANSFER => { - reply::on_recv_packet_cw20_transfer(deps, env, msg.result) + reply::on_recv_packet_cw20_transfer(deps, env, msg.result, msg.payload) } _ => Err(ContractError::UnknownReplyId(msg.id)), } @@ -145,7 +145,7 @@ mod execute { }; let ics26_msg = ics26_contract.call(send_packet_msg)?; - // TODO: Add events + // TODO: Add events, maybe Ok(Response::new().add_message(ics26_msg)) } @@ -190,7 +190,7 @@ mod reply { use super::{ContractError, DepsMut, Env, Response}; - use cosmwasm_std::SubMsgResult; + use cosmwasm_std::{Binary, SubMsgResult}; use cw_ibc_lite_shared::types::transfer::packet::Ics20Ack; /// Handles the reply to @@ -201,13 +201,14 @@ mod reply { deps: DepsMut, _env: Env, result: SubMsgResult, + payload: Binary, ) -> Result { match result { SubMsgResult::Ok(_) => { unreachable!("unexpected response on `SubMsg::reply_on_err`") } SubMsgResult::Err(err) => { - let reply_args = state::helpers::load_recv_packet_reply_args(deps.storage)?; + let reply_args: state::RecvPacketReplyPayload = cosmwasm_std::from_json(payload)?; // undo the escrow reduction ESCROW.update( deps.storage, diff --git a/contracts/ics20-transfer/src/ibc/relay.rs b/contracts/ics20-transfer/src/ibc/relay.rs index 0ce0b33..eef1688 100644 --- a/contracts/ics20-transfer/src/ibc/relay.rs +++ b/contracts/ics20-transfer/src/ibc/relay.rs @@ -30,7 +30,7 @@ pub fn on_send_packet( ) -> Result { // NOTE: We must ensure that the sender is the contract itself because the tokens were received // by the contract at an earlier point, on [`crate::types::msg::ExecuteMsg::Receive`]. - if sender != env.contract.address { + if sender != env.contract.address.as_str() { return Err(ContractError::Unauthorized); } if version != keys::ICS20_VERSION { @@ -96,15 +96,6 @@ pub fn on_recv_packet( }, )?; - // TODO: This can be removed in CosmWasm v2 since it introduces the ability to add custom data - // to reply. - let reply_args = state::RecvPacketReplyArgs { - channel_id: packet.destination_channel.into(), - denom: base_denom.to_string(), - amount: ics20_packet.amount, - }; - state::helpers::store_recv_packet_reply_args(deps.storage, &reply_args)?; - // TODO: move to helper let cw20_msg: CosmosMsg = WasmMsg::Execute { contract_addr: base_denom.to_string(), @@ -115,7 +106,13 @@ pub fn on_recv_packet( funds: vec![], } .into(); - let cw20_submsg = SubMsg::reply_on_error(cw20_msg, keys::reply::ON_RECV_PACKET_CW20_TRANSFER); + let reply_args = state::RecvPacketReplyPayload { + channel_id: packet.destination_channel.into(), + denom: base_denom.to_string(), + amount: ics20_packet.amount, + }; + let cw20_submsg = SubMsg::reply_on_error(cw20_msg, keys::reply::ON_RECV_PACKET_CW20_TRANSFER) + .with_payload(cosmwasm_std::to_json_binary(&reply_args)?); // NOTE: The success acknowledgement will be overwritten by the SubMsg reply in case of error. Ok(Response::new() diff --git a/contracts/ics20-transfer/src/types/state.rs b/contracts/ics20-transfer/src/types/state.rs index 1654e5d..830eb69 100644 --- a/contracts/ics20-transfer/src/types/state.rs +++ b/contracts/ics20-transfer/src/types/state.rs @@ -1,18 +1,15 @@ //! This module defines the state storage of the Contract. use cosmwasm_std::Uint128; -use cw_storage_plus::{Item, Map}; +use cw_storage_plus::Map; /// The item that stores the escrowed tokens per denom. /// It maps (`channel_id`, `denom`) to the escrowed amount. pub const ESCROW: Map<(&str, &str), Uint128> = Map::new("escrow"); -/// Used to pass state to the reply handler in `on_recv_packet`. -const RECV_PACKET_REPLY_ARGS: Item = Item::new("recv_packet_reply_args"); - /// Used to pass state to the reply handler in `on_recv_packet`. #[cosmwasm_schema::cw_serde] -pub struct RecvPacketReplyArgs { +pub struct RecvPacketReplyPayload { /// The channel identifier. pub channel_id: String, /// The denomination of the transferred tokens. @@ -20,36 +17,3 @@ pub struct RecvPacketReplyArgs { /// The amount of tokens transferred. pub amount: Uint128, } - -/// Contains state storage helpers. -pub mod helpers { - use cw_ibc_lite_shared::types::{error::ContractError, transfer::error::TransferError}; - - /// Stores the `RecvPacketReplyArgs` in the contract state. - /// - /// # Errors - /// Returns an error if the storage operation fails or there is an existing value. - pub fn store_recv_packet_reply_args( - storage: &mut dyn cosmwasm_std::Storage, - args: &super::RecvPacketReplyArgs, - ) -> Result<(), ContractError> { - if super::RECV_PACKET_REPLY_ARGS.exists(storage) { - return Err(TransferError::Reentrancy.into()); - } - - super::RECV_PACKET_REPLY_ARGS.save(storage, args)?; - Ok(()) - } - - /// Loads and removes the `RecvPacketReplyArgs` from the contract state. - /// - /// # Errors - /// Returns an error if the load operation fails. - pub fn load_recv_packet_reply_args( - storage: &mut dyn cosmwasm_std::Storage, - ) -> Result { - let args = super::RECV_PACKET_REPLY_ARGS.load(storage)?; - super::RECV_PACKET_REPLY_ARGS.remove(storage); - Ok(args) - } -} diff --git a/contracts/ics26-router/src/contract.rs b/contracts/ics26-router/src/contract.rs index 92b367f..b768d0e 100644 --- a/contracts/ics26-router/src/contract.rs +++ b/contracts/ics26-router/src/contract.rs @@ -75,7 +75,9 @@ pub fn execute( pub fn reply(deps: DepsMut, env: Env, msg: Reply) -> Result { match msg.id { // TODO: Ensure that events are emitted for all the replies. - keys::reply::ON_RECV_PACKET => reply::write_acknowledgement(deps, env, msg.result), + keys::reply::ON_RECV_PACKET => { + reply::write_acknowledgement(deps, env, msg.result, msg.payload) + } _ => Err(ContractError::UnknownReplyId(msg.id)), } } @@ -237,9 +239,9 @@ mod execute { .verify_membership(verify_membership_msg)?; state::helpers::set_packet_receipt(deps.storage, &packet)?; - state::helpers::save_packet_temp_store(deps.storage, &packet)?; let event = events::recv_packet::success(&packet); + let reply_payload = cosmwasm_std::to_json_binary(&packet)?; // NOTE: We must retreive a reply from the IBC app to set the acknowledgement. let callback_msg = apps::callbacks::IbcAppCallbackMsg::OnRecvPacket { packet, @@ -248,7 +250,8 @@ mod execute { let recv_packet_callback = SubMsg::reply_on_success( ibc_app_contract.call(callback_msg)?, keys::reply::ON_RECV_PACKET, - ); + ) + .with_payload(reply_payload); // TODO: Ensure event emission is reverted if the callback fails. Ok(Response::new() @@ -371,7 +374,7 @@ mod execute { } mod reply { - use cosmwasm_std::SubMsgResult; + use cosmwasm_std::{Binary, SubMsgResult}; use cw_ibc_lite_shared::types::ibc; use crate::types::events; @@ -386,14 +389,16 @@ mod reply { deps: DepsMut, _env: Env, result: SubMsgResult, + payload: Binary, ) -> Result { match result { SubMsgResult::Ok(resp) => { + #[allow(warnings)] // TODO: remove this once we have working tests and then fix it. let ack: ibc::Acknowledgement = resp .data .ok_or(ContractError::RecvPacketCallbackNoResponse)? .try_into()?; - let packet = state::helpers::remove_packet_temp_store(deps.storage)?; + let packet: ibc::Packet = cosmwasm_std::from_json(payload)?; state::helpers::commit_packet_ack(deps.storage, &packet, &ack)?; Ok( diff --git a/contracts/ics26-router/src/helpers.rs b/contracts/ics26-router/src/helpers.rs index 45b7188..ae1c15c 100644 --- a/contracts/ics26-router/src/helpers.rs +++ b/contracts/ics26-router/src/helpers.rs @@ -144,8 +144,12 @@ impl IbcLiteRouterCode { let creator_cannonical = api.addr_canonicalize(env.contract.address.as_str())?; let contract_addr = api.addr_humanize( - &instantiate2_address(&code_info.checksum, &creator_cannonical, salt.as_bytes()) - .map_err(|e| StdError::generic_err(e.to_string()))?, + &instantiate2_address( + code_info.checksum.as_slice(), + &creator_cannonical, + salt.as_bytes(), + ) + .map_err(|e| StdError::generic_err(e.to_string()))?, )?; let instantiate_msg = WasmMsg::Instantiate2 { diff --git a/contracts/ics26-router/src/types/state.rs b/contracts/ics26-router/src/types/state.rs index a57cb41..f8a898f 100644 --- a/contracts/ics26-router/src/types/state.rs +++ b/contracts/ics26-router/src/types/state.rs @@ -1,7 +1,6 @@ //! This module defines the state storage of the Contract. use cosmwasm_std::Addr; -use cw_ibc_lite_shared::types::ibc; use cw_storage_plus::{Item, Map}; @@ -17,10 +16,6 @@ pub const IBC_APPS: Map<&str, Addr> = Map::new("ibc_apps"); /// The item for storing the ics02-client router contract address. pub const ICS02_CLIENT_ADDRESS: Item = Item::new("ics02_client_address"); -/// The item for storing [`ibc::Packet`] to the temporary store for replies. -// TODO: remove this in CosmWasm v2 since it introduces the ability to add custom data to reply. -pub const PACKET_TEMP_STORE: Item = Item::new("recv_packet_temp_store"); - /// Contains state storage helpers. pub mod helpers { use cosmwasm_std::{StdResult, Storage}; @@ -150,33 +145,4 @@ pub mod helpers { item.save(storage, &ack.to_commitment_bytes()); Ok(()) } - - /// Saves the packet to [`super::PACKET_TEMP_STORE`]. - /// - /// # Errors - /// Returns an error if the packet has already been committed. - pub fn save_packet_temp_store( - storage: &mut dyn Storage, - packet: &ibc::Packet, - ) -> Result<(), ContractError> { - if super::PACKET_TEMP_STORE.exists(storage) { - return Err(ContractError::packet_already_commited( - super::PACKET_TEMP_STORE.as_slice().to_vec(), - )); - } - - Ok(super::PACKET_TEMP_STORE.save(storage, packet)?) - } - - /// Loads and removes the packet from the temporary store for the reply to - /// - /// # Errors - /// Returns an error if the packet identifier cannot be loaded. - pub fn remove_packet_temp_store( - storage: &mut dyn Storage, - ) -> Result { - let packet = super::PACKET_TEMP_STORE.load(storage)?; - super::PACKET_TEMP_STORE.remove(storage); - Ok(packet) - } } diff --git a/e2e/interchaintestv8/chainconfig/chain_config.go b/e2e/interchaintestv8/chainconfig/chain_config.go index 0aaf9d3..002a9e6 100644 --- a/e2e/interchaintestv8/chainconfig/chain_config.go +++ b/e2e/interchaintestv8/chainconfig/chain_config.go @@ -15,7 +15,7 @@ var DefaultChainSpecs = []*interchaintest.ChainSpec{ Images: []ibc.DockerImage{ { Repository: "cosmwasm/wasmd", // FOR LOCAL IMAGE USE: Docker Image Name - Version: "v0.50.0", // FOR LOCAL IMAGE USE: Docker Image Tag + Version: "v0.51.0", // FOR LOCAL IMAGE USE: Docker Image Tag UidGid: "1025:1025", }, }, @@ -39,7 +39,7 @@ var DefaultChainSpecs = []*interchaintest.ChainSpec{ Images: []ibc.DockerImage{ { Repository: "cosmwasm/wasmd", // FOR LOCAL IMAGE USE: Docker Image Name - Version: "v0.50.0", // FOR LOCAL IMAGE USE: Docker Image Tag + Version: "v0.51.0", // FOR LOCAL IMAGE USE: Docker Image Tag UidGid: "1025:1025", }, }, diff --git a/e2e/interchaintestv8/go.mod b/e2e/interchaintestv8/go.mod index 2092491..22d23fa 100644 --- a/e2e/interchaintestv8/go.mod +++ b/e2e/interchaintestv8/go.mod @@ -11,10 +11,10 @@ require ( cosmossdk.io/math v1.3.0 cosmossdk.io/x/tx v0.13.3 cosmossdk.io/x/upgrade v0.1.2 - github.com/CosmWasm/wasmd v0.50.0 + github.com/CosmWasm/wasmd v0.51.0 github.com/cosmos/cosmos-sdk v0.50.6 github.com/cosmos/gogoproto v1.4.12 - github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.1.1-0.20231213092650-57fcdb9a9a9d + github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.1.1-0.20240429153234-e1e6da7e4ead github.com/cosmos/ibc-go/v8 v8.3.0 github.com/cosmos/ics23/go v0.10.0 github.com/docker/docker v24.0.9+incompatible @@ -46,7 +46,7 @@ require ( github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect github.com/ChainSafe/go-schnorrkel/1 v0.0.0-00010101000000-000000000000 // indirect github.com/ComposableFi/go-subkey/v2 v2.0.0-tm03420 // indirect - github.com/CosmWasm/wasmvm v1.5.0 // indirect + github.com/CosmWasm/wasmvm/v2 v2.0.1 // indirect github.com/DataDog/datadog-go v3.2.0+incompatible // indirect github.com/DataDog/zstd v1.5.5 // indirect github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e // indirect diff --git a/e2e/interchaintestv8/go.sum b/e2e/interchaintestv8/go.sum index 53f1ffb..4af905f 100644 --- a/e2e/interchaintestv8/go.sum +++ b/e2e/interchaintestv8/go.sum @@ -231,10 +231,10 @@ github.com/ChainSafe/go-schnorrkel v1.0.0 h1:3aDA67lAykLaG1y3AOjs88dMxC88PgUuHRr github.com/ChainSafe/go-schnorrkel v1.0.0/go.mod h1:dpzHYVxLZcp8pjlV+O+UR8K0Hp/z7vcchBSbMBEhCw4= github.com/ComposableFi/go-subkey/v2 v2.0.0-tm03420 h1:oknQF/iIhf5lVjbwjsVDzDByupRhga8nhA3NAmwyHDA= github.com/ComposableFi/go-subkey/v2 v2.0.0-tm03420/go.mod h1:KYkiMX5AbOlXXYfxkrYPrRPV6EbVUALTQh5ptUOJzu8= -github.com/CosmWasm/wasmd v0.50.0 h1:NVaGqCSTRfb9UTDHJwT6nQIWcb6VjlQl88iI+u1+qjE= -github.com/CosmWasm/wasmd v0.50.0/go.mod h1:UjmShW4l9YxaMytwJZ7IB7MWzHiynSZP3DdWrG0FRtk= -github.com/CosmWasm/wasmvm v1.5.0 h1:3hKeT9SfwfLhxTGKH3vXaKFzBz1yuvP8SlfwfQXbQfw= -github.com/CosmWasm/wasmvm v1.5.0/go.mod h1:fXB+m2gyh4v9839zlIXdMZGeLAxqUdYdFQqYsTha2hc= +github.com/CosmWasm/wasmd v0.51.0 h1:3A2o20RrdF7P1D3Xb+R7A/pHbbHWsYCDXrHLa7S0SC8= +github.com/CosmWasm/wasmd v0.51.0/go.mod h1:7TSaj5HoolghujuVWeExqmcUKgpcYWEySGLSODbnnwY= +github.com/CosmWasm/wasmvm/v2 v2.0.1 h1:0YCQ7MKGNri7NFeRp75erPJXrqyCtH4gdc9jMstyMzk= +github.com/CosmWasm/wasmvm/v2 v2.0.1/go.mod h1:su9lg5qLr7adV95eOfzjZWkGiky8WNaNIHDr7Fpu7Ck= github.com/DataDog/datadog-go v3.2.0+incompatible h1:qSG2N4FghB1He/r2mFrWKCaL7dXCilEuNEeAn20fdD4= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= @@ -389,8 +389,8 @@ github.com/cosmos/iavl v1.1.2 h1:zL9FK7C4L/P4IF1Dm5fIwz0WXCnn7Bp1M2FxH0ayM7Y= github.com/cosmos/iavl v1.1.2/go.mod h1:jLeUvm6bGT1YutCaL2fIar/8vGUE8cPZvh/gXEWDaDM= github.com/cosmos/ibc-go/modules/capability v1.0.0 h1:r/l++byFtn7jHYa09zlAdSeevo8ci1mVZNO9+V0xsLE= github.com/cosmos/ibc-go/modules/capability v1.0.0/go.mod h1:D81ZxzjZAe0ZO5ambnvn1qedsFQ8lOwtqicG6liLBco= -github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.1.1-0.20231213092650-57fcdb9a9a9d h1:F4mhR61RZU4KJ38n5CeZrnNINU/KxMfP1sKfk5fTlHA= -github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.1.1-0.20231213092650-57fcdb9a9a9d/go.mod h1:u2FXNcSxzzn5IwjWBA51HKMwiYMRK6/G35VmSJULhP0= +github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.1.1-0.20240429153234-e1e6da7e4ead h1:hZ5M6lZPDhIpB9eMOj0hT7+gzORKkqOkMr4+vGxJfe4= +github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.1.1-0.20240429153234-e1e6da7e4ead/go.mod h1:AJeroAXnPKeFpD1AfEfjYBHGEWt5gBfzUjgs4SYn2ZY= github.com/cosmos/ibc-go/v8 v8.3.0 h1:fdW2S7NjZYFhSwmCaFjjyDv80kI1ePOJDQmco4qrnD0= github.com/cosmos/ibc-go/v8 v8.3.0/go.mod h1:izwHZvn9lKrBn8xWj0aXWut6HKcwHMPD3uyuvOJoPSA= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= diff --git a/packages/shared/src/types/clients/helpers.rs b/packages/shared/src/types/clients/helpers.rs index 25a37f6..373edcd 100644 --- a/packages/shared/src/types/clients/helpers.rs +++ b/packages/shared/src/types/clients/helpers.rs @@ -149,8 +149,12 @@ impl LightClientCode { let creator_cannonical = api.addr_canonicalize(env.contract.address.as_str())?; let contract_addr = api.addr_humanize( - &instantiate2_address(&code_info.checksum, &creator_cannonical, salt.as_bytes()) - .map_err(|e| StdError::generic_err(e.to_string()))?, + &instantiate2_address( + code_info.checksum.as_slice(), + &creator_cannonical, + salt.as_bytes(), + ) + .map_err(|e| StdError::generic_err(e.to_string()))?, )?; let instantiate_msg = WasmMsg::Instantiate2 { diff --git a/packages/shared/src/types/ibc.rs b/packages/shared/src/types/ibc.rs index 83cf104..c2bb396 100644 --- a/packages/shared/src/types/ibc.rs +++ b/packages/shared/src/types/ibc.rs @@ -106,7 +106,7 @@ impl TryFrom for Acknowledgement { type Error = ContractError; fn try_from(data: cosmwasm_std::Binary) -> Result { - data.0.try_into() + Vec::from(data).try_into() } }