Skip to content

Commit

Permalink
Apply patch for set-nil in ABI reflect.
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim committed Jun 13, 2019
1 parent faec20e commit f0c3471
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 5 deletions.
74 changes: 69 additions & 5 deletions patches/abi.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,74 @@
diff --git a/patches/abi.patch b/patches/abi.patch
index 1793c2d..e69de29 100644
--- a/patches/abi.patch
+++ b/patches/abi.patch
@@ -1,61 +0,0 @@
-diff --git a/vendor/github.com/ethereum/go-ethereum/accounts/abi/abi.go b/vendor/github.com/ethereum/go-ethereum/accounts/abi/abi.go
-index 7545387..b16e4f7 100644
---- a/vendor/github.com/ethereum/go-ethereum/accounts/abi/abi.go
-+++ b/vendor/github.com/ethereum/go-ethereum/accounts/abi/abi.go
-@@ -81,9 +80,11 @@ func (abi ABI) Unpack(v interface{}, name string, output []byte) (err error) {
- // we need to decide whether we're calling a method or an event
- if method, ok := abi.Methods[name]; ok {
- if len(output)%32 != 0 {
-+ if msg := getMessage(output); len(msg) > 0 {
-+ return fmt.Errorf("abi: thrown message: %s", msg)
-+ }
- return fmt.Errorf("abi: improperly formatted output: %s - Bytes: [%+v]", string(output), output)
- }
- return method.Outputs.Unpack(v, output)
- } else if event, ok := abi.Events[name]; ok {
- return event.Inputs.Unpack(v, output)
-@@ -91,6 +92,29 @@ func (abi ABI) Unpack(v interface{}, name string, output []byte) (err error) {
- return fmt.Errorf("abi: could not locate named method or event")
- }
-
-+func getMessage(data []byte) []byte {
-+ var inMessage bool
-+ var message []byte
-+ offset := bytes.IndexByte(data, 0x20)
-+ if offset < 0 || offset >= len(data)-1 {
-+ return nil
-+ }
-+ for i := offset + 1; i < len(data); i++ {
-+ if !inMessage && data[i] != 0x00 {
-+ inMessage = true
-+ if data[i] != 0x4e && data[i] != 0x1a {
-+ message = append(message, data[i])
-+ }
-+ } else if inMessage {
-+ if data[i] == 0x00 {
-+ return bytes.TrimSpace(message)
-+ }
-+ message = append(message, data[i])
-+ }
-+ }
-+ return bytes.TrimSpace(message)
-+}
-+
- // UnmarshalJSON implements json.Unmarshaler interface
- func (abi *ABI) UnmarshalJSON(data []byte) error {
- var fields []struct {
-diff --git a/vendor/github.com/ethereum/go-ethereum/accounts/abi/reflect.go b/vendor/github.com/ethereum/go-ethereum/accounts/abi/reflect.go
-index 1b0bb00..8af361d 100644
---- a/vendor/github.com/ethereum/go-ethereum/accounts/abi/reflect.go
-+++ b/vendor/github.com/ethereum/go-ethereum/accounts/abi/reflect.go
-@@ -72,6 +72,10 @@ func mustArrayToByteSlice(value reflect.Value) reflect.Value {
- // set is a bit more lenient when it comes to assignment and doesn't force an as
- // strict ruleset as bare `reflect` does.
- func set(dst, src reflect.Value) error {
-+ if dst.IsNil() {
-+ dst.Set(src)
-+ return nil
-+ }
- dstType, srcType := dst.Type(), src.Type()
- switch {
- case dstType.Kind() == reflect.Interface:
diff --git a/vendor/github.com/ethereum/go-ethereum/accounts/abi/abi.go b/vendor/github.com/ethereum/go-ethereum/accounts/abi/abi.go
index 7545387..b16e4f7 100644
index 08d5db9..b9b84bb 100644
--- a/vendor/github.com/ethereum/go-ethereum/accounts/abi/abi.go
+++ b/vendor/github.com/ethereum/go-ethereum/accounts/abi/abi.go
@@ -81,9 +80,11 @@ func (abi ABI) Unpack(v interface{}, name string, output []byte) (err error) {
@@ -80,6 +80,9 @@ func (abi ABI) Unpack(v interface{}, name string, output []byte) (err error) {
// we need to decide whether we're calling a method or an event
if method, ok := abi.Methods[name]; ok {
if len(output)%32 != 0 {
Expand All @@ -12,9 +78,7 @@ index 7545387..b16e4f7 100644
return fmt.Errorf("abi: improperly formatted output: %s - Bytes: [%+v]", string(output), output)
}
return method.Outputs.Unpack(v, output)
} else if event, ok := abi.Events[name]; ok {
return event.Inputs.Unpack(v, output)
@@ -91,6 +92,29 @@ func (abi ABI) Unpack(v interface{}, name string, output []byte) (err error) {
@@ -89,6 +92,29 @@ func (abi ABI) Unpack(v interface{}, name string, output []byte) (err error) {
return fmt.Errorf("abi: could not locate named method or event")
}

Expand Down
26 changes: 26 additions & 0 deletions vendor/github.com/ethereum/go-ethereum/accounts/abi/abi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f0c3471

Please sign in to comment.