Skip to content
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

🗞️ Add Aptos CLI example directories and stubs #1080

Open
wants to merge 156 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 73 commits
Commits
Show all changes
156 commits
Select commit Hold shift + click to select a range
860d2eb
aptos-v2-examples
abaltes-lz Nov 9, 2024
4d4cff9
add Aptos Move build and test automation scripts
AlexanderLiteplo Nov 12, 2024
eecd8d4
adding turbo (FULL TURBO)
AlexanderLiteplo Nov 13, 2024
0a357b5
feat: add full examples to CLI scaffolding
St0rmBr3w Nov 22, 2024
bedee82
Delete pnpm-lock.yaml
St0rmBr3w Nov 22, 2024
6fabba2
chore: fix pnpm lockfile
St0rmBr3w Nov 22, 2024
a997e5e
fix pnpm-lock.yaml
ryandgoulding Nov 25, 2024
caa5c99
chore: update json
St0rmBr3w Dec 10, 2024
012e23c
chore: update json
St0rmBr3w Dec 10, 2024
9780dbd
chore: update json
St0rmBr3w Dec 10, 2024
592ac38
chore: update json
St0rmBr3w Dec 10, 2024
8ae7b07
chore: update lockfile
St0rmBr3w Dec 10, 2024
0055df2
chore: update lockfile
St0rmBr3w Dec 10, 2024
c4d53a4
fix: replace evm OFT Adapter with vanilla OFT
St0rmBr3w Dec 10, 2024
76b0975
chore: add CI tests for aptos examples
St0rmBr3w Dec 10, 2024
b123561
fix: remove duplicate test
St0rmBr3w Dec 10, 2024
b6f8512
fix: remove changelogs from new packages
St0rmBr3w Dec 10, 2024
ae1b695
chore: bump child package versions
St0rmBr3w Dec 10, 2024
c2572c0
fix: remove hardhat test until can diagnose error
St0rmBr3w Dec 11, 2024
1d96927
fix: bumping hardhat.config.ts to match new versions
St0rmBr3w Dec 11, 2024
e811648
adding changes from previous branch to new + fixing stricter linting
AlexanderLiteplo Dec 11, 2024
5b3518a
cleanups
AlexanderLiteplo Dec 11, 2024
0269ecd
updating tests to work with new ofts
AlexanderLiteplo Dec 12, 2024
6d1bf44
cleanups
AlexanderLiteplo Dec 12, 2024
904122c
cleanups
AlexanderLiteplo Dec 12, 2024
9c5d618
making oft-aptos compatible with movement chain and renaming aptos sp…
AlexanderLiteplo Dec 12, 2024
531f147
type extension for hardhat.config.ts
shankars99 Dec 13, 2024
d0ca058
ignore: .aptos
shankars99 Dec 13, 2024
efdf6f1
chore: package json script - pnpm wire:evm
shankars99 Dec 13, 2024
509eef0
sample evmOAppConfig
shankars99 Dec 13, 2024
a60cd26
chore: script to accept user input before sending transactions
shankars99 Dec 13, 2024
e0c01b6
types: update to match linting
shankars99 Dec 13, 2024
aa09bcb
library to handle mesage library configs
shankars99 Dec 13, 2024
3e5e1b9
lint fix
shankars99 Dec 13, 2024
6860966
adding movement compatibility
AlexanderLiteplo Dec 16, 2024
c9fe525
Merge branch 'goulding/krak/aptops-v2-examples' of https://github.com…
AlexanderLiteplo Dec 16, 2024
2c59577
Merge branch 'goulding/krak/aptops-v2-examples' of https://github.com…
AlexanderLiteplo Dec 16, 2024
b163493
merging updates made during adapter impl into oft
AlexanderLiteplo Dec 16, 2024
2dadd36
adding error handling to init scripts, and making them oft type specific
AlexanderLiteplo Dec 16, 2024
fbb4e07
updating repo with todos for when oft impls updated
AlexanderLiteplo Dec 18, 2024
0dd9406
built rate limit and fee set script + cleanups + name update aptos ->…
AlexanderLiteplo Dec 18, 2024
504c40d
remove unused import -- @layerzero packages are all v3.XX.XX
shankars99 Dec 19, 2024
1c487c1
feat: base devtools-movement
shankars99 Dec 19, 2024
9a4bd3d
feat: core devtools movement
shankars99 Dec 30, 2024
8e64523
feat: OFT Fungible Asset
shankars99 Dec 30, 2024
a224795
pnpm-lock
shankars99 Dec 30, 2024
2abd971
feat: core oft fungible asset example
shankars99 Dec 30, 2024
82246c6
feat: initOFTFA extends AptosEVMCLI_Core from devtools-movement
shankars99 Jan 2, 2025
d74e215
chore: using global paths via process.cwd()
shankars99 Jan 2, 2025
cbf17d0
checks for pre-builds and deploys
shankars99 Jan 2, 2025
f75c025
feat: cli + exports
shankars99 Jan 2, 2025
fd3378c
private key is a variable that is passed between functions
shankars99 Jan 2, 2025
407aec8
hardhat and lz config
shankars99 Jan 2, 2025
e4bebd8
using local eslint instead of global
shankars99 Jan 2, 2025
1ce3542
using oft-movement extended cli
shankars99 Jan 2, 2025
105e531
chore: scripts to use the sdk + pnpm lock
shankars99 Jan 2, 2025
7ae04b3
init script does not take in type of oft as an argument
shankars99 Jan 2, 2025
686da82
using args from the cli instead of function definition
shankars99 Jan 3, 2025
e466f03
feat: devtools-extensible-cli used by move cli
shankars99 Jan 3, 2025
70fd071
devtools-cli operations to wire, build, and deploy
shankars99 Jan 3, 2025
2333ad7
move-oft-fa operations
shankars99 Jan 3, 2025
300c9f5
using devtools-extensible-cli
shankars99 Jan 3, 2025
db1b64c
INewOperation takes in a description
shankars99 Jan 6, 2025
8383896
extensible cli takes in help
shankars99 Jan 6, 2025
c15f92b
add scripting for lz:sdk:help
shankars99 Jan 6, 2025
49f9f82
help inits the cli
shankars99 Jan 6, 2025
26859cf
renaming, refactoring, bug fixing
AlexanderLiteplo Jan 7, 2025
f08efae
mergemerge
shankars99 Jan 7, 2025
d7a3675
adding quotesend test script
AlexanderLiteplo Jan 7, 2025
5057493
merge
shankars99 Jan 7, 2025
9af52b0
remove oft-movement
shankars99 Jan 7, 2025
dbd07db
bug fixes + preparing for new oft integration
AlexanderLiteplo Jan 7, 2025
07111af
Merge branch 'goulding/krak/aptops-v2-examples' of https://github.com…
AlexanderLiteplo Jan 7, 2025
7a6f0e0
bug fixes + removing extra files
AlexanderLiteplo Jan 8, 2025
fa8c8d1
adding oft fa adapter
AlexanderLiteplo Jan 8, 2025
5680dae
removed tests copy and changes package.json package name
shankars99 Jan 8, 2025
312c303
add decode for diff printer
shankars99 Jan 9, 2025
05df29c
verbose options printing
shankars99 Jan 9, 2025
e364833
update path
shankars99 Jan 9, 2025
9c172ce
refactored wire to extract looping, deleting old oft examples, updati…
AlexanderLiteplo Jan 9, 2025
e9b0c80
Merge branch 'goulding/krak/aptops-v2-examples' of https://github.com…
AlexanderLiteplo Jan 9, 2025
49ba70f
updating reviewer guide
AlexanderLiteplo Jan 9, 2025
592acfa
improving reviewer guide readme
AlexanderLiteplo Jan 9, 2025
4c84987
remove duplicated path
shankars99 Jan 9, 2025
990e2f9
removing old aptos packages
AlexanderLiteplo Jan 9, 2025
280f17b
removing old tests
AlexanderLiteplo Jan 9, 2025
0a434dd
updating command names, and adding, dsable-blocklist, disable-freezin…
AlexanderLiteplo Jan 9, 2025
0226bf6
readme adjustment
AlexanderLiteplo Jan 9, 2025
58771d4
adding rate limit description to readme
AlexanderLiteplo Jan 9, 2025
5f73352
cleanup
AlexanderLiteplo Jan 9, 2025
12a375f
fixing bugs and updating printing for evm wire
AlexanderLiteplo Jan 10, 2025
17ccad7
adapter coin payload
shankars99 Jan 10, 2025
f51eed0
merge
shankars99 Jan 10, 2025
2a726b1
fix: config UI and treat default library value != default config
shankars99 Jan 10, 2025
f6cc0d2
anvil fork checks for running processes on the predicted anvil ports …
shankars99 Jan 10, 2025
d206d51
fix: wire evm waits on transactions to complete
shankars99 Jan 10, 2025
e63e2a7
making evm wire prinouts more clear
AlexanderLiteplo Jan 10, 2025
f432eb3
adding quote, send, and mint commands
AlexanderLiteplo Jan 11, 2025
f4ecb68
adding transfer ownership functionality
AlexanderLiteplo Jan 11, 2025
64fd09d
use --oapp-config instead of --lz-config
shankars99 Jan 11, 2025
a097af3
remove unused optional argument in execute()
shankars99 Jan 11, 2025
db1bbd0
use ethers.constants.AddressZero instead of ZERO_ADDRESS
shankars99 Jan 11, 2025
c477ada
base-x -> bytes32 decoder
shankars99 Jan 11, 2025
789915f
adding new ofts
AlexanderLiteplo Jan 11, 2025
20cf1da
Merge branch 'goulding/krak/aptops-v2-examples' of https://github.com…
AlexanderLiteplo Jan 11, 2025
7a75efb
integrating endpoint update changes
AlexanderLiteplo Jan 11, 2025
fb409fa
updating CLI to handle new endpoint and oft codecs and params, also u…
AlexanderLiteplo Jan 11, 2025
101cf5c
base-x address conversion for solana and other networks
shankars99 Jan 12, 2025
14a422d
handles wiring evm,aptos,solana contracts onto an evm contract
shankars99 Jan 12, 2025
3dad57e
fix: pnpm lock
shankars99 Jan 12, 2025
6597478
revert changes artifacts
shankars99 Jan 12, 2025
47bbb2d
fix: pnpm-lock conflict with main
shankars99 Jan 12, 2025
d6a7963
removing old tests
AlexanderLiteplo Jan 12, 2025
e1ead74
Merge branch 'goulding/krak/aptops-v2-examples' of https://github.com…
AlexanderLiteplo Jan 12, 2025
a406d6e
merge + conflict at pnpmlock and turbo
shankars99 Jan 12, 2025
ce8fcae
Merge branch 'goulding/krak/aptops-v2-examples' of https://github.com…
shankars99 Jan 12, 2025
d97e9d5
chore: add tsup for pnpm build
shankars99 Jan 13, 2025
5e3cdc7
adding oft impl specific methods to adapter
AlexanderLiteplo Jan 13, 2025
c96b785
Merge branch 'goulding/krak/aptops-v2-examples' of https://github.com…
AlexanderLiteplo Jan 13, 2025
0da8226
getting rid of shell scripts that were made for internal testing and …
AlexanderLiteplo Jan 13, 2025
2adb4a4
adding handling of solana addresses in aptos-setpeer
AlexanderLiteplo Jan 13, 2025
e181d78
Revert "Merge branch 'goulding/krak/aptops-v2-examples' of https://gi…
shankars99 Jan 13, 2025
b1225f3
changes for pnpm lint:fix + pnpm lint:fix
shankars99 Jan 13, 2025
d89e442
fix: handles case of same argument being added more than once
shankars99 Jan 13, 2025
2422d99
fix: imports
shankars99 Jan 13, 2025
cc072be
handle: hardhat config connection eid not being interpreted as Endpoi…
shankars99 Jan 13, 2025
997ed2d
remove: unused tsconfig paths
shankars99 Jan 13, 2025
2811266
improve logging messages
shankars99 Jan 13, 2025
053dd83
pnpm lock
shankars99 Jan 13, 2025
5234993
chore: add APTOS_ACCOUNT_ADDRESS to .env.example
shankars99 Jan 13, 2025
a1720d1
txTypePool stores the dstEid
shankars99 Jan 13, 2025
a71d71e
logging transactions
shankars99 Jan 13, 2025
89749a6
faucet is an optional paramter + using fullnode to determine network …
shankars99 Jan 13, 2025
d51a3a7
split wire-evm and rename wireOntoOApps to peers
shankars99 Jan 13, 2025
2cfe460
fixing wire-evm printout
AlexanderLiteplo Jan 13, 2025
99fb8c8
fixes
AlexanderLiteplo Jan 13, 2025
c15d755
adding solana support to send and quote send
AlexanderLiteplo Jan 13, 2025
299dab0
updating deployment addresses for mainnet .
AlexanderLiteplo Jan 14, 2025
39cb92d
renaming examples move -> aptos-move
AlexanderLiteplo Jan 14, 2025
2218eec
refactor into seperate functions
shankars99 Jan 14, 2025
219a5c0
feat: evm quote send:
shankars99 Jan 14, 2025
87b747e
Merge branch 'goulding/krak/aptops-v2-examples' of https://github.com…
shankars99 Jan 14, 2025
23def77
chore: logging only when wire is called
shankars99 Jan 14, 2025
75681f7
update pnpm lock
shankars99 Jan 14, 2025
88a5d67
chore: quoteSend script added
shankars99 Jan 14, 2025
1a8e247
untested send
shankars99 Jan 14, 2025
0a36158
deleting adapter deployments folder and making configs blank
AlexanderLiteplo Jan 14, 2025
e3cfbb2
🧹 provide a working example move.layerzero.config.ts (#1165)
ryandgoulding Jan 14, 2025
12faec8
🧹lint fixes for aptos examples (#1166)
ryandgoulding Jan 14, 2025
67b9c5c
🪲 rm unnecessary view (#1167)
ryandgoulding Jan 14, 2025
9e292e3
🧹update snapshots (#1168)
ryandgoulding Jan 14, 2025
32fe845
minor printout adjustment to deployment success message
AlexanderLiteplo Jan 15, 2025
8655aff
minor console log change to clarify build path of aptos build
AlexanderLiteplo Jan 15, 2025
c77b9cc
chore: --simulate {true || false} default true to enable/disable fork…
shankars99 Jan 15, 2025
2f464d0
validation: validate rpc url and supported eids
shankars99 Jan 15, 2025
ce92fd8
logging validation steps are more consistent
shankars99 Jan 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
15 changes: 15 additions & 0 deletions examples/oapp-aptos/.env.example
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=
10 changes: 10 additions & 0 deletions examples/oapp-aptos/.eslintignore
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
10 changes: 10 additions & 0 deletions examples/oapp-aptos/.eslintrc.js
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',
},
};
25 changes: 25 additions & 0 deletions examples/oapp-aptos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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

build/
1 change: 1 addition & 0 deletions examples/oapp-aptos/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18.18.0
10 changes: 10 additions & 0 deletions examples/oapp-aptos/.prettierignore
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
3 changes: 3 additions & 0 deletions examples/oapp-aptos/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
...require('@layerzerolabs/prettier-config-next'),
};
72 changes: 72 additions & 0 deletions examples/oapp-aptos/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
[package]
name = "oapp"
version = "1.0.0"
authors = []

[addresses]
oapp = "_"
oft_common = "_"
router_node_0 = "_"
simple_msglib = "_"
blocked_msglib = "_"
uln_302 = "_"
router_node_1 = "_"
endpoint_v2_common = "_"
endpoint_v2 = "_"
layerzero_admin = "_"
layerzero_treasury_admin = "_"
msglib_types = "_"
treasury = "_"
worker_peripherals = "_"
price_feed_router_0 = "_"
price_feed_router_1 = "_"
price_feed_module_0 = "_"
worker_common = "_"
executor_fee_lib_router_0 = "_"
executor_fee_lib_router_1 = "_"
dvn_fee_lib_router_0 = "_"
dvn_fee_lib_router_1 = "_"
executor_fee_lib_0 = "_"
dvn_fee_lib_0 = "_"
dvn = "_"
native_token_metadata_address = "0xa"

[dev-addresses]
oapp = "0x302814823"
oft_common = "0x30281482332"
router_node_0 = "0x10000f"
simple_msglib = "0x100011"
blocked_msglib = "0x100001"
uln_302 = "0x100013"
router_node_1 = "0x100010"
endpoint_v2_common = "0x100007"
endpoint_v2 = "0x100006"
layerzero_admin = "0x200001"
layerzero_treasury_admin = "0x200002"
msglib_types = "0x10000b"
treasury = "0x100012"
worker_peripherals = "0x3000"
price_feed_router_0 = "0x10000d"
price_feed_router_1 = "0x10000e"
price_feed_module_0 = "0x10000c"
worker_common = "0x100014"
executor_fee_lib_router_0 = "0x100009"
executor_fee_lib_router_1 = "0x10000a"
dvn_fee_lib_router_0 = "0x100004"
dvn_fee_lib_router_1 = "0x100005"
executor_fee_lib_0 = "0x100008"
dvn_fee_lib_0 = "0x100003"
dvn = "0x100002"

[dependencies.AptosFramework]
git = "https://github.com/aptos-labs/aptos-core.git"
rev = "mainnet"
subdir = "aptos-move/framework/aptos-framework"

[dependencies]
endpoint_v2_common = { git = "https://github.com/LayerZero-Labs/LayerZero-v2", rev = "aptos-v2", subdir = "packages/layerzero-v2/aptos/contracts/endpoint_v2_common" }
endpoint_v2 = { git = "https://github.com/LayerZero-Labs/LayerZero-v2", rev = "aptos-v2", subdir = "packages/layerzero-v2/aptos/contracts/endpoint_v2" }
oft_common = { git = "https://github.com/LayerZero-Labs/LayerZero-v2", rev = "aptos-v2", subdir = "packages/layerzero-v2/aptos/contracts/oapps/oft_common" }

[dev-dependencies]
simple_msglib = { git = "https://github.com/LayerZero-Labs/LayerZero-v2", rev = "aptos-v2", subdir = "packages/layerzero-v2/aptos/contracts/msglib/libs/simple_msglib" }
108 changes: 108 additions & 0 deletions examples/oapp-aptos/README.md
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>
70 changes: 70 additions & 0 deletions examples/oapp-aptos/contracts/MyOApp.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.22;

import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { OApp, MessagingFee, Origin } from "@layerzerolabs/oapp-evm/contracts/oapp/OApp.sol";
import { MessagingReceipt } from "@layerzerolabs/oapp-evm/contracts/oapp/OAppSender.sol";

contract MyOApp is OApp {
constructor(address _endpoint, address _delegate) OApp(_endpoint, _delegate) Ownable(_delegate) {}

string public data = "Nothing received yet.";

/**
* @notice Sends a message from the source chain to a destination chain.
* @param _dstEid The endpoint ID of the destination chain.
* @param _message The message string to be sent.
* @param _options Additional options for message execution.
* @dev Encodes the message as bytes and sends it using the `_lzSend` internal function.
* @return receipt A `MessagingReceipt` struct containing details of the message sent.
*/
function send(
uint32 _dstEid,
string memory _message,
bytes calldata _options
) external payable returns (MessagingReceipt memory receipt) {
bytes memory _payload = abi.encode(_message);
receipt = _lzSend(_dstEid, _payload, _options, MessagingFee(msg.value, 0), payable(msg.sender));
}

/**
* @notice Quotes the gas needed to pay for the full omnichain transaction in native gas or ZRO token.
* @param _dstEid Destination chain's endpoint ID.
* @param _message The message.
* @param _options Message execution options (e.g., for sending gas to destination).
* @param _payInLzToken Whether to return fee in ZRO token.
* @return fee A `MessagingFee` struct containing the calculated gas fee in either the native token or ZRO token.
*/
function quote(
uint32 _dstEid,
string memory _message,
bytes memory _options,
bool _payInLzToken
) public view returns (MessagingFee memory fee) {
bytes memory payload = abi.encode(_message);
fee = _quote(_dstEid, payload, _options, _payInLzToken);
}

/**
* @dev Internal function override to handle incoming messages from another chain.
* @dev _origin A struct containing information about the message sender.
* @dev _guid A unique global packet identifier for the message.
* @param payload The encoded message payload being received.
*
* @dev The following params are unused in the current implementation of the OApp.
* @dev _executor The address of the Executor responsible for processing the message.
* @dev _extraData Arbitrary data appended by the Executor to the message.
*
* Decodes the received payload and processes it as per the business logic defined in the function.
*/
function _lzReceive(
Origin calldata /*_origin*/,
bytes32 /*_guid*/,
bytes calldata payload,
address /*_executor*/,
bytes calldata /*_extraData*/
) internal override {
data = abi.decode(payload, (string));
}
}
52 changes: 52 additions & 0 deletions examples/oapp-aptos/deploy/MyOApp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import assert from 'assert'

import { type DeployFunction } from 'hardhat-deploy/types'

// TODO declare your contract name here
const contractName = 'MyOApp'

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: [
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
Loading
Loading