aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/abigen
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/abigen')
-rw-r--r--cmd/abigen/main.go32
1 files changed, 26 insertions, 6 deletions
diff --git a/cmd/abigen/main.go b/cmd/abigen/main.go
index 3a1ae6f4c..3ac37ba7a 100644
--- a/cmd/abigen/main.go
+++ b/cmd/abigen/main.go
@@ -29,7 +29,7 @@ import (
)
var (
- abiFlag = flag.String("abi", "", "Path to the Ethereum contract ABI json to bind")
+ abiFlag = flag.String("abi", "", "Path to the Ethereum contract ABI json to bind, - for STDIN")
binFlag = flag.String("bin", "", "Path to the Ethereum contract bytecode (generate deploy method)")
typFlag = flag.String("type", "", "Struct name for the binding (default = package name)")
@@ -75,16 +75,27 @@ func main() {
bins []string
types []string
)
- if *solFlag != "" {
+ if *solFlag != "" || *abiFlag == "-" {
// 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
}
- contracts, err := compiler.CompileSolidity(*solcFlag, *solFlag)
- if err != nil {
- fmt.Printf("Failed to build Solidity contract: %v\n", err)
- os.Exit(-1)
+
+ var contracts map[string]*compiler.Contract
+ var err error
+ if *solFlag != "" {
+ contracts, err = compiler.CompileSolidity(*solcFlag, *solFlag)
+ if err != nil {
+ fmt.Printf("Failed to build Solidity contract: %v\n", err)
+ os.Exit(-1)
+ }
+ } else {
+ contracts, err = contractsFromStdin()
+ if err != nil {
+ fmt.Printf("Failed to read input ABIs from STDIN: %v\n", err)
+ os.Exit(-1)
+ }
}
// Gather all non-excluded contract for binding
for name, contract := range contracts {
@@ -138,3 +149,12 @@ func main() {
os.Exit(-1)
}
}
+
+func contractsFromStdin() (map[string]*compiler.Contract, error) {
+ bytes, err := ioutil.ReadAll(os.Stdin)
+ if err != nil {
+ return nil, err
+ }
+
+ return compiler.ParseCombinedJSON(bytes, "", "", "", "")
+}