-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathupgrade
executable file
·131 lines (102 loc) · 4.82 KB
/
upgrade
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
#set -e
#set -o pipefail
<< LICENSE
The MIT License (MIT)
Copyright 2017 - 2018, Autonomous Software.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
LICENSE
usage()
{
cat <<- _EOM_
deploy: compile and push TokenPorter and Validator contracts to a local parity instance by default,
By default, deploy deploys to a local clean ETH "dev chain" instance of parity.
If -i or --interactive is offerred in local deployment then it will do deploy and launch in one step.
If --test is offered, deploy will connect to test network and
deploy there. Note you will need testnet ETH. Contact your SA for help.
If --live is offered, deploy will connect to the default parity instance.
If --chain etc is offered, deploy will deploy to ETC. Note that deploy will
consider ETC to be the "Non OG" chain, and initialize a destination metronome.
usage: deploy [--supply supply of Metronome] [-P | --pass <password> ]
[--live | --test] [-O | --owner <owner eth address> ]
[-i | --interactive] [--chain eth|etc ] | [-h]
[-v | --validators <list of three validators address>]
[-p <parity host>]
_EOM_
}
source ./basescript
LOCAL_ETH=$ETHER_ADDR
if [[ $LOCAL = 0 ]] && [[ $VALIDATORS = "[]" ]];
then
echo " Live and Test net deploy requires validators address. Use -v or --validators."
exit 1
fi
echo "About to Deploy TokenPorter and Validator contracts to $DEST.."
read -p "Press enter to continue"
echo "Cleaning up old deploy stuff..."
rm $CHAIN_DIR/metronome-v2.js 2>/dev/null
#set account for devnet
if [[ $DEVNET = 1 ]]; then
LOCAL_ETH=0x004ec07d2329997267Ec62b4166639513386F32E
fi
echo "Authorizing deployer account ..."
curl -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"personal_unlockAccount","params":["'$LOCAL_ETH'", "'$PASS'","0x3000"],"id":1}' $PARITY_URL >/dev/null
if [[ $LOCAL = 1 ]] && [[ $OWNER_ADDRESS = 0x0 ]]
then
sleep 5
echo "Creating new account for the owner"
PASS=''
response=$(curl -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"personal_newAccount","params":["'$PASS'"],"id":1}' $PARITY_URL)
OWNER_ADDRESS=`echo "$response" | jq .result`
OWNER_ADDRESS=${OWNER_ADDRESS//\"/}
echo "Metronome owner for dev chain $OWNER_ADDRESS"
curl -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_sendTransaction","params":[{"from":"'$LOCAL_ETH'", "to":"'$OWNER_ADDRESS'", "value":"0x1BC16D674EC80000"}],"id":1}' $PARITY_URL >/dev/null
curl -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"personal_unlockAccount","params":["'$OWNER_ADDRESS'", "'$PASS'","0x3000"],"id":1}' $PARITY_URL >/dev/null
fi
sleep 5
echo "Deploying on $DEST.."
TMP_DIR=$CHAIN_DIR/tmp
mkdir $TMP_DIR
echo "" > $CHAIN_DIR/metronome-v2.js
sleep 5
echo -e "contracts/monolithic.sol:TokenPorter\n$TMP_DIR/TokenPorter.js" | SETH_URL=$PARITY_URL ETHER_ADDR=$LOCAL_ETH $SOLDEPLOY contracts/monolithic.sol >/dev/null
sleep 5
echo -e "contracts/monolithic.sol:Validator\n$TMP_DIR/Validator.js" | SETH_URL=$PARITY_URL ETHER_ADDR=$LOCAL_ETH $SOLDEPLOY contracts/monolithic.sol >/dev/null
sleep 5
cat $TMP_DIR/TokenPorter.js $TMP_DIR/Validator.js > $CHAIN_DIR/metronome-v2.js
rm -r $TMP_DIR
if [[ $LOCAL = 1 ]] && [[ $VALIDATORS = "[]" ]]; then
VALIDATORS="['$OWNER_ADDRESS', '$LOCAL_ETH', '$OWNER_ADDRESS']"
echo "VALIDATORS $VALIDATORS"
fi
cat <<EOF > $CHAIN_DIR/const-v2.js
// File generated by deploy -- edits will get overwritten!
var ONE = 1
var ETHER_ADDR = '$LOCAL_ETH'
var OWNER_ADDRESS = '$OWNER_ADDRESS'
var OWNER_PASS = '$PASS'
var VALIDATORS = $VALIDATORS
EOF
PRELOAD="--preload $CHAIN_DIR/metronome.js,$CHAIN_DIR/metronome-v2.js,$CHAIN_DIR/const-v2.js,$CHAIN_DIR/updateContracts.js"
if [[ $INTERACTIVE = 1 ]]
then
geth attach $PARITY_URL $PRELOAD
else
geth --exec 'eth.blockNumber' attach $PARITY_URL $PRELOAD
fi
exit 0