-
Notifications
You must be signed in to change notification settings - Fork 260
DEVREL-1052 feat: add tempo example to oft-alt example folder #1895
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
Open
St0rmBr3w
wants to merge
6
commits into
main
Choose a base branch
from
feat/add-tempo-example
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5805f89
feat: add tempo example to oft-alt example folder
St0rmBr3w c7adbe7
feat: add tempo example to oft-alt example folder
St0rmBr3w 818d2f6
fix: update lockfile
St0rmBr3w 1ca6317
chore: fix lockfile
St0rmBr3w 57130d5
fix: respond to cursor bot
St0rmBr3w 099d26d
chore: run linter
St0rmBr3w File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@layerzerolabs/oft-alt-example": minor | ||
| --- | ||
|
|
||
| Feat: add better support for simple config and the latest tooling found in OFT and OFT-Solana |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| // SPDX-License-Identifier: UNLICENSED | ||
| pragma solidity ^0.8.22; | ||
|
|
||
| import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; | ||
| import { OFT } from "@layerzerolabs/oft-evm/contracts/OFT.sol"; | ||
|
|
||
| /// @notice Standard OFT for regular EVM chains (uses native gas for fees). | ||
| /// @dev This contract is deployed on chains with standard EndpointV2 (not Alt). | ||
| /// It connects to OFTAlt contracts on chains with Alt Endpoints. | ||
| contract MyOFT is OFT { | ||
| constructor( | ||
| string memory _name, | ||
| string memory _symbol, | ||
| address _lzEndpoint, | ||
| address _delegate | ||
| ) OFT(_name, _symbol, _lzEndpoint, _delegate) Ownable(_delegate) {} | ||
| } | ||
|
|
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import assert from 'assert' | ||
|
|
||
| import { type DeployFunction } from 'hardhat-deploy/types' | ||
|
|
||
| const contractName = 'MyOFT' | ||
|
|
||
| const deploy: DeployFunction = async (hre) => { | ||
| const { getNamedAccounts, deployments } = hre | ||
|
|
||
| const { deploy } = deployments | ||
| const { deployer } = await getNamedAccounts() | ||
|
|
||
| assert(deployer, 'Missing named deployer account') | ||
|
|
||
| console.log(`Network: ${hre.network.name}`) | ||
| console.log(`Deployer: ${deployer}`) | ||
|
|
||
| // This is an external deployment pulled in from @layerzerolabs/lz-evm-sdk-v2 | ||
| // | ||
| // @layerzerolabs/toolbox-hardhat takes care of plugging in the external deployments | ||
| // from @layerzerolabs packages based on the configuration in your hardhat config | ||
| // | ||
| // For this to work correctly, your network config must define an eid property | ||
| // set to `EndpointId` as defined in @layerzerolabs/lz-definitions | ||
| // | ||
| // For example: | ||
| // | ||
| // networks: { | ||
| // 'optimism-testnet': { | ||
| // ... | ||
| // eid: EndpointId.OPTSEP_V2_TESTNET | ||
| // } | ||
| // } | ||
| const endpointV2Deployment = await hre.deployments.get('EndpointV2') | ||
|
|
||
| const { address } = await deploy(contractName, { | ||
| from: deployer, | ||
| args: [ | ||
| 'MyOFT', // name | ||
| 'MOFT', // symbol | ||
| endpointV2Deployment.address, // LayerZero's EndpointV2 address | ||
| deployer, // owner | ||
| ], | ||
| log: true, | ||
| skipIfAlreadyDeployed: false, | ||
| }) | ||
|
|
||
| console.log(`Deployed contract: ${contractName}, network: ${hre.network.name}, address: ${address}`) | ||
| } | ||
|
|
||
| deploy.tags = [contractName] | ||
|
|
||
| export default deploy |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,60 +1,94 @@ | ||
| import { EndpointId } from '@layerzerolabs/lz-definitions' | ||
| import { ExecutorOptionType } from '@layerzerolabs/lz-v2-utilities' | ||
| import { TwoWayConfig, generateConnectionsConfig } from '@layerzerolabs/metadata-tools' | ||
| import { OAppEnforcedOption } from '@layerzerolabs/toolbox-hardhat' | ||
|
|
||
| import type { OAppOmniGraphHardhat, OmniPointHardhat } from '@layerzerolabs/toolbox-hardhat' | ||
| import type { OmniPointHardhat } from '@layerzerolabs/toolbox-hardhat' | ||
|
|
||
| const sepoliaContract: OmniPointHardhat = { | ||
| eid: EndpointId.SEPOLIA_V2_TESTNET, | ||
| contractName: 'MyOFTAltAdapter', | ||
| } | ||
| // ====================================== | ||
| // SECTION 1: CONTRACT DEFINITIONS | ||
| // ====================================== | ||
| // This example demonstrates the primary use case for OFTAlt: | ||
| // Connecting an OFTAlt on a chain with an Alt Endpoint (ERC20 fee payment) | ||
| // to standard OFT contracts on regular EVM chains (native gas fee payment). | ||
| // | ||
| // Primary scenario: | ||
| // - OFTAlt deployed on Tempo (Alt Endpoint - fees paid in stablecoins) | ||
| // - Standard OFT deployed on Arbitrum (regular EndpointV2 - fees paid in native gas) | ||
|
|
||
| const fujiContract: OmniPointHardhat = { | ||
| eid: EndpointId.AVALANCHE_V2_TESTNET, | ||
| contractName: 'MyOFTAlt', | ||
| // ========== ALT ENDPOINT CHAINS ========== | ||
| // OFTAlt on chains with EndpointV2Alt (ERC20 fee payment) | ||
| // Tempo is a payments-focused blockchain where fees are paid in TIP-20 stablecoins | ||
| const tempoContract: OmniPointHardhat = { | ||
| eid: EndpointId.TEMPO_V2_TESTNET, | ||
| contractName: 'MyOFTAlt', // OFTAlt for Alt Endpoint chains (ERC20 fee payment) | ||
| } | ||
|
|
||
| const amoyContract: OmniPointHardhat = { | ||
| eid: EndpointId.AMOY_V2_TESTNET, | ||
| contractName: 'MyOFTAlt', | ||
| // ========== STANDARD EVM CHAINS ========== | ||
| // Standard OFT on chains with regular EndpointV2 (native gas fee payment) | ||
| const arbitrumContract: OmniPointHardhat = { | ||
| eid: EndpointId.ARBSEP_V2_TESTNET, | ||
| contractName: 'MyOFT', // Standard OFT for regular EVM chains | ||
| } | ||
|
|
||
| const config: OAppOmniGraphHardhat = { | ||
| contracts: [ | ||
| { | ||
| contract: fujiContract, | ||
| }, | ||
| { | ||
| contract: sepoliaContract, | ||
| }, | ||
| { | ||
| contract: amoyContract, | ||
| }, | ||
| ], | ||
| connections: [ | ||
| { | ||
| from: fujiContract, | ||
| to: sepoliaContract, | ||
| }, | ||
| { | ||
| from: fujiContract, | ||
| to: amoyContract, | ||
| }, | ||
| { | ||
| from: sepoliaContract, | ||
| to: fujiContract, | ||
| }, | ||
| { | ||
| from: sepoliaContract, | ||
| to: amoyContract, | ||
| }, | ||
| { | ||
| from: amoyContract, | ||
| to: sepoliaContract, | ||
| }, | ||
| { | ||
| from: amoyContract, | ||
| to: fujiContract, | ||
| }, | ||
| // ====================================== | ||
| // SECTION 2: ENFORCED OPTIONS | ||
| // ====================================== | ||
| // Define the gas options for destination chain execution. | ||
| // These options ensure a minimum gas amount is provided for lzReceive execution. | ||
| // | ||
| // For production, profile your contract's lzReceive gas usage on each destination | ||
| // chain and set appropriate values. The values below are examples. | ||
| // | ||
| // Learn more: https://docs.layerzero.network/v2/concepts/applications/oapp-standard#execution-options-and-enforced-settings | ||
|
|
||
| const EVM_ENFORCED_OPTIONS: OAppEnforcedOption[] = [ | ||
| { | ||
| msgType: 1, // SEND message type | ||
| optionType: ExecutorOptionType.LZ_RECEIVE, | ||
| gas: 80000, // Gas limit for lzReceive on destination | ||
| value: 0, // Native value to send (usually 0 for OFT) | ||
| }, | ||
| ] | ||
|
|
||
| // ====================================== | ||
| // SECTION 3: PATHWAY CONFIGURATION | ||
| // ====================================== | ||
| // Define bidirectional pathways between contracts. | ||
| // The Simple Config Generator automatically creates both directions (A→B and B→A). | ||
| // | ||
| // Each pathway specifies: | ||
| // - Contract pair (source, destination) | ||
| // - DVN configuration: [ [requiredDVNs], [optionalDVNs, threshold] ] | ||
| // - Block confirmations: [A→B confirmations, B→A confirmations] | ||
| // - Enforced options: [B's enforcedOptions, A's enforcedOptions] | ||
| // | ||
| // For production, configure appropriate DVNs for your security requirements. | ||
| // See: https://docs.layerzero.network/v2/developers/evm/configuration/dvn-executor-config | ||
|
|
||
| const pathways: TwoWayConfig[] = [ | ||
| // Tempo (Alt Endpoint) <-> Arbitrum (Standard Endpoint) | ||
| // This demonstrates the primary use case: OFTAlt on Alt chain ↔ OFT on standard chain | ||
| [ | ||
| tempoContract, // Alt Endpoint chain (OFTAlt with ERC20 fees) | ||
| arbitrumContract, // Standard chain (OFT with native gas fees) | ||
| [['LayerZero Labs'], []], // DVNs: Required=[LayerZero Labs], Optional=[] | ||
| [1, 1], // Block confirmations (increase for mainnet) | ||
| [EVM_ENFORCED_OPTIONS, EVM_ENFORCED_OPTIONS], // Enforced options | ||
| ], | ||
| } | ||
| ] | ||
|
|
||
| export default config | ||
| // ====================================== | ||
| // SECTION 4: EXPORT CONFIGURATION | ||
| // ====================================== | ||
| // The generateConnectionsConfig function creates the full connection configuration | ||
| // from the pathway definitions, including DVN addresses and executor settings | ||
| // resolved from LayerZero metadata. | ||
|
|
||
| export default async function () { | ||
| const connections = await generateConnectionsConfig(pathways) | ||
| return { | ||
| contracts: [{ contract: tempoContract }, { contract: arbitrumContract }], | ||
| connections, | ||
| } | ||
| } |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| import './sendOFT' |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.