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

Commit 5f570ac

Browse files
committed
feat(bindings): try parsing more custom errors (#531)
1 parent f044813 commit 5f570ac

9 files changed

+2243
-10
lines changed

bindings/.githead

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
08cab909e4cab27526b29226a22ea34675c2cc7e
1+
d2eda5966b463781c72580d4d30509422619824c

bindings/encoding/custom_error.go

+5-9
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,11 @@ func TryParsingCustomError(originalError error) error {
1616
return originalError
1717
}
1818

19-
for _, l1CustomError := range TaikoL1ABI.Errors {
20-
if strings.HasPrefix(l1CustomError.ID.Hex(), errData) {
21-
return errors.New(l1CustomError.Name)
22-
}
23-
}
24-
25-
for _, l2CustomError := range TaikoL2ABI.Errors {
26-
if strings.HasPrefix(l2CustomError.ID.Hex(), errData) {
27-
return errors.New(l2CustomError.Name)
19+
for _, customErrors := range customErrorMaps {
20+
for _, customError := range customErrors {
21+
if strings.HasPrefix(customError.ID.Hex(), errData) {
22+
return errors.New(customError.Name)
23+
}
2824
}
2925
}
3026

bindings/encoding/input.go

+44
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,15 @@ var (
267267
var (
268268
TaikoL1ABI *abi.ABI
269269
TaikoL2ABI *abi.ABI
270+
GuardianProverABI *abi.ABI
271+
LibDepositingABI *abi.ABI
272+
LibProposingABI *abi.ABI
273+
LibProvingABI *abi.ABI
274+
LibUtilsABI *abi.ABI
275+
LibVerifyingABI *abi.ABI
270276
AssignmentHookABI *abi.ABI
277+
278+
customErrorMaps []map[string]abi.Error
271279
)
272280

273281
func init() {
@@ -281,9 +289,45 @@ func init() {
281289
log.Crit("Get TaikoL2 ABI error", "error", err)
282290
}
283291

292+
if GuardianProverABI, err = bindings.GuardianProverMetaData.GetAbi(); err != nil {
293+
log.Crit("Get GuardianProver ABI error", "error", err)
294+
}
295+
296+
if LibDepositingABI, err = bindings.LibDepositingMetaData.GetAbi(); err != nil {
297+
log.Crit("Get LibDepositing ABI error", "error", err)
298+
}
299+
300+
if LibProposingABI, err = bindings.LibProposingMetaData.GetAbi(); err != nil {
301+
log.Crit("Get LibProposing ABI error", "error", err)
302+
}
303+
304+
if LibProvingABI, err = bindings.LibProvingMetaData.GetAbi(); err != nil {
305+
log.Crit("Get LibProving ABI error", "error", err)
306+
}
307+
308+
if LibUtilsABI, err = bindings.LibUtilsMetaData.GetAbi(); err != nil {
309+
log.Crit("Get LibUtils ABI error", "error", err)
310+
}
311+
312+
if LibVerifyingABI, err = bindings.LibVerifyingMetaData.GetAbi(); err != nil {
313+
log.Crit("Get LibVerifying ABI error", "error", err)
314+
}
315+
284316
if AssignmentHookABI, err = bindings.AssignmentHookMetaData.GetAbi(); err != nil {
285317
log.Crit("Get AssignmentHook ABI error", "error", err)
286318
}
319+
320+
customErrorMaps = []map[string]abi.Error{
321+
TaikoL1ABI.Errors,
322+
TaikoL2ABI.Errors,
323+
GuardianProverABI.Errors,
324+
LibDepositingABI.Errors,
325+
LibProposingABI.Errors,
326+
LibProvingABI.Errors,
327+
LibUtilsABI.Errors,
328+
LibVerifyingABI.Errors,
329+
AssignmentHookABI.Errors,
330+
}
287331
}
288332

289333
// EncodeBlockParams performs the solidity `abi.encode` for the given blockParams.

0 commit comments

Comments
 (0)