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
parent
dd5478f740
commit
8c456c97f4
@ -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; |
||||||
|
} |
@ -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; |
|
||||||
}; |
|
@ -1,20 +1,40 @@ |
|||||||
import { ethers } from 'ethers'; |
import { ethers } from 'ethers'; |
||||||
|
|
||||||
import { ProxyAdmin__factory } from '@hyperlane-xyz/core'; |
import { ProxyAdmin__factory } from '@hyperlane-xyz/core'; |
||||||
|
|
||||||
import { |
import { |
||||||
InterchainAccountContracts, |
InterchainAccountRouter, |
||||||
InterchainAccountFactories, |
InterchainAccountRouter__factory, |
||||||
InterchainQueryContracts, |
InterchainQueryRouter, |
||||||
InterchainQueryFactories, |
InterchainQueryRouter__factory, |
||||||
interchainAccountFactories, |
} from '@hyperlane-xyz/core'; |
||||||
interchainQueryFactories, |
|
||||||
} from '../../middleware'; |
import { MultiProvider } from '../providers/MultiProvider'; |
||||||
import { MultiProvider } from '../../providers/MultiProvider'; |
|
||||||
import { ProxiedRouterContracts, RouterFactories } from '../../router'; |
|
||||||
import { ChainMap, ChainName } from '../../types'; |
|
||||||
import { HyperlaneRouterDeployer } from '../router/HyperlaneRouterDeployer'; |
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< |
export abstract class MiddlewareRouterDeployer< |
||||||
MiddlewareRouterConfig extends RouterConfig, |
MiddlewareRouterConfig extends RouterConfig, |
@ -0,0 +1,5 @@ |
|||||||
|
{ |
||||||
|
"rules": { |
||||||
|
"no-console": ["off"] |
||||||
|
} |
||||||
|
} |
@ -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; |
||||||
|
}; |
@ -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), |
|
||||||
); |
|
||||||
} |
|
||||||
} |
|
@ -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; |
||||||
|
}; |
Loading…
Reference in new issue