@ -12,7 +12,7 @@ import { MultiProvider } from '../../providers/MultiProvider';
import { ProxiedRouterDeployer } from '../../router/ProxiedRouterDeployer' ;
import { ProxiedRouterDeployer } from '../../router/ProxiedRouterDeployer' ;
import { RouterConfig } from '../../router/types' ;
import { RouterConfig } from '../../router/types' ;
import { ChainMap , ChainName } from '../../types' ;
import { ChainMap , ChainName } from '../../types' ;
import { objMap } from '../../utils/objects' ;
import { objFilter , obj Map } from '../../utils/objects' ;
import { LiquidityLayerFactories , liquidityLayerFactories } from './contracts' ;
import { LiquidityLayerFactories , liquidityLayerFactories } from './contracts' ;
@ -93,18 +93,32 @@ export class LiquidityLayerDeployer extends ProxiedRouterDeployer<
this . logger ( ` Enroll CircleBridgeAdapters with each other ` ) ;
this . logger ( ` Enroll CircleBridgeAdapters with each other ` ) ;
// Hack to allow use of super.enrollRemoteRouters
// Hack to allow use of super.enrollRemoteRouters
await super . enrollRemoteRouters (
await super . enrollRemoteRouters (
objMap ( contractsMap , ( _ , contracts ) = > ( {
objMap (
objFilter (
contractsMap ,
( _ , c ) : c is HyperlaneContracts < LiquidityLayerFactories > = >
! ! c . circleBridgeAdapter ,
) ,
( _ , contracts ) = > ( {
liquidityLayerRouter : contracts.circleBridgeAdapter ,
liquidityLayerRouter : contracts.circleBridgeAdapter ,
} ) ) as unknown as HyperlaneContractsMap < LiquidityLayerFactories > ,
} ) ,
) as unknown as HyperlaneContractsMap < LiquidityLayerFactories > ,
configMap ,
configMap ,
) ;
) ;
this . logger ( ` Enroll PortalAdapters with each other ` ) ;
this . logger ( ` Enroll PortalAdapters with each other ` ) ;
// Hack to allow use of super.enrollRemoteRouters
// Hack to allow use of super.enrollRemoteRouters
await super . enrollRemoteRouters (
await super . enrollRemoteRouters (
objMap ( contractsMap , ( _ , contracts ) = > ( {
objMap (
objFilter (
contractsMap ,
( _ , c ) : c is HyperlaneContracts < LiquidityLayerFactories > = >
! ! c . portalAdapter ,
) ,
( _ , contracts ) = > ( {
liquidityLayerRouter : contracts.portalAdapter ,
liquidityLayerRouter : contracts.portalAdapter ,
} ) ) as unknown as HyperlaneContractsMap < LiquidityLayerFactories > ,
} ) ,
) as unknown as HyperlaneContractsMap < LiquidityLayerFactories > ,
configMap ,
configMap ,
) ;
) ;
}
}
@ -115,6 +129,9 @@ export class LiquidityLayerDeployer extends ProxiedRouterDeployer<
chain : ChainName ,
chain : ChainName ,
config : LiquidityLayerConfig ,
config : LiquidityLayerConfig ,
) : Promise < HyperlaneContracts < LiquidityLayerFactories > > {
) : Promise < HyperlaneContracts < LiquidityLayerFactories > > {
// This is just the temp owner for contracts, and HyperlaneRouterDeployer#transferOwnership actually sets the configured owner
const deployer = await this . multiProvider . getSignerAddress ( chain ) ;
const routerContracts = await super . deployContracts ( chain , config ) ;
const routerContracts = await super . deployContracts ( chain , config ) ;
const bridgeAdapters : Partial <
const bridgeAdapters : Partial <
@ -125,7 +142,7 @@ export class LiquidityLayerDeployer extends ProxiedRouterDeployer<
bridgeAdapters . circleBridgeAdapter = await this . deployCircleBridgeAdapter (
bridgeAdapters . circleBridgeAdapter = await this . deployCircleBridgeAdapter (
chain ,
chain ,
config . circle ,
config . circle ,
config . own er,
deploy er,
routerContracts . liquidityLayerRouter ,
routerContracts . liquidityLayerRouter ,
) ;
) ;
}
}
@ -133,7 +150,7 @@ export class LiquidityLayerDeployer extends ProxiedRouterDeployer<
bridgeAdapters . portalAdapter = await this . deployPortalAdapter (
bridgeAdapters . portalAdapter = await this . deployPortalAdapter (
chain ,
chain ,
config . portal ,
config . portal ,
config . own er,
deploy er,
routerContracts . liquidityLayerRouter ,
routerContracts . liquidityLayerRouter ,
) ;
) ;
}
}
@ -173,9 +190,11 @@ export class LiquidityLayerDeployer extends ProxiedRouterDeployer<
this . logger (
this . logger (
` Set wormhole domain ${ wormholeDomain } for hyperlane domain ${ hyperlaneDomain } ` ,
` Set wormhole domain ${ wormholeDomain } for hyperlane domain ${ hyperlaneDomain } ` ,
) ;
) ;
await this . multiProvider . handleTx (
await this . runIfOwner ( chain , portalAdapter , ( ) = >
this . multiProvider . handleTx (
chain ,
chain ,
portalAdapter . addDomain ( hyperlaneDomain , wormholeDomain ) ,
portalAdapter . addDomain ( hyperlaneDomain , wormholeDomain ) ,
) ,
) ;
) ;
}
}
@ -186,12 +205,14 @@ export class LiquidityLayerDeployer extends ProxiedRouterDeployer<
)
)
) {
) {
this . logger ( 'Set Portal as LiquidityLayerAdapter on Router' ) ;
this . logger ( 'Set Portal as LiquidityLayerAdapter on Router' ) ;
await this . multiProvider . handleTx (
await this . runIfOwner ( chain , portalAdapter , ( ) = >
this . multiProvider . handleTx (
chain ,
chain ,
router . setLiquidityLayerAdapter (
router . setLiquidityLayerAdapter (
adapterConfig . type ,
adapterConfig . type ,
portalAdapter . address ,
portalAdapter . address ,
) ,
) ,
) ,
) ;
) ;
}
}
@ -223,9 +244,11 @@ export class LiquidityLayerDeployer extends ProxiedRouterDeployer<
)
)
) {
) {
this . logger ( ` Set USDC token contract ` ) ;
this . logger ( ` Set USDC token contract ` ) ;
await this . multiProvider . handleTx (
await this . runIfOwner ( chain , circleBridgeAdapter , ( ) = >
this . multiProvider . handleTx (
chain ,
chain ,
circleBridgeAdapter . addToken ( adapterConfig . usdcAddress , 'USDC' ) ,
circleBridgeAdapter . addToken ( adapterConfig . usdcAddress , 'USDC' ) ,
) ,
) ;
) ;
}
}
// Set domain mappings
// Set domain mappings
@ -242,9 +265,11 @@ export class LiquidityLayerDeployer extends ProxiedRouterDeployer<
this . logger (
this . logger (
` Set circle domain ${ circleDomain } for hyperlane domain ${ hyperlaneDomain } ` ,
` Set circle domain ${ circleDomain } for hyperlane domain ${ hyperlaneDomain } ` ,
) ;
) ;
await this . multiProvider . handleTx (
await this . runIfOwner ( chain , circleBridgeAdapter , ( ) = >
this . multiProvider . handleTx (
chain ,
chain ,
circleBridgeAdapter . addDomain ( hyperlaneDomain , circleDomain ) ,
circleBridgeAdapter . addDomain ( hyperlaneDomain , circleDomain ) ,
) ,
) ;
) ;
}
}
@ -255,12 +280,14 @@ export class LiquidityLayerDeployer extends ProxiedRouterDeployer<
)
)
) {
) {
this . logger ( 'Set Circle as LiquidityLayerAdapter on Router' ) ;
this . logger ( 'Set Circle as LiquidityLayerAdapter on Router' ) ;
await this . multiProvider . handleTx (
await this . runIfOwner ( chain , circleBridgeAdapter , ( ) = >
this . multiProvider . handleTx (
chain ,
chain ,
router . setLiquidityLayerAdapter (
router . setLiquidityLayerAdapter (
adapterConfig . type ,
adapterConfig . type ,
circleBridgeAdapter . address ,
circleBridgeAdapter . address ,
) ,
) ,
) ,
) ;
) ;
}
}