-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding contracts and some oapp boilerplate
- Loading branch information
1 parent
fc7974d
commit e87240f
Showing
62 changed files
with
14,472 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,23 @@ | ||
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'), | ||
}; |
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,108 @@ | ||
<p align="center"> | ||
<a href="https://layerzero.network"> | ||
<img alt="LayerZero" style="width: 400px" src="https://docs.layerzero.network/img/LayerZero_Logo_White.svg"/> | ||
</a> | ||
</p> | ||
|
||
<p align="center"> | ||
<a href="https://layerzero.network" style="color: #a77dff">Homepage</a> | <a href="https://docs.layerzero.network/" style="color: #a77dff">Docs</a> | <a href="https://layerzero.network/developers" style="color: #a77dff">Developers</a> | ||
</p> | ||
|
||
<h1 align="center">OApp Example</h1> | ||
|
||
<p align="center"> | ||
<a href="https://docs.layerzero.network/contracts/oapp" style="color: #a77dff">Quickstart</a> | <a href="https://docs.layerzero.network/contracts/oapp-configuration" style="color: #a77dff">Configuration</a> | <a href="https://docs.layerzero.network/contracts/options" style="color: #a77dff">Message Execution Options</a> | <a href="https://docs.layerzero.network/contracts/endpoint-addresses" style="color: #a77dff">Endpoint Addresses</a> | ||
</p> | ||
|
||
<p align="center">Template project for getting started with LayerZero's <code>OApp</code> contract development.</p> | ||
|
||
## 1) Developing Contracts | ||
|
||
#### Installing dependencies | ||
|
||
We recommend using `pnpm` as a package manager (but you can of course use a package manager of your choice): | ||
|
||
```bash | ||
pnpm install | ||
``` | ||
|
||
#### Compiling your contracts | ||
|
||
This project supports both `hardhat` and `forge` compilation. By default, the `compile` command will execute both: | ||
|
||
```bash | ||
pnpm compile | ||
``` | ||
|
||
If you prefer one over the other, you can use the tooling-specific commands: | ||
|
||
```bash | ||
pnpm compile:forge | ||
pnpm compile:hardhat | ||
``` | ||
|
||
Or adjust the `package.json` to for example remove `forge` build: | ||
|
||
```diff | ||
- "compile": "$npm_execpath run compile:forge && $npm_execpath run compile:hardhat", | ||
- "compile:forge": "forge build", | ||
- "compile:hardhat": "hardhat compile", | ||
+ "compile": "hardhat compile" | ||
``` | ||
|
||
#### Running tests | ||
|
||
Similarly to the contract compilation, we support both `hardhat` and `forge` tests. By default, the `test` command will execute both: | ||
|
||
```bash | ||
pnpm test | ||
``` | ||
|
||
If you prefer one over the other, you can use the tooling-specific commands: | ||
|
||
```bash | ||
pnpm test:forge | ||
pnpm test:hardhat | ||
``` | ||
|
||
Or adjust the `package.json` to for example remove `hardhat` tests: | ||
|
||
```diff | ||
- "test": "$npm_execpath test:forge && $npm_execpath test:hardhat", | ||
- "test:forge": "forge test", | ||
- "test:hardhat": "$npm_execpath hardhat test" | ||
+ "test": "forge test" | ||
``` | ||
|
||
## 2) Deploying Contracts | ||
|
||
Set up deployer wallet/account: | ||
|
||
- Rename `.env.example` -> `.env` | ||
- Choose your preferred means of setting up your deployer wallet/account: | ||
|
||
``` | ||
MNEMONIC="test test test test test test test test test test test junk" | ||
or... | ||
PRIVATE_KEY="0xabc...def" | ||
``` | ||
|
||
To deploy your contracts to your desired blockchains, run the following command in your project's folder: | ||
|
||
```bash | ||
npx hardhat lz:deploy | ||
``` | ||
|
||
More information about available CLI arguments can be found using the `--help` flag: | ||
|
||
```bash | ||
npx hardhat lz:deploy --help | ||
``` | ||
|
||
By following these steps, you can focus more on creating innovative omnichain solutions and less on the complexities of cross-chain communication. | ||
|
||
<br></br> | ||
|
||
<p align="center"> | ||
Join our community on <a href="https://discord-layerzero.netlify.app/discord" style="color: #a77dff">Discord</a> | Follow us on <a href="https://twitter.com/LayerZero_Labs" style="color: #a77dff">Twitter</a> | ||
</p> |
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,84 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
|
||
pragma solidity ^0.7.0; | ||
|
||
import "@openzeppelin/contracts/access/Ownable.sol"; | ||
import "./TransparentUpgradeableProxy.sol"; | ||
|
||
/** | ||
* @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an | ||
* explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}. | ||
*/ | ||
contract DefaultProxyAdmin is Ownable { | ||
constructor(address initialOwner) { | ||
transferOwnership(initialOwner); | ||
} | ||
|
||
/** | ||
* @dev Returns the current implementation of `proxy`. | ||
* | ||
* Requirements: | ||
* | ||
* - This contract must be the admin of `proxy`. | ||
*/ | ||
function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) { | ||
// We need to manually run the static call since the getter cannot be flagged as view | ||
// bytes4(keccak256("implementation()")) == 0x5c60da1b | ||
(bool success, bytes memory returndata) = address(proxy).staticcall(hex"5c60da1b"); | ||
require(success); | ||
return abi.decode(returndata, (address)); | ||
} | ||
|
||
/** | ||
* @dev Returns the current admin of `proxy`. | ||
* | ||
* Requirements: | ||
* | ||
* - This contract must be the admin of `proxy`. | ||
*/ | ||
function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) { | ||
// We need to manually run the static call since the getter cannot be flagged as view | ||
// bytes4(keccak256("admin()")) == 0xf851a440 | ||
(bool success, bytes memory returndata) = address(proxy).staticcall(hex"f851a440"); | ||
require(success); | ||
return abi.decode(returndata, (address)); | ||
} | ||
|
||
/** | ||
* @dev Changes the admin of `proxy` to `newAdmin`. | ||
* | ||
* Requirements: | ||
* | ||
* - This contract must be the current admin of `proxy`. | ||
*/ | ||
function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner { | ||
proxy.changeAdmin(newAdmin); | ||
} | ||
|
||
/** | ||
* @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}. | ||
* | ||
* Requirements: | ||
* | ||
* - This contract must be the admin of `proxy`. | ||
*/ | ||
function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner { | ||
proxy.upgradeTo(implementation); | ||
} | ||
|
||
/** | ||
* @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See | ||
* {TransparentUpgradeableProxy-upgradeToAndCall}. | ||
* | ||
* Requirements: | ||
* | ||
* - This contract must be the admin of `proxy`. | ||
*/ | ||
function upgradeAndCall( | ||
TransparentUpgradeableProxy proxy, | ||
address implementation, | ||
bytes memory data | ||
) public payable virtual onlyOwner { | ||
proxy.upgradeToAndCall{value: msg.value}(implementation, data); | ||
} | ||
} |
Oops, something went wrong.