mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
common/compiler, cmd/abigen: style
This commit is contained in:
parent
eb8fb04abb
commit
00b02834be
6 changed files with 17 additions and 14 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2016 The go-ethereum Authors
|
// Copyright 2019 The go-ethereum Authors
|
||||||
// This file is part of go-ethereum.
|
// This file is part of go-ethereum.
|
||||||
//
|
//
|
||||||
// go-ethereum is free software: you can redistribute it and/or modify
|
// go-ethereum is free software: you can redistribute it and/or modify
|
||||||
|
|
@ -90,19 +90,21 @@ func main() {
|
||||||
|
|
||||||
var contracts map[string]*compiler.Contract
|
var contracts map[string]*compiler.Contract
|
||||||
var err error
|
var err error
|
||||||
if *solFlag != "" {
|
|
||||||
|
switch {
|
||||||
|
case *solFlag != "":
|
||||||
contracts, err = compiler.CompileSolidity(*solcFlag, *solFlag)
|
contracts, err = compiler.CompileSolidity(*solcFlag, *solFlag)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Failed to build Solidity contract: %v\n", err)
|
fmt.Printf("Failed to build Solidity contract: %v\n", err)
|
||||||
os.Exit(-1)
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
} else if *vyFlag != "" {
|
case *vyFlag != "":
|
||||||
contracts, err = compiler.CompileVyper(*vyperFlag, *vyFlag)
|
contracts, err = compiler.CompileVyper(*vyperFlag, *vyFlag)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Failed to build Vyper contract: %v\n", err)
|
fmt.Printf("Failed to build Vyper contract: %v\n", err)
|
||||||
os.Exit(-1)
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
} else {
|
default:
|
||||||
contracts, err = contractsFromStdin()
|
contracts, err = contractsFromStdin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Failed to read input ABIs from STDIN: %v\n", err)
|
fmt.Printf("Failed to read input ABIs from STDIN: %v\n", err)
|
||||||
|
|
@ -114,7 +116,11 @@ func main() {
|
||||||
if exclude[strings.ToLower(name)] {
|
if exclude[strings.ToLower(name)] {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
abi, _ := json.Marshal(contract.Info.AbiDefinition) // Flatten the compiler parse
|
abi, err := json.Marshal(contract.Info.AbiDefinition) // Flatten the compiler parse
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("Failed to parse ABIs from compiler output: %v\n", err)
|
||||||
|
os.Exit(-1)
|
||||||
|
}
|
||||||
abis = append(abis, string(abi))
|
abis = append(abis, string(abi))
|
||||||
bins = append(bins, contract.Code)
|
bins = append(bins, contract.Code)
|
||||||
|
|
||||||
|
|
@ -152,7 +158,6 @@ func main() {
|
||||||
types = append(types, kind)
|
types = append(types, kind)
|
||||||
}
|
}
|
||||||
// Generate the contract binding
|
// Generate the contract binding
|
||||||
fmt.Printf("%+v", abis)
|
|
||||||
code, err := bind.Bind(types, abis, bins, *pkgFlag, lang)
|
code, err := bind.Bind(types, abis, bins, *pkgFlag, lang)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Failed to generate ABI binding: %v\n", err)
|
fmt.Printf("Failed to generate ABI binding: %v\n", err)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2015 The go-ethereum Authors
|
// Copyright 2019 The go-ethereum Authors
|
||||||
// This file is part of the go-ethereum library.
|
// This file is part of the go-ethereum library.
|
||||||
//
|
//
|
||||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2015 The go-ethereum Authors
|
// Copyright 2019 The go-ethereum Authors
|
||||||
// This file is part of the go-ethereum library.
|
// This file is part of the go-ethereum library.
|
||||||
//
|
//
|
||||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
|
@ -28,8 +28,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
var solVersionRegexp = regexp.MustCompile(`([0-9]+)\.([0-9]+)\.([0-9]+)`)
|
|
||||||
|
|
||||||
// Solidity contains information about the solidity compiler.
|
// Solidity contains information about the solidity compiler.
|
||||||
type Solidity struct {
|
type Solidity struct {
|
||||||
Path, Version, FullVersion string
|
Path, Version, FullVersion string
|
||||||
|
|
@ -69,7 +67,7 @@ func SolidityVersion(solc string) (*Solidity, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
matches := solVersionRegexp.FindStringSubmatch(out.String())
|
matches := versionRegexp.FindStringSubmatch(out.String())
|
||||||
if len(matches) != 4 {
|
if len(matches) != 4 {
|
||||||
return nil, fmt.Errorf("can't parse solc version %q", out.String())
|
return nil, fmt.Errorf("can't parse solc version %q", out.String())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2015 The go-ethereum Authors
|
// Copyright 2019 The go-ethereum Authors
|
||||||
// This file is part of the go-ethereum library.
|
// This file is part of the go-ethereum library.
|
||||||
//
|
//
|
||||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2015 The go-ethereum Authors
|
// Copyright 2019 The go-ethereum Authors
|
||||||
// This file is part of the go-ethereum library.
|
// This file is part of the go-ethereum library.
|
||||||
//
|
//
|
||||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2015 The go-ethereum Authors
|
// Copyright 2019 The go-ethereum Authors
|
||||||
// This file is part of the go-ethereum library.
|
// This file is part of the go-ethereum library.
|
||||||
//
|
//
|
||||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue