diff --git a/packages/ics721-types/Cargo.toml b/packages/ics721-types/Cargo.toml index fd3e8246..06bd28e9 100644 --- a/packages/ics721-types/Cargo.toml +++ b/packages/ics721-types/Cargo.toml @@ -2,7 +2,7 @@ name = "ics721-types" version = "0.1.0" edition = "2021" -authors = ["ekez ", "mr-t ", "Art3mix ", "m@publicawesome.com", "s+git@publicawesome.com"] +authors = ["ekez ", "mr-t ", "Art3mix "] description = "an implementation of the ICS721 specification for transfering NFTs between blockchains" [dependencies] diff --git a/packages/ics721-types/README b/packages/ics721-types/README new file mode 100644 index 00000000..ed516796 --- /dev/null +++ b/packages/ics721-types/README @@ -0,0 +1,3 @@ +# ICS721 Types Package + +Contains all types being used by ICS721, Incoming Proxy, and Outgoing Proxy. \ No newline at end of file diff --git a/packages/ics721-types/src/types.rs b/packages/ics721-types/src/types.rs index 68b6810f..35d0367b 100644 --- a/packages/ics721-types/src/types.rs +++ b/packages/ics721-types/src/types.rs @@ -69,6 +69,9 @@ pub enum ReceiverExecuteMsg { /// Note - Failing this message will NOT fail the transfer, its just a status update. Ics721AckCallback(Ics721AckCallbackMsg), + /// Being called on receiving the NFT before transfer is completed. (destination side) + /// `on_recieve` hook + /// Note - Failing this message will fail the transfer. Ics721ReceivePacketMsg { packet: IbcPacket, data: NonFungibleTokenPacketData, diff --git a/packages/ics721/src/execute.rs b/packages/ics721/src/execute.rs index 6fe3bb7a..457fba58 100644 --- a/packages/ics721/src/execute.rs +++ b/packages/ics721/src/execute.rs @@ -41,20 +41,23 @@ where msg: InstantiateMsg, ) -> StdResult> { CW721_CODE_ID.save(deps.storage, &msg.cw721_base_code_id)?; - OUTGOING_PROXY.save(deps.storage, &None)?; + // proxy contracts are optional INCOMING_PROXY.save(deps.storage, &None)?; + OUTGOING_PROXY.save(deps.storage, &None)?; PO.set_pauser(deps.storage, deps.api, msg.pauser.as_deref())?; let mut proxies_instantiate: Vec> = Vec::new(); if let Some(cii) = msg.incoming_proxy { proxies_instantiate.push(SubMsg::reply_on_success( cii.into_wasm_msg(env.clone().contract.address), + // on reply proxy contract is set in INCOMING_PROXY INSTANTIATE_INCOMING_PROXY_REPLY_ID, )); } if let Some(cii) = msg.outgoing_proxy { proxies_instantiate.push(SubMsg::reply_on_success( cii.into_wasm_msg(env.contract.address), + // on reply proxy contract is set in OUTGOING_PROXY INSTANTIATE_OUTGOING_PROXY_REPLY_ID, )); } @@ -449,6 +452,7 @@ where outgoing_proxy, cw721_base_code_id, } => { + // disables incoming proxy if none is provided! INCOMING_PROXY.save( deps.storage, &incoming_proxy @@ -456,6 +460,7 @@ where .map(|h| deps.api.addr_validate(h)) .transpose()?, )?; + // disables outgoing proxy if none is provided! OUTGOING_PROXY.save( deps.storage, &outgoing_proxy diff --git a/packages/ics721/src/ibc_packet_receive.rs b/packages/ics721/src/ibc_packet_receive.rs index eee645f8..c00df453 100644 --- a/packages/ics721/src/ibc_packet_receive.rs +++ b/packages/ics721/src/ibc_packet_receive.rs @@ -60,6 +60,9 @@ pub(crate) fn receive_ibc_packet( let data: NonFungibleTokenPacketData = from_json(&packet.data)?; data.validate()?; + // 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 let incoming_proxy_msg = match INCOMING_PROXY.load(deps.storage).ok().flatten() { Some(incoming_proxy) => { let msg = to_json_binary(&ReceiverExecuteMsg::Ics721ReceivePacketMsg { diff --git a/packages/ics721/src/testing/integration_tests.rs b/packages/ics721/src/testing/integration_tests.rs index 62243bd9..c203cdee 100644 --- a/packages/ics721/src/testing/integration_tests.rs +++ b/packages/ics721/src/testing/integration_tests.rs @@ -282,6 +282,7 @@ struct Test { } impl Test { + /// Test setup with optional pauser and proxy contracts. fn new( outgoing_proxy: bool, incoming_proxy: bool,