diff --git a/packages/thirdweb/src/extensions/erc1155/drop1155.test.ts b/packages/thirdweb/src/extensions/erc1155/drop1155.test.ts index 879881ecc39..385f4d6d2ab 100644 --- a/packages/thirdweb/src/extensions/erc1155/drop1155.test.ts +++ b/packages/thirdweb/src/extensions/erc1155/drop1155.test.ts @@ -1,3 +1,4 @@ +import { type Abi, toFunctionSelector } from "viem"; import { beforeAll, describe, expect, it } from "vitest"; import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js"; import { VITALIK_WALLET } from "../../../test/src/addresses.js"; @@ -8,6 +9,7 @@ import { TEST_ACCOUNT_B, TEST_ACCOUNT_D, } from "../../../test/src/test-wallets.js"; +import { resolveContractAbi } from "../../contract/actions/resolve-abi.js"; import { type ThirdwebContract, getContract } from "../../contract/contract.js"; import { sendAndConfirmTransaction } from "../../transaction/actions/send-and-confirm-transaction.js"; import { resolvePromisedValue } from "../../utils/promise/resolve-promised-value.js"; @@ -20,6 +22,7 @@ import { claimTo } from "./drops/write/claimTo.js"; import { resetClaimEligibility } from "./drops/write/resetClaimEligibility.js"; import { setClaimConditions } from "./drops/write/setClaimConditions.js"; import { getNFT } from "./read/getNFT.js"; +import { isGetNFTsSupported } from "./read/getNFTs.js"; import { lazyMint } from "./write/lazyMint.js"; describe.runIf(process.env.TW_SECRET_KEY)( @@ -398,5 +401,13 @@ describe.runIf(process.env.TW_SECRET_KEY)( balanceOf({ tokenId: 6n, contract, owner: TEST_ACCOUNT_D.address }), ).resolves.toBe(2n); }); + + it("isGetNFTsSupported should work with our Edition Drop contracts", async () => { + 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/read/getNFTs.test.ts b/packages/thirdweb/src/extensions/erc1155/read/getNFTs.test.ts deleted file mode 100644 index 4490c1c1e1e..00000000000 --- a/packages/thirdweb/src/extensions/erc1155/read/getNFTs.test.ts +++ /dev/null @@ -1,44 +0,0 @@ -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/read/getOwnedNFTs.test.ts b/packages/thirdweb/src/extensions/erc1155/read/getOwnedNFTs.test.ts deleted file mode 100644 index 573693859fa..00000000000 --- a/packages/thirdweb/src/extensions/erc1155/read/getOwnedNFTs.test.ts +++ /dev/null @@ -1,62 +0,0 @@ -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_A } from "~test/test-wallets.js"; -import { getContract } from "../../../contract/contract.js"; -import { sendAndConfirmTransaction } from "../../../transaction/actions/send-and-confirm-transaction.js"; -import { deployERC1155Contract } from "../../prebuilts/deploy-erc1155.js"; -import { mintTo } from "../write/mintTo.js"; -import { getOwnedNFTs } from "./getOwnedNFTs.js"; - -const account = TEST_ACCOUNT_A; -const client = TEST_CLIENT; -const chain = ANVIL_CHAIN; - -describe.runIf(process.env.TW_SECRET_KEY)("ERC1155 getOwnedTokenIds", () => { - it("should fetch owned tokenIds", async () => { - const address = await deployERC1155Contract({ - type: "TokenERC1155", - chain, - client, - account, - params: { - name: "edition", - contractURI: TEST_CONTRACT_URI, - }, - }); - - const contract = getContract({ - address, - chain, - client, - }); - - const transaction = mintTo({ - contract, - nft: { name: "token 0" }, - to: account.address, - supply: 20n, - }); - await sendAndConfirmTransaction({ transaction, account }); - - const ownedTokenIds = await getOwnedNFTs({ - contract, - address: account.address, - }); - - expect(ownedTokenIds).toStrictEqual([ - { - id: 0n, - metadata: { - name: "token 0", - }, - owner: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", - quantityOwned: 20n, - supply: 20n, - tokenURI: "ipfs://QmPZ6LpGqMuFbHKTXrNW1NRNLHf1nrxS4dtoFqdZZTKvPX/0", - type: "ERC1155", - }, - ]); - }); -}); diff --git a/packages/thirdweb/src/extensions/erc1155/read/getOwnedTokenIds.test.ts b/packages/thirdweb/src/extensions/erc1155/read/getOwnedTokenIds.test.ts deleted file mode 100644 index 7835a8c1196..00000000000 --- a/packages/thirdweb/src/extensions/erc1155/read/getOwnedTokenIds.test.ts +++ /dev/null @@ -1,50 +0,0 @@ -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_A } from "~test/test-wallets.js"; -import { getContract } from "../../../contract/contract.js"; -import { sendAndConfirmTransaction } from "../../../transaction/actions/send-and-confirm-transaction.js"; -import { deployERC1155Contract } from "../../prebuilts/deploy-erc1155.js"; -import { mintTo } from "../write/mintTo.js"; -import { getOwnedTokenIds } from "./getOwnedTokenIds.js"; - -const account = TEST_ACCOUNT_A; -const client = TEST_CLIENT; -const chain = ANVIL_CHAIN; - -describe.runIf(process.env.TW_SECRET_KEY)("ERC1155 getOwnedTokenIds", () => { - it("should fetch owned tokenIds", async () => { - const address = await deployERC1155Contract({ - type: "TokenERC1155", - chain, - client, - account, - params: { - name: "edition", - contractURI: TEST_CONTRACT_URI, - }, - }); - - const contract = getContract({ - address, - chain, - client, - }); - - const transaction = mintTo({ - contract, - nft: { name: "token 0" }, - to: account.address, - supply: 20n, - }); - await sendAndConfirmTransaction({ transaction, account }); - - const ownedTokenIds = await getOwnedTokenIds({ - contract, - address: account.address, - }); - - expect(ownedTokenIds).toStrictEqual([{ tokenId: 0n, balance: 20n }]); - }); -}); diff --git a/packages/thirdweb/src/extensions/erc1155/token1155.test.ts b/packages/thirdweb/src/extensions/erc1155/token1155.test.ts index 4e012717a64..0396f8bca50 100644 --- a/packages/thirdweb/src/extensions/erc1155/token1155.test.ts +++ b/packages/thirdweb/src/extensions/erc1155/token1155.test.ts @@ -1,3 +1,4 @@ +import { type Abi, toFunctionSelector } from "viem"; import { beforeAll, describe, expect, it } from "vitest"; import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js"; import { ANVIL_CHAIN } from "../../../test/src/chains.js"; @@ -5,17 +6,27 @@ import { TEST_CLIENT } from "../../../test/src/test-clients.js"; import { TEST_ACCOUNT_A, TEST_ACCOUNT_B, + TEST_ACCOUNT_C, } from "../../../test/src/test-wallets.js"; +import { resolveContractAbi } from "../../contract/actions/resolve-abi.js"; import { type ThirdwebContract, getContract } from "../../contract/contract.js"; import { sendAndConfirmTransaction } from "../../transaction/actions/send-and-confirm-transaction.js"; import { deployERC1155Contract } from "../prebuilts/deploy-erc1155.js"; import { balanceOf } from "./__generated__/IERC1155/read/balanceOf.js"; import { totalSupply } from "./__generated__/IERC1155/read/totalSupply.js"; +import { uri } from "./__generated__/IERC1155/read/uri.js"; import { nextTokenIdToMint } from "./__generated__/IERC1155Enumerable/read/nextTokenIdToMint.js"; import { getNFT } from "./read/getNFT.js"; -import { getNFTs } from "./read/getNFTs.js"; -import { mintAdditionalSupplyTo } from "./write/mintAdditionalSupplyTo.js"; +import { getNFTs, isGetNFTsSupported } from "./read/getNFTs.js"; +import { getOwnedTokenIds } from "./read/getOwnedTokenIds.js"; +import { + isMintAdditionalSupplyToSupported, + mintAdditionalSupplyTo, +} from "./write/mintAdditionalSupplyTo.js"; +import { mintAdditionalSupplyToBatch } from "./write/mintAdditionalSupplyToBatch.js"; import { mintTo } from "./write/mintTo.js"; +import { mintToBatch } from "./write/mintToBatch.js"; +import { updateTokenURI } from "./write/updateTokenURI.js"; describe.runIf(process.env.TW_SECRET_KEY)("TokenERC1155", () => { let contract: ThirdwebContract; @@ -158,4 +169,161 @@ describe.runIf(process.env.TW_SECRET_KEY)("TokenERC1155", () => { ] `); }); + + it("isGetNFTsSupported should work with our Edition contracts", async () => { + const abi = await resolveContractAbi(contract); + const selectors = abi + .filter((f) => f.type === "function") + .map((f) => toFunctionSelector(f)); + expect(isGetNFTsSupported(selectors)).toBe(true); + }); + + // tokenId #0 is updated in this test + it("should update tokenURI", async () => { + await sendAndConfirmTransaction({ + transaction: updateTokenURI({ + contract, + newMetadata: { name: "Test1 Updated" }, + tokenId: 0n, + }), + account: TEST_ACCOUNT_A, + }); + const nft = await getNFT({ contract, tokenId: 0n }); + expect(nft.metadata.name).toBe("Test1 Updated"); + }); + + it("should mint with `nft` being declared as a string", async () => { + await sendAndConfirmTransaction({ + transaction: mintTo({ + contract, + nft: TEST_CONTRACT_URI, + to: TEST_ACCOUNT_A.address, + supply: 1n, + }), + account: TEST_ACCOUNT_A, + }); + + const tokenUri = await uri({ contract, tokenId: 2n }); + expect(tokenUri).toBe(TEST_CONTRACT_URI); + }); + + it("`isMintAdditionalSupplyToSupported` should work with our Edition contracts", async () => { + const abi = await resolveContractAbi(contract); + const selectors = abi + .filter((f) => f.type === "function") + .map((f) => toFunctionSelector(f)); + expect(isMintAdditionalSupplyToSupported(selectors)).toBe(true); + }); + + it("should mint multiple tokens in one tx", async () => { + await sendAndConfirmTransaction({ + account: TEST_ACCOUNT_A, + transaction: mintToBatch({ + contract, + to: TEST_ACCOUNT_C.address, + nfts: [ + { metadata: { name: "batch token 0" }, supply: 1n }, + { metadata: { name: "batch token 1" }, supply: 2n }, + { metadata: { name: "batch token 2" }, supply: 3n }, + ], + }), + }); + + const nfts = await getNFTs({ contract }); + expect(nfts).toStrictEqual([ + { + // Updated tokenURI from the test above + metadata: { name: "Test1 Updated" }, + owner: null, + id: 0n, + tokenURI: "ipfs://QmTSyt6YgoFtH8yhWgevC22BxjyrkCKuzdk86nqQJCwrV9/0", + type: "ERC1155", + supply: 15n, + }, + { + metadata: { name: "Test NFT 2" }, + owner: null, + id: 1n, + tokenURI: "ipfs://QmV6gsfzdiMRtpnh8ay3CgutStVbes7qoF4DKpYE64h8hT/0", + type: "ERC1155", + supply: 5n, + }, + { + metadata: { + name: "tw-contract-name", + symbol: "tw-contract-symbol", + description: "tw-contract-description", + }, + owner: null, + id: 2n, + // Minted using URI from the test above + tokenURI: + "ipfs://bafybeiewg2e3vehsb5pb34xwk25eyyfwlvajzmgz3rtdrvn3upsxnsbhzi/contractUri.json", + type: "ERC1155", + supply: 1n, + }, + { + metadata: { name: "batch token 0" }, + owner: null, + id: 3n, + tokenURI: "ipfs://QmPSQhC2J6Wig4pH1Lt5th19FM58J5oukhfLfpc9L1i39Q/0", + type: "ERC1155", + supply: 1n, + }, + { + metadata: { name: "batch token 1" }, + owner: null, + id: 4n, + tokenURI: "ipfs://QmWRQwLBAeq6Wr65Yj7A4aeYqMD1C7Hs1moz15ncS6EhGu/0", + type: "ERC1155", + supply: 2n, + }, + { + metadata: { name: "batch token 2" }, + owner: null, + id: 5n, + tokenURI: "ipfs://QmTg1wxKGvdZR4NrdkYZGcfB5YYaBz75DH83td5RwprMRP/0", + type: "ERC1155", + supply: 3n, + }, + ]); + }); + + it("getOwnedTokenIds should work", async () => { + const ownedTokenIds = await getOwnedTokenIds({ + contract, + address: TEST_ACCOUNT_C.address, + }); + expect(ownedTokenIds).toStrictEqual([ + { tokenId: 3n, balance: 1n }, + { tokenId: 4n, balance: 2n }, + { tokenId: 5n, balance: 3n }, + ]); + }); + + it("should mint multiple ADDITIONAL tokens in one tx", async () => { + await sendAndConfirmTransaction({ + account: TEST_ACCOUNT_A, + transaction: mintAdditionalSupplyToBatch({ + contract, + nfts: [ + { tokenId: 3n, supply: 99n, to: TEST_ACCOUNT_C.address }, + { tokenId: 4n, supply: 94n, to: TEST_ACCOUNT_C.address }, + { tokenId: 5n, supply: 97n, to: TEST_ACCOUNT_C.address }, + { tokenId: 3n, supply: 4n, to: TEST_ACCOUNT_C.address }, + ], + }), + }); + + const ownedTokenIds = await getOwnedTokenIds({ + contract, + address: TEST_ACCOUNT_C.address, + }); + + expect(ownedTokenIds).toStrictEqual([ + { tokenId: 3n, balance: 104n }, + { tokenId: 4n, balance: 96n }, + { tokenId: 5n, balance: 100n }, + ]); + }); }); diff --git a/packages/thirdweb/src/extensions/erc1155/write/lazyMint.test.ts b/packages/thirdweb/src/extensions/erc1155/write/lazyMint.test.ts index a1e64b1d47c..5de433448fa 100644 --- a/packages/thirdweb/src/extensions/erc1155/write/lazyMint.test.ts +++ b/packages/thirdweb/src/extensions/erc1155/write/lazyMint.test.ts @@ -1,32 +1,12 @@ 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 { DROP1155_CONTRACT } from "~test/test-contracts.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 abi = await resolveContractAbi(DROP1155_CONTRACT); const selectors = abi .filter((f) => f.type === "function") .map((f) => toFunctionSelector(f)); diff --git a/packages/thirdweb/src/extensions/erc1155/write/mintAdditionalSupplyToBatch.test.ts b/packages/thirdweb/src/extensions/erc1155/write/mintAdditionalSupplyToBatch.test.ts index 841b7680825..0cba2b0c342 100644 --- a/packages/thirdweb/src/extensions/erc1155/write/mintAdditionalSupplyToBatch.test.ts +++ b/packages/thirdweb/src/extensions/erc1155/write/mintAdditionalSupplyToBatch.test.ts @@ -1,117 +1,21 @@ -import { type Abi, toFunctionSelector } from "viem"; +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 { resolveContractAbi } from "../../../contract/actions/resolve-abi.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 { getNFTs } from "../read/getNFTs.js"; -import { isMintAdditionalSupplyToSupported } from "./mintAdditionalSupplyTo.js"; -import { - mintAdditionalSupplyToBatch, - optimizeMintBatchContent, -} from "./mintAdditionalSupplyToBatch.js"; -import { mintToBatch } from "./mintToBatch.js"; +import { optimizeMintBatchContent } from "./mintAdditionalSupplyToBatch.js"; -const chain = ANVIL_CHAIN; -const client = TEST_CLIENT; const account = TEST_ACCOUNT_C; -describe.runIf(process.env.TW_SECRET_KEY)( - "ERC1155 Edition: mintToBatch", - () => { - it("should optimize the mint content", () => { - expect( - optimizeMintBatchContent([ - { tokenId: 0n, supply: 99n, to: account.address }, - { tokenId: 1n, supply: 49n, to: account.address }, - { tokenId: 1n, supply: 51n, to: account.address }, - ]), - ).toStrictEqual([ +describe("ERC1155 Edition: mintToBatch", () => { + it("should optimize the mint content", () => { + expect( + optimizeMintBatchContent([ { tokenId: 0n, supply: 99n, to: account.address }, - { tokenId: 1n, supply: 100n, to: account.address }, - ]); - }); - - it("should mint multiple tokens in one tx", async () => { - const contract = getContract({ - chain, - client, - address: await deployERC1155Contract({ - chain, - client, - account, - type: "TokenERC1155", - params: { - name: "edition", - contractURI: TEST_CONTRACT_URI, - }, - }), - }); - - // `isMintAdditionalSupplyToSupported` should work with our Edition contracts - const abi = await resolveContractAbi(contract); - const selectors = abi - .filter((f) => f.type === "function") - .map((f) => toFunctionSelector(f)); - expect(isMintAdditionalSupplyToSupported(selectors)).toBe(true); - - await sendAndConfirmTransaction({ - account, - transaction: mintToBatch({ - contract, - to: account.address, - nfts: [ - { metadata: { name: "token 0" }, supply: 1n }, - { metadata: { name: "token 1" }, supply: 2n }, - { metadata: { name: "token 2" }, supply: 3n }, - ], - }), - }); - - await sendAndConfirmTransaction({ - account, - transaction: mintAdditionalSupplyToBatch({ - contract, - nfts: [ - { tokenId: 0n, supply: 99n, to: account.address }, - { tokenId: 1n, supply: 94n, to: account.address }, - { tokenId: 2n, supply: 97n, to: account.address }, - { tokenId: 1n, supply: 4n, to: account.address }, - ], - }), - }); - - const nfts = await getNFTs({ contract }); - expect(nfts).toStrictEqual([ - { - metadata: { name: "token 0" }, - owner: null, - id: 0n, - tokenURI: "ipfs://QmPZ6LpGqMuFbHKTXrNW1NRNLHf1nrxS4dtoFqdZZTKvPX/0", - type: "ERC1155", - supply: 100n, - }, - { - metadata: { name: "token 1" }, - owner: null, - id: 1n, - tokenURI: "ipfs://QmRFPyc3yEYxR4pQxwyTQWTine51TxWCoD6nzJWR3eX45b/0", - type: "ERC1155", - supply: 100n, - }, - { - metadata: { name: "token 2" }, - owner: null, - id: 2n, - tokenURI: "ipfs://QmesQiRLHCgqWZM2GFCs7Nb7rr2S72hU1BVQc7xiTyKZtT/0", - type: "ERC1155", - supply: 100n, - }, - ]); - }); - }, -); + { tokenId: 1n, supply: 49n, to: account.address }, + { tokenId: 1n, supply: 51n, to: account.address }, + ]), + ).toStrictEqual([ + { tokenId: 0n, supply: 99n, to: account.address }, + { tokenId: 1n, supply: 100n, to: account.address }, + ]); + }); +}); diff --git a/packages/thirdweb/src/extensions/erc1155/write/mintTo.test.ts b/packages/thirdweb/src/extensions/erc1155/write/mintTo.test.ts deleted file mode 100644 index 07aa3b44835..00000000000 --- a/packages/thirdweb/src/extensions/erc1155/write/mintTo.test.ts +++ /dev/null @@ -1,42 +0,0 @@ -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/erc1155/write/mintToBatch.test.ts b/packages/thirdweb/src/extensions/erc1155/write/mintToBatch.test.ts deleted file mode 100644 index 64c9bd7f077..00000000000 --- a/packages/thirdweb/src/extensions/erc1155/write/mintToBatch.test.ts +++ /dev/null @@ -1,77 +0,0 @@ -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 { getNFTs } from "../read/getNFTs.js"; -import { mintToBatch } from "./mintToBatch.js"; - -const chain = ANVIL_CHAIN; -const client = TEST_CLIENT; -const account = TEST_ACCOUNT_C; - -describe.runIf(process.env.TW_SECRET_KEY)( - "ERC1155 Edition: mintToBatch", - () => { - it("should mint multiple tokens in one tx", async () => { - const contract = getContract({ - chain, - client, - address: await deployERC1155Contract({ - chain, - client, - account, - type: "TokenERC1155", - params: { - name: "edition", - contractURI: TEST_CONTRACT_URI, - }, - }), - }); - - await sendAndConfirmTransaction({ - account, - transaction: mintToBatch({ - contract, - to: account.address, - nfts: [ - { metadata: { name: "token 0" }, supply: 1n }, - { metadata: { name: "token 1" }, supply: 2n }, - { metadata: { name: "token 2" }, supply: 3n }, - ], - }), - }); - - const nfts = await getNFTs({ contract }); - expect(nfts).toStrictEqual([ - { - metadata: { name: "token 0" }, - owner: null, - id: 0n, - tokenURI: "ipfs://QmPZ6LpGqMuFbHKTXrNW1NRNLHf1nrxS4dtoFqdZZTKvPX/0", - type: "ERC1155", - supply: 1n, - }, - { - metadata: { name: "token 1" }, - owner: null, - id: 1n, - tokenURI: "ipfs://QmRFPyc3yEYxR4pQxwyTQWTine51TxWCoD6nzJWR3eX45b/0", - type: "ERC1155", - supply: 2n, - }, - { - metadata: { name: "token 2" }, - owner: null, - id: 2n, - tokenURI: "ipfs://QmesQiRLHCgqWZM2GFCs7Nb7rr2S72hU1BVQc7xiTyKZtT/0", - type: "ERC1155", - supply: 3n, - }, - ]); - }); - }, -); diff --git a/packages/thirdweb/src/extensions/erc1155/write/updateTokenURI.test.ts b/packages/thirdweb/src/extensions/erc1155/write/updateTokenURI.test.ts deleted file mode 100644 index c32b824f5ed..00000000000 --- a/packages/thirdweb/src/extensions/erc1155/write/updateTokenURI.test.ts +++ /dev/null @@ -1,54 +0,0 @@ -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_A } 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 { getNFT } from "../read/getNFT.js"; -import { mintTo } from "./mintTo.js"; -import { updateTokenURI } from "./updateTokenURI.js"; - -const client = TEST_CLIENT; -const chain = ANVIL_CHAIN; -const account = TEST_ACCOUNT_A; - -describe.runIf(process.env.TW_SECRET_KEY)("Edition: Update token uri", () => { - it("should update token uri", async () => { - const address = await deployERC1155Contract({ - client, - chain, - account, - type: "TokenERC1155", - params: { - name: "Edition", - contractURI: TEST_CONTRACT_URI, - }, - }); - const contract = getContract({ - address, - client, - chain, - }); - await sendAndConfirmTransaction({ - transaction: mintTo({ - contract, - nft: { name: "Test1" }, - to: account.address, - supply: 1n, - }), - account, - }); - await sendAndConfirmTransaction({ - transaction: updateTokenURI({ - contract, - newMetadata: { name: "Test1 Updated" }, - tokenId: 0n, - }), - account, - }); - const nft = await getNFT({ contract, tokenId: 0n }); - expect(nft.metadata.name).toBe("Test1 Updated"); - }); -});