@ -12,6 +12,7 @@ import {
ChainSubmissionStrategy ,
ChainSubmissionStrategySchema ,
ContractVerifier ,
DestinationGas ,
EvmERC20WarpModule ,
EvmERC20WarpRouteReader ,
EvmIsmModule ,
@ -54,7 +55,6 @@ import {
Address ,
ProtocolType ,
assert ,
isObjEmpty ,
objFilter ,
objKeys ,
objMap ,
@ -474,7 +474,6 @@ async function extendWarpRoute(
warpDeployConfig : WarpRouteDeployConfig ,
warpCoreConfigByChain : ChainMap < WarpCoreConfig [ ' tokens ' ] [ number ] > ,
) {
logBlue ( 'Extending Warp Route' ) ;
const { multiProvider } = params . context ;
const warpCoreChains = Object . keys ( warpCoreConfigByChain ) ;
@ -489,7 +488,10 @@ async function extendWarpRoute(
( chain , _config ) : _config is any = > ! warpCoreChains . includes ( chain ) ,
) ;
if ( isObjEmpty ( extendedConfigs ) ) return [ ] ;
const extendedChains = Object . keys ( extendedConfigs ) ;
if ( extendedChains . length === 0 ) return [ ] ;
logBlue ( ` Extending Warp Route to ${ extendedChains . join ( ', ' ) } ` ) ;
extendedConfigs = await deriveMetadataFromExisting (
multiProvider ,
@ -536,28 +538,33 @@ async function updateExistingWarpRoute(
ExplorerLicenseType . MIT ,
) ;
const transactions : AnnotatedEV5Transaction [ ] = [ ] ;
await promiseObjAll (
objMap ( warpDeployConfig , async ( chain , config ) = > {
const deployedConfig = warpCoreConfigByChain [ chain ] ;
if ( ! deployedConfig )
return logGray (
` Missing artifacts for ${ chain } . Probably new deployment. Skipping update... ` ,
) ;
config . ismFactoryAddresses = addresses [
chain
] as ProxyFactoryFactoriesAddresses ;
const evmERC20WarpModule = new EvmERC20WarpModule (
multiProvider ,
{
config ,
chain ,
addresses : {
deployedTokenRoute : deployedConfig.addressOrDenom ! ,
await retryAsync ( async ( ) = > {
logGray ( ` Update existing warp route for chain ${ chain } ` ) ;
const deployedConfig = warpCoreConfigByChain [ chain ] ;
if ( ! deployedConfig )
return logGray (
` Missing artifacts for ${ chain } . Probably new deployment. Skipping update... ` ,
) ;
config . ismFactoryAddresses = addresses [
chain
] as ProxyFactoryFactoriesAddresses ;
const evmERC20WarpModule = new EvmERC20WarpModule (
multiProvider ,
{
config ,
chain ,
addresses : {
deployedTokenRoute : deployedConfig.addressOrDenom ! ,
} ,
} ,
} ,
contractVerifier ,
) ;
transactions . push ( . . . ( await evmERC20WarpModule . update ( config ) ) ) ;
contractVerifier ,
) ;
transactions . push ( . . . ( await evmERC20WarpModule . update ( config ) ) ) ;
} ) ;
} ) ,
) ;
return transactions ;
@ -636,11 +643,17 @@ async function enrollRemoteRouters(
) : Promise < AnnotatedEV5Transaction [ ] > {
logBlue ( ` Enrolling deployed routers with each other... ` ) ;
const { multiProvider } = params . context ;
const deployedRouters : ChainMap < Address > = objMap (
const deployedRoutersAddresses : ChainMap < Address > = objMap (
deployedContractsMap ,
( _ , contracts ) = > getRouter ( contracts ) . address ,
) ;
const allChains = Object . keys ( deployedRouters ) ;
const deployedDestinationGas : DestinationGas = await populateDestinationGas (
multiProvider ,
params . warpDeployConfig ,
deployedContractsMap ,
) ;
const deployedChains = Object . keys ( deployedRoutersAddresses ) ;
const transactions : AnnotatedEV5Transaction [ ] = [ ] ;
await promiseObjAll (
objMap ( deployedContractsMap , async ( chain , contracts ) = > {
@ -662,14 +675,23 @@ async function enrollRemoteRouters(
const otherChains = multiProvider
. getRemoteChains ( chain )
. filter ( ( c ) = > all Chains. includes ( c ) ) ;
. filter ( ( c ) = > deployed Chains. includes ( c ) ) ;
mutatedWarpRouteConfig . remoteRouters =
otherChains . reduce < RemoteRouters > ( ( remoteRouters , c hain) = > {
remoteRouters [ multiProvider . getDomainId ( c hain) ] =
deployedRouters [ c hain] ;
otherChains . reduce < RemoteRouters > ( ( remoteRouters , otherC hain) = > {
remoteRouters [ multiProvider . getDomainId ( otherC hain) ] =
deployedRoutersAddresses [ otherC hain ] ;
return remoteRouters ;
} , { } ) ;
mutatedWarpRouteConfig . destinationGas =
otherChains . reduce < DestinationGas > ( ( destinationGas , otherChain ) = > {
const otherChainDomain = multiProvider . getDomainId ( otherChain ) ;
destinationGas [ otherChainDomain ] =
deployedDestinationGas [ otherChainDomain ] ;
return destinationGas ;
} , { } ) ;
const mutatedConfigTxs : AnnotatedEV5Transaction [ ] =
await evmERC20WarpModule . update ( mutatedWarpRouteConfig ) ;
@ -685,6 +707,38 @@ async function enrollRemoteRouters(
return transactions ;
}
/ * *
* Populates the destination gas amounts for each chain using warpConfig . gas OR querying other router ' s destinationGas
* /
async function populateDestinationGas (
multiProvider : MultiProvider ,
warpDeployConfig : WarpRouteDeployConfig ,
deployedContractsMap : HyperlaneContractsMap < HypERC20Factories > ,
) : Promise < DestinationGas > {
const destinationGas : DestinationGas = { } ;
const deployedChains = Object . keys ( deployedContractsMap ) ;
await promiseObjAll (
objMap ( deployedContractsMap , async ( chain , contracts ) = > {
await retryAsync ( async ( ) = > {
const router = getRouter ( contracts ) ;
const otherChains = multiProvider
. getRemoteChains ( chain )
. filter ( ( c ) = > deployedChains . includes ( c ) ) ;
for ( const otherChain of otherChains ) {
const otherDomain = multiProvider . getDomainId ( otherChain ) ;
if ( ! destinationGas [ otherDomain ] )
destinationGas [ otherDomain ] =
warpDeployConfig [ otherChain ] . gas ? . toString ( ) ||
( await router . destinationGas ( otherDomain ) ) . toString ( ) ;
}
} ) ;
} ) ,
) ;
return destinationGas ;
}
function getRouter ( contracts : HyperlaneContracts < HypERC20Factories > ) {
for ( const key of objKeys ( hypERC20factories ) ) {
if ( contracts [ key ] ) return contracts [ key ] ;
@ -830,24 +884,29 @@ async function submitWarpApplyTransactions(
const { multiProvider } = params . context ;
await promiseObjAll (
objMap ( chainTransactions , async ( chainId , transactions ) = > {
const chain = multiProvider . getChainName ( chainId ) ;
const submitter : TxSubmitterBuilder < ProtocolType > =
await getWarpApplySubmitter ( {
chain ,
context : params.context ,
strategyUrl : params.strategyUrl ,
} ) ;
const transactionReceipts = await submitter . submit ( . . . transactions ) ;
if ( transactionReceipts ) {
const receiptPath = ` ${ params . receiptsDir } / ${ chain } - ${
submitter . txSubmitterType
} - $ { Date . now ( ) } - receipts . json ` ;
writeYamlOrJson ( receiptPath , transactionReceipts ) ;
logGreen (
` Transactions receipts successfully written to ${ receiptPath } ` ,
) ;
}
await retryAsync (
async ( ) = > {
const chain = multiProvider . getChainName ( chainId ) ;
const submitter : TxSubmitterBuilder < ProtocolType > =
await getWarpApplySubmitter ( {
chain ,
context : params.context ,
strategyUrl : params.strategyUrl ,
} ) ;
const transactionReceipts = await submitter . submit ( . . . transactions ) ;
if ( transactionReceipts ) {
const receiptPath = ` ${ params . receiptsDir } / ${ chain } - ${
submitter . txSubmitterType
} - $ { Date . now ( ) } - receipts . json ` ;
writeYamlOrJson ( receiptPath , transactionReceipts ) ;
logGreen (
` Transactions receipts successfully written to ${ receiptPath } ` ,
) ;
}
} ,
5 , // attempts
100 , // baseRetryMs
) ;
} ) ,
) ;
}