Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
feat(bindings): try parsing more custom errors
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha committed Jan 25, 2024
1 parent 0e8aa05 commit 7441806
Show file tree
Hide file tree
Showing 9 changed files with 2,243 additions and 10 deletions.
2 changes: 1 addition & 1 deletion bindings/.githead
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ff8690e52f1d4e5e506b156f7e4042cf13d8d858
d2eda5966b463781c72580d4d30509422619824c
28 changes: 19 additions & 9 deletions bindings/encoding/custom_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,22 @@ package encoding
import (
"errors"
"strings"

"github.com/ethereum/go-ethereum/accounts/abi"
)

var customErrors = []map[string]abi.Error{
TaikoL1ABI.Errors,
TaikoL2ABI.Errors,
GuardianProverABI.Errors,
LibDepositingABI.Errors,
LibProposingABI.Errors,
LibProvingABI.Errors,
LibUtilsABI.Errors,
LibVerifyingABI.Errors,
AssignmentHookABI.Errors,
}

// TryParsingCustomError tries to checks whether the given error is one of the
// custom errors defined the TaikoL1 / TaikoL2's ABI, if so, it will return
// the matched custom error, otherwise, it simply returns the original error.
Expand All @@ -16,15 +30,11 @@ func TryParsingCustomError(originalError error) error {
return originalError
}

for _, l1CustomError := range TaikoL1ABI.Errors {
if strings.HasPrefix(l1CustomError.ID.Hex(), errData) {
return errors.New(l1CustomError.Name)
}
}

for _, l2CustomError := range TaikoL2ABI.Errors {
if strings.HasPrefix(l2CustomError.ID.Hex(), errData) {
return errors.New(l2CustomError.Name)
for _, customErrors := range customErrors {
for _, cuscustomError := range customErrors {
if strings.HasPrefix(cuscustomError.ID.Hex(), errData) {
return errors.New(cuscustomError.Name)
}
}
}

Expand Down
30 changes: 30 additions & 0 deletions bindings/encoding/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,12 @@ var (
var (
TaikoL1ABI *abi.ABI
TaikoL2ABI *abi.ABI
GuardianProverABI *abi.ABI
LibDepositingABI *abi.ABI
LibProposingABI *abi.ABI
LibProvingABI *abi.ABI
LibUtilsABI *abi.ABI
LibVerifyingABI *abi.ABI
AssignmentHookABI *abi.ABI
)

Expand All @@ -286,6 +292,30 @@ func init() {
log.Crit("Get TaikoL2 ABI error", "error", err)
}

if GuardianProverABI, err = bindings.GuardianProverMetaData.GetAbi(); err != nil {
log.Crit("Get GuardianProver ABI error", "error", err)
}

if LibDepositingABI, err = bindings.LibDepositingMetaData.GetAbi(); err != nil {
log.Crit("Get LibDepositing ABI error", "error", err)
}

if LibProposingABI, err = bindings.LibProposingMetaData.GetAbi(); err != nil {
log.Crit("Get LibProposing ABI error", "error", err)
}

if LibProvingABI, err = bindings.LibProvingMetaData.GetAbi(); err != nil {
log.Crit("Get LibProving ABI error", "error", err)
}

if LibUtilsABI, err = bindings.LibUtilsMetaData.GetAbi(); err != nil {
log.Crit("Get LibUtils ABI error", "error", err)
}

if LibVerifyingABI, err = bindings.LibVerifyingMetaData.GetAbi(); err != nil {
log.Crit("Get LibVerifying ABI error", "error", err)
}

if AssignmentHookABI, err = bindings.AssignmentHookMetaData.GetAbi(); err != nil {
log.Crit("Get AssignmentHook ABI error", "error", err)
}
Expand Down
Loading

0 comments on commit 7441806

Please sign in to comment.