-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflow.sh
55 lines (41 loc) · 1.99 KB
/
flow.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
# Build the wasm binary
echo "cd to contract directory"
cd ./contract || { echo "Failed to cd to contract directory"; exit 1; }
echo "Building wasm binary..."
cargo build --target wasm32-unknown-unknown --release
# Create testnet account
echo "Creating testnet account..."
account_info=$(cargo-near near create-dev-account use-random-account-id autogenerate-new-keypair save-to-legacy-keychain network-config testnet create 2>&1)
# Check if account_info is retrieved successfully
if [ -z "$account_info" ]; then
echo "Failed to create testnet account"
exit 1
fi
# Extract account name using awk
account_name=$(echo "$account_info" | awk '/-- create account:/ {print $4}')
# Check if account_name is extracted successfully
if [ -z "$account_name" ]; then
echo "Failed to extract account name"
exit 1
fi
echo "Account created: $account_name"
echo "Adding NEAR tokens to your account..."
echo "Current smart-contract use a lot of space, so we will need to faucet additonal tokens to it"
echo "Go to https://near-faucet.io/ and bump $account_name balance..."
read -p "After you are done with this press ENTER..."
echo "Let's wait a bit..."
sleep 20
# Deploy contract to testnet
echo "Deploying contract to testnet..."
near contract deploy "$account_name" use-file ./target/wasm32-unknown-unknown/release/btc_light_client_contract.wasm without-init-call network-config testnet sign-with-keychain send
# Setup relayer service
echo "cd to relayer directory..."
cd ../relayer || exit
echo "Setting up relayer service..."
key_file_path=$(echo "$account_info" | grep -oP '(?<=Key file path: ).*')
private_key=$(cat "$key_file_path" | jq -r '.private_key')
echo "Private key: $private_key"
echo "You can inspect the results of the script execution by inspecting account info at https://testnet.nearblocks.io/address/$account_name"
read -p "Press Enter to continue and remove testnet account"
near account delete-account "$account_name" beneficiary devnull.testnet network-config testnet sign-with-keychain send