diff --git a/.changeset/quiet-ways-pay.md b/.changeset/quiet-ways-pay.md new file mode 100644 index 000000000..89eed483b --- /dev/null +++ b/.changeset/quiet-ways-pay.md @@ -0,0 +1,5 @@ +--- +'@hyperlane-xyz/cli': patch +--- + +Remove extra fields from warp core config diff --git a/typescript/cli/src/deploy/warp.ts b/typescript/cli/src/deploy/warp.ts index 58758eac8..a00974618 100644 --- a/typescript/cli/src/deploy/warp.ts +++ b/typescript/cli/src/deploy/warp.ts @@ -19,7 +19,12 @@ import { isTokenMetadata, serializeContracts, } from '@hyperlane-xyz/sdk'; -import { ProtocolType, objMap, promiseObjAll } from '@hyperlane-xyz/utils'; +import { + ProtocolType, + assert, + objMap, + promiseObjAll, +} from '@hyperlane-xyz/utils'; import { readWarpRouteDeployConfig } from '../config/warp.js'; import { MINIMUM_WARP_DEPLOY_GAS } from '../consts.js'; @@ -261,31 +266,24 @@ async function getWarpCoreConfig( context.multiProvider, configMap, ); + assert( + tokenMetadata && isTokenMetadata(tokenMetadata), + 'Missing required token metadata', + ); + const { decimals, symbol, name } = tokenMetadata; + assert(decimals, 'Missing decimals on token metadata'); // First pass, create token configs for (const [chainName, contract] of Object.entries(contracts)) { const config = configMap[chainName]; - const metadata = { - ...tokenMetadata, - ...config, - }; - - if (!isTokenMetadata(metadata)) { - throw new Error('Missing required token metadata'); - } - - const { decimals } = metadata; - if (!decimals) { - throw new Error('Missing decimals on token metadata'); - } - const collateralAddressOrDenom = config.type === TokenType.collateral ? config.token : undefined; warpCoreConfig.tokens.push({ chainName, standard: TOKEN_TYPE_TO_STANDARD[config.type], - ...metadata, decimals, + symbol, + name, addressOrDenom: contract[configMap[chainName].type as keyof TokenFactories].address, collateralAddressOrDenom, diff --git a/typescript/utils/src/validation.ts b/typescript/utils/src/validation.ts index 1b3dd2289..29ac931c6 100644 --- a/typescript/utils/src/validation.ts +++ b/typescript/utils/src/validation.ts @@ -1,7 +1,7 @@ export function assert( predicate: T, errorMessage?: string, -): asserts predicate is NonNullable { +): asserts predicate { if (!predicate) { throw new Error(errorMessage ?? 'Error'); }