Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for logging custom errors on tx execution revert in not only real tx execution but also gas estimation #39

Merged
merged 13 commits into from
Apr 26, 2024
Merged
14 changes: 9 additions & 5 deletions pkg/relay/ethereum/error_parse.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ethereum

import (
"bytes"
"encoding/json"
"fmt"
"os"
@@ -22,14 +21,19 @@ func CreateErrorRepository(abiPaths []string) (ErrorRepository, error) {
return err
}
if !info.IsDir() && strings.HasSuffix(info.Name(), ".json") {
data, err := os.ReadFile(path)
f, err := os.Open(path)
if err != nil {
return err
}
defer f.Close()

contractABI, err := abi.JSON(bytes.NewReader(data))
for _, error := range contractABI.Errors {
errABIs = append(errABIs, error)
contractABI, err := abi.JSON(f)
if err != nil {
return err
siburu marked this conversation as resolved.
Show resolved Hide resolved
}

for _, errABI := range contractABI.Errors {
errABIs = append(errABIs, errABI)
}
}
return nil