@ -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 (
liquidityLayerRouter : contracts.circleBridgeAdapter ,
objFilter (
} ) ) as unknown as HyperlaneContractsMap < LiquidityLayerFactories > ,
contractsMap ,
( _ , c ) : c is HyperlaneContracts < LiquidityLayerFactories > = >
! ! c . circleBridgeAdapter ,
) ,
( _ , contracts ) = > ( {
liquidityLayerRouter : contracts.circleBridgeAdapter ,
} ) ,
) 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 (
liquidityLayerRouter : contracts.portalAdapter ,
objFilter (
} ) ) as unknown as HyperlaneContractsMap < LiquidityLayerFactories > ,
contractsMap ,
( _ , c ) : c is HyperlaneContracts < LiquidityLayerFactories > = >
! ! c . portalAdapter ,
) ,
( _ , contracts ) = > ( {
liquidityLayerRouter : contracts.portalAdapter ,
} ) ,
) 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 , ( ) = >
chain ,
this . multiProvider . handleTx (
portalAdapter . addDomain ( hyperlaneDomain , wormholeDomain ) ,
chain ,
portalAdapter . addDomain ( hyperlaneDomain , wormholeDomain ) ,
) ,
) ;
) ;
}
}
@ -186,11 +205,13 @@ 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 , ( ) = >
chain ,
this . multiProvider . handleTx (
router . setLiquidityLayerAdapter (
chain ,
adapterConfig . type ,
router . setLiquidityLayerAdapter (
portalAdapter . address ,
adapterConfig . type ,
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 , ( ) = >
chain ,
this . multiProvider . handleTx (
circleBridgeAdapter . addToken ( adapterConfig . usdcAddress , 'USDC' ) ,
chain ,
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 , ( ) = >
chain ,
this . multiProvider . handleTx (
circleBridgeAdapter . addDomain ( hyperlaneDomain , circleDomain ) ,
chain ,
circleBridgeAdapter . addDomain ( hyperlaneDomain , circleDomain ) ,
) ,
) ;
) ;
}
}
@ -255,11 +280,13 @@ 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 , ( ) = >
chain ,
this . multiProvider . handleTx (
router . setLiquidityLayerAdapter (
chain ,
adapterConfig . type ,
router . setLiquidityLayerAdapter (
circleBridgeAdapter . address ,
adapterConfig . type ,
circleBridgeAdapter . address ,
) ,
) ,
) ,
) ;
) ;
}
}