Skip to content

Commit aa20b6e

Browse files
Primataclaude
andcommitted
add movement changes
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent c4f82be commit aa20b6e

12 files changed

Lines changed: 904 additions & 57 deletions

File tree

examples/Move.toml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
[package]
2+
name = "oft"
3+
version = "1.0.0"
4+
authors = []
5+
6+
[addresses]
7+
oft = "_"
8+
oft_admin = "_"
9+
# aptos-mainnet
10+
oft_common = "0xcf4e1eb4b32b84266f27efe35539a9a3b7a3ec822299d8eb828ca32e581aa72c"
11+
router_node_0 = "0x6de27e5aa7dbee0fc32af2a92b8aa0b96e0033026ade8f22e4692cd8603220e9"
12+
simple_msglib = "0x52d5c6f8dcb20ed8ace8dbaa7cc09a98eb1dbec0f184720795310c031ace5111"
13+
blocked_msglib = "0x3ca0d187f1938cf9776a0aa821487a650fc7bb2ab1c1d241ba319192aae4afc6"
14+
uln_302 = "0xc33752e0220faf79e45385dd73fb28d681dcd9f1569a1480725507c1f3c3aba9"
15+
router_node_1 = "0x2ae54c38567f217c42b255016a38ccd68b67eb276a6cc3ebad609935fe3cc70c"
16+
endpoint_v2_common = "0xe1dc2a62b445403bea0dbd73df8cee03b3ead0a06b003e72e401c030a810a133"
17+
endpoint_v2 = "0xe60045e20fc2c99e869c1c34a65b9291c020cd12a0d37a00a53ac1348af4f43c"
18+
layerzero_admin = "0x19f1c63510f3ea8b8cd467ebe663897371919c185218d2859927f5a357b0bcae"
19+
layerzero_treasury_admin = "0x19f1c63510f3ea8b8cd467ebe663897371919c185218d2859927f5a357b0bcae"
20+
msglib_types = "0xa3fac5ed887625dd1d4371a60c7bfd5869e8ce5c3c5783fb8898dc0128365c31"
21+
treasury = "0x77c941e60b8e2c8d784de2ee456fd497283edfe1e15704c99a192ff795fc38b7"
22+
worker_peripherals = "0x19f1c63510f3ea8b8cd467ebe663897371919c185218d2859927f5a357b0bcae"
23+
price_feed_router_0 = "0x969722e6e181bb17165c17492c037514cd213a0ce9830a59724190e13c011136"
24+
price_feed_router_1 = "0x3808a699d1a14d25de813a4e0bbcde7a8ce8d27ccc9055aee8070d28172faced"
25+
price_feed_module_0 = "0xad0f7141f626c07db99a7fe5b864fde080bc4966c144d88f6f14ac4af391f30"
26+
worker_common = "0x1bffc83ec332cb9de738e8f0c27dd2230ee57bdbc71473047fcfe8bfaa21fab7"
27+
executor_fee_lib_router_0 = "0xfb941d4e28fc08b94fe53c9043e392d6405a16475bccbfee5222d588cef5b709"
28+
executor_fee_lib_router_1 = "0xf8ed27afba36de5693de4c9ea654ee73de7b0e2ac7c43a54d36bc155a944d9d1"
29+
dvn_fee_lib_router_0 = "0x707f09a7db866c4be5d2ee7c4ffcfe38e1b893f8d757712fe224fa19da881c93"
30+
dvn_fee_lib_router_1 = "0x31dcc84f4bfffff09648cb9ae6d84261ddb7c04646d1f2f6c38bf6d7551a0831"
31+
executor_fee_lib_0 = "0xbbb5d80871b10c4a7c10b9bbc636fdca4faa05feb3b03dc27e3018a7bfcbd8cb"
32+
dvn_fee_lib_0 = "0x349c43bc506cbbe7b754b164867bd1751763410b6458a798c25bb6f3c3e9e487"
33+
dvn = "0xdf8f0a53b20f1656f998504b81259698d126523a31bdbbae45ba1e8a3078d8da"
34+
native_token_metadata_address = "0xa"
35+
36+
[dev-addresses]
37+
oft = "0x302814823"
38+
oft_admin = "0x12321241"
39+
oft_common = "0x30281482332"
40+
router_node_0 = "0x10000f"
41+
simple_msglib = "0x100011"
42+
blocked_msglib = "0x100001"
43+
uln_302 = "0x100013"
44+
router_node_1 = "0x100010"
45+
endpoint_v2_common = "0x100007"
46+
endpoint_v2 = "0x100006"
47+
layerzero_admin = "0x200001"
48+
layerzero_treasury_admin = "0x200002"
49+
msglib_types = "0x10000b"
50+
treasury = "0x100012"
51+
worker_peripherals = "0x3000"
52+
price_feed_router_0 = "0x10000d"
53+
price_feed_router_1 = "0x10000e"
54+
price_feed_module_0 = "0x10000c"
55+
worker_common = "0x100014"
56+
executor_fee_lib_router_0 = "0x100009"
57+
executor_fee_lib_router_1 = "0x10000a"
58+
dvn_fee_lib_router_0 = "0x100004"
59+
dvn_fee_lib_router_1 = "0x100005"
60+
executor_fee_lib_0 = "0x100008"
61+
dvn_fee_lib_0 = "0x100003"
62+
dvn = "0x100002"
63+
64+
[dependencies.AptosFramework]
65+
git = "https://github.com/aptos-labs/aptos-framework.git"
66+
rev = "99f5e915b6d231d0ffbc1aff282d36148d2a8b24"
67+
subdir = "aptos-framework"
68+
69+
[dependencies]
70+
endpoint_v2_common = { git = "https://github.com/LayerZero-Labs/LayerZero-v2", rev = "main", subdir = "packages/layerzero-v2/aptos/contracts/endpoint_v2_common" }
71+
endpoint_v2 = { git = "https://github.com/LayerZero-Labs/LayerZero-v2", rev = "main", subdir = "packages/layerzero-v2/aptos/contracts/endpoint_v2" }
72+
oft_common = { git = "https://github.com/LayerZero-Labs/LayerZero-v2", rev = "main", subdir = "packages/layerzero-v2/aptos/contracts/oapps/oft_common" }
73+
74+
[dev-dependencies]
75+
simple_msglib = { git = "https://github.com/LayerZero-Labs/LayerZero-v2", rev = "main", subdir = "packages/layerzero-v2/aptos/contracts/msglib/libs/simple_msglib" }

examples/config.sh

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
module_address="${1:-}"
2+
admin="${2:-}"
3+
eid="${3:-40101}"
4+
peer="${4:-}"
5+
cli=${5:-"movement"}
6+
network=${6:-"mainnet"}
7+
profile=${7:-"default"}
8+
9+
echo "Using CLI: $cli"
10+
echo "Using Network: $network"
11+
echo "Module Address: $module_address"
12+
echo "Admin: $admin"
13+
echo "EID: $eid"
14+
echo "Peer: $peer"
15+
16+
multisig=false
17+
multisig_address=""
18+
19+
# ── Set these per deployment ─────────────────────────────────────────────────
20+
21+
# ─────────────────────────────────────────────────────────────────────────────
22+
23+
if $multisig; then
24+
if [ -z "$multisig_address" ]; then
25+
echo "Error: multisig_address must be set if multisig is true"
26+
exit 1
27+
fi
28+
command="multisig create_transaction --multisig-address $multisig_address"
29+
else
30+
command="move run"
31+
fi
32+
33+
deployer=$(awk '/^ '$profile':/{flag=1} flag && /^ account:/{print $2; exit}' .$cli/config.yaml)
34+
[[ "$deployer" != 0x* ]] && deployer="0x${deployer}"
35+
if [ -z "$module_address" ]; then
36+
module_address="$deployer"
37+
fi
38+
[[ "$module_address" != 0x* ]] && module_address="0x${module_address}"
39+
[[ -n "$multisig_address" && "$multisig_address" != 0x* ]] && multisig_address="0x${multisig_address}"
40+
[[ -n "$peer" && "$peer" != 0x* ]] && peer="0x${peer}"
41+
[[ -n "$admin" && "$admin" != 0x* ]] && admin="0x${admin}"
42+
43+
case "${cli}:${network}" in
44+
movement:testnet)
45+
msg_lib=0xcc1c03aed42e2841211865758b5efe93c0dde2cb7a2a5dc6cf25a4e33ad23690
46+
executor=0x93353700091200ef9fdc536ce6a86182cc7e62da25f94356be9421c6310b9585
47+
endpoint=0x7f03103b83c51c8b09be1751a797a65ac6e755f72947ecdecffc203d32d816c6
48+
required_dvns="0x5b983a8faf6977f0bc76ed2a96fda5abdacaeb829841c2d4da176acd78d19d97,0x5e621608b81aa5243d193bf69438c9402712303490d5d974f06f63c154fd977b,0x756f8ab056688d22687740f4a9aeec3b361170b28d08b719e28c4d38eed1043e"
49+
;;
50+
movement:mainnet)
51+
msg_lib=0xc33752e0220faf79e45385dd73fb28d681dcd9f1569a1480725507c1f3c3aba9
52+
executor=0x15a5bbf1eb7998a22c9f23810d424abe40bd59ddd8e6ab7e59529853ebed41c4
53+
endpoint=0xe60045e20fc2c99e869c1c34a65b9291c020cd12a0d37a00a53ac1348af4f43c
54+
required_dvns="0x2b696b3ee859b7eb624e1fd5de49f4d3806f49862f1177d6827fd1beffde9179,0xdf8f0a53b20f1656f998504b81259698d126523a31bdbbae45ba1e8a3078d8da,0xbcfb6d3ce5e99275e5fa09b3f53eaaea32365c776d023c51a680c4c420d88b91"
55+
;;
56+
aptos:testnet)
57+
msg_lib=0xcc1c03aed42e2841211865758b5efe93c0dde2cb7a2a5dc6cf25a4e33ad23690
58+
executor=0x93353700091200ef9fdc536ce6a86182cc7e62da25f94356be9421c6310b9585
59+
endpoint=0x7f03103b83c51c8b09be1751a797a65ac6e755f72947ecdecffc203d32d816c6
60+
required_dvns="0x5e621608b81aa5243d193bf69438c9402712303490d5d974f06f63c154fd977b,0x756f8ab056688d22687740f4a9aeec3b361170b28d08b719e28c4d38eed1043e,0x5b983a8faf6977f0bc76ed2a96fda5abdacaeb829841c2d4da176acd78d19d97"
61+
;;
62+
aptos:mainnet)
63+
msg_lib=0xc33752e0220faf79e45385dd73fb28d681dcd9f1569a1480725507c1f3c3aba9
64+
executor=0x15a5bbf1eb7998a22c9f23810d424abe40bd59ddd8e6ab7e59529853ebed41c4
65+
endpoint=0xe60045e20fc2c99e869c1c34a65b9291c020cd12a0d37a00a53ac1348af4f43c
66+
required_dvns="0x9880ed7ade7e7f8f8eb070ce72c51b231921e29e65b3d51fa3810814bba32c00,0xf3f0a412626edba5ddd3613d91109b241893873ac5479ade231cf0b3130572b5,0xcb2ab3c2fb799c6578b9950f9db7ff555a2d4967ef15437230346f56599801ae"
67+
;;
68+
*)
69+
echo "Error: unknown cli/network combination '${cli}:${network}'. Use cli=movement|aptos and network=testnet|mainnet."
70+
exit 1
71+
;;
72+
esac
73+
74+
enforced_options="0x00030100110100000000000000000000000000013880"
75+
optional_dvns=""
76+
use_default_dvns=false
77+
use_default_confirmations=false
78+
use_default_optional_dvns=false
79+
send_confirmations=10
80+
receive_confirmations=10
81+
max_message_length=10000
82+
83+
source ./encode_configs.sh
84+
read -r executor_config send_config receive_config <<<"$(encode_lz_configs \
85+
$use_default_confirmations $send_confirmations $receive_confirmations \
86+
$use_default_dvns $use_default_optional_dvns \
87+
"$required_dvns" "$optional_dvns" \
88+
$executor $max_message_length $msg_lib)"
89+
90+
echo "Executor Config: $executor_config"
91+
echo "Send Config: $send_config"
92+
echo "Receive Config: $receive_config"
93+
94+
echo yes | $cli $command \
95+
--function-id "$module_address::oapp_core::set_delegate" \
96+
--args address:$deployer \
97+
--profile $profile
98+
99+
echo yes | $cli $command \
100+
--function-id "$module_address::oapp_core::set_enforced_options" \
101+
--args u32:$eid u16:1 hex:$enforced_options \
102+
--profile $profile
103+
104+
echo yes | $cli $command \
105+
--function-id "$module_address::oapp_core::set_enforced_options" \
106+
--args u32:$eid u16:2 hex:$enforced_options \
107+
--profile $profile
108+
109+
echo yes | $cli $command \
110+
--function-id "$module_address::oapp_core::set_send_library" \
111+
--args u32:$eid address:$msg_lib \
112+
--profile $profile
113+
114+
echo yes | $cli $command \
115+
--function-id "$module_address::oapp_core::set_receive_library" \
116+
--args u32:$eid address:$msg_lib u64:0 \
117+
--profile $profile
118+
119+
echo yes | $cli $command \
120+
--function-id "$module_address::oapp_core::set_config" \
121+
--args address:$msg_lib u32:$eid u32:1 hex:$executor_config \
122+
--profile $profile
123+
124+
echo yes | $cli $command \
125+
--function-id "$module_address::oapp_core::set_config" \
126+
--args address:$msg_lib u32:$eid u32:2 hex:$send_config \
127+
--profile $profile
128+
129+
echo yes | $cli $command \
130+
--function-id "$module_address::oapp_core::set_config" \
131+
--args address:$msg_lib u32:$eid u32:3 hex:$receive_config \
132+
--profile $profile
133+
134+
echo yes | $cli $command \
135+
--function-id "$module_address::oapp_core::set_peer" \
136+
--args u32:$eid hex:$peer \
137+
--profile $profile

examples/deploy.sh

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# #!/bin/sh
2+
3+
# # Exit on any error
4+
set -e
5+
# Exit on undefined variables
6+
set -u
7+
# Exit on pipe failures
8+
set -o pipefail
9+
cli="aptos"
10+
environment="mainnet"
11+
profile="gui"
12+
token_name="GUI"
13+
symbol="GUI"
14+
icon_uri="https://www.guiinu.com/favicon.svg"
15+
project_uri="https://www.guiinu.com/"
16+
module_name="oft_adapter_fa"
17+
target_eid=30325
18+
target_fa="0x0009da434d9b873b5159e8eeed70202ad22dc075867a7793234fbc981b63e119"
19+
shared_decimals=6
20+
peer="0xc78639b024a4c159d13f8c8a80e4fed0bd5aa62a1924c905239e3b6bcb7aa81f"
21+
dir=""
22+
if [ "$module_name" == "oft_fa" ] ; then
23+
dir="oft-aptos-move"
24+
elif [ "$module_name" == "oft_adapter_fa" ] ; then
25+
dir="oft-adapter-aptos-move"
26+
fi
27+
28+
source ./set_move_env.sh
29+
set_move_env "$cli" "$environment" "$dir"
30+
31+
echo "Initializing $cli..."
32+
if [ $profile == "testnet" ]; then
33+
echo "" | $cli init --assume-yes --network $environment --profile $profile
34+
fi
35+
36+
echo "Extracting deployer address from $profile account..."
37+
deployer=$(awk '/^ '$profile':/{flag=1} flag && /^ account:/{print $2; exit}' .$cli/config.yaml)
38+
# Validate deployer address is not empty
39+
if [ -z "$deployer" ]; then
40+
echo "Error: Failed to extract deployer address from .$cli/config.yaml"
41+
exit 1
42+
fi
43+
44+
45+
# config the final admin (can be the same as deployer or different)
46+
final_admin=$deployer
47+
48+
echo "Publishing module..."
49+
# publish_result=$($cli move deploy-object --address-name oft --named-addresses oft_admin=$deployer --profile $profile --assume-yes --package-dir $dir 2>&1)
50+
# echo "Publish result: $publish_result"
51+
# object_addr=$(echo "$publish_result" | grep -oE 'object address (0x[0-9a-fA-F]+)' | grep -oE '0x[0-9a-fA-F]+' | head -n 1 || true)
52+
object_addr="0xc78639b024a4c159d13f8c8a80e4fed0bd5aa62a1924c905239e3b6bcb7aa81f"
53+
54+
if [ -z "$object_addr" ]; then
55+
echo "Error: Failed to extract object address from publish result"
56+
echo "Publish output:"
57+
# echo "$publish_result"
58+
exit 1
59+
fi
60+
61+
echo "Deployer address: $deployer"
62+
echo "Initializing $symbol..."
63+
64+
to_u8_vec() {
65+
printf "%s" "$1" \
66+
| od -An -t u1 \
67+
| tr -s '[:space:]' '\n' \
68+
| grep -E '^[0-9]+$' \
69+
| awk 'NR==1{printf "%s",$1; next} {printf ", %s",$1}'
70+
}
71+
72+
token_name_u8=$(to_u8_vec "$token_name")
73+
symbol_u8=$(to_u8_vec "$symbol")
74+
icon_uri_u8=$(to_u8_vec "$icon_uri")
75+
project_uri_u8=$(to_u8_vec "$project_uri")
76+
77+
# if [ "$module_name" == "oft_fa" ] ; then
78+
# echo yes | $cli move run --function-id ${object_addr}::${module_name}::initialize \
79+
# --args "u8:[$token_name_u8]" \
80+
# "u8:[$symbol_u8]" \
81+
# "u8:[$icon_uri_u8]" \
82+
# "u8:[$project_uri_u8]" \
83+
# u8:$shared_decimals \
84+
# u8:$shared_decimals \
85+
# --profile $profile
86+
87+
# elif [ "$module_name" == "oft_adapter_fa" ] ; then
88+
# echo yes | $cli move run --function-id ${object_addr}::${module_name}::initialize \
89+
# --args --args address:$target_fa \
90+
# u8:$shared_decimals \
91+
# --profile $profile
92+
# fi
93+
94+
95+
if [ "$final_admin" != "$deployer" ]; then
96+
movement move run --assume-yes --function-id 0x1::object::transfer_call \
97+
--args address:${object_addr} \
98+
address:${final_admin} \
99+
--profile $profile
100+
fi
101+
102+
if [ "$peer" ]; then
103+
echo "Configuring $symbol with peer $peer and target EID $target_eid client $cli on network $environment..."
104+
bash config.sh "$object_addr" "$final_admin" "$target_eid" "$peer" "$cli" "$environment" "$profile"
105+
fi

0 commit comments

Comments
 (0)