-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbobcat-deploy.sh
More file actions
executable file
·73 lines (58 loc) · 1.8 KB
/
Copy pathbobcat-deploy.sh
File metadata and controls
executable file
·73 lines (58 loc) · 1.8 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/sh -e
# Note on the arguments: generally speaking, it's better to use
# environment variables for private information. Environment variables
# are shielded from the process table, which is usually not private, so
# you couldn't use these tools safely on a time shared system (aka, not
# your own). Unfortunately, Foundry doesn't care about this, and
# no-one uses Seth, so we externalise this to you.
endpoint="$1"
private_key="$2"
wasm_file="$3"
usage() {
>&2 echo $(basename $0) "<endpoint> <private key> <wasm file>"
exit 2
}
[ -z "$endpoint" ] && usage
[ -z "$private_key" ] && usage
[ -z "$wasm_file" ] && usage
if ! [ -e "$wasm_file" ]; then
>&2 echo $wasm_file does not exist
exit 1
fi
if [ -z "$BC_CONTRACT" ]; then
compressed="eff00000$(brotli -cq 11 $wasm_file | xxd -p -c0)"
len="$(printf '%08x' $(echo $(echo -n "$compressed" | wc -c) ' / 2' | bc))"
with_preamble="63${len}80600c5f395ff3$compressed"
BC_CONTRACT="$(\
cast send \
--json \
--rpc-url "$endpoint" \
--private-key "$private_key" \
--create "0x$with_preamble" \
| jq -r .contractAddress)"
fi
echo $BC_CONTRACT
arb_wasm=0x0000000000000000000000000000000000000071
random_sender="0x$(dd count=20 bs=1 status=none if=/dev/urandom | xxd -p)"
max_eth=115792089237316195423570985008687907853269984665640564039457584007913129639935
if [ -z "$BC_ACTIVATION" ]; then
export BC_ACTIVATION="$(\
cast call \
--json \
--rpc-url "$endpoint" \
--override-balance "$random_sender:$max_eth" \
--from "$random_sender" \
--value "$max_eth" \
$arb_wasm \
"activateProgram(address)(uint16,uint256)" \
$BC_CONTRACT \
| jq -r '.[1]')"
fi
cast send \
--json \
--rpc-url "$endpoint" \
--private-key "$private_key" \
--value "$BC_ACTIVATION" \
"$arb_wasm" \
"activateProgram(address)" \
"$BC_CONTRACT" >/dev/null