@@ -4,20 +4,20 @@ import * as sinon from "sinon";
44import { IPAccountClient } from "../../../src/resources/ipAccount" ;
55import { IPAccountExecuteRequest , IPAccountExecuteWithSigRequest } from "../../../src" ;
66import * as utils from "../../../src/utils/utils" ;
7- import { Account , PublicClient , WalletClient , zeroAddress } from "viem" ;
8- const { IpAccountImplClient } = require ( "../../../src/abi/generated" ) ;
7+ import { Account , PublicClient , toHex , WalletClient , zeroAddress } from "viem" ;
8+ import { aeneid , ipId , txHash } from "../mockData" ;
9+ import { IpAccountImplClient } from "../../../src/abi/generated" ;
910
1011describe ( "Test IPAccountClient" , ( ) => {
1112 let ipAccountClient : IPAccountClient ;
1213 let rpcMock : PublicClient ;
1314 let walletMock : WalletClient ;
14- const txHash = "0x129f7dd802200f096221dd89d5b086e4bd3ad6eafb378a0c75e3b04fc375f997" ;
1515 beforeEach ( ( ) => {
1616 rpcMock = createMock < PublicClient > ( ) ;
1717 walletMock = createMock < WalletClient > ( ) ;
1818 const accountMock = createMock < Account > ( ) ;
1919 walletMock . account = accountMock ;
20- ipAccountClient = new IPAccountClient ( rpcMock , walletMock ) ;
20+ ipAccountClient = new IPAccountClient ( rpcMock , walletMock , aeneid ) ;
2121 sinon . stub ( IpAccountImplClient . prototype , "execute" ) . resolves ( txHash ) ;
2222 sinon . stub ( IpAccountImplClient . prototype , "executeEncode" ) . returns ( { data : "0x" , to : "0x" } ) ;
2323 sinon . stub ( IpAccountImplClient . prototype , "executeWithSig" ) . resolves ( txHash ) ;
@@ -195,4 +195,26 @@ describe("Test IPAccountClient", () => {
195195 expect ( token ) . to . deep . equal ( { chainId : 1513n , tokenContract : zeroAddress , tokenId : 1n } ) ;
196196 } ) ;
197197 } ) ;
198+
199+ describe ( "Test setIpMetadata" , ( ) => {
200+ it ( "should throw error when call setIpMetadata given wrong ipId" , async ( ) => {
201+ try {
202+ await ipAccountClient . setIpMetadata ( {
203+ ipId : "0x" ,
204+ metadataURI : "https://example.com" ,
205+ metadataHash : toHex ( "test" , { size : 32 } ) ,
206+ } ) ;
207+ } catch ( err ) {
208+ expect ( ( err as Error ) . message ) . equal ( "Failed to set the IP metadata: Invalid address: 0x." ) ;
209+ }
210+ } ) ;
211+ it ( "should return txHash when call setIpMetadata successfully" , async ( ) => {
212+ const result = await ipAccountClient . setIpMetadata ( {
213+ ipId : ipId ,
214+ metadataURI : "https://example.com" ,
215+ metadataHash : toHex ( "test" , { size : 32 } ) ,
216+ } ) ;
217+ expect ( result ) . to . equal ( txHash ) ;
218+ } ) ;
219+ } ) ;
198220} ) ;
0 commit comments