Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 137 additions & 0 deletions examples/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
module_address="${1:-}"
admin="${2:-}"
eid="${3:-40101}"
peer="${4:-}"
cli=${5:-"movement"}
network=${6:-"mainnet"}
profile=${7:-"default"}

echo "Using CLI: $cli"
echo "Using Network: $network"
echo "Module Address: $module_address"
echo "Admin: $admin"
echo "EID: $eid"
echo "Peer: $peer"

multisig=false
multisig_address=""

# ── Set these per deployment ─────────────────────────────────────────────────

# ─────────────────────────────────────────────────────────────────────────────

if $multisig; then
if [ -z "$multisig_address" ]; then
echo "Error: multisig_address must be set if multisig is true"
exit 1
fi
command="multisig create_transaction --multisig-address $multisig_address"
else
command="move run"
fi

deployer=$(awk '/^ '$profile':/{flag=1} flag && /^ account:/{print $2; exit}' .$cli/config.yaml)
[[ "$deployer" != 0x* ]] && deployer="0x${deployer}"
if [ -z "$module_address" ]; then
module_address="$deployer"
fi
[[ "$module_address" != 0x* ]] && module_address="0x${module_address}"
[[ -n "$multisig_address" && "$multisig_address" != 0x* ]] && multisig_address="0x${multisig_address}"
[[ -n "$peer" && "$peer" != 0x* ]] && peer="0x${peer}"
[[ -n "$admin" && "$admin" != 0x* ]] && admin="0x${admin}"

case "${cli}:${network}" in
movement:testnet)
msg_lib=0xcc1c03aed42e2841211865758b5efe93c0dde2cb7a2a5dc6cf25a4e33ad23690
executor=0x93353700091200ef9fdc536ce6a86182cc7e62da25f94356be9421c6310b9585
endpoint=0x7f03103b83c51c8b09be1751a797a65ac6e755f72947ecdecffc203d32d816c6
required_dvns="0x5b983a8faf6977f0bc76ed2a96fda5abdacaeb829841c2d4da176acd78d19d97,0x5e621608b81aa5243d193bf69438c9402712303490d5d974f06f63c154fd977b,0x756f8ab056688d22687740f4a9aeec3b361170b28d08b719e28c4d38eed1043e"
;;
movement:mainnet)
msg_lib=0xc33752e0220faf79e45385dd73fb28d681dcd9f1569a1480725507c1f3c3aba9
executor=0x15a5bbf1eb7998a22c9f23810d424abe40bd59ddd8e6ab7e59529853ebed41c4
endpoint=0xe60045e20fc2c99e869c1c34a65b9291c020cd12a0d37a00a53ac1348af4f43c
required_dvns="0x2b696b3ee859b7eb624e1fd5de49f4d3806f49862f1177d6827fd1beffde9179,0xdf8f0a53b20f1656f998504b81259698d126523a31bdbbae45ba1e8a3078d8da,0xbcfb6d3ce5e99275e5fa09b3f53eaaea32365c776d023c51a680c4c420d88b91"
;;
aptos:testnet)
msg_lib=0xcc1c03aed42e2841211865758b5efe93c0dde2cb7a2a5dc6cf25a4e33ad23690
executor=0x93353700091200ef9fdc536ce6a86182cc7e62da25f94356be9421c6310b9585
endpoint=0x7f03103b83c51c8b09be1751a797a65ac6e755f72947ecdecffc203d32d816c6
required_dvns="0x5e621608b81aa5243d193bf69438c9402712303490d5d974f06f63c154fd977b,0x756f8ab056688d22687740f4a9aeec3b361170b28d08b719e28c4d38eed1043e,0x5b983a8faf6977f0bc76ed2a96fda5abdacaeb829841c2d4da176acd78d19d97"
;;
aptos:mainnet)
msg_lib=0xc33752e0220faf79e45385dd73fb28d681dcd9f1569a1480725507c1f3c3aba9
executor=0x15a5bbf1eb7998a22c9f23810d424abe40bd59ddd8e6ab7e59529853ebed41c4
endpoint=0xe60045e20fc2c99e869c1c34a65b9291c020cd12a0d37a00a53ac1348af4f43c
required_dvns="0x9880ed7ade7e7f8f8eb070ce72c51b231921e29e65b3d51fa3810814bba32c00,0xf3f0a412626edba5ddd3613d91109b241893873ac5479ade231cf0b3130572b5,0xcb2ab3c2fb799c6578b9950f9db7ff555a2d4967ef15437230346f56599801ae"
;;
*)
echo "Error: unknown cli/network combination '${cli}:${network}'. Use cli=movement|aptos and network=testnet|mainnet."
exit 1
;;
esac

enforced_options="0x00030100110100000000000000000000000000013880"
optional_dvns=""
use_default_dvns=false
use_default_confirmations=false
use_default_optional_dvns=false
send_confirmations=10
receive_confirmations=10
max_message_length=10000

source ./encode_configs.sh
read -r executor_config send_config receive_config <<<"$(encode_lz_configs \
$use_default_confirmations $send_confirmations $receive_confirmations \
$use_default_dvns $use_default_optional_dvns \
"$required_dvns" "$optional_dvns" \
$executor $max_message_length $msg_lib)"

echo "Executor Config: $executor_config"
echo "Send Config: $send_config"
echo "Receive Config: $receive_config"

echo yes | $cli $command \
--function-id "$module_address::oapp_core::set_delegate" \
--args address:$deployer \
--profile $profile

echo yes | $cli $command \
--function-id "$module_address::oapp_core::set_enforced_options" \
--args u32:$eid u16:1 hex:$enforced_options \
--profile $profile

echo yes | $cli $command \
--function-id "$module_address::oapp_core::set_enforced_options" \
--args u32:$eid u16:2 hex:$enforced_options \
--profile $profile

echo yes | $cli $command \
--function-id "$module_address::oapp_core::set_send_library" \
--args u32:$eid address:$msg_lib \
--profile $profile

echo yes | $cli $command \
--function-id "$module_address::oapp_core::set_receive_library" \
--args u32:$eid address:$msg_lib u64:0 \
--profile $profile

echo yes | $cli $command \
--function-id "$module_address::oapp_core::set_config" \
--args address:$msg_lib u32:$eid u32:1 hex:$executor_config \
--profile $profile

echo yes | $cli $command \
--function-id "$module_address::oapp_core::set_config" \
--args address:$msg_lib u32:$eid u32:2 hex:$send_config \
--profile $profile

echo yes | $cli $command \
--function-id "$module_address::oapp_core::set_config" \
--args address:$msg_lib u32:$eid u32:3 hex:$receive_config \
--profile $profile

echo yes | $cli $command \
--function-id "$module_address::oapp_core::set_peer" \
--args u32:$eid hex:$peer \
--profile $profile
105 changes: 105 additions & 0 deletions examples/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# #!/bin/sh

# # Exit on any error
set -e
# Exit on undefined variables
set -u
# Exit on pipe failures
set -o pipefail
cli="aptos"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be movement? This script is using a mix of movement and aptos

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use whatever, it depends on what you want. I used this to deploy GUI adapter on aptos, that's why it's currently aptos, but it's up to the user to use the correct cli.

environment="mainnet"
profile="gui"
token_name="GUI"
symbol="GUI"
icon_uri="https://www.guiinu.com/favicon.svg"
project_uri="https://www.guiinu.com/"
module_name="oft_adapter_fa"
target_eid=30325
target_fa="0x0009da434d9b873b5159e8eeed70202ad22dc075867a7793234fbc981b63e119"
shared_decimals=6
peer="0xc78639b024a4c159d13f8c8a80e4fed0bd5aa62a1924c905239e3b6bcb7aa81f"
dir=""
if [ "$module_name" == "oft_fa" ] ; then
dir="oft-aptos-move"
elif [ "$module_name" == "oft_adapter_fa" ] ; then
dir="oft-adapter-aptos-move"
fi

source ./set_move_env.sh
set_move_env "$cli" "$environment" "$dir"

echo "Initializing $cli..."
if [ $profile == "testnet" ]; then
echo "" | $cli init --assume-yes --network $environment --profile $profile
fi

echo "Extracting deployer address from $profile account..."
deployer=$(awk '/^ '$profile':/{flag=1} flag && /^ account:/{print $2; exit}' .$cli/config.yaml)
# Validate deployer address is not empty
if [ -z "$deployer" ]; then
echo "Error: Failed to extract deployer address from .$cli/config.yaml"
exit 1
fi


# config the final admin (can be the same as deployer or different)
final_admin=$deployer

echo "Publishing module..."
# publish_result=$($cli move deploy-object --address-name oft --named-addresses oft_admin=$deployer --profile $profile --assume-yes --package-dir $dir 2>&1)
# echo "Publish result: $publish_result"
# 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)
object_addr="0xc78639b024a4c159d13f8c8a80e4fed0bd5aa62a1924c905239e3b6bcb7aa81f"

if [ -z "$object_addr" ]; then
echo "Error: Failed to extract object address from publish result"
echo "Publish output:"
# echo "$publish_result"
exit 1
fi

echo "Deployer address: $deployer"
echo "Initializing $symbol..."

to_u8_vec() {
printf "%s" "$1" \
| od -An -t u1 \
| tr -s '[:space:]' '\n' \
| grep -E '^[0-9]+$' \
| awk 'NR==1{printf "%s",$1; next} {printf ", %s",$1}'
}

token_name_u8=$(to_u8_vec "$token_name")
symbol_u8=$(to_u8_vec "$symbol")
icon_uri_u8=$(to_u8_vec "$icon_uri")
project_uri_u8=$(to_u8_vec "$project_uri")

# if [ "$module_name" == "oft_fa" ] ; then
# echo yes | $cli move run --function-id ${object_addr}::${module_name}::initialize \
# --args "u8:[$token_name_u8]" \
# "u8:[$symbol_u8]" \
# "u8:[$icon_uri_u8]" \
# "u8:[$project_uri_u8]" \
# u8:$shared_decimals \
# u8:$shared_decimals \
# --profile $profile

# elif [ "$module_name" == "oft_adapter_fa" ] ; then
# echo yes | $cli move run --function-id ${object_addr}::${module_name}::initialize \
# --args --args address:$target_fa \
# u8:$shared_decimals \
# --profile $profile
# fi


if [ "$final_admin" != "$deployer" ]; then
movement move run --assume-yes --function-id 0x1::object::transfer_call \
--args address:${object_addr} \
address:${final_admin} \
--profile $profile
fi

if [ "$peer" ]; then
echo "Configuring $symbol with peer $peer and target EID $target_eid client $cli on network $environment..."
bash config.sh "$object_addr" "$final_admin" "$target_eid" "$peer" "$cli" "$environment" "$profile"
fi
Loading
Loading