diff --git a/typescript/sdk/src/core/HyperlaneCore.ts b/typescript/sdk/src/core/HyperlaneCore.ts index 9785a9247..4c9d6ba5e 100644 --- a/typescript/sdk/src/core/HyperlaneCore.ts +++ b/typescript/sdk/src/core/HyperlaneCore.ts @@ -7,7 +7,7 @@ import { HyperlaneApp } from '../HyperlaneApp'; import { environments } from '../consts/environments'; import { buildContracts } from '../contracts'; import { MultiProvider } from '../providers/MultiProvider'; -import { ConnectionClientConfig } from '../router'; +import { ConnectionClientConfig } from '../router/types'; import { ChainMap, ChainName } from '../types'; import { objMap, pick } from '../utils/objects'; diff --git a/typescript/sdk/src/deploy/core/HyperlaneCoreChecker.ts b/typescript/sdk/src/core/HyperlaneCoreChecker.ts similarity index 98% rename from typescript/sdk/src/deploy/core/HyperlaneCoreChecker.ts rename to typescript/sdk/src/core/HyperlaneCoreChecker.ts index a53bef19b..5f91391de 100644 --- a/typescript/sdk/src/deploy/core/HyperlaneCoreChecker.ts +++ b/typescript/sdk/src/core/HyperlaneCoreChecker.ts @@ -2,10 +2,10 @@ import { utils as ethersUtils } from 'ethers'; import { types, utils } from '@hyperlane-xyz/utils'; -import { HyperlaneCore } from '../../core/HyperlaneCore'; -import { ChainName } from '../../types'; -import { HyperlaneAppChecker } from '../HyperlaneAppChecker'; +import { HyperlaneAppChecker } from '../deploy/HyperlaneAppChecker'; +import { ChainName } from '../types'; +import { HyperlaneCore } from './HyperlaneCore'; import { CoreConfig, CoreViolationType, diff --git a/typescript/sdk/src/deploy/core/HyperlaneCoreDeployer.ts b/typescript/sdk/src/core/HyperlaneCoreDeployer.ts similarity index 96% rename from typescript/sdk/src/deploy/core/HyperlaneCoreDeployer.ts rename to typescript/sdk/src/core/HyperlaneCoreDeployer.ts index 32cd60930..8f2615375 100644 --- a/typescript/sdk/src/deploy/core/HyperlaneCoreDeployer.ts +++ b/typescript/sdk/src/core/HyperlaneCoreDeployer.ts @@ -14,18 +14,14 @@ import { } from '@hyperlane-xyz/core'; import { types, utils } from '@hyperlane-xyz/utils'; -import multisigIsmVerifyCosts from '../../consts/multisigIsmVerifyCosts.json'; -import { - CoreContracts, - GasOracleContracts, - coreFactories, -} from '../../core/contracts'; -import { MultiProvider } from '../../providers/MultiProvider'; -import { ProxiedContract, TransparentProxyAddresses } from '../../proxy'; -import { ChainMap, ChainName } from '../../types'; -import { objMap } from '../../utils/objects'; -import { DeployOptions, HyperlaneDeployer } from '../HyperlaneDeployer'; - +import multisigIsmVerifyCosts from '../consts/multisigIsmVerifyCosts.json'; +import { DeployOptions, HyperlaneDeployer } from '../deploy/HyperlaneDeployer'; +import { MultiProvider } from '../providers/MultiProvider'; +import { ProxiedContract, TransparentProxyAddresses } from '../proxy'; +import { ChainMap, ChainName } from '../types'; +import { objMap } from '../utils/objects'; + +import { CoreContracts, GasOracleContracts, coreFactories } from './contracts'; import { CoreConfig, GasOracleContractType } from './types'; export class HyperlaneCoreDeployer extends HyperlaneDeployer< diff --git a/typescript/sdk/src/core/TestCoreDeployer.ts b/typescript/sdk/src/core/TestCoreDeployer.ts index 6cfc667dd..e01b0a902 100644 --- a/typescript/sdk/src/core/TestCoreDeployer.ts +++ b/typescript/sdk/src/core/TestCoreDeployer.ts @@ -7,13 +7,13 @@ import { TestMailbox__factory, } from '@hyperlane-xyz/core'; -import { HyperlaneCoreDeployer } from '../deploy/core/HyperlaneCoreDeployer'; -import { CoreConfig, GasOracleContractType } from '../deploy/core/types'; import { MultiProvider } from '../providers/MultiProvider'; import { ChainMap, ChainName } from '../types'; +import { HyperlaneCoreDeployer } from './HyperlaneCoreDeployer'; import { TestCoreApp } from './TestCoreApp'; import { coreFactories } from './contracts'; +import { CoreConfig, GasOracleContractType } from './types'; const nonZeroAddress = ethers.constants.AddressZero.replace('00', '01'); diff --git a/typescript/sdk/src/deploy/core/types.ts b/typescript/sdk/src/core/types.ts similarity index 96% rename from typescript/sdk/src/deploy/core/types.ts rename to typescript/sdk/src/core/types.ts index 176648345..8aa337951 100644 --- a/typescript/sdk/src/deploy/core/types.ts +++ b/typescript/sdk/src/core/types.ts @@ -5,8 +5,8 @@ import { } from '@hyperlane-xyz/core'; import type { types } from '@hyperlane-xyz/utils'; -import { ChainMap, ChainName } from '../../types'; -import type { CheckerViolation } from '../types'; +import type { CheckerViolation } from '../deploy/types'; +import { ChainMap, ChainName } from '../types'; export enum GasOracleContractType { StorageGasOracle = 'StorageGasOracle', diff --git a/typescript/sdk/src/deploy/router/types.ts b/typescript/sdk/src/deploy/router/types.ts deleted file mode 100644 index 7d813f753..000000000 --- a/typescript/sdk/src/deploy/router/types.ts +++ /dev/null @@ -1,15 +0,0 @@ -import type { types } from '@hyperlane-xyz/utils'; - -import type { ConnectionClientConfig } from '../../router'; - -export type OwnableConfig = { - owner: types.Address; -}; - -export type RouterConfig = ConnectionClientConfig & OwnableConfig; - -type GasConfig = { - gas: number; -}; - -export type GasRouterConfig = RouterConfig & GasConfig; diff --git a/typescript/sdk/src/deploy/.eslintrc b/typescript/sdk/src/deploy/verify/.eslintrc similarity index 100% rename from typescript/sdk/src/deploy/.eslintrc rename to typescript/sdk/src/deploy/verify/.eslintrc diff --git a/typescript/sdk/src/gas/types.ts b/typescript/sdk/src/gas/types.ts new file mode 100644 index 000000000..d42b4dc25 --- /dev/null +++ b/typescript/sdk/src/gas/types.ts @@ -0,0 +1,70 @@ +import { Mailbox, MultisigIsm } from '@hyperlane-xyz/core'; +import type { types } from '@hyperlane-xyz/utils'; + +import type { CheckerViolation } from '../deploy/types'; +import { ChainName } from '../types'; + +export type MultisigIsmConfig = { + validators: Array; + threshold: number; +}; + +export type CoreConfig = { + multisigIsm: MultisigIsmConfig; + owner: types.Address; + remove?: boolean; +}; + +export enum CoreViolationType { + MultisigIsm = 'MultisigIsm', + Mailbox = 'Mailbox', + ConnectionManager = 'ConnectionManager', + ValidatorAnnounce = 'ValidatorAnnounce', +} + +export enum MultisigIsmViolationType { + EnrolledValidators = 'EnrolledValidators', + Threshold = 'Threshold', +} + +export enum MailboxViolationType { + DefaultIsm = 'DefaultIsm', +} + +export interface MailboxViolation extends CheckerViolation { + type: CoreViolationType.Mailbox; + contract: Mailbox; + mailboxType: MailboxViolationType; +} + +export interface MailboxMultisigIsmViolation extends MailboxViolation { + actual: types.Address; + expected: types.Address; +} + +export interface MultisigIsmViolation extends CheckerViolation { + type: CoreViolationType.MultisigIsm; + contract: MultisigIsm; + subType: MultisigIsmViolationType; + remote: ChainName; +} + +export interface EnrolledValidatorsViolation extends MultisigIsmViolation { + subType: MultisigIsmViolationType.EnrolledValidators; + actual: Set; + expected: Set; +} + +export interface ThresholdViolation extends MultisigIsmViolation { + subType: MultisigIsmViolationType.Threshold; + actual: number; + expected: number; +} + +export interface ValidatorAnnounceViolation extends CheckerViolation { + type: CoreViolationType.ValidatorAnnounce; + chain: ChainName; + validator: types.Address; + actual: boolean; + expected: boolean; +} diff --git a/typescript/sdk/src/index.ts b/typescript/sdk/src/index.ts index d3a41eefa..e5bf65a04 100644 --- a/typescript/sdk/src/index.ts +++ b/typescript/sdk/src/index.ts @@ -50,8 +50,8 @@ export { } from './core/HyperlaneCore'; export { TestCoreApp, TestCoreContracts } from './core/TestCoreApp'; export { TestCoreDeployer } from './core/TestCoreDeployer'; -export { HyperlaneCoreChecker } from './deploy/core/HyperlaneCoreChecker'; -export { HyperlaneCoreDeployer } from './deploy/core/HyperlaneCoreDeployer'; +export { HyperlaneCoreChecker } from './core/HyperlaneCoreChecker'; +export { HyperlaneCoreDeployer } from './core/HyperlaneCoreDeployer'; export { CoreConfig, CoreViolationType, @@ -63,26 +63,26 @@ export { IgpViolationType, MultisigIsmViolation, MultisigIsmViolationType, -} from './deploy/core/types'; +} from './core/types'; export { HyperlaneAppChecker } from './deploy/HyperlaneAppChecker'; export { HyperlaneDeployer } from './deploy/HyperlaneDeployer'; export { InterchainAccountDeployer, InterchainQueryDeployer, -} from './deploy/middleware/deploy'; -export { LiquidityLayerApp } from './deploy/middleware/LiquidityLayerApp'; +} from './middleware/deploy'; +export { LiquidityLayerApp } from './middleware/liquidity-layer/LiquidityLayerApp'; export { BridgeAdapterConfig, BridgeAdapterType, CircleBridgeAdapterConfig, LiquidityLayerDeployer, PortalAdapterConfig, -} from './deploy/middleware/LiquidityLayerRouterDeployer'; +} from './middleware/liquidity-layer/LiquidityLayerRouterDeployer'; export { ProxyViolation } from './deploy/proxy'; -export { GasRouterDeployer } from './deploy/router/GasRouterDeployer'; -export { HyperlaneRouterChecker } from './deploy/router/HyperlaneRouterChecker'; -export { HyperlaneRouterDeployer } from './deploy/router/HyperlaneRouterDeployer'; -export { GasRouterConfig, RouterConfig } from './deploy/router/types'; +export { GasRouterDeployer } from './router/GasRouterDeployer'; +export { HyperlaneRouterChecker } from './router/HyperlaneRouterChecker'; +export { HyperlaneRouterDeployer } from './router/HyperlaneRouterDeployer'; +export { GasRouterConfig, RouterConfig } from './router/types'; export { CheckerViolation, OwnerViolation, @@ -111,9 +111,11 @@ export { HyperlaneApp } from './HyperlaneApp'; export { interchainAccountFactories, interchainQueryFactories, +} from './middleware/deploy'; +export { LiquidityLayerContracts, liquidityLayerFactories, -} from './middleware'; +} from './middleware/liquidity-layer/contracts'; export { MultiProvider } from './providers/MultiProvider'; export { RetryJsonRpcProvider, RetryProvider } from './providers/RetryProvider'; export { @@ -121,13 +123,8 @@ export { ProxyAddresses, TransparentProxyAddresses, } from './proxy'; -export { - GasRouterApp, - Router, - RouterApp, - RouterContracts, - RouterFactories, -} from './router'; +export { GasRouterApp, Router, RouterApp } from './router/RouterApps'; +export { RouterContracts, RouterFactories } from './router/types'; export { getTestOwnerConfig } from './test/testUtils'; export { ChainMap, diff --git a/typescript/sdk/src/middleware.ts b/typescript/sdk/src/middleware.ts deleted file mode 100644 index 76c61db0c..000000000 --- a/typescript/sdk/src/middleware.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { - CircleBridgeAdapter, - CircleBridgeAdapter__factory, - InterchainAccountRouter, - InterchainAccountRouter__factory, - InterchainQueryRouter, - InterchainQueryRouter__factory, - LiquidityLayerRouter, - LiquidityLayerRouter__factory, - PortalAdapter, - PortalAdapter__factory, -} from '@hyperlane-xyz/core'; - -import { ProxiedRouterContracts, RouterFactories } from './router'; - -export type InterchainAccountFactories = - RouterFactories; - -export const interchainAccountFactories: InterchainAccountFactories = { - router: new InterchainAccountRouter__factory(), -}; - -export type InterchainAccountContracts = - ProxiedRouterContracts; - -export type InterchainQueryFactories = RouterFactories; - -export const interchainQueryFactories: InterchainQueryFactories = { - router: new InterchainQueryRouter__factory(), -}; - -export type InterchainQueryContracts = - ProxiedRouterContracts; - -export type LiquidityLayerFactories = RouterFactories & { - circleBridgeAdapter: CircleBridgeAdapter__factory; - portalAdapter: PortalAdapter__factory; -}; - -export const liquidityLayerFactories: LiquidityLayerFactories = { - router: new LiquidityLayerRouter__factory(), - circleBridgeAdapter: new CircleBridgeAdapter__factory(), - portalAdapter: new PortalAdapter__factory(), -}; - -export type LiquidityLayerContracts = - ProxiedRouterContracts & { - circleBridgeAdapter?: CircleBridgeAdapter; - portalAdapter?: PortalAdapter; - }; diff --git a/typescript/sdk/src/middleware/accounts.hardhat-test.ts b/typescript/sdk/src/middleware/accounts.hardhat-test.ts index 5e012084d..7583d3d9e 100644 --- a/typescript/sdk/src/middleware/accounts.hardhat-test.ts +++ b/typescript/sdk/src/middleware/accounts.hardhat-test.ts @@ -11,14 +11,17 @@ import { utils } from '@hyperlane-xyz/utils'; import { Chains } from '../consts/chains'; import { TestCoreApp } from '../core/TestCoreApp'; import { TestCoreDeployer } from '../core/TestCoreDeployer'; -import { InterchainAccountDeployer } from '../deploy/middleware/deploy'; -import { RouterConfig } from '../deploy/router/types'; -import { InterchainAccountContracts } from '../middleware'; import { MultiProvider } from '../providers/MultiProvider'; +import { RouterConfig } from '../router/types'; import { getTestOwnerConfig } from '../test/testUtils'; import { ChainMap } from '../types'; import { objMap, promiseObjAll } from '../utils/objects'; +import { + InterchainAccountContracts, + InterchainAccountDeployer, +} from './deploy'; + describe('InterchainAccountRouter', async () => { const localChain = Chains.test1; const remoteChain = Chains.test2; diff --git a/typescript/sdk/src/deploy/middleware/deploy.ts b/typescript/sdk/src/middleware/deploy.ts similarity index 74% rename from typescript/sdk/src/deploy/middleware/deploy.ts rename to typescript/sdk/src/middleware/deploy.ts index 251008018..26ac5400e 100644 --- a/typescript/sdk/src/deploy/middleware/deploy.ts +++ b/typescript/sdk/src/middleware/deploy.ts @@ -1,20 +1,40 @@ import { ethers } from 'ethers'; import { ProxyAdmin__factory } from '@hyperlane-xyz/core'; - import { - InterchainAccountContracts, - InterchainAccountFactories, - InterchainQueryContracts, - InterchainQueryFactories, - interchainAccountFactories, - interchainQueryFactories, -} from '../../middleware'; -import { MultiProvider } from '../../providers/MultiProvider'; -import { ProxiedRouterContracts, RouterFactories } from '../../router'; -import { ChainMap, ChainName } from '../../types'; + InterchainAccountRouter, + InterchainAccountRouter__factory, + InterchainQueryRouter, + InterchainQueryRouter__factory, +} from '@hyperlane-xyz/core'; + +import { MultiProvider } from '../providers/MultiProvider'; import { HyperlaneRouterDeployer } from '../router/HyperlaneRouterDeployer'; -import { RouterConfig } from '../router/types'; +import { + ProxiedRouterContracts, + RouterConfig, + RouterFactories, +} from '../router/types'; +import { ChainMap, ChainName } from '../types'; + +export type InterchainAccountFactories = + RouterFactories; + +export const interchainAccountFactories: InterchainAccountFactories = { + router: new InterchainAccountRouter__factory(), +}; + +export type InterchainAccountContracts = + ProxiedRouterContracts; + +export type InterchainQueryFactories = RouterFactories; + +export const interchainQueryFactories: InterchainQueryFactories = { + router: new InterchainQueryRouter__factory(), +}; + +export type InterchainQueryContracts = + ProxiedRouterContracts; export abstract class MiddlewareRouterDeployer< MiddlewareRouterConfig extends RouterConfig, diff --git a/typescript/sdk/src/middleware/liquidity-layer/.eslintrc b/typescript/sdk/src/middleware/liquidity-layer/.eslintrc new file mode 100644 index 000000000..e3f712414 --- /dev/null +++ b/typescript/sdk/src/middleware/liquidity-layer/.eslintrc @@ -0,0 +1,5 @@ +{ + "rules": { + "no-console": ["off"] + } +} diff --git a/typescript/sdk/src/deploy/middleware/LiquidityLayerApp.ts b/typescript/sdk/src/middleware/liquidity-layer/LiquidityLayerApp.ts similarity index 99% rename from typescript/sdk/src/deploy/middleware/LiquidityLayerApp.ts rename to typescript/sdk/src/middleware/liquidity-layer/LiquidityLayerApp.ts index f695aa4ef..6ce62dfc7 100644 --- a/typescript/sdk/src/deploy/middleware/LiquidityLayerApp.ts +++ b/typescript/sdk/src/middleware/liquidity-layer/LiquidityLayerApp.ts @@ -11,11 +11,11 @@ import { utils } from '@hyperlane-xyz/utils'; import { HyperlaneApp } from '../../HyperlaneApp'; import { Chains } from '../../consts/chains'; -import { LiquidityLayerContracts } from '../../middleware'; import { MultiProvider } from '../../providers/MultiProvider'; import { ChainMap, ChainName } from '../../types'; import { BridgeAdapterConfig } from './LiquidityLayerRouterDeployer'; +import { LiquidityLayerContracts } from './contracts'; const PORTAL_VAA_SERVICE_TESTNET_BASE_URL = 'https://wormhole-v2-testnet-api.certus.one/v1/signed_vaa/'; diff --git a/typescript/sdk/src/deploy/middleware/LiquidityLayerRouterDeployer.ts b/typescript/sdk/src/middleware/liquidity-layer/LiquidityLayerRouterDeployer.ts similarity index 98% rename from typescript/sdk/src/deploy/middleware/LiquidityLayerRouterDeployer.ts rename to typescript/sdk/src/middleware/liquidity-layer/LiquidityLayerRouterDeployer.ts index c94dde8e2..60b4452b8 100644 --- a/typescript/sdk/src/deploy/middleware/LiquidityLayerRouterDeployer.ts +++ b/typescript/sdk/src/middleware/liquidity-layer/LiquidityLayerRouterDeployer.ts @@ -7,17 +7,17 @@ import { } from '@hyperlane-xyz/core'; import { utils } from '@hyperlane-xyz/utils'; -import { - LiquidityLayerContracts, - LiquidityLayerFactories, - liquidityLayerFactories, -} from '../../middleware'; import { MultiProvider } from '../../providers/MultiProvider'; +import { RouterConfig } from '../../router/types'; import { ChainMap, ChainName } from '../../types'; import { objFilter, objMap } from '../../utils/objects'; -import { RouterConfig } from '../router/types'; +import { MiddlewareRouterDeployer } from '../deploy'; -import { MiddlewareRouterDeployer } from './deploy'; +import { + LiquidityLayerContracts, + LiquidityLayerFactories, + liquidityLayerFactories, +} from './contracts'; export enum BridgeAdapterType { Circle = 'Circle', diff --git a/typescript/sdk/src/middleware/liquidity-layer/contracts.ts b/typescript/sdk/src/middleware/liquidity-layer/contracts.ts new file mode 100644 index 000000000..f53ffc654 --- /dev/null +++ b/typescript/sdk/src/middleware/liquidity-layer/contracts.ts @@ -0,0 +1,27 @@ +import { + CircleBridgeAdapter, + CircleBridgeAdapter__factory, + LiquidityLayerRouter, + LiquidityLayerRouter__factory, + PortalAdapter, + PortalAdapter__factory, +} from '@hyperlane-xyz/core'; + +import { ProxiedRouterContracts, RouterFactories } from '../../router/types'; + +export type LiquidityLayerFactories = RouterFactories & { + circleBridgeAdapter: CircleBridgeAdapter__factory; + portalAdapter: PortalAdapter__factory; +}; + +export const liquidityLayerFactories: LiquidityLayerFactories = { + router: new LiquidityLayerRouter__factory(), + circleBridgeAdapter: new CircleBridgeAdapter__factory(), + portalAdapter: new PortalAdapter__factory(), +}; + +export type LiquidityLayerContracts = + ProxiedRouterContracts & { + circleBridgeAdapter?: CircleBridgeAdapter; + portalAdapter?: PortalAdapter; + }; diff --git a/typescript/sdk/src/middleware/liquidity-layer.hardhat-test.ts b/typescript/sdk/src/middleware/liquidity-layer/liquidity-layer.hardhat-test.ts similarity index 91% rename from typescript/sdk/src/middleware/liquidity-layer.hardhat-test.ts rename to typescript/sdk/src/middleware/liquidity-layer/liquidity-layer.hardhat-test.ts index 9c0306387..76bdebc3f 100644 --- a/typescript/sdk/src/middleware/liquidity-layer.hardhat-test.ts +++ b/typescript/sdk/src/middleware/liquidity-layer/liquidity-layer.hardhat-test.ts @@ -16,22 +16,23 @@ import { } from '@hyperlane-xyz/core'; import { utils } from '@hyperlane-xyz/utils'; -import { chainMetadata } from '../consts/chainMetadata'; -import { Chains } from '../consts/chains'; -import { TestCoreApp } from '../core/TestCoreApp'; -import { TestCoreDeployer } from '../core/TestCoreDeployer'; -import { LiquidityLayerApp } from '../deploy/middleware/LiquidityLayerApp'; +import { chainMetadata } from '../../consts/chainMetadata'; +import { Chains } from '../../consts/chains'; +import { TestCoreApp } from '../../core/TestCoreApp'; +import { TestCoreDeployer } from '../../core/TestCoreDeployer'; +import { MultiProvider } from '../../providers/MultiProvider'; +import { getTestOwnerConfig } from '../../test/testUtils'; +import { ChainMap } from '../../types'; +import { objMap } from '../../utils/objects'; + +import { LiquidityLayerApp } from './LiquidityLayerApp'; import { BridgeAdapterType, CircleBridgeAdapterConfig, LiquidityLayerConfig, LiquidityLayerDeployer, PortalAdapterConfig, -} from '../deploy/middleware/LiquidityLayerRouterDeployer'; -import { MultiProvider } from '../providers/MultiProvider'; -import { getTestOwnerConfig } from '../test/testUtils'; -import { ChainMap } from '../types'; -import { objMap } from '../utils/objects'; +} from './LiquidityLayerRouterDeployer'; describe('LiquidityLayerRouter', async () => { const localChain = Chains.test1; diff --git a/typescript/sdk/src/middleware/queries.hardhat-test.ts b/typescript/sdk/src/middleware/queries.hardhat-test.ts index 7b1951c8c..367eb67b7 100644 --- a/typescript/sdk/src/middleware/queries.hardhat-test.ts +++ b/typescript/sdk/src/middleware/queries.hardhat-test.ts @@ -13,12 +13,13 @@ import { chainMetadata } from '../consts/chainMetadata'; import { Chains } from '../consts/chains'; import { TestCoreApp } from '../core/TestCoreApp'; import { TestCoreDeployer } from '../core/TestCoreDeployer'; -import { InterchainQueryDeployer } from '../deploy/middleware/deploy'; -import { RouterConfig } from '../deploy/router/types'; import { MultiProvider } from '../providers/MultiProvider'; +import { RouterConfig } from '../router/types'; import { getTestOwnerConfig } from '../test/testUtils'; import { ChainMap } from '../types'; +import { InterchainQueryDeployer } from './deploy'; + describe('InterchainQueryRouter', async () => { const localChain = Chains.test1; const remoteChain = Chains.test2; diff --git a/typescript/sdk/src/router.ts b/typescript/sdk/src/router.ts deleted file mode 100644 index 1f738c0a1..000000000 --- a/typescript/sdk/src/router.ts +++ /dev/null @@ -1,68 +0,0 @@ -import type { BigNumber, ethers } from 'ethers'; - -import { GasRouter, ProxyAdmin, Router } from '@hyperlane-xyz/core'; -import type { types } from '@hyperlane-xyz/utils'; - -import { HyperlaneApp } from './HyperlaneApp'; -import { HyperlaneContracts, HyperlaneFactories } from './contracts'; -import { ProxiedContract, TransparentProxyAddresses } from './proxy'; -import { ChainMap, ChainName } from './types'; -import { objMap, promiseObjAll } from './utils/objects'; - -export type RouterContracts = - HyperlaneContracts & { - router: RouterContract; - }; - -export type ProxiedRouterContracts = - RouterContracts & { - proxyAdmin: ProxyAdmin; - proxiedRouter: ProxiedContract; - }; - -type RouterFactory = - ethers.ContractFactory & { - deploy: (...args: any[]) => Promise; - }; - -export type RouterFactories = - HyperlaneFactories & { - router: RouterFactory; - }; - -export type ConnectionClientConfig = { - mailbox: types.Address; - interchainGasPaymaster: types.Address; - interchainSecurityModule?: types.Address; -}; - -export { Router } from '@hyperlane-xyz/core'; - -export class RouterApp< - Contracts extends RouterContracts, -> extends HyperlaneApp { - getSecurityModules = (): Promise> => - promiseObjAll( - objMap(this.contractsMap, (_, contracts) => - contracts.router.interchainSecurityModule(), - ), - ); - - getOwners = (): Promise> => - promiseObjAll( - objMap(this.contractsMap, (_, contracts) => contracts.router.owner()), - ); -} - -export class GasRouterApp< - Contracts extends RouterContracts, -> extends RouterApp { - async quoteGasPayment( - origin: ChainName, - destination: ChainName, - ): Promise { - return this.getContracts(origin).router.quoteGasPayment( - this.multiProvider.getDomainId(destination), - ); - } -} diff --git a/typescript/sdk/src/deploy/router/GasRouterDeployer.ts b/typescript/sdk/src/router/GasRouterDeployer.ts similarity index 86% rename from typescript/sdk/src/deploy/router/GasRouterDeployer.ts rename to typescript/sdk/src/router/GasRouterDeployer.ts index 39d8555f3..dfc251fd4 100644 --- a/typescript/sdk/src/deploy/router/GasRouterDeployer.ts +++ b/typescript/sdk/src/router/GasRouterDeployer.ts @@ -2,13 +2,12 @@ import { debug } from 'debug'; import { GasRouter } from '@hyperlane-xyz/core'; -import { MultiProvider } from '../../providers/MultiProvider'; -import { RouterContracts, RouterFactories } from '../../router'; -import { ChainMap } from '../../types'; -import { DeployerOptions } from '../HyperlaneDeployer'; +import { DeployerOptions } from '../deploy/HyperlaneDeployer'; +import { MultiProvider } from '../providers/MultiProvider'; +import { ChainMap } from '../types'; import { HyperlaneRouterDeployer } from './HyperlaneRouterDeployer'; -import { GasRouterConfig } from './types'; +import { GasRouterConfig, RouterContracts, RouterFactories } from './types'; export abstract class GasRouterDeployer< Config extends GasRouterConfig, diff --git a/typescript/sdk/src/deploy/router/HyperlaneRouterChecker.ts b/typescript/sdk/src/router/HyperlaneRouterChecker.ts similarity index 91% rename from typescript/sdk/src/deploy/router/HyperlaneRouterChecker.ts rename to typescript/sdk/src/router/HyperlaneRouterChecker.ts index 05d27bbc2..2a618a4a6 100644 --- a/typescript/sdk/src/deploy/router/HyperlaneRouterChecker.ts +++ b/typescript/sdk/src/router/HyperlaneRouterChecker.ts @@ -3,10 +3,10 @@ import { ethers } from 'ethers'; import { Ownable } from '@hyperlane-xyz/core'; import { utils } from '@hyperlane-xyz/utils'; -import { HyperlaneApp } from '../../HyperlaneApp'; -import { RouterContracts } from '../../router'; -import { ChainName } from '../../types'; -import { HyperlaneAppChecker } from '../HyperlaneAppChecker'; +import { HyperlaneApp } from '../HyperlaneApp'; +import { HyperlaneAppChecker } from '../deploy/HyperlaneAppChecker'; +import { RouterContracts } from '../router/types'; +import { ChainName } from '../types'; import { RouterConfig } from './types'; diff --git a/typescript/sdk/src/deploy/router/HyperlaneRouterDeployer.ts b/typescript/sdk/src/router/HyperlaneRouterDeployer.ts similarity index 93% rename from typescript/sdk/src/deploy/router/HyperlaneRouterDeployer.ts rename to typescript/sdk/src/router/HyperlaneRouterDeployer.ts index 2f97bfe32..afd38d2d8 100644 --- a/typescript/sdk/src/deploy/router/HyperlaneRouterDeployer.ts +++ b/typescript/sdk/src/router/HyperlaneRouterDeployer.ts @@ -2,13 +2,18 @@ import { debug } from 'debug'; import { utils } from '@hyperlane-xyz/utils'; -import { MultiProvider } from '../../providers/MultiProvider'; -import { RouterContracts, RouterFactories } from '../../router'; -import { ChainMap } from '../../types'; -import { objMap, promiseObjAll } from '../../utils/objects'; -import { DeployerOptions, HyperlaneDeployer } from '../HyperlaneDeployer'; - -import { RouterConfig } from './types'; +import { + DeployerOptions, + HyperlaneDeployer, +} from '../deploy/HyperlaneDeployer'; +import { MultiProvider } from '../providers/MultiProvider'; +import { + RouterConfig, + RouterContracts, + RouterFactories, +} from '../router/types'; +import { ChainMap } from '../types'; +import { objMap, promiseObjAll } from '../utils/objects'; export abstract class HyperlaneRouterDeployer< Config extends RouterConfig, diff --git a/typescript/sdk/src/router/RouterApps.ts b/typescript/sdk/src/router/RouterApps.ts new file mode 100644 index 000000000..3801cf850 --- /dev/null +++ b/typescript/sdk/src/router/RouterApps.ts @@ -0,0 +1,41 @@ +import type { BigNumber } from 'ethers'; + +import { GasRouter } from '@hyperlane-xyz/core'; +import type { types } from '@hyperlane-xyz/utils'; + +import { HyperlaneApp } from '../HyperlaneApp'; +import { ChainMap, ChainName } from '../types'; +import { objMap, promiseObjAll } from '../utils/objects'; + +import { RouterContracts } from './types'; + +export { Router } from '@hyperlane-xyz/core'; + +export class RouterApp< + Contracts extends RouterContracts, +> extends HyperlaneApp { + getSecurityModules = (): Promise> => + promiseObjAll( + objMap(this.contractsMap, (_, contracts) => + contracts.router.interchainSecurityModule(), + ), + ); + + getOwners = (): Promise> => + promiseObjAll( + objMap(this.contractsMap, (_, contracts) => contracts.router.owner()), + ); +} + +export class GasRouterApp< + Contracts extends RouterContracts, +> extends RouterApp { + async quoteGasPayment( + origin: ChainName, + destination: ChainName, + ): Promise { + return this.getContracts(origin).router.quoteGasPayment( + this.multiProvider.getDomainId(destination), + ); + } +} diff --git a/typescript/sdk/src/router/types.ts b/typescript/sdk/src/router/types.ts new file mode 100644 index 000000000..fccf928fe --- /dev/null +++ b/typescript/sdk/src/router/types.ts @@ -0,0 +1,46 @@ +import { ethers } from 'ethers'; + +import { ProxyAdmin, Router } from '@hyperlane-xyz/core'; +import type { types } from '@hyperlane-xyz/utils'; + +import { HyperlaneContracts, HyperlaneFactories } from '../contracts'; +import { ProxiedContract, TransparentProxyAddresses } from '../proxy'; + +export type OwnableConfig = { + owner: types.Address; +}; + +export type RouterConfig = ConnectionClientConfig & OwnableConfig; + +type GasConfig = { + gas: number; +}; + +export type GasRouterConfig = RouterConfig & GasConfig; + +export type RouterContracts = + HyperlaneContracts & { + router: RouterContract; + }; + +export type ProxiedRouterContracts = + RouterContracts & { + proxyAdmin: ProxyAdmin; + proxiedRouter: ProxiedContract; + }; + +type RouterFactory = + ethers.ContractFactory & { + deploy: (...args: any[]) => Promise; + }; + +export type RouterFactories = + HyperlaneFactories & { + router: RouterFactory; + }; + +export type ConnectionClientConfig = { + mailbox: types.Address; + interchainGasPaymaster: types.Address; + interchainSecurityModule?: types.Address; +}; diff --git a/typescript/sdk/src/test/envSubsetDeployer/app.ts b/typescript/sdk/src/test/envSubsetDeployer/app.ts index bdbea263d..036cf8b68 100644 --- a/typescript/sdk/src/test/envSubsetDeployer/app.ts +++ b/typescript/sdk/src/test/envSubsetDeployer/app.ts @@ -5,11 +5,14 @@ import { chainMetadata } from '../../consts/chainMetadata'; import { Chains, TestChains } from '../../consts/chains'; import { HyperlaneCore } from '../../core/HyperlaneCore'; import { HyperlaneDeployer } from '../../deploy/HyperlaneDeployer'; -import { HyperlaneRouterChecker } from '../../deploy/router/HyperlaneRouterChecker'; -import { HyperlaneRouterDeployer } from '../../deploy/router/HyperlaneRouterDeployer'; -import { RouterConfig } from '../../deploy/router/types'; import { MultiProvider } from '../../providers/MultiProvider'; -import { RouterContracts, RouterFactories } from '../../router'; +import { HyperlaneRouterChecker } from '../../router/HyperlaneRouterChecker'; +import { HyperlaneRouterDeployer } from '../../router/HyperlaneRouterDeployer'; +import { + RouterConfig, + RouterContracts, + RouterFactories, +} from '../../router/types'; import { ChainMap, ChainName } from '../../types'; import { objMap, pick, promiseObjAll } from '../../utils/objects'; diff --git a/typescript/sdk/src/test/envSubsetDeployer/check-single-chain.ts b/typescript/sdk/src/test/envSubsetDeployer/check-single-chain.ts index fbcb37be6..8632ee869 100644 --- a/typescript/sdk/src/test/envSubsetDeployer/check-single-chain.ts +++ b/typescript/sdk/src/test/envSubsetDeployer/check-single-chain.ts @@ -2,7 +2,7 @@ import { buildContracts } from '../../contracts'; import { HyperlaneCore } from '../../core/HyperlaneCore'; import { getChainToOwnerMap } from '../../deploy/utils'; import { MultiProvider } from '../../providers/MultiProvider'; -import { RouterContracts } from '../../router'; +import { RouterContracts } from '../../router/types'; import { ChainMap } from '../../types'; import { diff --git a/typescript/sdk/src/test/envSubsetDeployer/deploy.hardhat-test.ts b/typescript/sdk/src/test/envSubsetDeployer/deploy.hardhat-test.ts index d03c94e83..0c9c48ca9 100644 --- a/typescript/sdk/src/test/envSubsetDeployer/deploy.hardhat-test.ts +++ b/typescript/sdk/src/test/envSubsetDeployer/deploy.hardhat-test.ts @@ -4,10 +4,9 @@ import { ethers } from 'hardhat'; import { ChainMetadata } from '../../consts/chainMetadata'; import { TestCoreApp } from '../../core/TestCoreApp'; import { TestCoreDeployer } from '../../core/TestCoreDeployer'; -import { RouterConfig } from '../../deploy/router/types'; import { getChainToOwnerMap } from '../../deploy/utils'; import { MultiProvider } from '../../providers/MultiProvider'; -import { RouterContracts } from '../../router'; +import { RouterConfig, RouterContracts } from '../../router/types'; import { ChainMap } from '../../types'; import {