diff --git a/Cargo.lock b/Cargo.lock index ad275cd..155c213 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -242,9 +242,9 @@ dependencies = [ [[package]] name = "cw-multi-test" -version = "0.16.2" +version = "0.16.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2eb84554bbfa6b66736abcd6a9bfdf237ee0ecb83910f746dff7f799093c80a" +checksum = "2a18afd2e201221c6d72a57f0886ef2a22151bbc9e6db7af276fde8a91081042" dependencies = [ "anyhow", "cosmwasm-std", @@ -370,7 +370,9 @@ dependencies = [ [[package]] name = "cw20-ics20-msg" -version = "0.0.1" +version = "0.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e04064b936344caa428fa764b4f92859c9619cc0cfc6b3d155d26f8f0a45b13f" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -508,9 +510,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" dependencies = [ "cfg-if", "libc", @@ -581,9 +583,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.140" +version = "0.2.141" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" +checksum = "3304a64d199bb964be99741b7a14d26972741915b3649639149b2479bb46f4b5" [[package]] name = "once_cell" @@ -626,9 +628,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.54" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e472a104799c74b514a57226160104aa483546de37e839ec50e3c2e41dd87534" +checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" dependencies = [ "unicode-ident", ] @@ -764,31 +766,31 @@ checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" [[package]] name = "serde" -version = "1.0.159" +version = "1.0.160" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c04e8343c3daeec41f58990b9d77068df31209f2af111e059e9fe9646693065" +checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c" dependencies = [ "serde_derive", ] [[package]] name = "serde-json-wasm" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15bee9b04dd165c3f4e142628982ddde884c2022a89e8ddf99c4829bf2c3a58" +checksum = "16a62a1fad1e1828b24acac8f2b468971dade7b8c3c2e672bcadefefb1f8c137" dependencies = [ "serde", ] [[package]] name = "serde_derive" -version = "1.0.159" +version = "1.0.160" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c614d17805b093df4b147b51339e7e44bf05ef59fba1e45d83500bcfb4d8585" +checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df" dependencies = [ "proc-macro2", "quote", - "syn 2.0.11", + "syn 2.0.15", ] [[package]] @@ -804,9 +806,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.95" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d721eca97ac802aa7777b701877c8004d950fc142651367300d21c1cc0194744" +checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" dependencies = [ "itoa", "ryu", @@ -882,9 +884,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.11" +version = "2.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21e3787bb71465627110e7d87ed4faaa36c1f61042ee67badb9e2ef173accc40" +checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" dependencies = [ "proc-macro2", "quote", @@ -908,7 +910,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.11", + "syn 2.0.15", ] [[package]] diff --git a/contracts/cw-ics20-latest/Cargo.toml b/contracts/cw-ics20-latest/Cargo.toml index be62e24..b3c697a 100644 --- a/contracts/cw-ics20-latest/Cargo.toml +++ b/contracts/cw-ics20-latest/Cargo.toml @@ -22,7 +22,7 @@ cosmwasm-schema = "1.1.9" cw-utils = "0.16.0" cw2 = "1.0.1" cw20 = "1.0.1" -cw20-ics20-msg = {path = "../../packages/cw20-ics20-msg"} +cw20-ics20-msg = "0.0.2" oraiswap = "1.0.0" cosmwasm-std = { version = "1.1.0", features = ["stargate"] } cw-storage-plus = "1.0.1" diff --git a/packages/cw20-ics20-msg/Cargo.toml b/packages/cw20-ics20-msg/Cargo.toml index 5de795e..e755457 100644 --- a/packages/cw20-ics20-msg/Cargo.toml +++ b/packages/cw20-ics20-msg/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw20-ics20-msg" -version = "0.0.1" +version = "0.0.2" authors = ["Oraichain Labs"] edition = "2021" description = "Definition and types for the cw20-ics20-msg interface" diff --git a/packages/cw20-ics20-msg/README.md b/packages/cw20-ics20-msg/README.md index b80c599..8fc0447 100644 --- a/packages/cw20-ics20-msg/README.md +++ b/packages/cw20-ics20-msg/README.md @@ -1,58 +1 @@ -# CW2 Spec: Contract Info - -Most of the CW* specs are focused on the *public interfaces* -of the contract. The APIs used for `ExecuteMsg` or `QueryMsg`. -However, when we wish to migrate or inspect smart contract info, -we need some form of smart contract information embedded on state. - -This is where CW2 comes in. It specifies a special Item to -be stored on disk by all contracts on `instantiate`. - -`ContractInfo` must be stored under the `"contract_info"` key which translates -to `"636F6E74726163745F696E666F"` in hex format. -Since the state is well defined, we do not need to support any "smart queries". -We do provide a helper to construct a "raw query" to read the ContractInfo -of any CW2-compliant contract. - -You can query using: -```shell -wasmd query wasm contract-state raw [contract_addr] 636F6E74726163745F696E666F --node $RPC -``` - -When the `migrate` function is called, then the new contract -can read that data andsee if this is an expected contract we can -migrate from. And also contain extra version information if we -support multiple migrate paths. - -### Data structures - -**Required** - -All CW2-compliant contracts must store the following data: - -* key: `contract_info` -* data: Json-serialized `ContractVersion` - -```rust -pub struct ContractVersion { - /// contract is a globally unique identifier for the contract. - /// it should build off standard namespacing for whichever language it is in, - /// and prefix it with the registry we use. - /// For rust we prefix with `crates.io:`, to give us eg. `crates.io:cw20-base` - pub contract: String, - /// version is any string that this implementation knows. It may be simple counter "1", "2". - /// or semantic version on release tags "v0.7.0", or some custom feature flag list. - /// the only code that needs to understand the version parsing is code that knows how to - /// migrate from the given contract (and is tied to it's implementation somehow) - pub version: String, -} -``` - -Thus, an serialized example may looks like: - -```json -{ - "contract": "crates.io:cw20-base", - "version": "v0.1.0" -} -``` +# Cw20-Ics20-Msg diff --git a/packages/cw20-ics20-msg/src/ack_fail.rs b/packages/cw20-ics20-msg/src/ack_fail.rs deleted file mode 100644 index 961050e..0000000 --- a/packages/cw20-ics20-msg/src/ack_fail.rs +++ /dev/null @@ -1,39 +0,0 @@ -use cosmwasm_schema::cw_serde; -use cosmwasm_std::{to_binary, Binary, CosmosMsg, StdResult, WasmMsg}; - -use crate::amount::Amount; - -/// Cw20ReceiveMsg should be de/serialized under `IbcWasmReceive()` variant in a ExecuteMsg -#[cw_serde] - -pub struct TransferBackFailAckMsg { - pub original_sender: String, - pub from_decimals: u8, - pub amount: Amount, -} - -impl TransferBackFailAckMsg { - /// serializes the message - pub fn into_binary(self) -> StdResult { - let msg = ReceiverExecuteMsg::IbcWasmTransferAckFailed(self); - to_binary(&msg) - } - - /// creates a cosmos_msg sending this struct to the named contract - pub fn into_cosmos_msg>(self, contract_addr: T) -> StdResult { - let msg = self.into_binary()?; - let execute = WasmMsg::Execute { - contract_addr: contract_addr.into(), - msg, - funds: vec![], - }; - Ok(execute.into()) - } -} - -// This is just a helper to properly serialize the above message -#[cw_serde] - -enum ReceiverExecuteMsg { - IbcWasmTransferAckFailed(TransferBackFailAckMsg), -} diff --git a/packages/cw20-ics20-msg/src/lib.rs b/packages/cw20-ics20-msg/src/lib.rs index 19e8c0a..babc670 100644 --- a/packages/cw20-ics20-msg/src/lib.rs +++ b/packages/cw20-ics20-msg/src/lib.rs @@ -2,6 +2,5 @@ Shared msgs for the cw20-ics20 and other contracts that interact with it */ -pub mod ack_fail; pub mod amount; pub mod receiver;