DEVREL-518 Feat: add send task to oft - #1561
Merged
Merged
Conversation
shankars99
reviewed
Jun 10, 2025
shankars99
reviewed
Jun 10, 2025
DanL0
previously approved these changes
Jun 12, 2025
DanL0
left a comment
Contributor
There was a problem hiding this comment.
Looks good.
Two improvement ideas for future:
- Support OFT adapter
- 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")',
AlexanderLiteplo
previously requested changes
Jun 30, 2025
nazreen
previously approved these changes
Jul 2, 2025
nazreen
approved these changes
Jul 2, 2025
nazreen
approved these changes
Jul 2, 2025
DanL0
approved these changes
Jul 2, 2025
DanL0
left a comment
Contributor
There was a problem hiding this comment.
approving, in future would be cool to see if it's possible to reuse the code between the examples
shankars99
pushed a commit
that referenced
this pull request
Jul 20, 2025
mattsse
pushed a commit
to mattsse/devtools
that referenced
this pull request
Aug 12, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In this PR: