Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add custom Hardhat tasks for LayerZero V2 OFT example deployment and configuration #684

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

westonnelson
Copy link

Overview

This PR introduces some custom Hardhat tasks to help with developers/hackathon attendees with the deployment and configuration of the LayerZero OFT example. The following tasks have been added:

  1. lz:deploy: Deploys the OFT example contract.
  2. lz:oapp:config:init: Initializes OAPP configuration.
  3. lz:oapp:config:wire: Wires OAPP configuration.
  4. lz:oft:send: Sends tokens from either SwellOFTAdapter or SwellOFT.

Changes

  • Added tasks/deploy.ts to handle the deployment of the OFT contract.
  • Added tasks/oappConfigInit.ts to initialize OAPP config.
  • Added tasks/oappConfigWire.ts to wire the OAPP config.
  • Added tasks/sendOFT.ts to send tokens between chains.
  • Updated hardhat.config.ts to include and register the newly created Hardhat tasks.

Usage

To use the new tasks:

  • See the updated README in the example directory that includes a step-by-step process.:

Copy link
Contributor

@janjakubnanista janjakubnanista left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! However, it's not clear why this should be included in devtools, it seems partially incomplete and specific to a particular use-case.

Comment on lines +1 to +17
import { task } from 'hardhat/config';
import { getEidForNetworkName } from '@layerzerolabs/devtools-evm-hardhat';
import { addressToBytes32 } from '@layerzerolabs/lz-v2-utilities';
import { SendParam } from "../utils/typeDefinitions";
import { Options } from '@layerzerolabs/lz-v2-utilities';
import { EndpointId } from '@layerzerolabs/lz-definitions';

// Deploy the OFT example contract
task('lz:deploy', 'Deploys the OFT example contract')
.setAction(async (taskArgs, { ethers, deployments }) => {
const OFT = await ethers.getContractFactory("OFT");
const oft = await OFT.deploy();
await oft.deployed();
console.log("OFT deployed to:", oft.address);
});

export default 'deployOFT';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There already is a deploy script for the OFT, this is not necessary

Comment on lines +1 to +15
import { task } from 'hardhat/config';
import { getEidForNetworkName } from '@layerzerolabs/devtools-evm-hardhat';
import { addressToBytes32 } from '@layerzerolabs/lz-v2-utilities';
import { SendParam } from "../utils/typeDefinitions";
import { Options } from '@layerzerolabs/lz-v2-utilities';
import { EndpointId } from '@layerzerolabs/lz-definitions';

// Initialize OAPP config
task('lz:oapp:config:init', 'Initializes OAPP config')
.setAction(async (taskArgs, { ethers, deployments }) => {
console.log("Initialize OAPP config here");
// Add your custom initialization logic here
});

export default 'oappConfigInit';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of this task? It seems to overwrite the existing task with an empty one

Comment on lines +1 to +15
import { task } from 'hardhat/config';
import { getEidForNetworkName } from '@layerzerolabs/devtools-evm-hardhat';
import { addressToBytes32 } from '@layerzerolabs/lz-v2-utilities';
import { SendParam } from "../utils/typeDefinitions";
import { Options } from '@layerzerolabs/lz-v2-utilities';
import { EndpointId } from '@layerzerolabs/lz-definitions';

// Wire OAPP config
task('lz:oapp:config:wire', 'Wires OAPP config')
.setAction(async (taskArgs, { ethers, deployments }) => {
console.log("Wire OAPP config here");
// Add your custom wiring logic here
});

export default 'oappConfigWire';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of this task?

import { EndpointId } from '@layerzerolabs/lz-definitions';

// send tokens from a contract on one network to another
task('lz:oft:send', 'Sends tokens from either SwellOFTAdapter or SwellOFT')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This task seems to be specific to SwellOFT. Devtools is a collection of generic, reusable developer utilities.

@westonnelson
Copy link
Author

westonnelson commented Jul 10, 2024

Thanks for the PR! However, it's not clear why this should be included in devtools, it seems partially incomplete and specific to a particular use-case.

Hi @janjakubnanista! Thanks for the note - the purpose of adding these Hardhat tasks is to show some more utility available to devs using the CLI tool. Then, adding a step by step overview was to help streamline the process for any devs at a hackathon/getting started with the OFT example and showing some more utilities available to them!

I understand your point/question about Swell as part of the example as well... no specific reason for this OFT being the one shown, just for reference only, no particular need for that OFT or adapter to be included if perhaps you mean it would be better to use a generic, hypothetical name instead.

I hope this is helpful, and just let me know your thoughts!

Weston

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants