Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Commit

Permalink
feat:configure hooks in the CLI (hyperlane-xyz#2964)
Browse files Browse the repository at this point in the history
### Description

- enable configuring hooks in the CLI (merkle, igp, protocolFee,
aggregation, routing)
- use preset by default without prompting

### Drive-by changes

<!--
Are there any minor or drive-by changes also included?
-->

### Related issues

<!--
- Fixes #[issue number here]
-->

### Backward compatibility

<!--
Are these changes backward compatible? Are there any infrastructure
implications, e.g. changes that would prohibit deploying older commits
using this infra tooling?

Yes/No
-->

### Testing

<!--
What kind of testing have these changes undergone?

None/Manual/Unit Tests
-->
  • Loading branch information
aroralanuk committed Dec 1, 2023
1 parent 9fc0866 commit 7e620c9
Show file tree
Hide file tree
Showing 15 changed files with 539 additions and 196 deletions.
7 changes: 7 additions & 0 deletions .changeset/odd-keys-pretend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@hyperlane-xyz/cli': minor
'@hyperlane-xyz/infra': patch
'@hyperlane-xyz/sdk': patch
---

Allow CLI to accept hook as a config
18 changes: 0 additions & 18 deletions typescript/cli/examples/hook-config.yaml

This file was deleted.

66 changes: 66 additions & 0 deletions typescript/cli/examples/hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# A config to define the hooks for core contract deployments
# Ideally, use the `hyperlane config create hooks` command to generate this file
# but you we can refer to https://github.com/hyperlane-xyz/hyperlane-monorepo/blob/main/typescript/sdk/src/hook/types.ts for the matching types

# HooksConfig:
# required: HookConfig
# default: HookConfig

# HookConfig:
# type: HookType
# ... hook-specific config

# HookType:
# - merkleTreeHook
# - domainRoutingHook
# - interchainGasPaymaster
# - protocolFee
# - aggregationHook
# - opStack (not yet supported)

anvil1:
required:
type: protocolFee
maxProtocolFee: '1000000000000000000' # in wei (string)
protocolFee: '200000000000000' # in wei (string)
beneficiary: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'
owner: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'
default:
type: domainRoutingHook
owner: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'
domains:
anvil2:
type: aggregationHook
hooks:
- type: merkleTreeHook
- type: interchainGasPaymaster
beneficiary: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'
owner: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'
oracleKey: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'
overhead:
anvil2: 50000 # gas amount (number)
gasOracleType:
anvil2: StorageGasOracle
anvil2:
required:
type: protocolFee
maxProtocolFee: '1000000000000000000'
protocolFee: '200000000000000'
beneficiary: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'
owner: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'
default:
type: domainRoutingHook
owner: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'
domains:
anvil1:
type: aggregationHook
hooks:
- type: merkleTreeHook
- type: interchainGasPaymaster
beneficiary: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'
owner: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'
oracleKey: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'
overhead:
anvil1: 50000
gasOracleType:
anvil1: StorageGasOracle
8 changes: 4 additions & 4 deletions typescript/cli/src/commands/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { CommandModule } from 'yargs';

import { log, logGreen } from '../../logger.js';
import { createChainConfig, readChainConfigs } from '../config/chain.js';
import { createHookConfig } from '../config/hooks.js';
import { createHooksConfigMap } from '../config/hooks.js';
import { createIsmConfigMap, readIsmConfig } from '../config/ism.js';
import {
createMultisigConfig,
Expand Down Expand Up @@ -96,8 +96,8 @@ const createIsmConfigCommand: CommandModule = {
};

const createHookConfigCommand: CommandModule = {
command: 'hook',
describe: 'Create a new Hook config',
command: 'hooks',
describe: 'Create a new hooks config (required & default)',
builder: (yargs) =>
yargs.options({
output: outputFileOption('./configs/hooks.yaml'),
Expand All @@ -108,7 +108,7 @@ const createHookConfigCommand: CommandModule = {
const format: FileFormat = argv.format;
const outPath: string = argv.output;
const chainConfigPath: string = argv.chains;
await createHookConfig({ format, outPath, chainConfigPath });
await createHooksConfigMap({ format, outPath, chainConfigPath });
process.exit(0);
},
};
Expand Down
Loading

0 comments on commit 7e620c9

Please sign in to comment.