Skip to content

Commit

Permalink
Update ethier/gen.go to match output of old and new versions of abige…
Browse files Browse the repository at this point in the history
…n after ethereum/go-ethereum#24835.

See the TODO in ethier/gen.go re direct modification of the bind.Bind() template.
  • Loading branch information
ARR4N committed Jun 8, 2022
1 parent 5050138 commit 7f7ad1f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,4 @@ jobs:
sudo apt-get install -y solc abigen
- name: Run tests
run: |
solc --version
abigen --version
npm run test
run: npm run test
11 changes: 8 additions & 3 deletions ethier/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,14 @@ var (

// Regular expressions for modifying abigen-generated code to work with the
// extraTemplate code above.
deployedRegexp = regexp.MustCompile(`^\s*return address, tx, &(.+?)\{.*Transactor.*\}, nil\s*$`)
libReplacementRegexp = regexp.MustCompile(`^\s*(.+?)Bin = strings.Replace\(.+?, "__\$([0-9a-f]{34})\$__", (.+?), -1\)\s*$`)
deployedRegexp = regexp.MustCompile(`^\s*return address, tx, &(.+?)\{.*Transactor.*\}, nil\s*$`)
// Note the option for matching strings.Replace or strings.ReplaceAll due to
// a recent change in abigen.
libReplacementRegexp = regexp.MustCompile(`^\s*(.+?)Bin = strings.Replace(?:All)?\(.+?, "__\$([0-9a-f]{34})\$__", (.+?)(?:, -1)?\)\s*$`)
// TODO(aschlosberg) replace regular expressions with a more explicit
// approach for modifying the output code. This likely requires a PR to the
// go-ethereum repo to allow bind.Bind (+/- abigen) to accept an alternate
// template.
)

// extendGeneratedCode adds ethier-specific functionality to code generated by
Expand Down Expand Up @@ -254,6 +260,5 @@ func extendGeneratedCode(generated, combinedJSON *bytes.Buffer) ([]byte, error)
if err := format.Node(buf, fset, f); err != nil {
return nil, fmt.Errorf("format.Node(%T, %T, %T): %v", buf, fset, f, err)
}
panic(buf.String())
return buf.Bytes(), nil
}

0 comments on commit 7f7ad1f

Please sign in to comment.