Skip to content

Commit b55a5e5

Browse files
committed
Update
1 parent f3fee56 commit b55a5e5

File tree

6 files changed

+162
-2
lines changed

6 files changed

+162
-2
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { type Abi, toFunctionSelector } from "viem";
2+
import { describe, expect, it } from "vitest";
3+
import { ANVIL_CHAIN } from "~test/chains.js";
4+
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
5+
import { TEST_CLIENT } from "~test/test-clients.js";
6+
import { DROP1155_CONTRACT } from "~test/test-contracts.js";
7+
import { TEST_ACCOUNT_C } from "~test/test-wallets.js";
8+
import { resolveContractAbi } from "../../../contract/actions/resolve-abi.js";
9+
import { getContract } from "../../../contract/contract.js";
10+
import { deployERC1155Contract } from "../../../extensions/prebuilts/deploy-erc1155.js";
11+
import { isGetNFTsSupported } from "./getNFTs.js";
12+
13+
describe.runIf(process.env.TW_SECRET_KEY)("ERC1155 getNFTs", () => {
14+
it("isGetNFTsSupported should work with our Edition Drop contracts", async () => {
15+
const abi = await resolveContractAbi<Abi>(DROP1155_CONTRACT);
16+
const selectors = abi
17+
.filter((f) => f.type === "function")
18+
.map((f) => toFunctionSelector(f));
19+
expect(isGetNFTsSupported(selectors)).toBe(true);
20+
});
21+
22+
it("isGetNFTsSupported should work with our Edition contracts", async () => {
23+
const contract = getContract({
24+
address: await deployERC1155Contract({
25+
chain: ANVIL_CHAIN,
26+
client: TEST_CLIENT,
27+
params: {
28+
name: "",
29+
contractURI: TEST_CONTRACT_URI,
30+
},
31+
type: "TokenERC1155",
32+
account: TEST_ACCOUNT_C,
33+
}),
34+
chain: ANVIL_CHAIN,
35+
client: TEST_CLIENT,
36+
});
37+
38+
const abi = await resolveContractAbi<Abi>(contract);
39+
const selectors = abi
40+
.filter((f) => f.type === "function")
41+
.map((f) => toFunctionSelector(f));
42+
expect(isGetNFTsSupported(selectors)).toBe(true);
43+
});
44+
});
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { type Abi, toFunctionSelector } from "viem";
2+
import { describe, expect, it } from "vitest";
3+
import { ANVIL_CHAIN } from "~test/chains.js";
4+
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
5+
import { TEST_CLIENT } from "~test/test-clients.js";
6+
import { TEST_ACCOUNT_C } from "~test/test-wallets.js";
7+
import { resolveContractAbi } from "../../../contract/actions/resolve-abi.js";
8+
import { getContract } from "../../../contract/contract.js";
9+
import { deployERC1155Contract } from "../../../extensions/prebuilts/deploy-erc1155.js";
10+
import { isLazyMintSupported } from "./lazyMint.js";
11+
12+
describe.runIf(process.env.TW_SECRET_KEY)("erc1155: lazyMint", () => {
13+
it("`isLazyMintSupported` should work with our Edition Drop contracts", async () => {
14+
const contract = getContract({
15+
address: await deployERC1155Contract({
16+
chain: ANVIL_CHAIN,
17+
client: TEST_CLIENT,
18+
params: {
19+
name: "",
20+
contractURI: TEST_CONTRACT_URI,
21+
},
22+
type: "DropERC1155",
23+
account: TEST_ACCOUNT_C,
24+
}),
25+
chain: ANVIL_CHAIN,
26+
client: TEST_CLIENT,
27+
});
28+
29+
const abi = await resolveContractAbi<Abi>(contract);
30+
const selectors = abi
31+
.filter((f) => f.type === "function")
32+
.map((f) => toFunctionSelector(f));
33+
expect(isLazyMintSupported(selectors)).toBe(true);
34+
});
35+
});
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { type Abi, toFunctionSelector } from "viem";
2+
import { describe, expect, it } from "vitest";
3+
import { ANVIL_CHAIN } from "~test/chains.js";
4+
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
5+
import { TEST_CLIENT } from "~test/test-clients.js";
6+
import { TEST_ACCOUNT_C } from "~test/test-wallets.js";
7+
import { resolveContractAbi } from "../../../contract/actions/resolve-abi.js";
8+
import { getContract } from "../../../contract/contract.js";
9+
import { deployERC1155Contract } from "../../../extensions/prebuilts/deploy-erc1155.js";
10+
import { isMintAdditionalSupplyToSupported } from "./mintAdditionalSupplyTo.js";
11+
12+
describe.runIf(process.env.TW_SECRET_KEY)(
13+
"erc1155: mintAdditionalSupplyTo",
14+
() => {
15+
it("`isMintAdditionalSupplyToSupported` should work with our Edition contracts", async () => {
16+
const contract = getContract({
17+
address: await deployERC1155Contract({
18+
chain: ANVIL_CHAIN,
19+
client: TEST_CLIENT,
20+
params: {
21+
name: "",
22+
contractURI: TEST_CONTRACT_URI,
23+
},
24+
type: "TokenERC1155",
25+
account: TEST_ACCOUNT_C,
26+
}),
27+
chain: ANVIL_CHAIN,
28+
client: TEST_CLIENT,
29+
});
30+
31+
const abi = await resolveContractAbi<Abi>(contract);
32+
const selectors = abi
33+
.filter((f) => f.type === "function")
34+
.map((f) => toFunctionSelector(f));
35+
expect(isMintAdditionalSupplyToSupported(selectors)).toBe(true);
36+
});
37+
},
38+
);
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import {} from "viem";
2+
import { describe, expect, it } from "vitest";
3+
import { ANVIL_CHAIN } from "~test/chains.js";
4+
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
5+
import { TEST_CLIENT } from "~test/test-clients.js";
6+
import { TEST_ACCOUNT_C } from "~test/test-wallets.js";
7+
import { getContract } from "../../../contract/contract.js";
8+
import { deployERC1155Contract } from "../../../extensions/prebuilts/deploy-erc1155.js";
9+
import { sendAndConfirmTransaction } from "../../../transaction/actions/send-and-confirm-transaction.js";
10+
import { uri } from "../__generated__/IERC1155/read/uri.js";
11+
import { mintTo } from "./mintTo.js";
12+
13+
describe.runIf(process.env.TW_SECRET_KEY)("erc1155: mintTo", () => {
14+
it("should mint with `nft` being declared as a string", async () => {
15+
const contract = getContract({
16+
address: await deployERC1155Contract({
17+
chain: ANVIL_CHAIN,
18+
client: TEST_CLIENT,
19+
params: {
20+
name: "",
21+
contractURI: TEST_CONTRACT_URI,
22+
},
23+
type: "TokenERC1155",
24+
account: TEST_ACCOUNT_C,
25+
}),
26+
chain: ANVIL_CHAIN,
27+
client: TEST_CLIENT,
28+
});
29+
30+
await sendAndConfirmTransaction({
31+
transaction: mintTo({
32+
contract,
33+
nft: TEST_CONTRACT_URI,
34+
to: TEST_ACCOUNT_C.address,
35+
supply: 1n,
36+
}),
37+
account: TEST_ACCOUNT_C,
38+
});
39+
40+
const tokenUri = await uri({ contract, tokenId: 0n });
41+
expect(tokenUri).toBe(TEST_CONTRACT_URI);
42+
});
43+
});

packages/thirdweb/src/extensions/erc20/read/isERC20.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
import { resolveContractAbi } from "../../../contract/actions/resolve-abi.js";
99
import { isERC20 } from "./isERC20.js";
1010

11-
describe("isERC20", () => {
11+
describe.runIf(process.env.TW_SECRET_KEY)("isERC20", () => {
1212
it("should detect USDT as a valid erc20 contract", async () => {
1313
const abi = await resolveContractAbi<Abi>(USDT_CONTRACT);
1414
const selectors = abi

packages/thirdweb/src/extensions/erc20/write/transferBatch.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const chain = ANVIL_CHAIN;
1919
const client = TEST_CLIENT;
2020
const account = TEST_ACCOUNT_A;
2121

22-
describe("erc20: transferBatch", () => {
22+
describe.runIf(process.env.TW_SECRET_KEY)("erc20: transferBatch", () => {
2323
it("should transfer tokens to multiple recipients", async () => {
2424
const address = await deployERC20Contract({
2525
type: "TokenERC20",

0 commit comments

Comments
 (0)