Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
taitruong committed Dec 28, 2023
1 parent a488a23 commit 4e2f400
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/ics721-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "ics721-types"
version = "0.1.0"
edition = "2021"
authors = ["ekez <ekez@withoutdoing.com>", "mr-t <mr-t@arkprotocol.io>", "Art3mix <art3mix.90@gmail.com>", "m@publicawesome.com", "s+git@publicawesome.com"]
authors = ["ekez <ekez@withoutdoing.com>", "mr-t <mr-t@arkprotocol.io>", "Art3mix <art3mix.90@gmail.com>"]
description = "an implementation of the ICS721 specification for transfering NFTs between blockchains"

[dependencies]
Expand Down
3 changes: 3 additions & 0 deletions packages/ics721-types/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# ICS721 Types Package

Contains all types being used by ICS721, Incoming Proxy, and Outgoing Proxy.
3 changes: 3 additions & 0 deletions packages/ics721-types/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion packages/ics721/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,23 @@ where
msg: InstantiateMsg,
) -> StdResult<Response<T>> {
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<SubMsg<T>> = 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,
));
}
Expand Down Expand Up @@ -449,13 +452,15 @@ where
outgoing_proxy,
cw721_base_code_id,
} => {
// disables incoming proxy if none is provided!
INCOMING_PROXY.save(
deps.storage,
&incoming_proxy
.as_ref()
.map(|h| deps.api.addr_validate(h))
.transpose()?,
)?;
// disables outgoing proxy if none is provided!
OUTGOING_PROXY.save(
deps.storage,
&outgoing_proxy
Expand Down
3 changes: 3 additions & 0 deletions packages/ics721/src/ibc_packet_receive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions packages/ics721/src/testing/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ struct Test {
}

impl Test {
/// Test setup with optional pauser and proxy contracts.
fn new(
outgoing_proxy: bool,
incoming_proxy: bool,
Expand Down

0 comments on commit 4e2f400

Please sign in to comment.