Skip to content

Commit

Permalink
Add functionality for deploying and modifying deployments (#132)
Browse files Browse the repository at this point in the history
* added option to specify instantiator when uploading contracts

* Add option to set ism

* cleanup

* parameterize transfer amount and denom

* missed some logic

* Parameterize adding validator to test recipient ism

* change ismAdress type to

* added admin support for remote

* Fix warp deploy function args

* Parameterize erc20 contract attrs

* Separate bridged and fee tokens

* added cli commands for address conversions

* added ism support to warp scripts

* Add register new ism and igp commands

* format

* rm break

* Add to index and rename

* SP comments

* created evm.ts - copied from warp.ts

* first pass at updated evm warp command

* debugging

* added threshold

* final changes

* allowed multiple validators in ism

* Support empty values for those configs

* fixed bug from evm script

* added command to create an ism

* nit changes while testing

* trivial tweak

---------

Co-authored-by: sampocs <[email protected]>
Co-authored-by: sampocs <[email protected]>
Co-authored-by: flaf <[email protected]>
  • Loading branch information
4 people authored Jun 11, 2024
1 parent 00f64a9 commit f10ba02
Show file tree
Hide file tree
Showing 14 changed files with 643 additions and 46 deletions.
16 changes: 16 additions & 0 deletions config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,22 @@ networks:
denom: 'untrn'
domain: 1302

# Networks that already have hyperlane deployments
# but might require new warp route connections
evm_networks:
- name: 'mantasepolia'
chain_id: 3441006
rpc_endpoint: "http://localhost:8545"
network: 'sepolia'
nativeCurrency:
name: 'Sepolia Ether'
symbol: 'ETH'
decimals: 18
mailbox_address: "0x123..."
multisig_ism_factory_address: "0x123..."



signer: deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef

deploy:
Expand Down
14 changes: 10 additions & 4 deletions example/src/recipient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@ import { HYP_MULTSIG_ISM_FACTORY } from './constants';
import { CONTAINER, Dependencies } from './ioc';
import { expectNextContractAddr, logTx } from './utils';

export const recipientCmd = new Command('deploy-test-recipient').action(
export const recipientCmd = new Command('deploy-test-recipient')
.option('--validator-address <validator-address>', 'validator address to use')
.action(
deployTestRecipient,
);

async function deployTestRecipient() {
type DeployTestRecipientArgs = {
validatorAddress?: `0x{string}`
}

async function deployTestRecipient({validatorAddress}: DeployTestRecipientArgs) {
const {
account,
provider: { query, exec },
Expand All @@ -37,7 +43,7 @@ async function deployTestRecipient() {
abi: StaticMessageIdMultisigIsmFactory__factory.abi,
address: HYP_MULTSIG_ISM_FACTORY,
functionName: 'getAddress',
args: [[account.address], 1],
args: [[validatorAddress || account.address], 1],
});
console.log(`Deploying multisigIsm at "${multisigIsmAddr.green}"...`);

Expand All @@ -46,7 +52,7 @@ async function deployTestRecipient() {
abi: StaticMessageIdMultisigIsmFactory__factory.abi,
address: HYP_MULTSIG_ISM_FACTORY,
functionName: 'deploy',
args: [[account.address], 1],
args: [[validatorAddress || account.address], 1],
});
logTx('Deploy multisig ism', tx);
await query.waitForTransactionReceipt({ hash: tx });
Expand Down
111 changes: 98 additions & 13 deletions example/src/warp.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { HypERC20__factory } from '@hyperlane-xyz/core';
import { Command } from 'commander';
import {
HypERC20__factory,
StaticMessageIdMultisigIsmFactory__factory,
} from '@hyperlane-xyz/core';
import { Command, Option} from 'commander';
import { isAddress } from 'viem';

import { HYP_MAILBOX } from './constants';
import { HYP_MAILBOX, HYP_MULTSIG_ISM_FACTORY } from './constants';
import { CONTAINER, Dependencies } from './ioc';
import {
expectNextContractAddr,
Expand All @@ -12,7 +15,32 @@ import {

const warpCmd = new Command('warp');

warpCmd.command('deploy').action(deployWarpRoute);
warpCmd.command('deploy')
.option(
'--contract-name <contract-name>',
'Warp contract name e.g. Hyperlane Bridged TIA',
'Hyperlane Bridged Osmo'
)
.option(
'--asset-name <asset-name>',
'Warp route asset name e.g. TIA',
'TIA'
)
.option(
'--create-new-ism',
'Option to create a new ISM for the the warp route',
false
)
.option(
'--warp-ism-address <warp-ism-address>',
'ISM to set on the warp route recipient'
)
.option(
'--ism-validator-address <ism-validator-address>',
'Validator address on the ism',
)
.action(deployWarpRoute);

warpCmd
.command('link')
.argument('<warp>', 'address of warp route')
Expand All @@ -29,42 +57,99 @@ warpCmd

export { warpCmd };

async function deployWarpRoute() {
type DeployWarpRouteArgs = {
contractName: string,
assetName: string,
createNewIsm?: boolean,
warpIsmAddress?: `0x${string}`,
ismValidatorAddress?: `0x${string}`,
};

async function deployWarpRoute({
contractName,
assetName,
createNewIsm,
warpIsmAddress,
ismValidatorAddress,
}: DeployWarpRouteArgs) {
const {
account,
provider: { query, exec },
} = CONTAINER.get(Dependencies);

// deploy hyp erc20 (implementation)
if (createNewIsm && warpIsmAddress !== undefined) {
throw new Error("invalid options: cannot create a new ISM and pass a custom ISM address at the same time")
}

const hypErc20OsmoAddr = await expectNextContractAddr(query, account);
console.log(`Deploying HypERC20 at "${hypErc20OsmoAddr.green}"...`);
// deploy hyp erc20 (implementation)
const hypErc20Addr = await expectNextContractAddr(query, account);
console.log(`Deploying HypERC20 at "${hypErc20Addr.green}"...`);

{
const tx = await exec.deployContract({
abi: HypERC20__factory.abi,
bytecode: HypERC20__factory.bytecode,
args: [6, HYP_MAILBOX],
});
logTx('Deploying HypERC20Osmo', tx);
logTx('Deploying HypERC20', tx);
await query.waitForTransactionReceipt({ hash: tx });
}

{
const tx = await exec.writeContract({
abi: HypERC20__factory.abi,
address: hypErc20OsmoAddr,
address: hypErc20Addr,
functionName: 'initialize',
args: [0n, 'Hyperlane Bridged Osmosis', 'OSMO'],
args: [0n, contractName ? contractName : 'Hyperlane Bridged OSMO', assetName ? assetName : 'OSMO'],
});
logTx('Initialize HypERC20', tx);
await query.waitForTransactionReceipt({ hash: tx });
}

// If the option was specifed to create a new ISM, deploy the multisig ISM contract
if (createNewIsm) {
ismValidatorAddress = ismValidatorAddress ? ismValidatorAddress : account.address

const multisigIsmAddr = await query.readContract({
abi: StaticMessageIdMultisigIsmFactory__factory.abi,
address: HYP_MULTSIG_ISM_FACTORY,
functionName: 'getAddress',
args: [[ismValidatorAddress], 1],
});
console.log(`Deploying multisigIsm at "${multisigIsmAddr.green}"...`);

{
const tx = await exec.writeContract({
abi: StaticMessageIdMultisigIsmFactory__factory.abi,
address: HYP_MULTSIG_ISM_FACTORY,
functionName: 'deploy',
args: [[ismValidatorAddress], 1],
});
logTx('Deploy multisig ism', tx);
await query.waitForTransactionReceipt({ hash: tx });
}

warpIsmAddress = multisigIsmAddr
}

// If a custom ISM address was specified or if a new ISM was created,
// register that address in the warp contract
// Otherwise, the default ISM will be used
if (warpIsmAddress !== undefined) {
const tx = await exec.writeContract({
abi: HypERC20__factory.abi,
address: hypErc20Addr,
functionName: 'setInterchainSecurityModule',
args: [warpIsmAddress],
});
logTx('Initialize HypERC20Osmo', tx);
logTx('Set ism for warp route', tx);
await query.waitForTransactionReceipt({ hash: tx });
}

console.log('== Done! ==');

console.log({
hypErc20Osmo: hypErc20OsmoAddr,
hypErc20: hypErc20Addr,
});
}

Expand Down
Loading

0 comments on commit f10ba02

Please sign in to comment.