aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-03-26 17:43:09 +0800
committerPéter Szilágyi <peterke@gmail.com>2016-03-26 17:43:09 +0800
commitb813e4d411989a5a1f3606bd69fb888062dbed88 (patch)
treec09a89e94e7ef80e523ad66da85a8471a3c3ef50 /cmd
parent798e4fb4edb1a4a9be24815528b5296df8f5fcb1 (diff)
downloaddexon-b813e4d411989a5a1f3606bd69fb888062dbed88.tar
dexon-b813e4d411989a5a1f3606bd69fb888062dbed88.tar.gz
dexon-b813e4d411989a5a1f3606bd69fb888062dbed88.tar.bz2
dexon-b813e4d411989a5a1f3606bd69fb888062dbed88.tar.lz
dexon-b813e4d411989a5a1f3606bd69fb888062dbed88.tar.xz
dexon-b813e4d411989a5a1f3606bd69fb888062dbed88.tar.zst
dexon-b813e4d411989a5a1f3606bd69fb888062dbed88.zip
accounts/abi/bind, cmd/abigen: dedup structs, exclude patterns
Diffstat (limited to 'cmd')
-rw-r--r--cmd/abigen/main.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/cmd/abigen/main.go b/cmd/abigen/main.go
index 329e9b109..88d27e443 100644
--- a/cmd/abigen/main.go
+++ b/cmd/abigen/main.go
@@ -22,6 +22,7 @@ import (
"fmt"
"io/ioutil"
"os"
+ "strings"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common/compiler"
@@ -34,6 +35,7 @@ var (
solFlag = flag.String("sol", "", "Path to the Ethereum contract Solidity source to build and bind")
solcFlag = flag.String("solc", "solc", "Solidity compiler to use if source builds are requested")
+ excFlag = flag.String("exc", "", "Comma separated types to exclude from binding")
pkgFlag = flag.String("pkg", "", "Go package name to generate the binding into")
outFlag = flag.String("out", "", "Output file for the generated binding (default = stdout)")
@@ -61,6 +63,12 @@ func main() {
types []string
)
if *solFlag != "" {
+ // Generate the list of types to exclude from binding
+ exclude := make(map[string]bool)
+ for _, kind := range strings.Split(*excFlag, ",") {
+ exclude[strings.ToLower(kind)] = true
+ }
+ // Build the Solidity source into bindable components
solc, err := compiler.New(*solcFlag)
if err != nil {
fmt.Printf("Failed to locate Solidity compiler: %v\n", err)
@@ -76,7 +84,11 @@ func main() {
fmt.Printf("Failed to build Solidity contract: %v\n", err)
os.Exit(-1)
}
+ // Gather all non-excluded contract for binding
for name, contract := range contracts {
+ if exclude[strings.ToLower(name)] {
+ continue
+ }
abi, _ := json.Marshal(contract.Info.AbiDefinition) // Flatten the compiler parse
abis = append(abis, string(abi))
bins = append(bins, contract.Code)