@@ -277,14 +277,19 @@ describe('erc7710RedeemDelegationAction', () => {
277277
278278 const sendTransaction = stub ( walletClient , 'sendTransaction' ) ;
279279
280+ const expectedDelegationManager = randomAddress ( ) ;
281+ overrideDeployedEnvironment ( chain . id , '1.3.0' , {
282+ DelegationManager : expectedDelegationManager ,
283+ } as any as SmartAccountsEnvironment ) ;
284+
280285 const args : SendTransactionWithDelegationParameters = {
281286 account,
282287 chain,
283288 to : randomAddress ( ) ,
284289 value : 0n ,
285290 data : randomBytes ( 128 ) ,
286291 permissionsContext : randomBytes ( 128 ) ,
287- delegationManager : randomAddress ( ) ,
292+ delegationManager : expectedDelegationManager ,
288293 } ;
289294
290295 await extendedWalletClient . sendTransactionWithDelegation ( args ) ;
@@ -349,14 +354,19 @@ describe('erc7710RedeemDelegationAction', () => {
349354
350355 const sendTransaction = stub ( walletClient , 'sendTransaction' ) ;
351356
357+ const expectedDelegationManager = randomAddress ( ) ;
358+ overrideDeployedEnvironment ( chain . id , '1.3.0' , {
359+ DelegationManager : expectedDelegationManager ,
360+ } as any as SmartAccountsEnvironment ) ;
361+
352362 const args : SendTransactionWithDelegationParameters = {
353363 account,
354364 chain,
355365 to : randomAddress ( ) ,
356366 value : 100n ,
357367 data : randomBytes ( 128 ) ,
358368 permissionsContext : randomBytes ( 128 ) ,
359- delegationManager : randomAddress ( ) ,
369+ delegationManager : expectedDelegationManager ,
360370 } ;
361371
362372 await extendedWalletClient . sendTransactionWithDelegation ( args ) ;
@@ -371,5 +381,53 @@ describe('erc7710RedeemDelegationAction', () => {
371381 undefined ,
372382 ) ;
373383 } ) ;
384+
385+ it ( 'should throw an error when DelegationManager does not match expected address for the chain' , async ( ) => {
386+ const extendedWalletClient = walletClient . extend ( erc7710WalletActions ( ) ) ;
387+
388+ const expectedDelegationManager = randomAddress ( ) ;
389+ const invalidDelegationManager = randomAddress ( ) ;
390+
391+ overrideDeployedEnvironment ( chain . id , '1.3.0' , {
392+ DelegationManager : expectedDelegationManager ,
393+ } as any as SmartAccountsEnvironment ) ;
394+
395+ await expect (
396+ extendedWalletClient . sendTransactionWithDelegation ( {
397+ account,
398+ chain,
399+ to : randomAddress ( ) ,
400+ value : 0n ,
401+ data : randomBytes ( 128 ) ,
402+ permissionsContext : randomBytes ( 128 ) ,
403+ delegationManager : invalidDelegationManager ,
404+ } ) ,
405+ ) . rejects . toThrow (
406+ `Invalid DelegationManager: expected ${ expectedDelegationManager } for chain ${ chain . id } , but got ${ invalidDelegationManager } ` ,
407+ ) ;
408+ } ) ;
409+
410+ it ( 'should throw an error when chain ID is not set' , async ( ) => {
411+ const walletClientWithoutChain = createWalletClient ( {
412+ account,
413+ transport : custom ( { request : async ( ) => '0x' } ) ,
414+ } ) ;
415+
416+ const extendedWalletClient = walletClientWithoutChain . extend (
417+ erc7710WalletActions ( ) ,
418+ ) ;
419+
420+ await expect (
421+ extendedWalletClient . sendTransactionWithDelegation ( {
422+ account,
423+ chain : undefined ,
424+ to : randomAddress ( ) ,
425+ value : 0n ,
426+ data : randomBytes ( 128 ) ,
427+ permissionsContext : randomBytes ( 128 ) ,
428+ delegationManager : randomAddress ( ) ,
429+ } ) ,
430+ ) . rejects . toThrow ( 'Chain ID is not set' ) ;
431+ } ) ;
374432 } ) ;
375433} ) ;
0 commit comments