-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Shankar <[email protected]>
- Loading branch information
1 parent
30e01b8
commit a91e603
Showing
21 changed files
with
1,668 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,15 @@ | ||
# .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.- | ||
# / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ | ||
# `-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' | ||
# | ||
# Example environment configuration | ||
# | ||
# .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.- | ||
# / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ | ||
# `-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' | ||
|
||
# By default, the examples support both mnemonic-based and private key-based authentication | ||
# | ||
# You don't need to set both of these values, just pick the one that you prefer and set that one | ||
MNEMONIC= | ||
PRIVATE_KEY= |
This file contains 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,10 @@ | ||
artifacts | ||
cache | ||
dist | ||
node_modules | ||
out | ||
*.log | ||
*.sol | ||
*.yaml | ||
*.lock | ||
package-lock.json |
This file contains 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,10 @@ | ||
require('@rushstack/eslint-patch/modern-module-resolution'); | ||
|
||
module.exports = { | ||
extends: ['@layerzerolabs/eslint-config-next/recommended'], | ||
rules: { | ||
// @layerzerolabs/eslint-config-next defines rules for turborepo-based projects | ||
// that are not relevant for this particular project | ||
'turbo/no-undeclared-env-vars': 'off', | ||
}, | ||
}; |
This file contains 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,24 @@ | ||
node_modules | ||
.env | ||
coverage | ||
coverage.json | ||
typechain | ||
typechain-types | ||
|
||
# Hardhat files | ||
cache | ||
artifacts | ||
|
||
|
||
# LayerZero specific files | ||
.layerzero | ||
|
||
# foundry test compilation files | ||
out | ||
|
||
# pnpm | ||
pnpm-error.log | ||
|
||
# Editor and OS files | ||
.DS_Store | ||
.idea |
This file contains 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 @@ | ||
v18.18.0 |
This file contains 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,10 @@ | ||
artifacts/ | ||
cache/ | ||
dist/ | ||
node_modules/ | ||
out/ | ||
*.log | ||
*ignore | ||
*.yaml | ||
*.lock | ||
package-lock.json |
This file contains 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,3 @@ | ||
module.exports = { | ||
...require('@layerzerolabs/prettier-config-next'), | ||
}; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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,13 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.22; | ||
|
||
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; | ||
import { OFTAdapterAlt } from "@layerzerolabs/oft-alt-evm/contracts/OFTAdapterAlt.sol"; | ||
|
||
contract MyOFTAdapterAlt is OFTAdapterAlt { | ||
constructor( | ||
address _address, | ||
address _lzEndpoint, | ||
address _delegate | ||
) OFTAdapterAlt(_address, _lzEndpoint, _delegate) Ownable(_delegate) {} | ||
} |
This file contains 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,14 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.22; | ||
|
||
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; | ||
import { OFTAlt } from "@layerzerolabs/oft-alt-evm/contracts/OFTAlt.sol"; | ||
|
||
contract MyOFTAlt is OFTAlt { | ||
constructor( | ||
string memory _name, | ||
string memory _symbol, | ||
address _lzEndpoint, | ||
address _delegate | ||
) OFTAlt(_name, _symbol, _lzEndpoint, _delegate) Ownable(_delegate) {} | ||
} |
This file contains 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 { MyOFTAlt } from "../MyOFTAlt.sol"; | ||
|
||
// @dev WARNING: This is for testing purposes only | ||
contract MyOFTAltMock is MyOFTAlt { | ||
constructor( | ||
string memory _name, | ||
string memory _symbol, | ||
address _lzEndpoint, | ||
address _delegate | ||
) MyOFTAlt(_name, _symbol, _lzEndpoint, _delegate) {} | ||
|
||
function mint(address _to, uint256 _amount) public { | ||
_mint(_to, _amount); | ||
} | ||
} |
This file contains 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 = 'MyOFTAlt' | ||
|
||
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: { | ||
// fuji: { | ||
// ... | ||
// eid: EndpointId.AVALANCHE_V2_TESTNET | ||
// } | ||
// } | ||
const endpointV2Deployment = await hre.deployments.get('EndpointV2') | ||
|
||
const { address } = await deploy(contractName, { | ||
from: deployer, | ||
args: [ | ||
'MyOFTAlt', // name | ||
'MOFTAlt', // 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 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,31 @@ | ||
[profile.default] | ||
solc-version = '0.8.22' | ||
src = 'contracts' | ||
out = 'out' | ||
test = 'test/foundry' | ||
cache_path = 'cache/foundry' | ||
verbosity = 3 | ||
libs = [ | ||
# We provide a set of useful contract utilities | ||
# in the lib directory of @layerzerolabs/toolbox-foundry: | ||
# | ||
# - forge-std | ||
# - ds-test | ||
# - solidity-bytes-utils | ||
'node_modules/@layerzerolabs/toolbox-foundry/lib', | ||
'node_modules', | ||
] | ||
|
||
remappings = [ | ||
# Due to a misconfiguration of solidity-bytes-utils, an outdated version | ||
# of forge-std is being dragged in | ||
# | ||
# To remedy this, we'll remap the ds-test and forge-std imports to our own versions | ||
'ds-test/=node_modules/@layerzerolabs/toolbox-foundry/lib/ds-test', | ||
'forge-std/=node_modules/@layerzerolabs/toolbox-foundry/lib/forge-std', | ||
'@layerzerolabs/=node_modules/@layerzerolabs/', | ||
'@openzeppelin/=node_modules/@openzeppelin/', | ||
] | ||
|
||
[fuzz] | ||
runs = 1000 |
This file contains 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,82 @@ | ||
// Get the environment configuration from .env file | ||
// | ||
// To make use of automatic environment setup: | ||
// - Duplicate .env.example file and name it .env | ||
// - Fill in the environment variables | ||
import 'dotenv/config' | ||
|
||
import 'hardhat-deploy' | ||
import 'hardhat-contract-sizer' | ||
import '@nomiclabs/hardhat-ethers' | ||
import '@layerzerolabs/toolbox-hardhat' | ||
import { HardhatUserConfig, HttpNetworkAccountsUserConfig } from 'hardhat/types' | ||
|
||
import { EndpointId } from '@layerzerolabs/lz-definitions' | ||
|
||
// Set your preferred authentication method | ||
// | ||
// If you prefer using a mnemonic, set a MNEMONIC environment variable | ||
// to a valid mnemonic | ||
const MNEMONIC = process.env.MNEMONIC | ||
|
||
// If you prefer to be authenticated using a private key, set a PRIVATE_KEY environment variable | ||
const PRIVATE_KEY = process.env.PRIVATE_KEY | ||
|
||
const accounts: HttpNetworkAccountsUserConfig | undefined = MNEMONIC | ||
? { mnemonic: MNEMONIC } | ||
: PRIVATE_KEY | ||
? [PRIVATE_KEY] | ||
: undefined | ||
|
||
if (accounts == null) { | ||
console.warn( | ||
'Could not find MNEMONIC or PRIVATE_KEY environment variables. It will not be possible to execute transactions in your example.' | ||
) | ||
} | ||
|
||
const config: HardhatUserConfig = { | ||
paths: { | ||
cache: 'cache/hardhat', | ||
}, | ||
solidity: { | ||
compilers: [ | ||
{ | ||
version: '0.8.22', | ||
settings: { | ||
optimizer: { | ||
enabled: true, | ||
runs: 200, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
networks: { | ||
'sepolia-testnet': { | ||
eid: EndpointId.SEPOLIA_V2_TESTNET, | ||
url: process.env.RPC_URL_SEPOLIA || 'https://rpc.sepolia.org/', | ||
accounts, | ||
}, | ||
'avalanche-testnet': { | ||
eid: EndpointId.AVALANCHE_V2_TESTNET, | ||
url: process.env.RPC_URL_FUJI || 'https://rpc.ankr.com/avalanche_fuji', | ||
accounts, | ||
}, | ||
'amoy-testnet': { | ||
eid: EndpointId.AMOY_V2_TESTNET, | ||
url: process.env.RPC_URL_AMOY || 'https://polygon-amoy-bor-rpc.publicnode.com', | ||
accounts, | ||
}, | ||
hardhat: { | ||
// Need this for testing because TestHelperOz5.sol is exceeding the compiled contract size limit | ||
allowUnlimitedContractSize: true, | ||
}, | ||
}, | ||
namedAccounts: { | ||
deployer: { | ||
default: 0, // wallet address of index[0], of the mnemonic in .env | ||
}, | ||
}, | ||
} | ||
|
||
export default config |
This file contains 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,60 @@ | ||
import { EndpointId } from '@layerzerolabs/lz-definitions' | ||
|
||
import type { OAppOmniGraphHardhat, OmniPointHardhat } from '@layerzerolabs/toolbox-hardhat' | ||
|
||
const sepoliaContract: OmniPointHardhat = { | ||
eid: EndpointId.SEPOLIA_V2_TESTNET, | ||
contractName: 'MyOFT', | ||
} | ||
|
||
const fujiContract: OmniPointHardhat = { | ||
eid: EndpointId.AVALANCHE_V2_TESTNET, | ||
contractName: 'MyOFT', | ||
} | ||
|
||
const amoyContract: OmniPointHardhat = { | ||
eid: EndpointId.AMOY_V2_TESTNET, | ||
contractName: 'MyOFT', | ||
} | ||
|
||
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, | ||
}, | ||
], | ||
} | ||
|
||
export default config |
Oops, something went wrong.