diff --git a/accounts/abi/bind/bind.go b/accounts/abi/bind/bind.go index 762008d9bf..73e95e02a1 100644 --- a/accounts/abi/bind/bind.go +++ b/accounts/abi/bind/bind.go @@ -41,26 +41,6 @@ const ( LangObjC ) -type BindOpts struct { - Abi string - Bin string - Typ string - - Link string - SolFiles string - RemapPaths string - Compiler string - Exec string - - Lang Lang - Pkg string - OutputFile string -} - -func CompileAndBind(files ...string) - -func BindIndividualFiles(abis string, bytecodes string, pkg string, lang Lang) - // Bind generates a Go wrapper around a contract ABI. This wrapper isn't meant // to be used as is in client code, but rather as an intermediate struct which // enforces compile time type safety and naming convention opposed to having to diff --git a/cmd/abigen/main.go b/cmd/abigen/main.go index fd4ac7f1e3..65294a023c 100644 --- a/cmd/abigen/main.go +++ b/cmd/abigen/main.go @@ -33,11 +33,9 @@ var ( 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)") - linkFlag = flag.String("link", "", "Library flag linker for name to addresses in the code") - solFlag = flag.String("sol", "", "Comma separated path(s) to Solidity source(s) to build and bind") - pathsFlag = flag.String("paths", "", "Comma separated path(s) in the form of solidity remappings (advanced only)") - solcFlag = flag.String("compiler", "solc", "Compiler to use if source builds are requested (default = solc)") - execFlag = flag.String("exec", "", "Execute compiler with user generated command, advanced only, use commas to represent spaces in one string") + 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", "", "Package name to generate the binding into") outFlag = flag.String("out", "", "Output file for the generated binding (default = stdout)") @@ -54,9 +52,6 @@ func main() { } else if (*abiFlag != "" || *binFlag != "" || *typFlag != "") && *solFlag != "" { fmt.Printf("Contract ABI (--abi), bytecode (--bin) and type (--type) flags are mutually exclusive with the Solidity source (--sol) flag\n") os.Exit(-1) - } else if (*binFlag == "" || *solFlag == "") && *linkFlag != "" { - fmt.Printf("No contract bytecode created through (--bin) or (--sol) options to use with (--link) option\n") - os.Exit(-1) } if *pkgFlag == "" { fmt.Printf("No destination package specified (--pkg)\n") @@ -81,18 +76,26 @@ 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 + } solc, err := compiler.InitSolc(*solcFlag) + + solReturn, err := solc.Compile(compiler.SolcFlagOpts{}, *solFlag) if err != nil { - fmt.Printf("Failed to initialize Solidity compiler: %v\n", err) + fmt.Printf("Failed to build Solidity contract: %v\n", err) os.Exit(-1) } - - solc.Compile(compiler.FlagOpts{}, strings.Split(*solFlag, ",")) // Gather all non-excluded contract for binding - for name, contract := range contracts { - abi, _ := json.Marshal(contract.Info.AbiDefinition) // Flatten the compiler parse - abis = append(abis, string(abi)) - bins = append(bins, contract.Code) + for name, contract := range solReturn.Contracts { + if exclude[strings.ToLower(name)] { + continue + } + + abis = append(abis, contract.Abi) + bins = append(bins, contract.Bin) nameParts := strings.Split(name, ":") types = append(types, nameParts[len(nameParts)-1])