diff --git a/typescript/sdk/src/middleware/account/InterchainAccountDeployer.ts b/typescript/sdk/src/middleware/account/InterchainAccountDeployer.ts index 44170d5b12..2b8ab225bc 100644 --- a/typescript/sdk/src/middleware/account/InterchainAccountDeployer.ts +++ b/typescript/sdk/src/middleware/account/InterchainAccountDeployer.ts @@ -1,5 +1,8 @@ import { ethers } from 'ethers'; +import { Router } from '@hyperlane-xyz/core'; +import { objKeys } from '@hyperlane-xyz/utils'; + import { HyperlaneContracts } from '../../contracts/types'; import { ContractVerifier } from '../../deploy/verify/ContractVerifier'; import { MultiProvider } from '../../providers/MultiProvider'; @@ -19,8 +22,6 @@ export class InterchainAccountDeployer extends ProxiedRouterDeployer< InterchainAccountFactories, 'interchainAccountRouter' > { - readonly routerContractNameConstant = 'interchainAccountRouter'; - constructor( multiProvider: MultiProvider, contractVerifier?: ContractVerifier, @@ -36,6 +37,15 @@ export class InterchainAccountDeployer extends ProxiedRouterDeployer< return 'interchainAccountRouter' as K; } + router(contracts: HyperlaneContracts): Router { + for (const key of objKeys(interchainAccountFactories)) { + if (contracts[key]) { + return contracts[key] as Router; + } + } + throw new Error('No matching contract found'); + } + async constructorArgs(_: string, config: RouterConfig): Promise<[string]> { return [config.mailbox]; } diff --git a/typescript/sdk/src/middleware/liquidity-layer/LiquidityLayerRouterDeployer.ts b/typescript/sdk/src/middleware/liquidity-layer/LiquidityLayerRouterDeployer.ts index 3296b74f00..be8a58ade7 100644 --- a/typescript/sdk/src/middleware/liquidity-layer/LiquidityLayerRouterDeployer.ts +++ b/typescript/sdk/src/middleware/liquidity-layer/LiquidityLayerRouterDeployer.ts @@ -4,8 +4,15 @@ import { CircleBridgeAdapter, LiquidityLayerRouter, PortalAdapter, + Router, } from '@hyperlane-xyz/core'; -import { Address, eqAddress, objFilter, objMap } from '@hyperlane-xyz/utils'; +import { + Address, + eqAddress, + objFilter, + objKeys, + objMap, +} from '@hyperlane-xyz/utils'; import { HyperlaneContracts, @@ -56,8 +63,6 @@ export class LiquidityLayerDeployer extends ProxiedRouterDeployer< LiquidityLayerFactories, 'liquidityLayerRouter' > { - readonly routerContractNameConstant = 'liquidityLayerRouter'; - constructor( multiProvider: MultiProvider, contractVerifier?: ContractVerifier, @@ -73,6 +78,15 @@ export class LiquidityLayerDeployer extends ProxiedRouterDeployer< return 'liquidityLayerRouter' as K; } + router(contracts: HyperlaneContracts): Router { + for (const key of objKeys(liquidityLayerFactories)) { + if (contracts[key]) { + return contracts[key] as Router; + } + } + throw new Error('No matching contract found'); + } + async constructorArgs( _: string, config: LiquidityLayerConfig, diff --git a/typescript/sdk/src/middleware/query/InterchainQueryDeployer.ts b/typescript/sdk/src/middleware/query/InterchainQueryDeployer.ts index a45a08e062..a0db2959c2 100644 --- a/typescript/sdk/src/middleware/query/InterchainQueryDeployer.ts +++ b/typescript/sdk/src/middleware/query/InterchainQueryDeployer.ts @@ -1,5 +1,9 @@ import { ethers } from 'ethers'; +import { Router } from '@hyperlane-xyz/core'; +import { objKeys } from '@hyperlane-xyz/utils'; + +import { HyperlaneContracts } from '../../contracts/types'; import { ContractVerifier } from '../../deploy/verify/ContractVerifier'; import { MultiProvider } from '../../providers/MultiProvider'; import { ProxiedRouterDeployer } from '../../router/ProxiedRouterDeployer'; @@ -17,8 +21,6 @@ export class InterchainQueryDeployer extends ProxiedRouterDeployer< InterchainQueryFactories, 'interchainQueryRouter' > { - readonly routerContractNameConstant = 'interchainQueryRouter'; - constructor( multiProvider: MultiProvider, contractVerifier?: ContractVerifier, @@ -34,6 +36,15 @@ export class InterchainQueryDeployer extends ProxiedRouterDeployer< return 'interchainQueryRouter' as K; } + router(contracts: HyperlaneContracts): Router { + for (const key of objKeys(interchainQueryFactories)) { + if (contracts[key]) { + return contracts[key] as Router; + } + } + throw new Error('No matching contract found'); + } + async constructorArgs(_: string, config: RouterConfig): Promise<[string]> { return [config.mailbox]; } diff --git a/typescript/sdk/src/router/ProxiedRouterDeployer.ts b/typescript/sdk/src/router/ProxiedRouterDeployer.ts index e1ba23ce82..1125b55284 100644 --- a/typescript/sdk/src/router/ProxiedRouterDeployer.ts +++ b/typescript/sdk/src/router/ProxiedRouterDeployer.ts @@ -18,11 +18,7 @@ export abstract class ProxiedRouterDeployer< Factories extends ProxiedFactories, RouterKey extends keyof Factories, > extends HyperlaneRouterDeployer { - abstract routerContractNameConstant: RouterKey; // @dev this is for backwards compatibility, should refactor later - - router(contracts: HyperlaneContracts): Router { - return contracts[this.routerContractNameConstant] as Router; - } + abstract router(contracts: HyperlaneContracts): Router; /** * Returns the contract name diff --git a/typescript/sdk/src/token/deploy.ts b/typescript/sdk/src/token/deploy.ts index 27c274a2a7..5fdcfe87dc 100644 --- a/typescript/sdk/src/token/deploy.ts +++ b/typescript/sdk/src/token/deploy.ts @@ -48,8 +48,6 @@ export class HypERC20Deployer extends GasRouterDeployer< HypERC20Factories, TokenType.native > { - readonly routerContractNameConstant = TokenType.native; - constructor( multiProvider: MultiProvider, ismFactory?: HyperlaneIsmFactory, @@ -255,8 +253,6 @@ export class HypERC721Deployer extends GasRouterDeployer< HypERC721Factories, TokenType.collateral > { - readonly routerContractNameConstant = TokenType.collateral; - constructor( multiProvider: MultiProvider, contractVerifier?: ContractVerifier, @@ -296,10 +292,15 @@ export class HypERC721Deployer extends GasRouterDeployer< //@ts-ignore ignore for now until the contracts get fixed async initializeArgs(_: ChainName, config: ERC721RouterConfig): Promise { + const defaultArgs = [ + config.hook ?? ethers.constants.AddressZero, + config.interchainSecurityModule ?? ethers.constants.AddressZero, + config.owner, + ]; if (isCollateralConfig(config)) { - return [config.token, config.mailbox]; + return defaultArgs; } else if (isSyntheticConfig(config)) { - return [config.totalSupply, config.name, config.symbol]; + return [config.totalSupply, config.name, config.symbol, ...defaultArgs]; } else { throw new Error('Unknown collateral type when initializing arguments'); }