1+ import { maxUint256 } from "viem" ;
12import { beforeAll , describe , expect , it } from "vitest" ;
23import { ANVIL_CHAIN } from "../../../../test/src/chains.js" ;
34import { TEST_CLIENT } from "../../../../test/src/test-clients.js" ;
@@ -14,6 +15,7 @@ import { sendTransaction } from "../../../transaction/actions/send-transaction.j
1415import { toHex } from "../../../utils/encoding/hex.js" ;
1516import { deployERC20Contract } from "../../prebuilts/deploy-erc20.js" ;
1617import { deployERC1155Contract } from "../../prebuilts/deploy-erc1155.js" ;
18+ import { getNFT } from "../read/getNFT.js" ;
1719import { generateMintSignature , mintWithSignature } from "./sigMint.js" ;
1820
1921// skip this test suite if there is no secret key available to test with
@@ -78,6 +80,46 @@ describe.runIf(process.env.TW_SECRET_KEY)("generateMintSignature1155", () => {
7880 account : TEST_ACCOUNT_A ,
7981 } ) ;
8082 expect ( transactionHash . length ) . toBe ( 66 ) ;
83+ const nft = await getNFT ( {
84+ contract : erc1155Contract ,
85+ tokenId : 0n ,
86+ } ) ;
87+ if ( nft . type !== "ERC1155" ) throw new Error ( "Expected ERC1155 NFT" ) ;
88+ expect ( nft . id ) . toBe ( 0n ) ;
89+ expect ( nft . supply ) . toBe ( 10n ) ;
90+ expect ( nft . metadata . name ) . toBe ( "My NFT" ) ;
91+ expect ( nft . metadata . description ) . toBe ( "This is my NFT" ) ;
92+ } ) ;
93+
94+ it ( "should mint additional supply" , async ( ) => {
95+ const { payload, signature } = await generateMintSignature ( {
96+ mintRequest : {
97+ to : TEST_ACCOUNT_B . address ,
98+ quantity : 5n ,
99+ tokenId : 0n ,
100+ } ,
101+ account : TEST_ACCOUNT_A ,
102+ contract : erc1155Contract ,
103+ } ) ;
104+ const transaction = mintWithSignature ( {
105+ contract : erc1155Contract ,
106+ payload,
107+ signature,
108+ } ) ;
109+ const { transactionHash } = await sendTransaction ( {
110+ transaction,
111+ account : TEST_ACCOUNT_A ,
112+ } ) ;
113+ expect ( transactionHash . length ) . toBe ( 66 ) ;
114+ const nft = await getNFT ( {
115+ contract : erc1155Contract ,
116+ tokenId : 0n ,
117+ } ) ;
118+ if ( nft . type !== "ERC1155" ) throw new Error ( "Expected ERC1155 NFT" ) ;
119+ expect ( nft . id ) . toBe ( 0n ) ;
120+ expect ( nft . supply ) . toBe ( 15n ) ;
121+ expect ( nft . metadata . name ) . toBe ( "My NFT" ) ;
122+ expect ( nft . metadata . description ) . toBe ( "This is my NFT" ) ;
81123 } ) ;
82124
83125 it ( "should generate a mint signature with default values" , async ( ) => {
@@ -92,6 +134,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("generateMintSignature1155", () => {
92134 } ) ;
93135
94136 expect ( payload . to ) . toBe ( TEST_ACCOUNT_B . address ) ;
137+ expect ( payload . tokenId ) . toBe ( maxUint256 ) ;
95138 expect ( payload . royaltyRecipient ) . toBe ( TEST_ACCOUNT_A . address ) ;
96139 expect ( payload . royaltyBps ) . toBe ( 0n ) ;
97140 expect ( payload . primarySaleRecipient ) . toBe ( TEST_ACCOUNT_A . address ) ;
@@ -125,7 +168,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("generateMintSignature1155", () => {
125168 royaltyRecipient : TEST_ACCOUNT_B . address ,
126169 royaltyBps : 500 ,
127170 primarySaleRecipient : TEST_ACCOUNT_A . address ,
128- metadata : "https://example.com/token" ,
171+ tokenId : 0n ,
129172 pricePerToken : "0.2" ,
130173 currency : erc20TokenContract . address ,
131174 validityStartTimestamp : new Date ( 1635724800 ) ,
@@ -137,10 +180,11 @@ describe.runIf(process.env.TW_SECRET_KEY)("generateMintSignature1155", () => {
137180 } ) ;
138181
139182 expect ( payload . to ) . toBe ( TEST_ACCOUNT_B . address ) ;
183+ expect ( payload . tokenId ) . toBe ( 0n ) ;
140184 expect ( payload . royaltyRecipient ) . toBe ( TEST_ACCOUNT_B . address ) ;
141185 expect ( payload . royaltyBps ) . toBe ( 500n ) ;
142186 expect ( payload . primarySaleRecipient ) . toBe ( TEST_ACCOUNT_A . address ) ;
143- expect ( payload . uri ) . toBe ( "https://example.com/token " ) ;
187+ expect ( payload . uri ) . toBe ( "" ) ;
144188 expect ( payload . pricePerToken ) . toBe ( 200000000000000000n ) ;
145189 expect ( payload . quantity ) . toBe ( 10n ) ;
146190 expect ( payload . currency ) . toBe ( erc20TokenContract . address ) ;
0 commit comments