@@ -189,5 +189,64 @@ describe("nftClient Functions", () => {
189189 } ) ;
190190 expect ( tokenURI ) . to . equal ( updatedMetadata ) ;
191191 } ) ;
192+
193+ it ( "updates URI for multiple tokens" , async ( ) => {
194+ const erc20Client = new ERC20Client ( publicClient , walletClient , erc20Address [ aeneid ] ) ;
195+ const txHash = await erc20Client . approve ( spgNftContract , maxUint256 ) ;
196+ await publicClient . waitForTransactionReceipt ( { hash : txHash } ) ;
197+
198+ const tokenURIs = [
199+ "ipfs://QmTest/1" ,
200+ "iipfs://QmTest/2" ,
201+ "ipfs://QmTest/3"
202+ ] ;
203+
204+ for ( let i = 0 ; i < tokenURIs . length ; i ++ ) {
205+ const tokenId = await mintBySpg ( spgNftContract , tokenURIs [ i ] ) ;
206+ expect ( tokenId ) . to . not . be . undefined ;
207+
208+ const updatedMetadata = "ipfs://QmUpdated/metadata.json" ;
209+ const result = await client . nftClient . setTokenURI ( {
210+ tokenId : tokenId ! ,
211+ tokenURI : updatedMetadata ,
212+ spgNftContract,
213+ txOptions : {
214+ waitForTransaction : true ,
215+ } ,
216+ } ) ;
217+
218+ expect ( result . txHash ) . to . be . a ( "string" ) . and . not . empty ;
219+
220+ const tokenURI = await client . nftClient . getTokenURI ( {
221+ tokenId : tokenId ! ,
222+ spgNftContract,
223+ } ) ;
224+ expect ( tokenURI ) . to . equal ( updatedMetadata ) ;
225+ }
226+ } ) ;
192227 } ) ;
228+
229+ describe ( "Error Cases" , ( ) => {
230+ it ( "fails with invalid token ID" , async ( ) => {
231+ const erc20Client = new ERC20Client ( publicClient , walletClient , erc20Address [ aeneid ] ) ;
232+ const txHash = await erc20Client . approve ( spgNftContract , maxUint256 ) ;
233+ await publicClient . waitForTransactionReceipt ( { hash : txHash } ) ;
234+
235+ const invalidTokenId = 999999999999999n ;
236+ const updatedMetadata = "ipfs://QmUpdated/metadata.json" ;
237+
238+ await expect (
239+ client . nftClient . setTokenURI ( {
240+ tokenId : invalidTokenId ! ,
241+ tokenURI : updatedMetadata ,
242+ spgNftContract,
243+ txOptions : {
244+ waitForTransaction : true ,
245+ } ,
246+ } )
247+ ) . to . be . rejectedWith ( "Failed to set token URI" ) ;
248+ } ) ;
249+ } )
193250} ) ;
251+
252+
0 commit comments