1- #! /bin/sh
1+ #! /usr/ bin/env sh
22
3- # Copyright 2020 - See NOTICE file for copyright holders.
3+ # Copyright 2021 - See NOTICE file for copyright holders.
44#
55# Licensed under the Apache License, Version 2.0 (the "License");
66# you may not use this file except in compliance with the License.
1616
1717set -e
1818
19- ABIGEN=abigen
20- SOLC=solc
19+ # Define ABIGEN and SOLC default values.
20+ ABIGEN=" ${ABIGEN-abigen} "
21+ SOLC=" ${SOLC-solc} "
2122
22- # Download solc.
23- if [ ` uname` == " Linux" ]; then
24- # GNU Linux
25- wget -nc " https://github.com/ethereum/solidity/releases/download/v0.7.4/solc-static-linux"
26- chmod +x solc-static-linux
27- SOLC=./solc-static-linux
28-
29- elif [ ` uname` == " Darwin" ]; then
30- # Mac OSX
31- curl -L " https://github.com/ethereum/solidity/releases/download/v0.7.4/solc-macos" -o solc-macos
32- chmod +x solc-macos
33- SOLC=./solc-macos
23+ if ! $ABIGEN --version
24+ then
25+ echo " Please install abigen v1.9.25+ or the environment varables AGIBEN."
26+ exit 1
27+ fi
3428
35- else
36- # Unsupported
37- echo " Unsupported operating system: ` uname ` . Exiting ."
29+ if ! $SOLC --version
30+ then
31+ echo " Please install abigen v0.7.4 or the environment varables SOLC ."
3832 exit 1
3933fi
4034
41- echo " Exec 'git submodule update --init --recursive' once after cloning."
42- echo " Ensure that the newest version of abigen is installed."
35+ echo " Please ensure that the repository was cloned with submodules: 'git submodule update --init --recursive'."
4336
4437# Generates optimized golang bindings and runtime binaries for sol contracts.
4538# $1 solidity file path, relative to ../contracts/contracts/.
4639# $2 golang package name.
47- function generate() {
40+ generate () {
4841 FILE=$1 ; PKG=$2 ; CONTRACT=$FILE
49- echo " generate package $PKG "
42+ echo " Generating $PKG bindings... "
5043
51- mkdir -p $PKG
44+ rm -r $PKG
45+ mkdir $PKG
5246
53- # generate abi
47+ # Generate bindings
5448 $ABIGEN --pkg $PKG --sol ../contracts/contracts/$FILE .sol --out $PKG /$FILE .go --solc $SOLC
5549
56- # generate go bindings
57- $SOLC --bin-runtime --optimize --allow-paths * , ../contracts/contracts/$FILE .sol --overwrite -o $PKG /
58-
59- # generate binary runtime
50+ # Generate binary runtime
51+ $SOLC --bin-runtime --optimize --allow-paths ../contracts/vendor, ../contracts/contracts/$FILE .sol -o $PKG /
6052 BIN_RUNTIME=` cat ${PKG} /${CONTRACT} .bin-runtime`
6153 OUT_FILE=" $PKG /${CONTRACT} BinRuntime.go"
6254 echo " package $PKG // import \" perun.network/go-perun/backend/ethereum/bindings/$PKG \" " > $OUT_FILE
@@ -79,4 +71,4 @@ generate "PerunToken" "peruntoken"
7971# Applications
8072generate " TrivialApp" " trivialapp"
8173
82- echo " Generated bindings "
74+ echo " Bindings generated successfully. "
0 commit comments