forked from InjectiveLabs/0x-exchange-omnibus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
abigen.sh
executable file
·61 lines (51 loc) · 2.27 KB
/
abigen.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
60
61
#!/bin/sh
truffle build
# dev_utils.go generation
cat build/contracts/DevUtils.json | jq .abi > DevUtils.abi
abigen --abi DevUtils.abi --pkg XXX > dev_utils.go
rm -f DevUtils.abi
perl -i.tmp -pe 's/package XXX/package wrappers/' dev_utils.go
perl -i.tmp -pe 's/XXXDevUtils/DevUtils/g' dev_utils.go
perl -i.tmp -pe 's/_XXX/f/g' dev_utils.go
perl -i.tmp -pe 's/XXX/DevUtils/g' dev_utils.go
perl -i.tmp -pe 'BEGIN {undef $/;} s/\/\/ LibOrderOrder[^\}]*\}//smg' dev_utils.go
perl -i.tmp -pe 's/LibOrderOrderInfo/OrderInfo/g' dev_utils.go
perl -i.tmp -pe 's/LibZeroExTransactionZeroExTransaction/ZeroExTransaction/g' dev_utils.go
perl -i.tmp -pe 's/LibOrderOrder/Order/g' dev_utils.go
rm -f dev_utils.go.tmp
gofmt -w dev_utils.go
# exchange.go generation
cat build/contracts/Exchange.json | jq .abi > Exchange.abi
abigen --abi Exchange.abi --pkg XXX > exchange.go
rm -f Exchange.abi
perl -i.tmp -pe 's/package XXX/package wrappers/' exchange.go
perl -i.tmp -pe 's/XXXExchange/Exchange/g' exchange.go
perl -i.tmp -pe 's/_XXX/f/g' exchange.go
perl -i.tmp -pe 's/XXX/Exchange/g' exchange.go
perl -i.tmp -pe 'BEGIN {undef $/;} s/\/\/ LibOrderOrder[^\}]*\}//smg' exchange.go
perl -i.tmp -pe 's/LibOrderOrderInfo/OrderInfo/g' exchange.go
perl -i.tmp -pe 's/LibZeroExTransactionZeroExTransaction/ZeroExTransaction/g' exchange.go
perl -i.tmp -pe 's/LibOrderOrder/Order/g' exchange.go
rm -f exchange.go.tmp
gofmt -w exchange.go
# erc20.go generation
cat build/contracts/ERC20Token.json | jq .abi > ERC20Token.abi
abigen --abi ERC20Token.abi --pkg XXX > erc20.go
rm -f ERC20Token.abi
perl -i.tmp -pe 's/package XXX/package wrappers/' erc20.go
perl -i.tmp -pe 's/XXXERC20/ERC20/g' erc20.go
perl -i.tmp -pe 's/_XXX/f/g' erc20.go
perl -i.tmp -pe 's/XXX/ERC20/g' erc20.go
rm -f erc20.go.tmp
gofmt -w erc20.go
# weth9.go generation
cat build/contracts/WETH9.json | jq .abi > WETH9.abi
abigen --abi WETH9.abi --pkg XXX > weth9.go
rm -f WETH9.abi
perl -i.tmp -pe 's/package XXX/package wrappers/' weth9.go
perl -i.tmp -pe 's/XXXWETH9/WETH9/g' weth9.go
perl -i.tmp -pe 's/_XXX/f/g' weth9.go
perl -i.tmp -pe 's/XXX/WETH9/g' weth9.go
rm -f weth9.go.tmp
gofmt -w weth9.go
echo "All done! Move dev_utils.go, exchange.go, erc20.go, weth9.go into zeroex-go/wrappers/ now.\nmv dev_utils.go exchange.go erc20.go weth9.go ../zeroex-go/wrappers"