Skip to content

Incoming proxy #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 40 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
0ebc458
use creator for withdraw address
taitruong Dec 13, 2023
659c87e
update branch
taitruong Dec 28, 2023
d74b39d
use cw721-base with withdraw address
taitruong Dec 28, 2023
3a06220
fix tests
taitruong Dec 28, 2023
3b6aac1
rename proxy > outgoing proxy
taitruong Dec 12, 2023
de167a3
fix test
taitruong Dec 12, 2023
26ee914
update libs
taitruong Dec 12, 2023
8b808ee
optional incoming proxy
taitruong Dec 27, 2023
e8f22b4
cargo clippy and fmt
taitruong Dec 27, 2023
7c5e9c3
move types to dedicated package
taitruong Dec 27, 2023
f5bba4c
cleanup
taitruong Dec 27, 2023
b8fcdca
integration test for incoming proxy
taitruong Dec 27, 2023
61a96cb
cleanup
taitruong Dec 27, 2023
0921f66
test sending to non-WLed channel in incoming proxy
taitruong Dec 27, 2023
a488a23
cleanup
taitruong Dec 27, 2023
4e2f400
docs
taitruong Dec 27, 2023
b1f5c07
use double quote to prevent globbing and word splitting
taitruong Dec 27, 2023
60277c0
fix CI
taitruong Dec 27, 2023
49667d5
cleanup based on review by humanalgorithm
taitruong Dec 28, 2023
c46edd4
remove ReceiveProxyNft (handled now by ReceiveNft)
taitruong Dec 30, 2023
9ec55ed
cleanup
taitruong Dec 30, 2023
549e9a0
cleanup
taitruong Dec 30, 2023
10d64ed
ts-relayer test for receive nft via outgoing proxy
taitruong Dec 30, 2023
0cdc119
fix test
taitruong Dec 30, 2023
28d28fe
cleanup
taitruong Dec 30, 2023
fee2aaa
cleanup
taitruong Dec 30, 2023
03091a0
moved to helper
taitruong Dec 30, 2023
88ae912
increase capacity to 3
taitruong Dec 30, 2023
62e118e
update versions
taitruong Dec 30, 2023
a7a4778
docs
taitruong Dec 30, 2023
b930ded
detailed docs on receive nft
taitruong Dec 31, 2023
f8c42c0
update libs
taitruong Dec 31, 2023
84ed066
update lib
taitruong Dec 31, 2023
565f56e
update wasm files for tests
taitruong Jan 1, 2024
d796fc9
update cw721-proxy
taitruong Jan 1, 2024
8bcfc38
update incoming wasm
taitruong Jan 1, 2024
3ec3ed5
update incoming proxy
taitruong Jan 1, 2024
a2d4965
use tag cw-721proxy v0.1.0
taitruong Jan 2, 2024
1fadd3b
rename cw721 -> cw-ics721
taitruong Jan 2, 2024
0b4fd68
cw-ics721-proxy: update lib
taitruong Jan 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 27 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ cw-ownable = "^0.5"
cw-paginate-storage = { version = "^2.4", git = "https://github.com/DA0-DA0/dao-contracts.git" }
cw-storage-plus = "1.1"
cw2 = "1.1"
cw721 = { git = "https://github.com/arkprotocol/cw-nfts", branch = "withdrawal_address"} # TODO switch to official repo, once merged
cw721 = { git = "https://github.com/CosmWasm/cw-nfts", branch = "main"} # TODO switch to version 0.18.1/0.19.0, once released
cw721-016 = { version = "0.16.0", package = "cw721" }
cw721-base = { git = "https://github.com/arkprotocol/cw-nfts", branch = "withdrawal_address"} # TODO switch to official repo, once merged
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" }
cw721-outgoing-proxy-derive = { git = "https://github.com/arkprotocol/cw721-proxy.git" }
cw721-outgoing-proxy-rate-limit = { git = "https://github.com/arkprotocol/cw721-proxy.git" }
cw-multi-test = { version = "^0.20", features = ["cosmwasm_1_2"] }
cw-utils = "^1.0"
Expand Down
4 changes: 2 additions & 2 deletions contracts/ics721-base-tester/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use cosmwasm_std::{
StdResult, WasmMsg,
};
use cw2::set_contract_version;
use ics721_types::ibc_types::NonFungibleTokenPacketData;
use ics721_types::ibc_types::{IbcOutgoingMsg, NonFungibleTokenPacketData};

use crate::{
error::ContractError,
Expand Down Expand Up @@ -220,7 +220,7 @@ fn execute_send_nft(
msg: to_json_binary(&cw721::Cw721ExecuteMsg::SendNft {
contract: ics721,
token_id,
msg: to_json_binary(&ics721::msg::IbcOutgoingMsg {
msg: to_json_binary(&IbcOutgoingMsg {
receiver: recipient,
channel_id,
timeout: IbcTimeout::with_timestamp(env.block.time.plus_seconds(1000)),
Expand Down
98 changes: 75 additions & 23 deletions contracts/sg-ics721/src/testing/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ use cw_pause_once::PauseError;
use ics721::{
execute::Ics721Execute,
ibc::Ics721Ibc,
msg::{CallbackMsg, ExecuteMsg, IbcOutgoingMsg, InstantiateMsg, MigrateMsg, QueryMsg},
msg::{CallbackMsg, ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg},
query::Ics721Query,
state::CollectionData,
token_types::VoucherCreation,
};
use ics721_types::token_types::{Class, ClassId, Token, TokenId};
use ics721_types::{
ibc_types::{IbcOutgoingMsg, IbcOutgoingProxyMsg},
token_types::{Class, ClassId, Token, TokenId},
};
use sg721::InstantiateMsg as Sg721InstantiateMsg;
use sg721_base::msg::{CollectionInfoResponse, QueryMsg as Sg721QueryMsg};
use sha2::{digest::Update, Digest, Sha256};
Expand Down Expand Up @@ -1988,23 +1991,71 @@ fn test_do_instantiate_and_mint_permissions() {
assert_eq!(err, ContractError::Unauthorized {});
}

/// Tests that we can not proxy NFTs if no proxy is configured.
/// Tests that we can not send IbcOutgoingProxyMsg if no proxy is configured.
#[test]
fn test_no_proxy_unauthorized() {
fn test_no_proxy_unknown_msg() {
let mut test = Test::new(false, false, None, None, sg721_base_contract());
let msg = IbcOutgoingProxyMsg {
collection: "foo".to_string(),
msg: to_json_binary(&IbcOutgoingMsg {
receiver: test.app.api().addr_make(NFT_OWNER_TARGET_CHAIN).to_string(),
channel_id: "channel-0".to_string(),
timeout: IbcTimeout::with_block(IbcTimeoutBlock {
revision: 0,
height: 10,
}),
memo: None,
})
.unwrap(),
};
let err: ContractError = test
.app
.execute_contract(
test.app.api().addr_make("proxy"),
test.ics721,
&ExecuteMsg::ReceiveProxyNft {
eyeball: "nft".to_string(),
msg: cw721::Cw721ReceiveMsg {
sender: test.app.api().addr_make(NFT_OWNER_TARGET_CHAIN).to_string(),
token_id: "1".to_string(),
msg: to_json_binary("").unwrap(),
},
},
&ExecuteMsg::ReceiveNft(cw721::Cw721ReceiveMsg {
sender: test.app.api().addr_make(NFT_OWNER_TARGET_CHAIN).to_string(),
token_id: "1".to_string(),
msg: to_json_binary(&msg).unwrap(),
}),
&[],
)
.unwrap_err()
.downcast()
.unwrap();
assert_eq!(
err,
ContractError::UnknownMsg(to_json_binary(&msg).unwrap())
);
}

/// Tests that we can non-proxy addresses can send if proxy is configured.
#[test]
fn test_no_proxy_unauthorized() {
let mut test = Test::new(true, false, None, None, sg721_base_contract());
let msg = IbcOutgoingProxyMsg {
collection: "foo".to_string(),
msg: to_json_binary(&IbcOutgoingMsg {
receiver: test.app.api().addr_make(NFT_OWNER_TARGET_CHAIN).to_string(),
channel_id: "channel-0".to_string(),
timeout: IbcTimeout::with_block(IbcTimeoutBlock {
revision: 0,
height: 10,
}),
memo: None,
})
.unwrap(),
};
let err: ContractError = test
.app
.execute_contract(
test.app.api().addr_make("foo"),
test.ics721,
&ExecuteMsg::ReceiveNft(cw721::Cw721ReceiveMsg {
sender: test.app.api().addr_make(NFT_OWNER_TARGET_CHAIN).to_string(),
token_id: "1".to_string(),
msg: to_json_binary(&msg).unwrap(),
}),
&[],
)
.unwrap_err()
Expand Down Expand Up @@ -2081,15 +2132,15 @@ fn test_proxy_authorized() {
.execute_contract(
proxy_address,
test.ics721,
&ExecuteMsg::ReceiveProxyNft {
eyeball: source_cw721.into_string(),
msg: cw721::Cw721ReceiveMsg {
sender: test
.app
.api()
.addr_make(COLLECTION_OWNER_SOURCE_CHAIN)
.to_string(),
token_id: "1".to_string(),
&ExecuteMsg::ReceiveNft(cw721::Cw721ReceiveMsg {
sender: test
.app
.api()
.addr_make(COLLECTION_OWNER_SOURCE_CHAIN)
.to_string(),
token_id: "1".to_string(),
msg: to_json_binary(&IbcOutgoingProxyMsg {
collection: source_cw721.into_string(),
msg: to_json_binary(&IbcOutgoingMsg {
receiver: test.app.api().addr_make(NFT_OWNER_TARGET_CHAIN).to_string(),
channel_id: "channel-0".to_string(),
Expand All @@ -2100,8 +2151,9 @@ fn test_proxy_authorized() {
memo: None,
})
.unwrap(),
},
},
})
.unwrap(),
}),
&[],
)
.unwrap();
Expand Down
Binary file modified external-wasms/cw721_incoming_proxy.wasm
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions packages/ics721-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ description = "an implementation of the ICS721 specification for transfering NFT
cosmwasm-std = { workspace = true, features = ["cosmwasm_1_2"] }
cosmwasm-schema = { workspace = true }
cw-storage-plus = { workspace = true }
cw721 = { workspace = true }
serde = { workspace = true }
thiserror = { workspace = true }
2 changes: 1 addition & 1 deletion packages/ics721-types/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use thiserror::Error;

#[derive(Error, Debug, PartialEq)]
pub enum ValidationError {
pub enum Ics721Error {
#[error("empty class ID")]
EmptyClassId {},

Expand Down
Loading