Skip to content

Commit

Permalink
feat(cli): display formatted deployment plan to confirm core deploy (#…
Browse files Browse the repository at this point in the history
…4050)

### Description

- Displays formatted deployment plan to confirm core deploy

### Drive-by changes

- none

### Related issues

- Fixes P1

### Backward compatibility

- yes
 
### Testing

- Output:
```
➜  cli git:(cli-2.0) ✗ hl core deploy --registry $HOME/workplace/Hyperlane/hyperlane-registry
Hyperlane CLI

Hyperlane permissionless deployment
------------------------------------------------
? Select chain to connect: alpha

Deployment plan
===============
Transaction signer and owner of new contracts: 0x16F4898F47c085C41d7Cc6b1dc72B91EA617dcBb
Deploying core contracts to network: alpha
┌────────────────────────┬──────────────────────────────────────────────┐
│ (index)                │ Values                                       │
├────────────────────────┼──────────────────────────────────────────────┤
│ Name                   │ 'alpha'                                      │
│ Display Name           │ 'Alpha'                                      │
│ Chain ID               │ 75904                                        │
│ Domain ID              │ 75904                                        │
│ Protocol               │ 'ethereum'                                   │
│ JSON RPC URL           │ 'https://alpha-tk.rpc.caldera.xyz/http' │
│ Native Token: Symbol   │ 'ETH'                                        │
│ Native Token: Name     │ 'Ether'                                      │
│ Native Token: Decimals │ 18                                           │
└────────────────────────┴──────────────────────────────────────────────┘
Note: There are several contracts required for each chain, but contracts in your provided registries will be skipped.
? Is this deployment plan correct? (Y/n)
```
  • Loading branch information
nbayindirli authored Jun 25, 2024
1 parent 47cba13 commit c81721e
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions typescript/cli/src/deploy/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { BigNumber, ethers } from 'ethers';

import {
ChainMap,
ChainMetadata,
ChainName,
IsmConfig,
MultisigConfig,
Expand All @@ -12,7 +13,14 @@ import { Address, ProtocolType } from '@hyperlane-xyz/utils';

import { parseIsmConfig } from '../config/ism.js';
import { WriteCommandContext } from '../context/types.js';
import { log, logBlue, logGray, logGreen, logPink } from '../logger.js';
import {
log,
logBlue,
logGray,
logGreen,
logPink,
logTable,
} from '../logger.js';
import { gasBalancesAreSufficient } from '../utils/balances.js';
import { ENV } from '../utils/env.js';
import { assertSigner } from '../utils/keys.js';
Expand Down Expand Up @@ -63,15 +71,19 @@ export async function runDeployPlanStep({
context: WriteCommandContext;
chain: ChainName;
}) {
const { signer, skipConfirmation } = context;
const { signer, chainMetadata: chainMetadataMap, skipConfirmation } = context;
const address = await signer.getAddress();

logBlue('\nDeployment plan');
logGray('===============');
log(`Transaction signer and owner of new contracts will be ${address}`);
log(`Deploying to ${chain}`);
log(`Transaction signer and owner of new contracts: ${address}`);
log(`Deploying core contracts to network: ${chain}`);
const transformedChainMetadata = transformChainMetadataForDisplay(
chainMetadataMap[chain],
);
logTable(transformedChainMetadata);
log(
`There are several contracts required for each chain but contracts in your provided registries will be skipped`,
`Note: There are several contracts required for each chain, but contracts in your provided registries will be skipped.`,
);

if (skipConfirmation) return;
Expand Down Expand Up @@ -143,3 +155,17 @@ export async function completeDeploy(
export function toUpperCamelCase(string: string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}

function transformChainMetadataForDisplay(chainMetadata: ChainMetadata) {
return {
Name: chainMetadata.name,
'Display Name': chainMetadata.displayName,
'Chain ID': chainMetadata.chainId,
'Domain ID': chainMetadata.domainId,
Protocol: chainMetadata.protocol,
'JSON RPC URL': chainMetadata.rpcUrls[0].http,
'Native Token: Symbol': chainMetadata.nativeToken?.symbol,
'Native Token: Name': chainMetadata.nativeToken?.name,
'Native Token: Decimals': chainMetadata.nativeToken?.decimals,
};
}

0 comments on commit c81721e

Please sign in to comment.