Skip to content

DEVREL-518 Feat: add send task to oft - #1561

Merged
St0rmBr3w merged 14 commits into
mainfrom
feat/add-send-task-to-oft
Jul 2, 2025
Merged

DEVREL-518 Feat: add send task to oft#1561
St0rmBr3w merged 14 commits into
mainfrom
feat/add-send-task-to-oft

Conversation

@St0rmBr3w

@St0rmBr3w St0rmBr3w commented Jun 10, 2025

Copy link
Copy Markdown
Contributor

@St0rmBr3w St0rmBr3w added the ready to review in a state where CI passes and the PR is quite upto date with main and you need reviews label Jun 10, 2025
Comment thread examples/oft/package.json Outdated
Comment thread examples/oft/tasks/sendOFT.ts
DanL0
DanL0 previously approved these changes Jun 12, 2025

@DanL0 DanL0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good.

Two improvement ideas for future:

  1. Support OFT adapter
  2. Support dynamic oapp-config parameter, because we accept such parameter in other commands

I have implemented 2 and tested:

diff --git a/tasks/sendEvm.ts b/tasks/sendEvm.ts
index 4c9118d..d260e37 100644
--- a/tasks/sendEvm.ts
+++ b/tasks/sendEvm.ts
@@ -2,15 +2,14 @@ import { BigNumber, ContractTransaction } from 'ethers'
 import { parseUnits } from 'ethers/lib/utils'
 import { HardhatRuntimeEnvironment } from 'hardhat/types'
 
-import { createGetHreByEid } from '@layerzerolabs/devtools-evm-hardhat'
+import { createGetHreByEid, OmniPointHardhat } from '@layerzerolabs/devtools-evm-hardhat'
 import { createLogger } from '@layerzerolabs/io-devtools'
 import { ChainType, endpointIdToChainType, endpointIdToNetwork } from '@layerzerolabs/lz-definitions'
 import { addressToBytes32 } from '@layerzerolabs/lz-v2-utilities'
 
-import layerzeroConfig from '../layerzero.config'
-
 import { SendResult } from './types'
 import { DebugLogger, KnownErrors, getLayerZeroScanLink } from './utils'
+import path from 'path'
 
 const logger = createLogger()
 
@@ -19,6 +18,7 @@ export interface EvmArgs {
     dstEid: number
     amount: string
     to: string
+    oappConfig: string
     minAmount?: string
     extraOptions?: string
     composeMsg?: string
@@ -26,7 +26,7 @@ export interface EvmArgs {
 }
 
 export async function sendEvm(
-    { srcEid, dstEid, amount, to, minAmount, extraOptions, composeMsg, oftAddress }: EvmArgs,
+    { srcEid, dstEid, amount, to, minAmount, extraOptions, composeMsg, oftAddress, oappConfig }: EvmArgs,
     hre: HardhatRuntimeEnvironment
 ): Promise<SendResult> {
     if (endpointIdToChainType(srcEid) !== ChainType.EVM) {
@@ -51,8 +51,9 @@ export async function sendEvm(
     if (oftAddress) {
         wrapperAddress = oftAddress
     } else {
-        const { contracts } = typeof layerzeroConfig === 'function' ? await layerzeroConfig() : layerzeroConfig
-        const wrapper = contracts.find((c) => c.contract.eid === srcEid)
+        const layerZeroConfig = (await import(path.resolve('./', oappConfig))).default
+        const { contracts } = typeof layerZeroConfig === 'function' ? await layerZeroConfig() : layerZeroConfig
+        const wrapper = contracts.find((c: { contract: OmniPointHardhat }) => c.contract.eid === srcEid)
         if (!wrapper) throw new Error(`No config for EID ${srcEid}`)
         wrapperAddress = wrapper.contract.contractName
             ? (await srcEidHre.deployments.get(wrapper.contract.contractName)).address
diff --git a/tasks/sendOFT.ts b/tasks/sendOFT.ts
index 6875e27..8e2f9d5 100644
--- a/tasks/sendOFT.ts
+++ b/tasks/sendOFT.ts
@@ -27,6 +27,12 @@ task('lz:oft:send', 'Sends OFT tokens cross‐chain from EVM chains')
     .addParam('dstEid', 'Destination endpoint ID', undefined, types.int)
     .addParam('amount', 'Amount to send (human readable units, e.g. "1.5")', undefined, types.string)
     .addParam('to', 'Recipient address (20-byte hex for EVM)', undefined, types.string)
+    .addOptionalParam(
+        'oappConfig',
+        'Path to the LayerZero config file',
+        'layerzero.config.ts',
+        types.string
+    )
     .addOptionalParam(
         'minAmount',
         'Minimum amount to receive in case of custom slippage or fees (human readable units, e.g. "1.5")',

Comment thread examples/oft/tasks/sendOFT.ts Outdated
nazreen
nazreen previously approved these changes Jul 2, 2025

@DanL0 DanL0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

approving, in future would be cool to see if it's possible to reuse the code between the examples

@St0rmBr3w
St0rmBr3w merged commit d103291 into main Jul 2, 2025
11 checks passed
@St0rmBr3w
St0rmBr3w deleted the feat/add-send-task-to-oft branch July 2, 2025 11:29
mattsse pushed a commit to mattsse/devtools that referenced this pull request Aug 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready to review in a state where CI passes and the PR is quite upto date with main and you need reviews

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants