-
Notifications
You must be signed in to change notification settings - Fork 185
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: Ryan Goulding <[email protected]>
- Loading branch information
1 parent
41c3a28
commit a1abdc1
Showing
98 changed files
with
10,249 additions
and
3,631 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.
13 changes: 13 additions & 0 deletions
13
examples/oft-upgradeable/contracts/MyOFTAdapterUpgradeable.sol
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 { OFTAdapterUpgradeable } from "@layerzerolabs/oft-evm-upgradeable/contracts/oft/OFTAdapterUpgradeable.sol"; | ||
|
||
contract MyOFTAdapterUpgradeable is OFTAdapterUpgradeable { | ||
constructor(address _token, address _lzEndpoint) OFTAdapterUpgradeable(_token, _lzEndpoint) {} | ||
|
||
function initialize(address _delegate) public initializer { | ||
__OFTAdapter_init(_delegate); | ||
__Ownable_init(_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,13 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.22; | ||
|
||
import { OFTUpgradeable } from "@layerzerolabs/oft-evm-upgradeable/contracts/oft/OFTUpgradeable.sol"; | ||
|
||
contract MyOFTUpgradeable is OFTUpgradeable { | ||
constructor(address _lzEndpoint) OFTUpgradeable(_lzEndpoint) {} | ||
|
||
function initialize(string memory _name, string memory _symbol, address _delegate) public initializer { | ||
__OFT_init(_name, _symbol, _delegate); | ||
__Ownable_init(_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,13 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.20; | ||
|
||
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | ||
|
||
// @dev WARNING: This is for testing purposes only | ||
contract MyERC20Mock is ERC20 { | ||
constructor(string memory _name, string memory _symbol) ERC20(_name, _symbol) {} | ||
|
||
function mint(address _to, uint256 _amount) public { | ||
_mint(_to, _amount); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
examples/oft-upgradeable/contracts/mocks/MyOFTAdapterUpgradeableMock.sol
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,9 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.22; | ||
|
||
import { MyOFTAdapterUpgradeable } from "../MyOFTAdapterUpgradeable.sol"; | ||
|
||
// @dev WARNING: This is for testing purposes only | ||
contract MyOFTAdapterUpgradeableMock is MyOFTAdapterUpgradeable { | ||
constructor(address _token, address _lzEndpoint) MyOFTAdapterUpgradeable(_token, _lzEndpoint) {} | ||
} |
13 changes: 13 additions & 0 deletions
13
examples/oft-upgradeable/contracts/mocks/MyOFTUpgradeableMock.sol
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 { MyOFTUpgradeable } from "../MyOFTUpgradeable.sol"; | ||
|
||
// @dev WARNING: This is for testing purposes only | ||
contract MyOFTUpgradeableMock is MyOFTUpgradeable { | ||
constructor(address _lzEndpoint) MyOFTUpgradeable(_lzEndpoint) {} | ||
|
||
function mint(address _to, uint256 _amount) public { | ||
_mint(_to, _amount); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
examples/oft-upgradeable/deploy/MyOFTAdapterUpgradeable.ts
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,39 @@ | ||
import { type DeployFunction } from 'hardhat-deploy/types' | ||
|
||
const contractName = 'MyOFTAdapterUpgradeable' | ||
|
||
const deploy: DeployFunction = async (hre) => { | ||
const { deploy } = hre.deployments | ||
const signer = (await hre.ethers.getSigners())[0] | ||
console.log(`deploying ${contractName} on network: ${hre.network.name} with ${signer.address}`) | ||
|
||
const endpointV2Deployment = await hre.deployments.get('EndpointV2') | ||
try { | ||
const proxy = await hre.ethers.getContract('MyOFTUpgradeable') | ||
console.log(`Proxy: ${proxy.address}`) | ||
} catch (e) { | ||
console.log(`Proxy not found`) | ||
} | ||
|
||
await deploy(contractName, { | ||
from: signer.address, | ||
args: ['0x', endpointV2Deployment.address], // replace '0x' with the address of the ERC-20 token | ||
log: true, | ||
waitConfirmations: 1, | ||
skipIfAlreadyDeployed: false, | ||
proxy: { | ||
checkABIConflict: false, | ||
owner: signer.address, | ||
execute: { | ||
init: { | ||
methodName: 'initialize', | ||
args: [signer.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,35 @@ | ||
import { type DeployFunction } from 'hardhat-deploy/types' | ||
|
||
const contractName = 'MyOFTUpgradeable' | ||
|
||
const deploy: DeployFunction = async (hre) => { | ||
const { deploy } = hre.deployments | ||
const signer = (await hre.ethers.getSigners())[0] | ||
console.log(`deploying ${contractName} on network: ${hre.network.name} with ${signer.address}`) | ||
|
||
const endpointV2Deployment = await hre.deployments.get('EndpointV2') | ||
const existing = await hre.ethers.getContract('MyOFTUpgradeable') | ||
console.log(`Proxy: ${existing.address}`) | ||
|
||
await deploy(contractName, { | ||
from: signer.address, | ||
args: [endpointV2Deployment.address], | ||
log: true, | ||
waitConfirmations: 1, | ||
skipIfAlreadyDeployed: false, | ||
proxy: { | ||
checkABIConflict: false, | ||
owner: signer.address, | ||
execute: { | ||
init: { | ||
methodName: 'initialize', | ||
args: ['MyOFT', 'MOFT', signer.address], // TODO: add name/symbol | ||
}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
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,27 @@ | ||
[profile.default] | ||
solc-version = '0.8.22' | ||
src = 'contracts' | ||
out = 'out' | ||
test = 'test/foundry' | ||
cache_path = 'cache/foundry' | ||
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 ou 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/', | ||
] |
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 '@openzeppelin/hardhat-upgrades' | ||
import 'hardhat-deploy' | ||
import '@nomiclabs/hardhat-waffle' | ||
import 'hardhat-deploy-ethers' | ||
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, | ||
}, | ||
}, | ||
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.