1
+ import { maxUint256 } from "viem" ;
1
2
import { beforeAll , describe , expect , it } from "vitest" ;
2
3
import { ANVIL_CHAIN } from "../../../../test/src/chains.js" ;
3
4
import { TEST_CLIENT } from "../../../../test/src/test-clients.js" ;
@@ -14,6 +15,7 @@ import { sendTransaction } from "../../../transaction/actions/send-transaction.j
14
15
import { toHex } from "../../../utils/encoding/hex.js" ;
15
16
import { deployERC20Contract } from "../../prebuilts/deploy-erc20.js" ;
16
17
import { deployERC1155Contract } from "../../prebuilts/deploy-erc1155.js" ;
18
+ import { getNFT } from "../read/getNFT.js" ;
17
19
import { generateMintSignature , mintWithSignature } from "./sigMint.js" ;
18
20
19
21
// 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", () => {
78
80
account : TEST_ACCOUNT_A ,
79
81
} ) ;
80
82
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" ) ;
81
123
} ) ;
82
124
83
125
it ( "should generate a mint signature with default values" , async ( ) => {
@@ -92,6 +134,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("generateMintSignature1155", () => {
92
134
} ) ;
93
135
94
136
expect ( payload . to ) . toBe ( TEST_ACCOUNT_B . address ) ;
137
+ expect ( payload . tokenId ) . toBe ( maxUint256 ) ;
95
138
expect ( payload . royaltyRecipient ) . toBe ( TEST_ACCOUNT_A . address ) ;
96
139
expect ( payload . royaltyBps ) . toBe ( 0n ) ;
97
140
expect ( payload . primarySaleRecipient ) . toBe ( TEST_ACCOUNT_A . address ) ;
@@ -125,7 +168,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("generateMintSignature1155", () => {
125
168
royaltyRecipient : TEST_ACCOUNT_B . address ,
126
169
royaltyBps : 500 ,
127
170
primarySaleRecipient : TEST_ACCOUNT_A . address ,
128
- metadata : "https://example.com/token" ,
171
+ tokenId : 0n ,
129
172
pricePerToken : "0.2" ,
130
173
currency : erc20TokenContract . address ,
131
174
validityStartTimestamp : new Date ( 1635724800 ) ,
@@ -137,10 +180,11 @@ describe.runIf(process.env.TW_SECRET_KEY)("generateMintSignature1155", () => {
137
180
} ) ;
138
181
139
182
expect ( payload . to ) . toBe ( TEST_ACCOUNT_B . address ) ;
183
+ expect ( payload . tokenId ) . toBe ( 0n ) ;
140
184
expect ( payload . royaltyRecipient ) . toBe ( TEST_ACCOUNT_B . address ) ;
141
185
expect ( payload . royaltyBps ) . toBe ( 500n ) ;
142
186
expect ( payload . primarySaleRecipient ) . toBe ( TEST_ACCOUNT_A . address ) ;
143
- expect ( payload . uri ) . toBe ( "https://example.com/token " ) ;
187
+ expect ( payload . uri ) . toBe ( "" ) ;
144
188
expect ( payload . pricePerToken ) . toBe ( 200000000000000000n ) ;
145
189
expect ( payload . quantity ) . toBe ( 10n ) ;
146
190
expect ( payload . currency ) . toBe ( erc20TokenContract . address ) ;
0 commit comments