forked from razor-network/oracle-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-contracts.sh
41 lines (34 loc) · 1.04 KB
/
generate-contracts.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
#!/bin/bash
touch core/contracts.go
echo "package core" > core/contracts.go
printf "\n" >> core/contracts.go
network=$1
addresses_path=""
if [[ "$network" == "mainnet" ]]; then
addresses_path="addresses/mainnet.json"
elif [[ "$network" == "testnet" ]]; then
addresses_path="addresses/testnet.json"
else
echo "Invalid network environment specified. Please use 'mainnet' or 'testnet'."
exit 1
fi
echo "Copying $addresses_path to core/contracts.go"
generate_contract_address() {
jsonFileKey=$(echo $1 | awk '{print $1}')
jsonFileKey="."$jsonFileKey
goContractKey=$(echo $1 | awk '{print $2}')
varDeclaration="var $goContractKey ="
contractAddress=$(cat $addresses_path | jq $jsonFileKey)
echo "$varDeclaration $contractAddress" >> core/contracts.go
}
contract_addresses_list=(
"StakeManager StakeManagerAddress"
"RAZOR RAZORAddress"
"CollectionManager CollectionManagerAddress"
"VoteManager VoteManagerAddress"
"BlockManager BlockManagerAddress"
)
for c in "${contract_addresses_list[@]}"
do
generate_contract_address "$c"
done