-
Notifications
You must be signed in to change notification settings - Fork 0
/
contract.sh
executable file
·59 lines (49 loc) · 1.64 KB
/
contract.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
56
57
58
59
###############################
# Scripts for Soroban contracts
#
# Andrey Kuprianov, 2024
###############################
SCRIPT_DIR=`dirname ${BASH_SOURCE[0]-$0}`
SCRIPT_DIR=`cd $SCRIPT_DIR && pwd`
. "$SCRIPT_DIR/net.sh"
# Install a WASM file to the ledger without creating a contract instance
# Args: WASM-FILE-NAME
contract-install() {
log-run contract-install "$*" \
"soroban contract install --wasm '$1'"
}
# Build a WASM file from soroban example contracts
# Args: EXAMPLE-CONTRACT-NAME
contract-example-build() {
cur_dir=$(pwd)
log contract-example-build "$*"
cd $SOROBAN_EXAMPLES/$1/ && soroban contract build && cd $cur_dir
}
# Install a WASM file from soroban example contracts
# Args: EXAMPLE-CONTRACT-NAME
contract-example-install() {
log-run contract-example-install "$*" \
"soroban contract install --wasm '$SOROBAN_EXAMPLES/$1/target/wasm32-unknown-unknown/release/soroban_${1}_contract.wasm'"
}
# Deploy a WASM contract
# Args: WASM-FILE-NAME
# Returns: CONTRACT-ID
contract-deploy() {
log-run contract-deploy "$*" \
"soroban contract deploy --wasm '$1'"
}
# Deploy a WASM file from soroban example contracts
# Args: EXAMPLE-CONTRACT-NAME
# Returns: CONTRACT-ID
contract-example-deploy() {
log-run contract-example-deploy "$*" \
"soroban contract deploy --wasm '$SOROBAN_EXAMPLES/$1/target/wasm32-unknown-unknown/release/soroban_${1}_contract.wasm'"
}
# Invoke a contract function
# Args: CONTRACT-ID SOURCE FUNCTION [--ARG-NAME ARG-VALUE]*
# Returns: function output
contract-invoke() {
args="${@:4}"
log-run contract-invoke "$*" \
"soroban contract invoke --source $1 --id $2 -- $3 $args"
}