@@ -24,7 +24,13 @@ import {
2424 HypModuleArgs ,
2525 TxReceipt ,
2626} from '@hyperlane-xyz/provider-sdk/module' ;
27- import { Address , Logger , rootLogger } from '@hyperlane-xyz/utils' ;
27+ import {
28+ Address ,
29+ Logger ,
30+ eqAddress ,
31+ isEmptyAddress ,
32+ rootLogger ,
33+ } from '@hyperlane-xyz/utils' ;
2834
2935import { AltVMCoreReader } from './AltVMCoreReader.js' ;
3036import { createHookWriter } from './hook/hook-writer.js' ;
@@ -289,6 +295,10 @@ export class AltVMCoreModule implements HypModule<CoreModuleType> {
289295 const updateTransactions : AnnotatedTx [ ] = [ ] ;
290296
291297 const actualDefaultIsmConfig = actualConfig . defaultIsm ;
298+ const actualIsmAddress =
299+ typeof actualDefaultIsmConfig === 'string'
300+ ? actualDefaultIsmConfig
301+ : actualDefaultIsmConfig . address ;
292302
293303 // Try to update (may also deploy) Ism with the expected config
294304 const { deployedIsm, ismUpdateTxs } = await this . deployOrUpdateIsm (
@@ -300,11 +310,11 @@ export class AltVMCoreModule implements HypModule<CoreModuleType> {
300310 updateTransactions . push ( ...ismUpdateTxs ) ;
301311 }
302312
303- const newIsmDeployed = actualDefaultIsmConfig . address !== deployedIsm ;
313+ const newIsmDeployed = ! eqAddress ( actualIsmAddress , deployedIsm ) ;
304314 if ( newIsmDeployed ) {
305315 const { mailbox } = this . serialize ( ) ;
306316 updateTransactions . push ( {
307- annotation : `Updating default ISM of Mailbox from ${ actualDefaultIsmConfig . address } to ${ deployedIsm } ` ,
317+ annotation : `Updating default ISM of Mailbox from ${ actualIsmAddress } to ${ deployedIsm } ` ,
308318 ...( await this . signer . getSetDefaultIsmTransaction ( {
309319 signer : actualConfig . owner ,
310320 mailboxAddress : mailbox ,
@@ -322,7 +332,7 @@ export class AltVMCoreModule implements HypModule<CoreModuleType> {
322332 * @returns Object with deployedIsm address, and update Transactions
323333 */
324334 public async deployOrUpdateIsm (
325- actualDefaultIsmConfig : DerivedIsmConfig ,
335+ actualDefaultIsmConfig : DerivedIsmConfig | string ,
326336 expectDefaultIsmConfig : IsmConfig | string ,
327337 ) : Promise < {
328338 deployedIsm : Address ;
@@ -343,15 +353,29 @@ export class AltVMCoreModule implements HypModule<CoreModuleType> {
343353 this . signer ,
344354 ) ;
345355
346- // Read actual ISM state
347- const actualArtifact = await writer . read ( actualDefaultIsmConfig . address ) ;
348-
349356 // Convert expected config to artifact format
350357 const expectedArtifact = ismConfigToArtifact (
351358 expectDefaultIsmConfig ,
352359 this . chainLookup ,
353360 ) ;
354361
362+ // No existing ISM on chain — deploy the expected one directly
363+ const actualIsmAddress =
364+ typeof actualDefaultIsmConfig === 'string'
365+ ? actualDefaultIsmConfig
366+ : actualDefaultIsmConfig . address ;
367+
368+ if ( isEmptyAddress ( actualIsmAddress ) ) {
369+ const [ deployed ] = await writer . create ( expectedArtifact ) ;
370+ return {
371+ deployedIsm : deployed . deployed . address ,
372+ ismUpdateTxs : [ ] ,
373+ } ;
374+ }
375+
376+ // Read actual ISM state
377+ const actualArtifact = await writer . read ( actualIsmAddress ) ;
378+
355379 this . logger . info (
356380 `Comparing target ISM config with ${ this . args . chain } chain` ,
357381 ) ;
@@ -391,6 +415,10 @@ export class AltVMCoreModule implements HypModule<CoreModuleType> {
391415 const updateTransactions : AnnotatedTx [ ] = [ ] ;
392416
393417 const actualDefaultHookConfig = actualConfig . defaultHook ;
418+ const actualDefaultHookAddress =
419+ typeof actualDefaultHookConfig === 'string'
420+ ? actualDefaultHookConfig
421+ : actualDefaultHookConfig . address ;
394422
395423 // Try to update (may also deploy) Hook with the expected config
396424 const { deployedHook, hookUpdateTxs } = await this . deployOrUpdateHook (
@@ -402,11 +430,11 @@ export class AltVMCoreModule implements HypModule<CoreModuleType> {
402430 updateTransactions . push ( ...hookUpdateTxs ) ;
403431 }
404432
405- const newHookDeployed = actualDefaultHookConfig . address !== deployedHook ;
433+ const newHookDeployed = ! eqAddress ( actualDefaultHookAddress , deployedHook ) ;
406434 if ( newHookDeployed ) {
407435 const { mailbox } = this . serialize ( ) ;
408436 updateTransactions . push ( {
409- annotation : `Updating default Hook of Mailbox from ${ actualDefaultHookConfig . address } to ${ deployedHook } ` ,
437+ annotation : `Updating default Hook of Mailbox from ${ actualDefaultHookAddress } to ${ deployedHook } ` ,
410438 ...( await this . signer . getSetDefaultHookTransaction ( {
411439 signer : actualConfig . owner ,
412440 mailboxAddress : mailbox ,
@@ -432,6 +460,10 @@ export class AltVMCoreModule implements HypModule<CoreModuleType> {
432460 const updateTransactions : AnnotatedTx [ ] = [ ] ;
433461
434462 const actualRequiredHookConfig = actualConfig . requiredHook ;
463+ const actualRequiredHookAddress =
464+ typeof actualRequiredHookConfig === 'string'
465+ ? actualRequiredHookConfig
466+ : actualRequiredHookConfig . address ;
435467
436468 // Try to update (may also deploy) Hook with the expected config
437469 const { deployedHook, hookUpdateTxs } = await this . deployOrUpdateHook (
@@ -443,11 +475,11 @@ export class AltVMCoreModule implements HypModule<CoreModuleType> {
443475 updateTransactions . push ( ...hookUpdateTxs ) ;
444476 }
445477
446- const newHookDeployed = actualRequiredHookConfig . address !== deployedHook ;
478+ const newHookDeployed = ! eqAddress ( actualRequiredHookAddress , deployedHook ) ;
447479 if ( newHookDeployed ) {
448480 const { mailbox } = this . serialize ( ) ;
449481 updateTransactions . push ( {
450- annotation : `Updating required Hook of Mailbox from ${ actualRequiredHookConfig . address } to ${ deployedHook } ` ,
482+ annotation : `Updating required Hook of Mailbox from ${ actualRequiredHookAddress } to ${ deployedHook } ` ,
451483 ...( await this . signer . getSetRequiredHookTransaction ( {
452484 signer : actualConfig . owner ,
453485 mailboxAddress : mailbox ,
@@ -465,7 +497,7 @@ export class AltVMCoreModule implements HypModule<CoreModuleType> {
465497 * @returns Object with deployedHook address, and update Transactions
466498 */
467499 public async deployOrUpdateHook (
468- actualHookConfig : DerivedHookConfig ,
500+ actualHookConfig : DerivedHookConfig | string ,
469501 expectHookConfig : HookConfig | string ,
470502 ) : Promise < {
471503 deployedHook : Address ;
@@ -493,9 +525,14 @@ export class AltVMCoreModule implements HypModule<CoreModuleType> {
493525 `Comparing target Hook config with ${ this . args . chain } chain` ,
494526 ) ;
495527
528+ const actualHookAddress =
529+ typeof actualHookConfig === 'string'
530+ ? actualHookConfig
531+ : actualHookConfig . address ;
532+
496533 // Use the new deployOrUpdate method from HookWriter
497534 const result = await writer . deployOrUpdate ( {
498- actualAddress : actualHookConfig . address ,
535+ actualAddress : actualHookAddress ,
499536 expectedConfig : expectHookConfig ,
500537 } ) ;
501538
0 commit comments