|
|
|
@ -5,7 +5,7 @@ import { |
|
|
|
|
TestRecipient, |
|
|
|
|
ValidatorAnnounce, |
|
|
|
|
} from '@hyperlane-xyz/core'; |
|
|
|
|
import { Address, rootLogger } from '@hyperlane-xyz/utils'; |
|
|
|
|
import { Address, isZeroishAddress, rootLogger } from '@hyperlane-xyz/utils'; |
|
|
|
|
|
|
|
|
|
import { HyperlaneContracts } from '../contracts/types.js'; |
|
|
|
|
import { HyperlaneDeployer } from '../deploy/HyperlaneDeployer.js'; |
|
|
|
@ -107,9 +107,14 @@ export class HyperlaneCoreDeployer extends HyperlaneDeployer< |
|
|
|
|
hookAddresses, |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// configure mailbox
|
|
|
|
|
try { |
|
|
|
|
const txOverrides = this.multiProvider.getTransactionOverrides(chain); |
|
|
|
|
|
|
|
|
|
// Check if the mailbox has already been initialized
|
|
|
|
|
const currentDefaultIsm = await mailbox.defaultIsm(); |
|
|
|
|
if (isZeroishAddress(currentDefaultIsm)) { |
|
|
|
|
// If the default ISM is the zero address, the mailbox hasn't been initialized
|
|
|
|
|
this.logger.debug('Initializing mailbox'); |
|
|
|
|
try { |
|
|
|
|
await this.multiProvider.handleTx( |
|
|
|
|
chain, |
|
|
|
|
mailbox.initialize( |
|
|
|
@ -117,33 +122,26 @@ export class HyperlaneCoreDeployer extends HyperlaneDeployer< |
|
|
|
|
defaultIsm, |
|
|
|
|
defaultHook.address, |
|
|
|
|
requiredHook.address, |
|
|
|
|
this.multiProvider.getTransactionOverrides(chain), |
|
|
|
|
txOverrides, |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
} catch (e: any) { |
|
|
|
|
if ( |
|
|
|
|
!e.message.includes('already initialized') && |
|
|
|
|
// Some RPC providers dont return the revert reason (nor allow ethers to parse it), so we have to check the message
|
|
|
|
|
!e.message.includes('Reverted 0x08c379a') && |
|
|
|
|
// Handle situation where the gas estimation fails on the call function,
|
|
|
|
|
// then the real error reason is not available in `e.message`, but rather in `e.error.reason`
|
|
|
|
|
!e.error?.reason?.includes('already initialized') && |
|
|
|
|
// Some providers, like on Viction, return a generic error message for all revert reasons
|
|
|
|
|
!e.message.includes('always failing transaction') |
|
|
|
|
) { |
|
|
|
|
// If we still get an error here, it's likely a genuine error
|
|
|
|
|
this.logger.error('Failed to initialize mailbox:', e); |
|
|
|
|
throw e; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
// If the default ISM is not the zero address, the mailbox has likely been initialized
|
|
|
|
|
this.logger.debug('Mailbox appears to be already initialized'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.logger.debug('Mailbox already initialized'); |
|
|
|
|
|
|
|
|
|
const overrides = this.multiProvider.getTransactionOverrides(chain); |
|
|
|
|
await this.configureHook( |
|
|
|
|
chain, |
|
|
|
|
mailbox, |
|
|
|
|
defaultHook.address, |
|
|
|
|
(_mailbox) => _mailbox.defaultHook(), |
|
|
|
|
(_mailbox, _hook) => |
|
|
|
|
_mailbox.populateTransaction.setDefaultHook(_hook, { ...overrides }), |
|
|
|
|
_mailbox.populateTransaction.setDefaultHook(_hook, { ...txOverrides }), |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
await this.configureHook( |
|
|
|
@ -152,7 +150,7 @@ export class HyperlaneCoreDeployer extends HyperlaneDeployer< |
|
|
|
|
requiredHook.address, |
|
|
|
|
(_mailbox) => _mailbox.requiredHook(), |
|
|
|
|
(_mailbox, _hook) => |
|
|
|
|
_mailbox.populateTransaction.setRequiredHook(_hook, { ...overrides }), |
|
|
|
|
_mailbox.populateTransaction.setRequiredHook(_hook, { ...txOverrides }), |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
await this.configureIsm( |
|
|
|
@ -163,7 +161,6 @@ export class HyperlaneCoreDeployer extends HyperlaneDeployer< |
|
|
|
|
(_mailbox, _module) => |
|
|
|
|
_mailbox.populateTransaction.setDefaultIsm(_module), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return mailbox; |
|
|
|
|
} |
|
|
|
|