|
| 1 | +import { describe, expect, it } from "vitest"; |
| 2 | +import { ANVIL_CHAIN } from "~test/chains.js"; |
| 3 | +import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js"; |
| 4 | +import { TEST_CLIENT } from "~test/test-clients.js"; |
| 5 | +import { TEST_ACCOUNT_C } from "~test/test-wallets.js"; |
| 6 | +import { getContract } from "../../../contract/contract.js"; |
| 7 | +import { deployERC1155Contract } from "../../../extensions/prebuilts/deploy-erc1155.js"; |
| 8 | +import { sendAndConfirmTransaction } from "../../../transaction/actions/send-and-confirm-transaction.js"; |
| 9 | +import { getNFTs } from "../read/getNFTs.js"; |
| 10 | +import { mintAdditionalSupplyToBatch } from "./mintAdditionalSupplyToBatch.js"; |
| 11 | +import { mintToBatch } from "./mintToBatch.js"; |
| 12 | + |
| 13 | +const chain = ANVIL_CHAIN; |
| 14 | +const client = TEST_CLIENT; |
| 15 | +const account = TEST_ACCOUNT_C; |
| 16 | + |
| 17 | +describe("ERC1155 Edition: mintToBatch", () => { |
| 18 | + it("should mint multiple tokens in one tx", async () => { |
| 19 | + const contract = getContract({ |
| 20 | + chain, |
| 21 | + client, |
| 22 | + address: await deployERC1155Contract({ |
| 23 | + chain, |
| 24 | + client, |
| 25 | + account, |
| 26 | + type: "TokenERC1155", |
| 27 | + params: { |
| 28 | + name: "edition", |
| 29 | + contractURI: TEST_CONTRACT_URI, |
| 30 | + }, |
| 31 | + }), |
| 32 | + }); |
| 33 | + |
| 34 | + await sendAndConfirmTransaction({ |
| 35 | + account, |
| 36 | + transaction: mintToBatch({ |
| 37 | + contract, |
| 38 | + to: account.address, |
| 39 | + nfts: [ |
| 40 | + { metadata: { name: "token 0" }, supply: 1n }, |
| 41 | + { metadata: { name: "token 1" }, supply: 2n }, |
| 42 | + { metadata: { name: "token 2" }, supply: 3n }, |
| 43 | + ], |
| 44 | + }), |
| 45 | + }); |
| 46 | + |
| 47 | + await sendAndConfirmTransaction({ |
| 48 | + account, |
| 49 | + transaction: mintAdditionalSupplyToBatch({ |
| 50 | + contract, |
| 51 | + nfts: [ |
| 52 | + { tokenId: 0n, supply: 99n, to: account.address }, |
| 53 | + { tokenId: 1n, supply: 98n, to: account.address }, |
| 54 | + { tokenId: 2n, supply: 97n, to: account.address }, |
| 55 | + ], |
| 56 | + }), |
| 57 | + }); |
| 58 | + |
| 59 | + const nfts = await getNFTs({ contract }); |
| 60 | + expect(nfts).toStrictEqual([ |
| 61 | + { |
| 62 | + metadata: { name: "token 0" }, |
| 63 | + owner: null, |
| 64 | + id: 0n, |
| 65 | + tokenURI: "ipfs://QmPZ6LpGqMuFbHKTXrNW1NRNLHf1nrxS4dtoFqdZZTKvPX/0", |
| 66 | + type: "ERC1155", |
| 67 | + supply: 100n, |
| 68 | + }, |
| 69 | + { |
| 70 | + metadata: { name: "token 1" }, |
| 71 | + owner: null, |
| 72 | + id: 1n, |
| 73 | + tokenURI: "ipfs://QmRFPyc3yEYxR4pQxwyTQWTine51TxWCoD6nzJWR3eX45b/0", |
| 74 | + type: "ERC1155", |
| 75 | + supply: 100n, |
| 76 | + }, |
| 77 | + { |
| 78 | + metadata: { name: "token 2" }, |
| 79 | + owner: null, |
| 80 | + id: 2n, |
| 81 | + tokenURI: "ipfs://QmesQiRLHCgqWZM2GFCs7Nb7rr2S72hU1BVQc7xiTyKZtT/0", |
| 82 | + type: "ERC1155", |
| 83 | + supply: 100n, |
| 84 | + }, |
| 85 | + ]); |
| 86 | + }); |
| 87 | +}); |
0 commit comments