Minor SDK refactor (#1904)

### Description

Move `sdk/src/deploy/X` to `sdk/src/X`, where appropriate

**Consumers of the SDK should not need to make any changes**

### Drive-by changes

None

### Related issues

Using this as a base for moving some of the IGP deployment tooling out
of `HyperlaneCoreDeployer` into `HyperlaneIgpDeployer`

### Backward compatibility

_Are these changes backward compatible?_

Yes

_Are there any infrastructure implications, e.g. changes that would
prohibit deploying older commits using this infra tooling?_

None


### Testing

_What kind of testing have these changes undergone?_

None

---------

Co-authored-by: Trevor Porter <trkporter@ucdavis.edu>
pull/1923/head
Asa Oines 2 years ago committed by GitHub
parent dd5478f740
commit 8c456c97f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      typescript/sdk/src/core/HyperlaneCore.ts
  2. 6
      typescript/sdk/src/core/HyperlaneCoreChecker.ts
  3. 20
      typescript/sdk/src/core/HyperlaneCoreDeployer.ts
  4. 4
      typescript/sdk/src/core/TestCoreDeployer.ts
  5. 4
      typescript/sdk/src/core/types.ts
  6. 15
      typescript/sdk/src/deploy/router/types.ts
  7. 0
      typescript/sdk/src/deploy/verify/.eslintrc
  8. 70
      typescript/sdk/src/gas/types.ts
  9. 33
      typescript/sdk/src/index.ts
  10. 50
      typescript/sdk/src/middleware.ts
  11. 9
      typescript/sdk/src/middleware/accounts.hardhat-test.ts
  12. 44
      typescript/sdk/src/middleware/deploy.ts
  13. 5
      typescript/sdk/src/middleware/liquidity-layer/.eslintrc
  14. 2
      typescript/sdk/src/middleware/liquidity-layer/LiquidityLayerApp.ts
  15. 14
      typescript/sdk/src/middleware/liquidity-layer/LiquidityLayerRouterDeployer.ts
  16. 27
      typescript/sdk/src/middleware/liquidity-layer/contracts.ts
  17. 21
      typescript/sdk/src/middleware/liquidity-layer/liquidity-layer.hardhat-test.ts
  18. 5
      typescript/sdk/src/middleware/queries.hardhat-test.ts
  19. 68
      typescript/sdk/src/router.ts
  20. 9
      typescript/sdk/src/router/GasRouterDeployer.ts
  21. 8
      typescript/sdk/src/router/HyperlaneRouterChecker.ts
  22. 19
      typescript/sdk/src/router/HyperlaneRouterDeployer.ts
  23. 41
      typescript/sdk/src/router/RouterApps.ts
  24. 46
      typescript/sdk/src/router/types.ts
  25. 11
      typescript/sdk/src/test/envSubsetDeployer/app.ts
  26. 2
      typescript/sdk/src/test/envSubsetDeployer/check-single-chain.ts
  27. 3
      typescript/sdk/src/test/envSubsetDeployer/deploy.hardhat-test.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';

@ -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,

@ -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<

@ -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');

@ -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',

@ -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;

@ -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<types.Address>;
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<types.Address>;
expected: Set<types.Address>;
}
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;
}

@ -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,

@ -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<InterchainAccountRouter>;
export const interchainAccountFactories: InterchainAccountFactories = {
router: new InterchainAccountRouter__factory(),
};
export type InterchainAccountContracts =
ProxiedRouterContracts<InterchainAccountRouter>;
export type InterchainQueryFactories = RouterFactories<InterchainQueryRouter>;
export const interchainQueryFactories: InterchainQueryFactories = {
router: new InterchainQueryRouter__factory(),
};
export type InterchainQueryContracts =
ProxiedRouterContracts<InterchainQueryRouter>;
export type LiquidityLayerFactories = RouterFactories<LiquidityLayerRouter> & {
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<LiquidityLayerRouter> & {
circleBridgeAdapter?: CircleBridgeAdapter;
portalAdapter?: PortalAdapter;
};

@ -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;

@ -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<InterchainAccountRouter>;
export const interchainAccountFactories: InterchainAccountFactories = {
router: new InterchainAccountRouter__factory(),
};
export type InterchainAccountContracts =
ProxiedRouterContracts<InterchainAccountRouter>;
export type InterchainQueryFactories = RouterFactories<InterchainQueryRouter>;
export const interchainQueryFactories: InterchainQueryFactories = {
router: new InterchainQueryRouter__factory(),
};
export type InterchainQueryContracts =
ProxiedRouterContracts<InterchainQueryRouter>;
export abstract class MiddlewareRouterDeployer<
MiddlewareRouterConfig extends RouterConfig,

@ -0,0 +1,5 @@
{
"rules": {
"no-console": ["off"]
}
}

@ -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/';

@ -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',

@ -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<LiquidityLayerRouter> & {
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<LiquidityLayerRouter> & {
circleBridgeAdapter?: CircleBridgeAdapter;
portalAdapter?: PortalAdapter;
};

@ -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;

@ -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;

@ -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<RouterContract extends Router = Router> =
HyperlaneContracts & {
router: RouterContract;
};
export type ProxiedRouterContracts<RouterContract extends Router = Router> =
RouterContracts<RouterContract> & {
proxyAdmin: ProxyAdmin;
proxiedRouter: ProxiedContract<RouterContract, TransparentProxyAddresses>;
};
type RouterFactory<RouterContract extends Router = Router> =
ethers.ContractFactory & {
deploy: (...args: any[]) => Promise<RouterContract>;
};
export type RouterFactories<RouterContract extends Router = Router> =
HyperlaneFactories & {
router: RouterFactory<RouterContract>;
};
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<Contracts> {
getSecurityModules = (): Promise<ChainMap<types.Address>> =>
promiseObjAll(
objMap(this.contractsMap, (_, contracts) =>
contracts.router.interchainSecurityModule(),
),
);
getOwners = (): Promise<ChainMap<types.Address>> =>
promiseObjAll(
objMap(this.contractsMap, (_, contracts) => contracts.router.owner()),
);
}
export class GasRouterApp<
Contracts extends RouterContracts<GasRouter>,
> extends RouterApp<Contracts> {
async quoteGasPayment(
origin: ChainName,
destination: ChainName,
): Promise<BigNumber> {
return this.getContracts(origin).router.quoteGasPayment(
this.multiProvider.getDomainId(destination),
);
}
}

@ -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,

@ -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';

@ -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,

@ -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<Contracts> {
getSecurityModules = (): Promise<ChainMap<types.Address>> =>
promiseObjAll(
objMap(this.contractsMap, (_, contracts) =>
contracts.router.interchainSecurityModule(),
),
);
getOwners = (): Promise<ChainMap<types.Address>> =>
promiseObjAll(
objMap(this.contractsMap, (_, contracts) => contracts.router.owner()),
);
}
export class GasRouterApp<
Contracts extends RouterContracts<GasRouter>,
> extends RouterApp<Contracts> {
async quoteGasPayment(
origin: ChainName,
destination: ChainName,
): Promise<BigNumber> {
return this.getContracts(origin).router.quoteGasPayment(
this.multiProvider.getDomainId(destination),
);
}
}

@ -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<RouterContract extends Router = Router> =
HyperlaneContracts & {
router: RouterContract;
};
export type ProxiedRouterContracts<RouterContract extends Router = Router> =
RouterContracts<RouterContract> & {
proxyAdmin: ProxyAdmin;
proxiedRouter: ProxiedContract<RouterContract, TransparentProxyAddresses>;
};
type RouterFactory<RouterContract extends Router = Router> =
ethers.ContractFactory & {
deploy: (...args: any[]) => Promise<RouterContract>;
};
export type RouterFactories<RouterContract extends Router = Router> =
HyperlaneFactories & {
router: RouterFactory<RouterContract>;
};
export type ConnectionClientConfig = {
mailbox: types.Address;
interchainGasPaymaster: types.Address;
interchainSecurityModule?: types.Address;
};

@ -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';

@ -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 {

@ -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 {

Loading…
Cancel
Save