Skip to content

Commit

Permalink
ts-relayer test: mint nft with onchain metadata and check it is trans…
Browse files Browse the repository at this point in the history
…ferred
  • Loading branch information
taitruong committed Aug 14, 2024
1 parent 96d2d20 commit 5b6b6d4
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 7 deletions.
Binary file not shown.
30 changes: 28 additions & 2 deletions ts-relayer-tests/src/cw721-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@ export function mint(
token_uri: string | undefined
) {
const msg = {
mint: { token_id, owner, token_uri },
mint: {
token_id,
owner,
token_uri,
extension: {
description: "This is a test NFT",
image: "https://ark.pass/image.png",
},
},
};
return client.sign.execute(
client.senderAddress,
Expand Down Expand Up @@ -82,11 +90,29 @@ export function allTokens(
return client.sign.queryContractSmart(cw721Contract, msg);
}

/// valid for v16 - v19
export function nftInfo(
client: CosmWasmSigner,
cw721Contract: string,
token_id: string
) {
): Promise<{
token_uri: string | null;
extension: {
image: string | null;
image_data: string | null;
external_url: string | null;
description: string | null;
name: string | null;
attributes: null | Array<{
trait_type: string;
value: string;
display_type: string | null;
}>;
background_color: string | null;
animation_url: string | null;
youtube_url: string | null;
};
}> {
const msg = {
nft_info: {
token_id,
Expand Down
26 changes: 21 additions & 5 deletions ts-relayer-tests/src/ics721.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
getCw721Minter_v16,
getCw721MinterOwnership,
mint,
nftInfo,
ownerOf,
sendNft,
} from "./cw721-utils";
Expand Down Expand Up @@ -67,7 +68,7 @@ interface TestContext {
const test = anyTest as TestFn<TestContext>;

const WASM_FILE_CW721 = "./internal/cw721_metadata_onchain_v0.19.0.wasm";
const WASM_FILE_CW721_v16 = "./internal/cw721_base_v0.16.0.wasm";
const WASM_FILE_CW721_v16 = "./internal/cw721_metadata_onchain_v0.16.0.wasm";
const WASM_FILE_CW721_INCOMING_PROXY = "./internal/cw721_incoming_proxy.wasm";
const WASM_FILE_CW721_OUTGOING_PROXY =
"./internal/cw721_outgoing_proxy_rate_limit.wasm";
Expand Down Expand Up @@ -375,7 +376,7 @@ const standardSetup = async (t: ExecutionContext<TestContext>) => {
t.pass();
};

test.skip("transfer NFT: wasmd -> osmo", async (t) => {
test.serial("transfer NFT: wasmd -> osmo", async (t) => {
await standardSetup(t);

const {
Expand Down Expand Up @@ -470,6 +471,14 @@ test.skip("transfer NFT: wasmd -> osmo", async (t) => {
const minterOwnerShip = await getCw721MinterOwnership(osmoClient, osmoCw721);
t.is(osmoIcs721, minterOwnerShip.owner);

const wasmNftInfo = await nftInfo(wasmClient, wasmCw721, tokenId);
// assert extension is not null
t.truthy(wasmNftInfo.extension);
const osmoNftInfo = await nftInfo(osmoClient, osmoCw721, tokenId);
t.truthy(osmoNftInfo.extension);
// assert nft with extension is same
t.deepEqual(wasmNftInfo, osmoNftInfo);

// test back transfer NFT to wasm chain
t.log(`transfering back to wasm chain via ${channel.channel.dest.channelId}`);
transferResponse = await sendNft(
Expand Down Expand Up @@ -925,9 +934,16 @@ test.serial("transfer NFT v16: wasm -> osmo", async (t) => {
);
// assert minter is set to ics721
const minterOwnerShip = await getCw721Minter_v16(osmoClient, osmoCw721);
console.log(">>>>>", minterOwnerShip);
t.is(osmoIcs721, minterOwnerShip.minter);

const wasmNftInfo = await nftInfo(wasmClient, wasmCw721_v16, tokenId);
// assert extension is not null
t.truthy(wasmNftInfo.extension);
const osmoNftInfo = await nftInfo(osmoClient, osmoCw721, tokenId);
t.truthy(osmoNftInfo.extension);
// assert nft with extension is same
t.deepEqual(wasmNftInfo, osmoNftInfo);

// test back transfer NFT to wasm chain
t.log(`transfering back to wasm chain via ${channel.channel.dest.channelId}`);
transferResponse = await sendNft(
Expand Down Expand Up @@ -1296,7 +1312,7 @@ test.serial("transfer NFT v16: wasm -> osmo", async (t) => {
t.is(wasmAddr, tokenOwner.owner);
});

test.skip("admin unescrow and burn NFT: wasmd -> osmo", async (t) => {
test.serial("admin unescrow and burn NFT: wasmd -> osmo", async (t) => {
await standardSetup(t);

const {
Expand Down Expand Up @@ -1481,7 +1497,7 @@ test.skip("admin unescrow and burn NFT: wasmd -> osmo", async (t) => {
);
});

test.skip("malicious NFT", async (t) => {
test.serial("malicious NFT", async (t) => {
await standardSetup(t);
const {
wasmClient,
Expand Down

0 comments on commit 5b6b6d4

Please sign in to comment.