Skip to content

Commit

Permalink
Merge branch 'goulding/krak/aptops-v2-examples' of https://github.com…
Browse files Browse the repository at this point in the history
…/LayerZero-Labs/devtools into goulding/krak/aptops-v2-examples
  • Loading branch information
AlexanderLiteplo committed Jan 7, 2025
2 parents dbd07db + 9af52b0 commit 07111af
Show file tree
Hide file tree
Showing 530 changed files with 61,730 additions and 72 deletions.
2 changes: 1 addition & 1 deletion examples/oft-move/deployments/aptos-testnet/oft.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"address": "0x3f710e858b91714fdf072dc5222025e4d4b718ff33588eb1e6bbc11ba090b4f5",
"address": "0x8401fa82eea1096b32fd39207889152f947d78de1b65976109493584636622a8",
"abi": [],
"transactionHash": "",
"receipt": {},
Expand Down
67 changes: 3 additions & 64 deletions examples/oft-move/test/evm/foundry/MyOFT.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
pragma solidity ^0.8.20;

// Mock imports
import { OFTMock } from "../mocks/OFTMock.sol";
import { ERC20Mock } from "../mocks/ERC20Mock.sol";
import { OFTComposerMock } from "../mocks/OFTComposerMock.sol";
import { MyOFT } from "../../../contracts/OFT.sol";

// OApp imports
import { IOAppOptionsType3, EnforcedOptionParam } from "@layerzerolabs/oapp-evm/contracts/oapp/libs/OAppOptionsType3.sol";
Expand All @@ -28,8 +26,8 @@ import { TestHelperOz5 } from "@layerzerolabs/test-devtools-evm-foundry/contract
contract MyOFTTest is TestHelperOz5 {
using OptionsBuilder for bytes;

uint32 private aEid = 1;
uint32 private bEid = 2;
uint32 private bscEid = ;
uint32 private aptosEid = 2;

OFTMock private aOFT;
OFTMock private bOFT;
Expand Down Expand Up @@ -57,7 +55,6 @@ contract MyOFTTest is TestHelperOz5 {
address[] memory ofts = new address[](2);
ofts[0] = address(aOFT);
ofts[1] = address(bOFT);
this.wireOApps(ofts);

// mint tokens
aOFT.mint(userA, initialBalance);
Expand Down Expand Up @@ -99,62 +96,4 @@ contract MyOFTTest is TestHelperOz5 {
assertEq(aOFT.balanceOf(userA), initialBalance - tokensToSend);
assertEq(bOFT.balanceOf(userB), initialBalance + tokensToSend);
}

function test_send_oft_compose_msg() public {
uint256 tokensToSend = 1 ether;

OFTComposerMock composer = new OFTComposerMock();

bytes memory options = OptionsBuilder
.newOptions()
.addExecutorLzReceiveOption(200000, 0)
.addExecutorLzComposeOption(0, 500000, 0);
bytes memory composeMsg = hex"1234";
SendParam memory sendParam = SendParam(
bEid,
addressToBytes32(address(composer)),
tokensToSend,
tokensToSend,
options,
composeMsg,
""
);
MessagingFee memory fee = aOFT.quoteSend(sendParam, false);

assertEq(aOFT.balanceOf(userA), initialBalance);
assertEq(bOFT.balanceOf(address(composer)), 0);

vm.prank(userA);
(MessagingReceipt memory msgReceipt, OFTReceipt memory oftReceipt) = aOFT.send{ value: fee.nativeFee }(
sendParam,
fee,
payable(address(this))
);
verifyPackets(bEid, addressToBytes32(address(bOFT)));

// lzCompose params
uint32 dstEid_ = bEid;
address from_ = address(bOFT);
bytes memory options_ = options;
bytes32 guid_ = msgReceipt.guid;
address to_ = address(composer);
bytes memory composerMsg_ = OFTComposeMsgCodec.encode(
msgReceipt.nonce,
aEid,
oftReceipt.amountReceivedLD,
abi.encodePacked(addressToBytes32(userA), composeMsg)
);
this.lzCompose(dstEid_, from_, options_, guid_, to_, composerMsg_);

assertEq(aOFT.balanceOf(userA), initialBalance - tokensToSend);
assertEq(bOFT.balanceOf(address(composer)), tokensToSend);

assertEq(composer.from(), from_);
assertEq(composer.guid(), guid_);
assertEq(composer.message(), composerMsg_);
assertEq(composer.executor(), address(this));
assertEq(composer.extraData(), composerMsg_); // default to setting the extraData to the message as well to test
}

// TODO import the rest of oft tests?
}
8 changes: 8 additions & 0 deletions packages/devtools-move/sdk/oft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,14 @@ export class OFT {
}
}

transferObjectPayload(object_address: string, new_owner_address: string): InputGenerateTransactionPayloadData {
return {
function: '0x1::object::transfer',
typeArguments: [`0x1::object::ObjectCore`],
functionArguments: [object_address, new_owner_address],
}
}

renounceAdminPayload(): InputGenerateTransactionPayloadData {
return {
function: `${this.oft_address}::oapp_core::renounce_admin`,
Expand Down
18 changes: 11 additions & 7 deletions packages/devtools-move/tasks/move/transferOwnership.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@ import { OFT } from '../../sdk/oft'
import { getEidFromAptosNetwork, getLzNetworkStage, parseYaml } from './utils/aptosNetworkParser'
import { setDelegate, transferOwner } from './utils/moveVMOftConfigOps'
import { getDelegateFromLzConfig, getMoveVMOftAddress, getOwnerFromLzConfig, sendAllTxs } from './utils/utils'
import path from 'path'

async function main() {
async function transferOwnership(args: any) {
const { account_address, private_key, network } = await parseYaml()

const aptosConfig = new AptosConfig({ network: network })
const configPath = args.lz_config

const aptos = new Aptos(aptosConfig)

const lzConfigPath = path.resolve(path.join(process.cwd(), configPath))
const lzConfigFile = await import(lzConfigPath)
const lzConfig = lzConfigFile.default

const lzNetworkStage = getLzNetworkStage(network)
const aptosOftAddress = getMoveVMOftAddress(lzNetworkStage)

Expand All @@ -20,8 +27,8 @@ async function main() {
const oft = new OFT(aptos, aptosOftAddress, account_address, private_key)

const eid = getEidFromAptosNetwork('aptos', network)
const delegate = getDelegateFromLzConfig(eid)
const owner = getOwnerFromLzConfig(eid)
const delegate = getDelegateFromLzConfig(eid, lzConfig)
const owner = getOwnerFromLzConfig(eid, lzConfig)

const setDelegatePayload = await setDelegate(oft, delegate, eid)
const transferOwnerPayload = await transferOwner(oft, owner, eid)
Expand All @@ -31,7 +38,4 @@ async function main() {
sendAllTxs(aptos, oft, account_address, payloads)
}

main().catch((error) => {
console.error('Error:', error)
process.exit(1)
})
export { transferOwnership }
103 changes: 103 additions & 0 deletions packages/oft-movement/build/oft/BuildInfo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
---
compiled_package_info:
package_name: oft
address_alias_instantiation:
Extensions: "0000000000000000000000000000000000000000000000000000000000000001"
aptos_framework: "0000000000000000000000000000000000000000000000000000000000000001"
aptos_fungible_asset: 000000000000000000000000000000000000000000000000000000000000000a
aptos_std: "0000000000000000000000000000000000000000000000000000000000000001"
aptos_token: "0000000000000000000000000000000000000000000000000000000000000003"
blocked_msglib: "0000000000000000000000000000000000000000000000000000000000100001"
core_resources: 000000000000000000000000000000000000000000000000000000000a550c18
dvn: "0000000000000000000000000000000000000000000000000000000000100002"
dvn_fee_lib_0: "0000000000000000000000000000000000000000000000000000000000100003"
dvn_fee_lib_router_0: "0000000000000000000000000000000000000000000000000000000000100004"
dvn_fee_lib_router_1: "0000000000000000000000000000000000000000000000000000000000100005"
endpoint_v2: "0000000000000000000000000000000000000000000000000000000000100006"
endpoint_v2_common: "0000000000000000000000000000000000000000000000000000000000100007"
executor_fee_lib_0: "0000000000000000000000000000000000000000000000000000000000100008"
executor_fee_lib_router_0: "0000000000000000000000000000000000000000000000000000000000100009"
executor_fee_lib_router_1: 000000000000000000000000000000000000000000000000000000000010000a
layerzero_admin: "0000000000000000000000000000000000000000000000000000000000200001"
layerzero_treasury_admin: "0000000000000000000000000000000000000000000000000000000000200002"
msglib_types: 000000000000000000000000000000000000000000000000000000000010000b
native_token_metadata_address: 000000000000000000000000000000000000000000000000000000000000000a
oft: "0000000000000000000000000000000000000000000000000000000302814823"
oft_admin: "0000000000000000000000000000000000000000000000000000000012321241"
oft_common: "0000000000000000000000000000000000000000000000000000030281482332"
price_feed_module_0: 000000000000000000000000000000000000000000000000000000000010000c
price_feed_router_0: 000000000000000000000000000000000000000000000000000000000010000d
price_feed_router_1: 000000000000000000000000000000000000000000000000000000000010000e
router_node_0: 000000000000000000000000000000000000000000000000000000000010000f
router_node_1: "0000000000000000000000000000000000000000000000000000000000100010"
simple_msglib: "0000000000000000000000000000000000000000000000000000000000100011"
std: "0000000000000000000000000000000000000000000000000000000000000001"
treasury: "0000000000000000000000000000000000000000000000000000000000100012"
uln_302: "0000000000000000000000000000000000000000000000000000000000100013"
vm: "0000000000000000000000000000000000000000000000000000000000000000"
vm_reserved: "0000000000000000000000000000000000000000000000000000000000000000"
worker_common: "0000000000000000000000000000000000000000000000000000000000100014"
worker_peripherals: "0000000000000000000000000000000000000000000000000000000000003000"
source_digest: ADAADBEB37D7B65BE9B5A959A336F1857371B1E5C95BE58BA01A534EE413D601
build_flags:
dev_mode: true
test_mode: false
override_std: ~
generate_docs: false
generate_abis: false
generate_move_model: true
full_model_generation: false
install_dir: ~
force_recompilation: false
additional_named_addresses: {}
architecture: ~
fetch_deps_only: false
skip_fetch_latest_git_deps: true
compiler_config:
bytecode_version: 6
known_attributes:
- bytecode_instruction
- deprecated
- event
- expected_failure
- "fmt::skip"
- legacy_entry_fun
- "lint::allow_unsafe_randomness"
- "lint::skip"
- native_interface
- randomness
- resource_group
- resource_group_member
- test
- test_only
- verify_only
- view
skip_attribute_checks: true
compiler_version: ~
language_version: ~
experiments:
- optimize=on
dependencies:
- AptosFramework
- AptosStdlib
- MoveStdlib
- blocked_msglib
- dvn_fee_lib_0
- dvn_fee_lib_router_0
- dvn_fee_lib_router_1
- endpoint_v2
- endpoint_v2_common
- executor_fee_lib_0
- executor_fee_lib_router_0
- executor_fee_lib_router_1
- msglib_types
- oft_common
- price_feed_module_0
- price_feed_router_0
- price_feed_router_1
- router_node_0
- router_node_1
- simple_msglib
- treasury
- uln_302
- worker_common
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 07111af

Please sign in to comment.