Skip to content

Commit

Permalink
accounts/abi: remove function Unpack2 (ethereum#20830)
Browse files Browse the repository at this point in the history
  • Loading branch information
gzliudan committed Jan 10, 2025
1 parent a96217d commit 9eae779
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
6 changes: 3 additions & 3 deletions accounts/abi/abi.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,10 @@ func UnpackRevert(data []byte) (string, error) {
if !bytes.Equal(data[:4], revertSelector) {
return "", errors.New("invalid data for unpacking")
}
var reason string
typ, _ := NewType("string", "", nil)
unpacked, err := (Arguments{{Type: typ}}).Unpack2(data[4:])
if err != nil {
if err := (Arguments{{Type: typ}}).Unpack(&reason, data[4:]); err != nil {
return "", err
}
return unpacked[0].(string), nil
return reason, nil
}
12 changes: 0 additions & 12 deletions accounts/abi/argument.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package abi

import (
"encoding/json"
"errors"
"fmt"
"reflect"
"strings"
Expand Down Expand Up @@ -113,17 +112,6 @@ func (arguments Arguments) Unpack(v interface{}, data []byte) error {
return arguments.unpackAtomic(v, marshalledValues[0])
}

// Unpack2 performs the operation hexdata -> Go format.
func (arguments Arguments) Unpack2(data []byte) ([]interface{}, error) {
if len(data) == 0 {
if len(arguments.NonIndexed()) != 0 {
return nil, errors.New("abi: attempting to unmarshall an empty string while arguments are expected")
}
return make([]interface{}, 0), nil
}
return arguments.UnpackValues(data)
}

// UnpackIntoMap performs the operation hexdata -> mapping of argument name to argument value
func (arguments Arguments) UnpackIntoMap(v map[string]interface{}, data []byte) error {
// Make sure map is not nil
Expand Down

0 comments on commit 9eae779

Please sign in to comment.