Skip to content

Commit

Permalink
refactor: Combine schema and types files (#4966)
Browse files Browse the repository at this point in the history
### Description

- Combine remaining schema and types files
- Rename TokenConfig related types and utilities for clarity. E.g.
`CollateralConfig` to `CollateralTokenConfig`.
- De-dupe some Ownable types
- Export more schemas from SDK

### Backward compatibility

No
  • Loading branch information
jmrossy authored Dec 9, 2024
1 parent 472b346 commit 26fbec8
Show file tree
Hide file tree
Showing 82 changed files with 815 additions and 818 deletions.
6 changes: 6 additions & 0 deletions .changeset/fresh-fishes-bake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@hyperlane-xyz/sdk': major
---

Rename TokenConfig related types and utilities for clarity. E.g. `CollateralConfig` to `CollateralTokenConfig`.
Export more config types and zod schemas
4 changes: 2 additions & 2 deletions typescript/cli/src/deploy/warp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import {
connectContractsMap,
getTokenConnectionId,
hypERC20factories,
isCollateralConfig,
isCollateralTokenConfig,
isTokenMetadata,
serializeContracts,
} from '@hyperlane-xyz/sdk';
Expand Down Expand Up @@ -398,7 +398,7 @@ function generateTokenConfigs(
): void {
for (const [chainName, contract] of Object.entries(contracts)) {
const config = warpDeployConfig[chainName];
const collateralAddressOrDenom = isCollateralConfig(config)
const collateralAddressOrDenom = isCollateralTokenConfig(config)
? config.token // gets set in the above deriveTokenMetadata()
: undefined;

Expand Down
4 changes: 2 additions & 2 deletions typescript/cli/src/tests/commands/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { $ } from 'zx';
import { ERC20Test__factory, ERC4626Test__factory } from '@hyperlane-xyz/core';
import { ChainAddresses } from '@hyperlane-xyz/registry';
import {
TokenRouterConfig,
HypTokenRouterConfig,
WarpCoreConfig,
WarpCoreConfigSchema,
} from '@hyperlane-xyz/sdk';
Expand Down Expand Up @@ -92,7 +92,7 @@ export async function updateOwner(
export async function extendWarpConfig(params: {
chain: string;
chainToExtend: string;
extendedConfig: TokenRouterConfig;
extendedConfig: HypTokenRouterConfig;
warpCorePath: string;
warpDeployPath: string;
strategyUrl?: string;
Expand Down
10 changes: 5 additions & 5 deletions typescript/cli/src/tests/warp-apply.e2e-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Wallet } from 'ethers';
import { ChainAddresses } from '@hyperlane-xyz/registry';
import {
HookType,
TokenRouterConfig,
HypTokenRouterConfig,
TokenType,
WarpRouteDeployConfig,
normalizeConfig,
Expand Down Expand Up @@ -144,7 +144,7 @@ describe('hyperlane warp apply e2e tests', async function () {
await readWarpConfig(CHAIN_NAME_2, WARP_CORE_CONFIG_PATH_2, warpConfigPath);

// Extend with new config
const config: TokenRouterConfig = {
const config: HypTokenRouterConfig = {
decimals: 18,
mailbox: chain2Addresses!.mailbox,
name: 'Ether',
Expand Down Expand Up @@ -197,7 +197,7 @@ describe('hyperlane warp apply e2e tests', async function () {
await readWarpConfig(CHAIN_NAME_2, WARP_CORE_CONFIG_PATH_2, warpConfigPath);

// Extend with new config
const config: TokenRouterConfig = {
const config: HypTokenRouterConfig = {
decimals: 18,
mailbox: chain2Addresses!.mailbox,
name: 'Ether',
Expand Down Expand Up @@ -257,7 +257,7 @@ describe('hyperlane warp apply e2e tests', async function () {

// Extend with new config
const randomOwner = new Wallet(ANVIL_KEY).address;
const extendedConfig: TokenRouterConfig = {
const extendedConfig: HypTokenRouterConfig = {
decimals: 18,
mailbox: chain2Addresses!.mailbox,
name: 'Ether',
Expand Down Expand Up @@ -317,7 +317,7 @@ describe('hyperlane warp apply e2e tests', async function () {

// Extend with new config
const GAS = 694200;
const extendedConfig: TokenRouterConfig = {
const extendedConfig: HypTokenRouterConfig = {
decimals: 18,
mailbox: chain2Addresses!.mailbox,
name: 'Ether',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { ethers } from 'ethers';

import {
ChainMap,
HypTokenRouterConfig,
OwnableConfig,
TokenRouterConfig,
TokenType,
buildAggregationIsmConfigs,
defaultMultisigConfigs,
Expand All @@ -17,14 +17,14 @@ import {
export const getAncient8EthereumUSDCWarpConfig = async (
routerConfig: ChainMap<RouterConfigWithoutOwner>,
abacusWorksEnvOwnerConfig: ChainMap<OwnableConfig>,
): Promise<ChainMap<TokenRouterConfig>> => {
): Promise<ChainMap<HypTokenRouterConfig>> => {
const ismConfig = buildAggregationIsmConfigs(
'ethereum',
['ancient8'],
defaultMultisigConfigs,
).ancient8;

const ethereum: TokenRouterConfig = {
const ethereum: HypTokenRouterConfig = {
...routerConfig.ethereum,
...abacusWorksEnvOwnerConfig.ethereum,
type: TokenType.collateral,
Expand All @@ -36,7 +36,7 @@ export const getAncient8EthereumUSDCWarpConfig = async (
hook: '0x19b2cF952b70b217c90FC408714Fbc1acD29A6A8',
};

const ancient8: TokenRouterConfig = {
const ancient8: HypTokenRouterConfig = {
...routerConfig.ancient8,
...abacusWorksEnvOwnerConfig.ancient8,
type: TokenType.synthetic,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import { ethers } from 'ethers';

import {
ChainMap,
HypTokenRouterConfig,
IsmConfig,
OwnableConfig,
RouterConfig,
TokenRouterConfig,
TokenType,
} from '@hyperlane-xyz/sdk';

Expand All @@ -18,10 +17,10 @@ export const getArbitrumBaseBlastBscEthereumGnosisMantleModeOptimismPolygonScrol
async (
routerConfig: ChainMap<RouterConfigWithoutOwner>,
abacusWorksEnvOwnerConfig: ChainMap<OwnableConfig>,
): Promise<ChainMap<TokenRouterConfig>> => {
): Promise<ChainMap<HypTokenRouterConfig>> => {
const ISM_CONFIG: IsmConfig = ethers.constants.AddressZero;

const arbitrum: TokenRouterConfig = {
const arbitrum: HypTokenRouterConfig = {
...routerConfig.arbitrum,
...abacusWorksEnvOwnerConfig.arbitrum,
proxyAdmin: {
Expand All @@ -32,7 +31,7 @@ export const getArbitrumBaseBlastBscEthereumGnosisMantleModeOptimismPolygonScrol
interchainSecurityModule: ISM_CONFIG,
};

const base: TokenRouterConfig = {
const base: HypTokenRouterConfig = {
...routerConfig.base,
...abacusWorksEnvOwnerConfig.base,
proxyAdmin: {
Expand All @@ -43,7 +42,7 @@ export const getArbitrumBaseBlastBscEthereumGnosisMantleModeOptimismPolygonScrol
interchainSecurityModule: ISM_CONFIG,
};

const blast: TokenRouterConfig = {
const blast: HypTokenRouterConfig = {
...routerConfig.blast,
...abacusWorksEnvOwnerConfig.blast,
proxyAdmin: {
Expand All @@ -54,7 +53,7 @@ export const getArbitrumBaseBlastBscEthereumGnosisMantleModeOptimismPolygonScrol
interchainSecurityModule: ISM_CONFIG,
};

const bsc: TokenRouterConfig = {
const bsc: HypTokenRouterConfig = {
...routerConfig.bsc,
...abacusWorksEnvOwnerConfig.bsc,
proxyAdmin: {
Expand All @@ -66,7 +65,7 @@ export const getArbitrumBaseBlastBscEthereumGnosisMantleModeOptimismPolygonScrol
interchainSecurityModule: ISM_CONFIG,
};

const ethereum: TokenRouterConfig = {
const ethereum: HypTokenRouterConfig = {
...routerConfig.ethereum,
...abacusWorksEnvOwnerConfig.ethereum,
proxyAdmin: {
Expand All @@ -77,7 +76,7 @@ export const getArbitrumBaseBlastBscEthereumGnosisMantleModeOptimismPolygonScrol
interchainSecurityModule: ISM_CONFIG,
};

const gnosis: TokenRouterConfig = {
const gnosis: HypTokenRouterConfig = {
...routerConfig.gnosis,
...abacusWorksEnvOwnerConfig.gnosis,
proxyAdmin: {
Expand All @@ -89,7 +88,7 @@ export const getArbitrumBaseBlastBscEthereumGnosisMantleModeOptimismPolygonScrol
interchainSecurityModule: ISM_CONFIG,
};

const mantle: TokenRouterConfig = {
const mantle: HypTokenRouterConfig = {
...routerConfig.mantle,
...abacusWorksEnvOwnerConfig.mantle,
proxyAdmin: {
Expand All @@ -101,7 +100,7 @@ export const getArbitrumBaseBlastBscEthereumGnosisMantleModeOptimismPolygonScrol
interchainSecurityModule: ISM_CONFIG,
};

const mode: TokenRouterConfig = {
const mode: HypTokenRouterConfig = {
...routerConfig.mode,
...abacusWorksEnvOwnerConfig.mode,
proxyAdmin: {
Expand All @@ -112,7 +111,7 @@ export const getArbitrumBaseBlastBscEthereumGnosisMantleModeOptimismPolygonScrol
interchainSecurityModule: ISM_CONFIG,
};

const optimism: TokenRouterConfig = {
const optimism: HypTokenRouterConfig = {
...routerConfig.optimism,
...abacusWorksEnvOwnerConfig.optimism,
proxyAdmin: {
Expand All @@ -123,7 +122,7 @@ export const getArbitrumBaseBlastBscEthereumGnosisMantleModeOptimismPolygonScrol
interchainSecurityModule: ISM_CONFIG,
};

const polygon: TokenRouterConfig = {
const polygon: HypTokenRouterConfig = {
...routerConfig.polygon,
...abacusWorksEnvOwnerConfig.polygon,
proxyAdmin: {
Expand All @@ -135,7 +134,7 @@ export const getArbitrumBaseBlastBscEthereumGnosisMantleModeOptimismPolygonScrol
interchainSecurityModule: ISM_CONFIG,
};

const scroll: TokenRouterConfig = {
const scroll: HypTokenRouterConfig = {
...routerConfig.scroll,
...abacusWorksEnvOwnerConfig.scroll,
proxyAdmin: {
Expand All @@ -146,7 +145,7 @@ export const getArbitrumBaseBlastBscEthereumGnosisMantleModeOptimismPolygonScrol
interchainSecurityModule: ISM_CONFIG,
};

const zeronetwork: TokenRouterConfig = {
const zeronetwork: HypTokenRouterConfig = {
...routerConfig.zeronetwork,
...abacusWorksEnvOwnerConfig.zeronetwork,
proxyAdmin: {
Expand All @@ -157,7 +156,7 @@ export const getArbitrumBaseBlastBscEthereumGnosisMantleModeOptimismPolygonScrol
interchainSecurityModule: ISM_CONFIG,
};

const zoramainnet: TokenRouterConfig = {
const zoramainnet: HypTokenRouterConfig = {
...routerConfig.zoramainnet,
...abacusWorksEnvOwnerConfig.zoramainnet,
proxyAdmin: {
Expand All @@ -168,7 +167,7 @@ export const getArbitrumBaseBlastBscEthereumGnosisMantleModeOptimismPolygonScrol
interchainSecurityModule: ISM_CONFIG,
};

const lisk: TokenRouterConfig = {
const lisk: HypTokenRouterConfig = {
...routerConfig.lisk,
...abacusWorksEnvOwnerConfig.lisk,
proxyAdmin: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import { ethers } from 'ethers';

import {
ChainMap,
HypTokenRouterConfig,
OwnableConfig,
RouterConfig,
TokenRouterConfig,
TokenType,
} from '@hyperlane-xyz/sdk';

Expand All @@ -16,10 +15,10 @@ import {
export const getArbitrumBaseEthereumOptimismPolygonZeroNetworkUSDC = async (
routerConfig: ChainMap<RouterConfigWithoutOwner>,
abacusWorksEnvOwnerConfig: ChainMap<OwnableConfig>,
): Promise<ChainMap<TokenRouterConfig>> => {
): Promise<ChainMap<HypTokenRouterConfig>> => {
const ISM_CONFIG = ethers.constants.AddressZero;

const arbitrum: TokenRouterConfig = {
const arbitrum: HypTokenRouterConfig = {
...routerConfig.arbitrum,
...abacusWorksEnvOwnerConfig.arbitrum,
proxyAdmin: {
Expand All @@ -31,7 +30,7 @@ export const getArbitrumBaseEthereumOptimismPolygonZeroNetworkUSDC = async (
interchainSecurityModule: ISM_CONFIG,
};

const base: TokenRouterConfig = {
const base: HypTokenRouterConfig = {
...routerConfig.base,
...abacusWorksEnvOwnerConfig.base,
proxyAdmin: {
Expand All @@ -43,7 +42,7 @@ export const getArbitrumBaseEthereumOptimismPolygonZeroNetworkUSDC = async (
interchainSecurityModule: ISM_CONFIG,
};

const optimism: TokenRouterConfig = {
const optimism: HypTokenRouterConfig = {
...routerConfig.optimism,
...abacusWorksEnvOwnerConfig.optimism,
proxyAdmin: {
Expand All @@ -55,7 +54,7 @@ export const getArbitrumBaseEthereumOptimismPolygonZeroNetworkUSDC = async (
interchainSecurityModule: ISM_CONFIG,
};

const polygon: TokenRouterConfig = {
const polygon: HypTokenRouterConfig = {
...routerConfig.polygon,
...abacusWorksEnvOwnerConfig.polygon,
proxyAdmin: {
Expand All @@ -67,7 +66,7 @@ export const getArbitrumBaseEthereumOptimismPolygonZeroNetworkUSDC = async (
interchainSecurityModule: ISM_CONFIG,
};

const zeronetwork: TokenRouterConfig = {
const zeronetwork: HypTokenRouterConfig = {
...routerConfig.zeronetwork,
...abacusWorksEnvOwnerConfig.zeronetwork,
proxyAdmin: {
Expand All @@ -79,7 +78,7 @@ export const getArbitrumBaseEthereumOptimismPolygonZeroNetworkUSDC = async (
interchainSecurityModule: ISM_CONFIG,
};

const ethereum: TokenRouterConfig = {
const ethereum: HypTokenRouterConfig = {
...routerConfig.ethereum,
...abacusWorksEnvOwnerConfig.ethereum,
proxyAdmin: {
Expand All @@ -91,7 +90,7 @@ export const getArbitrumBaseEthereumOptimismPolygonZeroNetworkUSDC = async (
interchainSecurityModule: ISM_CONFIG,
};

const lisk: TokenRouterConfig = {
const lisk: HypTokenRouterConfig = {
...routerConfig.lisk,
...abacusWorksEnvOwnerConfig.lisk,
proxyAdmin: {
Expand Down
Loading

0 comments on commit 26fbec8

Please sign in to comment.