diff --git a/packages/thirdweb/src/extensions/erc1155/read/getNFTs.test.ts b/packages/thirdweb/src/extensions/erc1155/read/getNFTs.test.ts new file mode 100644 index 00000000000..4490c1c1e1e --- /dev/null +++ b/packages/thirdweb/src/extensions/erc1155/read/getNFTs.test.ts @@ -0,0 +1,44 @@ +import { type Abi, toFunctionSelector } from "viem"; +import { describe, expect, it } from "vitest"; +import { ANVIL_CHAIN } from "~test/chains.js"; +import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js"; +import { TEST_CLIENT } from "~test/test-clients.js"; +import { DROP1155_CONTRACT } from "~test/test-contracts.js"; +import { TEST_ACCOUNT_C } from "~test/test-wallets.js"; +import { resolveContractAbi } from "../../../contract/actions/resolve-abi.js"; +import { getContract } from "../../../contract/contract.js"; +import { deployERC1155Contract } from "../../../extensions/prebuilts/deploy-erc1155.js"; +import { isGetNFTsSupported } from "./getNFTs.js"; + +describe.runIf(process.env.TW_SECRET_KEY)("ERC1155 getNFTs", () => { + it("isGetNFTsSupported should work with our Edition Drop contracts", async () => { + const abi = await resolveContractAbi(DROP1155_CONTRACT); + const selectors = abi + .filter((f) => f.type === "function") + .map((f) => toFunctionSelector(f)); + expect(isGetNFTsSupported(selectors)).toBe(true); + }); + + it("isGetNFTsSupported should work with our Edition contracts", async () => { + const contract = getContract({ + address: await deployERC1155Contract({ + chain: ANVIL_CHAIN, + client: TEST_CLIENT, + params: { + name: "", + contractURI: TEST_CONTRACT_URI, + }, + type: "TokenERC1155", + account: TEST_ACCOUNT_C, + }), + chain: ANVIL_CHAIN, + client: TEST_CLIENT, + }); + + const abi = await resolveContractAbi(contract); + const selectors = abi + .filter((f) => f.type === "function") + .map((f) => toFunctionSelector(f)); + expect(isGetNFTsSupported(selectors)).toBe(true); + }); +}); diff --git a/packages/thirdweb/src/extensions/erc1155/write/lazyMint.test.ts b/packages/thirdweb/src/extensions/erc1155/write/lazyMint.test.ts new file mode 100644 index 00000000000..a1e64b1d47c --- /dev/null +++ b/packages/thirdweb/src/extensions/erc1155/write/lazyMint.test.ts @@ -0,0 +1,35 @@ +import { type Abi, toFunctionSelector } from "viem"; +import { describe, expect, it } from "vitest"; +import { ANVIL_CHAIN } from "~test/chains.js"; +import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js"; +import { TEST_CLIENT } from "~test/test-clients.js"; +import { TEST_ACCOUNT_C } from "~test/test-wallets.js"; +import { resolveContractAbi } from "../../../contract/actions/resolve-abi.js"; +import { getContract } from "../../../contract/contract.js"; +import { deployERC1155Contract } from "../../../extensions/prebuilts/deploy-erc1155.js"; +import { isLazyMintSupported } from "./lazyMint.js"; + +describe.runIf(process.env.TW_SECRET_KEY)("erc1155: lazyMint", () => { + it("`isLazyMintSupported` should work with our Edition Drop contracts", async () => { + const contract = getContract({ + address: await deployERC1155Contract({ + chain: ANVIL_CHAIN, + client: TEST_CLIENT, + params: { + name: "", + contractURI: TEST_CONTRACT_URI, + }, + type: "DropERC1155", + account: TEST_ACCOUNT_C, + }), + chain: ANVIL_CHAIN, + client: TEST_CLIENT, + }); + + const abi = await resolveContractAbi(contract); + const selectors = abi + .filter((f) => f.type === "function") + .map((f) => toFunctionSelector(f)); + expect(isLazyMintSupported(selectors)).toBe(true); + }); +}); diff --git a/packages/thirdweb/src/extensions/erc1155/write/mintAdditionalSupplyTo.test.ts b/packages/thirdweb/src/extensions/erc1155/write/mintAdditionalSupplyTo.test.ts new file mode 100644 index 00000000000..d73eaa7d6e7 --- /dev/null +++ b/packages/thirdweb/src/extensions/erc1155/write/mintAdditionalSupplyTo.test.ts @@ -0,0 +1,38 @@ +import { type Abi, toFunctionSelector } from "viem"; +import { describe, expect, it } from "vitest"; +import { ANVIL_CHAIN } from "~test/chains.js"; +import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js"; +import { TEST_CLIENT } from "~test/test-clients.js"; +import { TEST_ACCOUNT_C } from "~test/test-wallets.js"; +import { resolveContractAbi } from "../../../contract/actions/resolve-abi.js"; +import { getContract } from "../../../contract/contract.js"; +import { deployERC1155Contract } from "../../../extensions/prebuilts/deploy-erc1155.js"; +import { isMintAdditionalSupplyToSupported } from "./mintAdditionalSupplyTo.js"; + +describe.runIf(process.env.TW_SECRET_KEY)( + "erc1155: mintAdditionalSupplyTo", + () => { + it("`isMintAdditionalSupplyToSupported` should work with our Edition contracts", async () => { + const contract = getContract({ + address: await deployERC1155Contract({ + chain: ANVIL_CHAIN, + client: TEST_CLIENT, + params: { + name: "", + contractURI: TEST_CONTRACT_URI, + }, + type: "TokenERC1155", + account: TEST_ACCOUNT_C, + }), + chain: ANVIL_CHAIN, + client: TEST_CLIENT, + }); + + const abi = await resolveContractAbi(contract); + const selectors = abi + .filter((f) => f.type === "function") + .map((f) => toFunctionSelector(f)); + expect(isMintAdditionalSupplyToSupported(selectors)).toBe(true); + }); + }, +); diff --git a/packages/thirdweb/src/extensions/erc1155/write/mintTo.test.ts b/packages/thirdweb/src/extensions/erc1155/write/mintTo.test.ts new file mode 100644 index 00000000000..4e21fe158a6 --- /dev/null +++ b/packages/thirdweb/src/extensions/erc1155/write/mintTo.test.ts @@ -0,0 +1,43 @@ +import {} from "viem"; +import { describe, expect, it } from "vitest"; +import { ANVIL_CHAIN } from "~test/chains.js"; +import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js"; +import { TEST_CLIENT } from "~test/test-clients.js"; +import { TEST_ACCOUNT_C } from "~test/test-wallets.js"; +import { getContract } from "../../../contract/contract.js"; +import { deployERC1155Contract } from "../../../extensions/prebuilts/deploy-erc1155.js"; +import { sendAndConfirmTransaction } from "../../../transaction/actions/send-and-confirm-transaction.js"; +import { uri } from "../__generated__/IERC1155/read/uri.js"; +import { mintTo } from "./mintTo.js"; + +describe.runIf(process.env.TW_SECRET_KEY)("erc1155: mintTo", () => { + it("should mint with `nft` being declared as a string", async () => { + const contract = getContract({ + address: await deployERC1155Contract({ + chain: ANVIL_CHAIN, + client: TEST_CLIENT, + params: { + name: "", + contractURI: TEST_CONTRACT_URI, + }, + type: "TokenERC1155", + account: TEST_ACCOUNT_C, + }), + chain: ANVIL_CHAIN, + client: TEST_CLIENT, + }); + + await sendAndConfirmTransaction({ + transaction: mintTo({ + contract, + nft: TEST_CONTRACT_URI, + to: TEST_ACCOUNT_C.address, + supply: 1n, + }), + account: TEST_ACCOUNT_C, + }); + + const tokenUri = await uri({ contract, tokenId: 0n }); + expect(tokenUri).toBe(TEST_CONTRACT_URI); + }); +}); diff --git a/packages/thirdweb/src/extensions/erc20/read/isERC20.test.ts b/packages/thirdweb/src/extensions/erc20/read/isERC20.test.ts index ae7814216b8..717b104d226 100644 --- a/packages/thirdweb/src/extensions/erc20/read/isERC20.test.ts +++ b/packages/thirdweb/src/extensions/erc20/read/isERC20.test.ts @@ -8,7 +8,7 @@ import { import { resolveContractAbi } from "../../../contract/actions/resolve-abi.js"; import { isERC20 } from "./isERC20.js"; -describe("isERC20", () => { +describe.runIf(process.env.TW_SECRET_KEY)("isERC20", () => { it("should detect USDT as a valid erc20 contract", async () => { const abi = await resolveContractAbi(USDT_CONTRACT); const selectors = abi diff --git a/packages/thirdweb/src/extensions/erc20/write/transferBatch.test.ts b/packages/thirdweb/src/extensions/erc20/write/transferBatch.test.ts index 739a4a0db52..fd1be09feb0 100644 --- a/packages/thirdweb/src/extensions/erc20/write/transferBatch.test.ts +++ b/packages/thirdweb/src/extensions/erc20/write/transferBatch.test.ts @@ -19,7 +19,7 @@ const chain = ANVIL_CHAIN; const client = TEST_CLIENT; const account = TEST_ACCOUNT_A; -describe("erc20: transferBatch", () => { +describe.runIf(process.env.TW_SECRET_KEY)("erc20: transferBatch", () => { it("should transfer tokens to multiple recipients", async () => { const address = await deployERC20Contract({ type: "TokenERC20",