Skip to content

Commit a505b82

Browse files
authored
dir improvements: mv compiler to execution/abi (#16783)
also cherry pick ethereum/go-ethereum@8541ddb Part of #15713
1 parent ce4d6e8 commit a505b82

File tree

7 files changed

+4
-398
lines changed

7 files changed

+4
-398
lines changed

cmd/abigen/main.go

Lines changed: 3 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,18 @@ import (
2424
"fmt"
2525
"io"
2626
"os"
27-
"path/filepath"
2827
"regexp"
2928
"strings"
3029

3130
"github.com/urfave/cli/v2"
3231

3332
"github.com/erigontech/erigon-lib/common"
34-
"github.com/erigontech/erigon-lib/common/compiler"
3533
"github.com/erigontech/erigon-lib/crypto"
3634
"github.com/erigontech/erigon-lib/log/v3"
3735
"github.com/erigontech/erigon/cmd/utils"
3836
"github.com/erigontech/erigon/db/version"
39-
"github.com/erigontech/erigon/execution/abi"
4037
"github.com/erigontech/erigon/execution/abi/bind"
38+
"github.com/erigontech/erigon/execution/abi/compiler"
4139
cli2 "github.com/erigontech/erigon/turbo/cli"
4240
)
4341

@@ -61,24 +59,6 @@ var (
6159
Name: "combined-json",
6260
Usage: "Path to the combined-json file generated by compiler",
6361
}
64-
solFlag = cli.StringFlag{
65-
Name: "sol",
66-
Usage: "Path to the Ethereum contract Solidity source to build and bind",
67-
}
68-
solcFlag = cli.StringFlag{
69-
Name: "solc",
70-
Usage: "Solidity compiler to use if source builds are requested",
71-
Value: "solc",
72-
}
73-
vyFlag = cli.StringFlag{
74-
Name: "vy",
75-
Usage: "Path to the Ethereum contract Vyper source to build and bind",
76-
}
77-
vyperFlag = cli.StringFlag{
78-
Name: "vyper",
79-
Usage: "Vyper compiler to use if source builds are requested",
80-
Value: "vyper",
81-
}
8262
excFlag = cli.StringFlag{
8363
Name: "exc",
8464
Usage: "Comma separated types to exclude from binding",
@@ -109,10 +89,6 @@ func init() {
10989
&binFlag,
11090
&typeFlag,
11191
&jsonFlag,
112-
&solFlag,
113-
&solcFlag,
114-
&vyFlag,
115-
&vyperFlag,
11692
&excFlag,
11793
&pkgFlag,
11894
&outFlag,
@@ -123,7 +99,7 @@ func init() {
12399
}
124100

125101
func abigen(c *cli.Context) error {
126-
utils.CheckExclusive(c, &abiFlag, &jsonFlag, &solFlag, &vyFlag) // Only one source can be selected.
102+
utils.CheckExclusive(c, &abiFlag, &jsonFlag) // Only one source can be selected.
127103
if c.String(pkgFlag.Name) == "" {
128104
utils.Fatalf("No destination package specified (--pkg)")
129105
}
@@ -187,33 +163,9 @@ func abigen(c *cli.Context) error {
187163
for _, kind := range common.CliString2Array(c.String(excFlag.Name)) {
188164
exclude[strings.ToLower(kind)] = true
189165
}
190-
var err error
191166
var contracts map[string]*compiler.Contract
192167

193-
switch {
194-
case c.IsSet(solFlag.Name):
195-
contracts, err = compiler.CompileSolidity(c.Context, c.String(solcFlag.Name), c.String(solFlag.Name))
196-
if err != nil {
197-
utils.Fatalf("Failed to build Solidity contract: %v", err)
198-
}
199-
case c.IsSet(vyFlag.Name):
200-
output, err := compiler.CompileVyper(c.Context, c.String(vyperFlag.Name), c.String(vyFlag.Name))
201-
if err != nil {
202-
utils.Fatalf("Failed to build Vyper contract: %v", err)
203-
}
204-
contracts = make(map[string]*compiler.Contract)
205-
for n, contract := range output {
206-
name := n
207-
// Sanitize the combined json names to match the
208-
// format expected by solidity.
209-
if !strings.Contains(n, ":") {
210-
// Remove extra path components
211-
name = abi.ToCamelCase(strings.TrimSuffix(filepath.Base(name), ".vy"))
212-
}
213-
contracts[name] = contract
214-
}
215-
216-
case c.IsSet(jsonFlag.Name):
168+
if c.IsSet(jsonFlag.Name) {
217169
jsonOutput, err := os.ReadFile(c.String(jsonFlag.Name))
218170
if err != nil {
219171
utils.Fatalf("Failed to read combined-json from compiler: %v", err)

erigon-lib/common/compiler/test.v.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

erigon-lib/common/compiler/test_bad.v.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

erigon-lib/common/compiler/vyper.go

Lines changed: 0 additions & 148 deletions
This file was deleted.

erigon-lib/common/compiler/vyper_test.go

Lines changed: 0 additions & 76 deletions
This file was deleted.

erigon-lib/common/compiler/helpers.go renamed to execution/abi/compiler/helpers.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,6 @@
2020
// Package compiler wraps the Solidity and Vyper compiler executables (solc; vyper).
2121
package compiler
2222

23-
import (
24-
"bytes"
25-
"os"
26-
"regexp"
27-
)
28-
29-
var versionRegexp = regexp.MustCompile(`([0-9]+)\.([0-9]+)\.([0-9]+)`)
30-
3123
// Contract contains information about a compiled contract, alongside its code and runtime code.
3224
type Contract struct {
3325
Code string `json:"code"`
@@ -54,15 +46,3 @@ type ContractInfo struct {
5446
DeveloperDoc interface{} `json:"developerDoc"`
5547
Metadata string `json:"metadata"`
5648
}
57-
58-
func slurpFiles(files []string) (string, error) {
59-
var concat bytes.Buffer
60-
for _, file := range files {
61-
content, err := os.ReadFile(file)
62-
if err != nil {
63-
return "", err
64-
}
65-
concat.Write(content)
66-
}
67-
return concat.String(), nil
68-
}

0 commit comments

Comments
 (0)