-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
32a99f4
commit 7a0d823
Showing
29 changed files
with
4,164 additions
and
94 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,5 @@ | ||
--- | ||
"create-lz-oapp": patch | ||
--- | ||
|
||
Add the ability to override the default example repository using env variables |
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
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,5 @@ | ||
require('@rushstack/eslint-patch/modern-module-resolution'); | ||
|
||
module.exports = { | ||
extends: ['@layerzerolabs/eslint-config-next/recommended'], | ||
}; |
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,16 @@ | ||
node_modules | ||
.env | ||
coverage | ||
coverage.json | ||
typechain | ||
typechain-types | ||
|
||
# Hardhat files | ||
cache | ||
artifacts | ||
|
||
#foundry test compilation files | ||
out | ||
|
||
# yarn | ||
yarn-error.log |
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'), | ||
}; |
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 @@ | ||
<p align="center"> | ||
<a href="https://layerzero.network"> | ||
<img alt="LayerZero" style="max-width: 500px" src="https://d3a2dpnnrypp5h.cloudfront.net/bridge-app/lz.png"/> | ||
</a> | ||
</p> | ||
|
||
<h1 align="center">@layerzerolabs/oft-example</h1> | ||
|
||
## Template repository for getting started with LayerZero using either Hardhat or Foundry in one project. | ||
|
||
### Getting Started | ||
|
||
#### Using Foundry | ||
|
||
```bash | ||
forge install | ||
forge build | ||
forge test | ||
``` | ||
|
||
#### Using Hardhat | ||
|
||
```bash | ||
yarn | ||
npx hardhat compile | ||
npx hardhat test | ||
``` |
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,46 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import { OFT } from "@layerzerolabs/lz-evm-oapp-v2/contracts/standards/oft/OFT.sol"; | ||
|
||
contract YourOFT is OFT { | ||
constructor( | ||
string memory _name, | ||
string memory _symbol, | ||
uint8 _localDecimals, | ||
address _endpoint | ||
) OFT(_name, _symbol, _localDecimals, _endpoint) {} | ||
|
||
// TODO In the event you wish to add custom logic to your OFT contract, uncomment these and alter any corresponding logic... | ||
|
||
// @dev allows the quote functions to mock sending the actual values that would be sent in a send()/sendAndCall() | ||
// function _debitView( | ||
// uint256 _amountLD, | ||
// uint256 _minAmountLD, | ||
// uint32 /*_dstEid*/ | ||
// ) internal view virtual override returns (uint256) { | ||
// uint256 amountLDSend = _removeDust(_amountLD); | ||
// if (amountLDSend < _minAmountLD) revert AmountSlippage(amountLDSend, _minAmountLD); | ||
// | ||
// return amountLDSend; | ||
// } | ||
|
||
// @dev hook applied to debit tokens on the src chain | ||
// function _debit( | ||
// uint256 _amountLD, | ||
// uint256 _minAmountLD, | ||
// uint32 _dstEid | ||
// ) internal virtual override returns (uint256) { | ||
// uint256 amountLDSend = _debitView(_amountLD, _minAmountLD, _dstEid); | ||
// | ||
// _burn(msg.sender, amountLDSend); | ||
// return amountLDSend; | ||
// } | ||
|
||
// @dev hook applied on the receipt of tokens on the dst chain | ||
// function _credit(address _to, uint256 _amountLD, uint32 /*_srcEid*/) internal virtual override returns (uint256) { | ||
// _mint(_to, _amountLD); | ||
// return _amountLD; | ||
// } | ||
} |
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 @@ | ||
import { type DeployFunction } from 'hardhat-deploy/types' | ||
|
||
// TODO declare your contract name here | ||
const contractName = 'YourOFT' | ||
|
||
const deploy: DeployFunction = async (hre) => { | ||
const { getNamedAccounts, deployments } = hre | ||
|
||
const { deploy } = deployments | ||
const { deployer } = await getNamedAccounts() | ||
|
||
console.log(`Network: ${hre.network.name}`) | ||
console.log(`Deployer: ${deployer}`) | ||
|
||
const { address } = await deploy(contractName, { | ||
from: deployer, | ||
args: [], | ||
log: true, | ||
waitConfirmations: 3, | ||
skipIfAlreadyDeployed: false, | ||
}) | ||
|
||
console.log(`Deployed contract: ${contractName}, network: ${hre.network.name}, address: ${address}`) | ||
} | ||
|
||
module.exports.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,8 @@ | ||
[profile.default] | ||
src = 'contracts' | ||
out = 'out' | ||
test = 'test/foundry' | ||
cache_path = 'cache' | ||
libs = ['node_modules', '../lib'] | ||
|
||
# See more config options https://github.com/foundry-rs/foundry/tree/master/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,18 @@ | ||
import 'hardhat-deploy' | ||
import 'hardhat-contract-sizer' | ||
import '@nomiclabs/hardhat-ethers' | ||
import { HardhatUserConfig } from 'hardhat/types' | ||
|
||
import './tasks/' | ||
|
||
const config: HardhatUserConfig = { | ||
solidity: '0.8.19', | ||
|
||
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,32 @@ | ||
{ | ||
"name": "@layerzerolabs/oft-example", | ||
"version": "0.0.1", | ||
"private": true, | ||
"license": "MIT", | ||
"scripts": { | ||
"compile": "npx hardhat compile", | ||
"lint": "yarn lint:js && yarn lint:sol", | ||
"lint:fix": "npx prettier --write . && solhint 'contracts/**/*.sol' --fix --noPrompt", | ||
"lint:js": "npx eslint '**/*.js' && npx prettier --check .", | ||
"lint:sol": "solhint 'contracts/**/*.sol'", | ||
"test": "npx hardhat test --parallel" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.23.3", | ||
"@layerzerolabs/eslint-config-next": "^1.5.60", | ||
"@layerzerolabs/lz-evm-oapp-v2": "latest", | ||
"@layerzerolabs/prettier-config-next": "^1.5.60", | ||
"@layerzerolabs/solhint-config": "^1.5.58", | ||
"@nomiclabs/hardhat-ethers": "^2.2.3", | ||
"@rushstack/eslint-patch": "^1.5.1", | ||
"ethers": "^5.7.0", | ||
"hardhat": "^2.9.9", | ||
"hardhat-contract-sizer": "^2.10.0", | ||
"hardhat-deploy": "^0.11.43", | ||
"hardhat-deploy-ethers": "^0.4.1", | ||
"prettier": "^3.0.3", | ||
"solhint": "^4.0.0", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^5.2.2" | ||
} | ||
} |
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 @@ | ||
module.exports = require('@layerzerolabs/solhint-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,21 @@ | ||
import { task, types } from 'hardhat/config' | ||
import { type ActionType } from 'hardhat/types' | ||
|
||
// TODO Figure out a way so this doesnt need to be defined in two places | ||
interface TaskArguments { | ||
n: number | ||
} | ||
|
||
const action: ActionType<TaskArguments> = async (taskArgs, hre) => { | ||
const signers = await hre.ethers.getSigners() | ||
for (let i = 0; i < taskArgs.n; ++i) { | ||
console.log(`${i}) ${signers[i].address}`) | ||
} | ||
} | ||
|
||
task('getSigners', 'show the signers of the current mnemonic', action).addOptionalParam( | ||
'n', | ||
'how many to show', | ||
3, | ||
types.int | ||
) |
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,2 @@ | ||
import './getSigners' | ||
// TODO get rid of index.ts somehow so we only need to define it in one place |
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 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
|
||
pragma solidity ^0.8.15; | ||
|
||
import { Test } from "forge-std/Test.sol"; | ||
|
||
contract YourOApp is Test { | ||
function setUp() public { | ||
//TODO | ||
} | ||
|
||
function test() public { | ||
//TODO | ||
} | ||
} |
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 @@ | ||
describe.skip('OFT: ', function () { | ||
before(async function () { | ||
//TODO | ||
}) | ||
|
||
beforeEach(async function () { | ||
//TODO | ||
}) | ||
|
||
it('OFT send', async function () { | ||
//TODO | ||
}) | ||
}) |
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 @@ | ||
{ | ||
"exclude": ["node_modules"], | ||
"include": ["deploy", "tasks", "hardhat.config.ts"], | ||
"compilerOptions": { | ||
"target": "es2020", | ||
"module": "commonjs", | ||
"esModuleInterop": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true, | ||
"skipLibCheck": true, | ||
"resolveJsonModule": true | ||
} | ||
} |
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 |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
"prepare": "husky install" | ||
}, | ||
"workspaces": [ | ||
"examples/*", | ||
"packages/*" | ||
], | ||
"devDependencies": { | ||
|
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,5 @@ | ||
{ | ||
"extensions": ["ts"], | ||
"spec": ["**/*.test.*"], | ||
"loader": "ts-node/esm" | ||
} |
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
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
Oops, something went wrong.