-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerator
executable file
·60 lines (47 loc) · 1.53 KB
/
generator
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
#!/bin/bash
# Colors
green='\033[0;32m'
red='\033[0;31m'
nocolor='\033[0m'
set -e
SOURCE_ABI_PATH=$PWD/contracts/artifacts/contracts/state/State.sol
# Check if `contracts` repository exists
if [ ! -d "contracts" ]; then
echo -e "${red}Contracts directory does not exist.${nocolor}"
exit 1
fi
# Check if jq exists
which jq 1>/dev/null || exit 1
pushd $PWD/contracts > /dev/null
# Print warning if current branch is not up to date with the remote branch. Only for master branch.
current_branch=$(git branch --show-current)
if [ "$current_branch" == "master" ]; then
git fetch
if git status -uno | grep "Your branch is up to date" > /dev/null ; then
echo -e \
"${green}Your branch '$current_branch' is up to date with the remote branch.${nocolor}"
else
echo -e \
"${red}Your branch '$current_branch' is not up to date with the remote branch.\n\
Please sync your branch with the remote branch.${nocolor}"
fi
fi
npm i
npm run compile
popd > /dev/null
touch $PWD/abi.json $PWD/bytecode $PWD/state/go/abi/abi.go
cat $SOURCE_ABI_PATH/State.json | jq .abi > $PWD/abi.json
cat $SOURCE_ABI_PATH/State.json | jq .bytecode > $PWD/bytecode
docker run \
-v $PWD/abi.json:/abi.json:ro \
-v $PWD/bytecode:/bytecode:ro \
-v $PWD/state/go/abi/abi.go:/state.go \
--rm --name ethereum-node \
ethereum/client-go:alltools-v1.11.5 \
abigen --abi=/abi.json --pkg=abi \
--out=state.go --type="State"
# Sync deps
pushd $PWD/state/go/abi > /dev/null
go mod tidy
popd > /dev/null
#TODO(illia-korotia): fill free to add new generators for js, flatter and etc.