From 1fadd3b4869b7cdcbc54128d34ad86b2fdfed0b2 Mon Sep 17 00:00:00 2001 From: mr-t Date: Tue, 2 Jan 2024 15:24:25 +0100 Subject: [PATCH] rename cw721 -> cw-ics721 --- Cargo.lock | 157 +++++++++--------- Cargo.toml | 5 +- README.md | 2 +- contracts/sg-ics721/Cargo.toml | 4 +- .../src/testing/integration_tests.rs | 28 ++-- packages/ics721/Cargo.toml | 4 +- packages/ics721/src/execute.rs | 8 +- packages/ics721/src/helpers.rs | 2 +- .../ics721/src/testing/integration_tests.rs | 28 ++-- 9 files changed, 122 insertions(+), 116 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 51d2ea92..b32013ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -232,13 +232,13 @@ dependencies = [ ] [[package]] -name = "cw-incoming-proxy" -version = "0.0.1" -source = "git+https://github.com/arkprotocol/cw721-proxy.git?tag=v0.1.0#07eb53fa4d39a7ef4412ab3bb74b1052b4d376b8" +name = "cw-ics721-incoming-proxy" +version = "0.1.0" +source = "git+https://github.com/arkprotocol/cw-ics721-proxy.git?tag=v0.1.0#4d6e3b0e168305044db00176494a28b318ae8dfe" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-incoming-proxy-derive", + "cw-ics721-incoming-proxy-derive", "cw-paginate-storage", "cw-storage-plus 1.2.0", "ics721-types 0.1.0 (git+https://github.com/arkprotocol/ark-cw-ics721?branch=incoming_proxy)", @@ -248,17 +248,82 @@ dependencies = [ ] [[package]] -name = "cw-incoming-proxy-derive" -version = "0.0.1" -source = "git+https://github.com/arkprotocol/cw721-proxy.git?tag=v0.1.0#07eb53fa4d39a7ef4412ab3bb74b1052b4d376b8" +name = "cw-ics721-incoming-proxy-base" +version = "0.1.0" +source = "git+https://github.com/arkprotocol/cw-ics721-proxy.git?tag=v0.1.0#4d6e3b0e168305044db00176494a28b318ae8dfe" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw-ics721-incoming-proxy", + "cw-ics721-incoming-proxy-derive", + "cw-ics721-outgoing-proxy", + "cw-ics721-outgoing-proxy-derive", + "cw-storage-plus 1.2.0", + "cw2 1.1.2", + "cw721 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ics721-types 0.1.0 (git+https://github.com/arkprotocol/ark-cw-ics721?branch=incoming_proxy)", + "serde", + "thiserror", +] + +[[package]] +name = "cw-ics721-incoming-proxy-derive" +version = "0.1.0" +source = "git+https://github.com/arkprotocol/cw-ics721-proxy.git?tag=v0.1.0#4d6e3b0e168305044db00176494a28b318ae8dfe" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "ics721-types 0.1.0 (git+https://github.com/arkprotocol/ark-cw-ics721?branch=incoming_proxy)", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "cw-ics721-outgoing-proxy" +version = "0.1.0" +source = "git+https://github.com/arkprotocol/cw-ics721-proxy.git?tag=v0.1.0#4d6e3b0e168305044db00176494a28b318ae8dfe" dependencies = [ + "cosmwasm-schema", "cosmwasm-std", + "cw-ics721-outgoing-proxy-derive", + "cw-storage-plus 1.2.0", + "cw721 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cw721-base 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", "ics721-types 0.1.0 (git+https://github.com/arkprotocol/ark-cw-ics721?branch=incoming_proxy)", + "thiserror", +] + +[[package]] +name = "cw-ics721-outgoing-proxy-derive" +version = "0.1.0" +source = "git+https://github.com/arkprotocol/cw-ics721-proxy.git?tag=v0.1.0#4d6e3b0e168305044db00176494a28b318ae8dfe" +dependencies = [ + "cw721 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2", "quote", "syn 1.0.109", ] +[[package]] +name = "cw-ics721-outgoing-proxy-rate-limit" +version = "0.1.0" +source = "git+https://github.com/arkprotocol/cw-ics721-proxy.git?tag=v0.1.0#4d6e3b0e168305044db00176494a28b318ae8dfe" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw-ics721-outgoing-proxy", + "cw-ics721-outgoing-proxy-derive", + "cw-rate-limiter", + "cw-storage-plus 1.2.0", + "cw2 1.1.2", + "cw721 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cw721-base 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ics721-types 0.1.0 (git+https://github.com/arkprotocol/ark-cw-ics721?branch=incoming_proxy)", + "serde", + "thiserror", +] + [[package]] name = "cw-multi-test" version = "0.20.0" @@ -329,8 +394,8 @@ dependencies = [ [[package]] name = "cw-rate-limiter" -version = "0.0.1" -source = "git+https://github.com/arkprotocol/cw721-proxy.git?tag=v0.1.0#07eb53fa4d39a7ef4412ab3bb74b1052b4d376b8" +version = "0.1.0" +source = "git+https://github.com/arkprotocol/cw-ics721-proxy.git?tag=v0.1.0#4d6e3b0e168305044db00176494a28b318ae8dfe" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -512,70 +577,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "cw721-incoming-proxy" -version = "0.1.0" -source = "git+https://github.com/arkprotocol/cw721-proxy.git?tag=v0.1.0#07eb53fa4d39a7ef4412ab3bb74b1052b4d376b8" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-incoming-proxy", - "cw-incoming-proxy-derive", - "cw-storage-plus 1.2.0", - "cw2 1.1.2", - "cw721 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cw721-outgoing-proxy", - "cw721-outgoing-proxy-derive", - "ics721-types 0.1.0 (git+https://github.com/arkprotocol/ark-cw-ics721?branch=incoming_proxy)", - "serde", - "thiserror", -] - -[[package]] -name = "cw721-outgoing-proxy" -version = "0.0.1" -source = "git+https://github.com/arkprotocol/cw721-proxy.git?tag=v0.1.0#07eb53fa4d39a7ef4412ab3bb74b1052b4d376b8" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-storage-plus 1.2.0", - "cw721 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cw721-base 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cw721-outgoing-proxy-derive", - "ics721-types 0.1.0 (git+https://github.com/arkprotocol/ark-cw-ics721?branch=incoming_proxy)", - "thiserror", -] - -[[package]] -name = "cw721-outgoing-proxy-derive" -version = "0.0.1" -source = "git+https://github.com/arkprotocol/cw721-proxy.git?tag=v0.1.0#07eb53fa4d39a7ef4412ab3bb74b1052b4d376b8" -dependencies = [ - "cw721 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "cw721-outgoing-proxy-rate-limit" -version = "0.1.0" -source = "git+https://github.com/arkprotocol/cw721-proxy.git?tag=v0.1.0#07eb53fa4d39a7ef4412ab3bb74b1052b4d376b8" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cw-rate-limiter", - "cw-storage-plus 1.2.0", - "cw2 1.1.2", - "cw721 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cw721-base 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cw721-outgoing-proxy", - "cw721-outgoing-proxy-derive", - "ics721-types 0.1.0 (git+https://github.com/arkprotocol/ark-cw-ics721?branch=incoming_proxy)", - "serde", - "thiserror", -] - [[package]] name = "cw721-tester" version = "0.1.0" @@ -781,6 +782,8 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-cii", + "cw-ics721-incoming-proxy-base", + "cw-ics721-outgoing-proxy-rate-limit", "cw-multi-test", "cw-ownable", "cw-paginate-storage", @@ -792,8 +795,6 @@ dependencies = [ "cw721 0.18.0 (git+https://github.com/CosmWasm/cw-nfts?branch=main)", "cw721-base 0.16.0", "cw721-base 0.18.0 (git+https://github.com/CosmWasm/cw-nfts?branch=main)", - "cw721-incoming-proxy", - "cw721-outgoing-proxy-rate-limit", "ics721-types 0.1.0", "serde", "sha2 0.10.8", @@ -840,7 +841,7 @@ dependencies = [ [[package]] name = "ics721-types" version = "0.1.0" -source = "git+https://github.com/arkprotocol/ark-cw-ics721?branch=incoming_proxy#3ec3ed5a233de9f2555f0b1b041b99c756c336f2" +source = "git+https://github.com/arkprotocol/ark-cw-ics721?branch=incoming_proxy#a2d4965572485c1085b4ece2cbb9d55a896b5b74" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -1108,14 +1109,14 @@ dependencies = [ "cosmwasm-schema", "cosmwasm-std", "cw-cii", + "cw-ics721-incoming-proxy-base", + "cw-ics721-outgoing-proxy-rate-limit", "cw-multi-test", "cw-pause-once", "cw-storage-plus 1.2.0", "cw2 1.1.2", "cw721 0.18.0 (git+https://github.com/CosmWasm/cw-nfts?branch=main)", "cw721-base 0.18.0 (git+https://github.com/CosmWasm/cw-nfts?branch=main)", - "cw721-incoming-proxy", - "cw721-outgoing-proxy-rate-limit", "ics721", "ics721-types 0.1.0", "sg-std", diff --git a/Cargo.toml b/Cargo.toml index 7715ff12..b4b09abd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,8 +20,9 @@ cw721 = { git = "https://github.com/CosmWasm/cw-nfts", branch = "main"} # TODO s cw721-016 = { version = "0.16.0", package = "cw721" } cw721-base = { git = "https://github.com/CosmWasm/cw-nfts", branch = "main"} # TODO switch to version 0.18.1/0.19.0, once released cw721-base-016 = { version = "0.16.0", package = "cw721-base" } -cw721-incoming-proxy = { git = "https://github.com/arkprotocol/cw721-proxy.git", tag = "v0.1.0" } -cw721-outgoing-proxy-rate-limit = { git = "https://github.com/arkprotocol/cw721-proxy.git", tag = "v0.1.0" } +cw-ics721-incoming-proxy = { git = "https://github.com/arkprotocol/cw-ics721-proxy.git", tag = "v0.1.0" } +cw-ics721-incoming-proxy-base = { git = "https://github.com/arkprotocol/cw-ics721-proxy.git", tag = "v0.1.0" } +cw-ics721-outgoing-proxy-rate-limit = { git = "https://github.com/arkprotocol/cw-ics721-proxy.git", tag = "v0.1.0" } cw-multi-test = { version = "^0.20", features = ["cosmwasm_1_2"] } cw-utils = "^1.0" sha2 = "^0.10" diff --git a/README.md b/README.md index b51ce829..d4725043 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ Pause functionality is designed to allow for quick pauses by a trusted group, wi After a pause, the ICS721 contract will remain paused until governance chooses to unpause it. During the unpause process governance may appoint a new subDAO or reappoint the existing one as pause manager. It is imagined that the admin of this contract will be a chain's community pool, and the pause manager will be a small, active subDAO. This process means that the subDAO may pause the contract in the event of a problem, but may not lock the contract, as in pausing the contract the subDAO burns its ability to do so again. -Filtering is enabled by an optional proxy that the ICS721 contract may be configured to use. If a proxy is configured, the ICS721 contract will only accept NFTs delivered by the proxy address. This proxy interface is very minimal and enables very flexible rate limiting and filtering. Currently, per-collection rate limiting is implemented. Users of this ICS721 contract are encouraged to implement their own filtering regimes and may add them to the [proxy repository](https://github.com/arkprotocol/cw721-proxy) so that others may use them. +Filtering is enabled by an optional proxy that the ICS721 contract may be configured to use. If a proxy is configured, the ICS721 contract will only accept NFTs delivered by the proxy address. This proxy interface is very minimal and enables very flexible rate limiting and filtering. Currently, per-collection rate limiting is implemented. Users of this ICS721 contract are encouraged to implement their own filtering regimes and may add them to the [proxy repository](https://github.com/arkprotocol/cw-ics721-proxy) so that others may use them. ## Failure handling errata diff --git a/contracts/sg-ics721/Cargo.toml b/contracts/sg-ics721/Cargo.toml index cf98d0fa..63ac889c 100644 --- a/contracts/sg-ics721/Cargo.toml +++ b/contracts/sg-ics721/Cargo.toml @@ -31,7 +31,7 @@ cw-multi-test = { workspace = true } cw-pause-once = { workspace = true } cw-storage-plus = { workspace = true } cw721 = { workspace = true} -cw721-incoming-proxy = { workspace = true } -cw721-outgoing-proxy-rate-limit = { workspace = true } +cw-ics721-incoming-proxy-base = { workspace = true } +cw-ics721-outgoing-proxy-rate-limit = { workspace = true } cw721-base = { workspace = true} sha2 = { workspace = true } diff --git a/contracts/sg-ics721/src/testing/integration_tests.rs b/contracts/sg-ics721/src/testing/integration_tests.rs index 31479e74..90cb9fa8 100644 --- a/contracts/sg-ics721/src/testing/integration_tests.rs +++ b/contracts/sg-ics721/src/testing/integration_tests.rs @@ -288,7 +288,7 @@ impl Test { fn new( outgoing_proxy: bool, incoming_proxy: bool, - source_channels: Option>, + channels: Option>, admin_and_pauser: Option, cw721_code: Box>, ) -> Self { @@ -307,10 +307,12 @@ impl Test { let proxy_id = app.store_code(outgoing_proxy_contract()); Some(ContractInstantiateInfo { code_id: proxy_id, - msg: to_json_binary(&cw721_outgoing_proxy_rate_limit::msg::InstantiateMsg { - rate_limit: cw721_outgoing_proxy_rate_limit::Rate::PerBlock(10), - origin: None, - }) + msg: to_json_binary( + &cw_ics721_outgoing_proxy_rate_limit::msg::InstantiateMsg { + rate_limit: cw_ics721_outgoing_proxy_rate_limit::Rate::PerBlock(10), + origin: None, + }, + ) .unwrap(), admin: Some(Admin::Instantiator {}), label: "outgoing proxy rate limit".to_string(), @@ -324,9 +326,9 @@ impl Test { let proxy_id = app.store_code(incoming_proxy_contract()); Some(ContractInstantiateInfo { code_id: proxy_id, - msg: to_json_binary(&cw721_incoming_proxy::msg::InstantiateMsg { + msg: to_json_binary(&cw_ics721_incoming_proxy_base::msg::InstantiateMsg { origin: None, - source_channels, + channels, }) .unwrap(), admin: Some(Admin::Instantiator {}), @@ -546,18 +548,18 @@ fn ics721_contract() -> Box> { fn incoming_proxy_contract() -> Box> { let contract = ContractWrapper::new( - cw721_incoming_proxy::contract::execute, - cw721_incoming_proxy::contract::instantiate, - cw721_incoming_proxy::contract::query, + cw_ics721_incoming_proxy_base::contract::execute, + cw_ics721_incoming_proxy_base::contract::instantiate, + cw_ics721_incoming_proxy_base::contract::query, ); Box::new(contract) } fn outgoing_proxy_contract() -> Box> { let contract = ContractWrapper::new( - cw721_outgoing_proxy_rate_limit::contract::execute, - cw721_outgoing_proxy_rate_limit::contract::instantiate, - cw721_outgoing_proxy_rate_limit::contract::query, + cw_ics721_outgoing_proxy_rate_limit::contract::execute, + cw_ics721_outgoing_proxy_rate_limit::contract::instantiate, + cw_ics721_outgoing_proxy_rate_limit::contract::query, ); Box::new(contract) } diff --git a/packages/ics721/Cargo.toml b/packages/ics721/Cargo.toml index 9778e9b1..e850a9fb 100644 --- a/packages/ics721/Cargo.toml +++ b/packages/ics721/Cargo.toml @@ -19,7 +19,6 @@ ics721-types = { workspace = true } thiserror = { workspace = true } serde = { workspace = true } cw-paginate-storage = { workspace = true } -cw721-incoming-proxy = { workspace = true } cw-pause-once = { workspace = true } cw-cii = { workspace = true } sha2 = { workspace = true } @@ -27,7 +26,8 @@ zip-optional = { workspace = true } [dev-dependencies] anyhow = { workspace = true } +cw-ics721-incoming-proxy-base = { workspace = true } +cw-ics721-outgoing-proxy-rate-limit = { workspace = true } cw-multi-test = { workspace = true } cw2 = { workspace = true } cw721-016 = { workspace = true } -cw721-outgoing-proxy-rate-limit = { workspace = true } diff --git a/packages/ics721/src/execute.rs b/packages/ics721/src/execute.rs index 36e403df..9eb345ac 100644 --- a/packages/ics721/src/execute.rs +++ b/packages/ics721/src/execute.rs @@ -119,22 +119,22 @@ where } from_json::(msg.clone()) .ok() - .and_then(|msg| { + .map(|msg| { let mut info = info; match deps.api.addr_validate(&msg.collection) { Ok(collection_addr) => { // set collection address as (initial) sender info.sender = collection_addr; - Some(self.receive_nft( + self.receive_nft( deps, env, info, TokenId::new(token_id), nft_owner, msg.msg, - )) + ) } - Err(err) => Some(Err(ContractError::Std(err))), + Err(err) => Err(ContractError::Std(err)), } }) } diff --git a/packages/ics721/src/helpers.rs b/packages/ics721/src/helpers.rs index 3d6dace1..f2d83586 100644 --- a/packages/ics721/src/helpers.rs +++ b/packages/ics721/src/helpers.rs @@ -69,7 +69,7 @@ pub(crate) fn ack_callback_msg( /// If there is an incoming proxy, let proxy validate the packet, in case it fails, we fail the transfer /// This proxy for example whitelist channels that can send to this contract: -/// https://github.com/arkprotocol/cw721-proxy/tree/main/contracts/cw721-incoming-proxy +/// https://github.com/arkprotocol/cw-ics721-proxy/tree/main/contracts/cw-ics721-incoming-proxy-base pub(crate) fn get_incoming_proxy_msg( storage: &dyn Storage, packet: IbcPacket, diff --git a/packages/ics721/src/testing/integration_tests.rs b/packages/ics721/src/testing/integration_tests.rs index 4a1e4a34..f6814f2c 100644 --- a/packages/ics721/src/testing/integration_tests.rs +++ b/packages/ics721/src/testing/integration_tests.rs @@ -289,7 +289,7 @@ impl Test { fn new( outgoing_proxy: bool, incoming_proxy: bool, - source_channels: Option>, + channels: Option>, admin_and_pauser: Option, cw721_code: Box>, is_cw721_018: bool, @@ -309,10 +309,12 @@ impl Test { let proxy_id = app.store_code(outgoing_proxy_contract()); Some(ContractInstantiateInfo { code_id: proxy_id, - msg: to_json_binary(&cw721_outgoing_proxy_rate_limit::msg::InstantiateMsg { - rate_limit: cw721_outgoing_proxy_rate_limit::Rate::PerBlock(10), - origin: None, - }) + msg: to_json_binary( + &cw_ics721_outgoing_proxy_rate_limit::msg::InstantiateMsg { + rate_limit: cw_ics721_outgoing_proxy_rate_limit::Rate::PerBlock(10), + origin: None, + }, + ) .unwrap(), admin: Some(Admin::Instantiator {}), label: "outgoing proxy rate limit".to_string(), @@ -326,9 +328,9 @@ impl Test { let proxy_id = app.store_code(incoming_proxy_contract()); Some(ContractInstantiateInfo { code_id: proxy_id, - msg: to_json_binary(&cw721_incoming_proxy::msg::InstantiateMsg { + msg: to_json_binary(&cw_ics721_incoming_proxy_base::msg::InstantiateMsg { origin: None, - source_channels, + channels, }) .unwrap(), admin: Some(Admin::Instantiator {}), @@ -550,18 +552,18 @@ fn ics721_contract() -> Box> { fn incoming_proxy_contract() -> Box> { let contract = ContractWrapper::new( - cw721_incoming_proxy::contract::execute, - cw721_incoming_proxy::contract::instantiate, - cw721_incoming_proxy::contract::query, + cw_ics721_incoming_proxy_base::contract::execute, + cw_ics721_incoming_proxy_base::contract::instantiate, + cw_ics721_incoming_proxy_base::contract::query, ); Box::new(contract) } fn outgoing_proxy_contract() -> Box> { let contract = ContractWrapper::new( - cw721_outgoing_proxy_rate_limit::contract::execute, - cw721_outgoing_proxy_rate_limit::contract::instantiate, - cw721_outgoing_proxy_rate_limit::contract::query, + cw_ics721_outgoing_proxy_rate_limit::contract::execute, + cw_ics721_outgoing_proxy_rate_limit::contract::instantiate, + cw_ics721_outgoing_proxy_rate_limit::contract::query, ); Box::new(contract) }