mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 02:40:45 +00:00
accounts/abi: remove function Unpack2 (#20830)
This commit is contained in:
parent
56f9c17817
commit
91f6259135
2 changed files with 3 additions and 15 deletions
|
|
@ -250,10 +250,10 @@ func UnpackRevert(data []byte) (string, error) {
|
||||||
if !bytes.Equal(data[:4], revertSelector) {
|
if !bytes.Equal(data[:4], revertSelector) {
|
||||||
return "", errors.New("invalid data for unpacking")
|
return "", errors.New("invalid data for unpacking")
|
||||||
}
|
}
|
||||||
|
var reason string
|
||||||
typ, _ := NewType("string", "", nil)
|
typ, _ := NewType("string", "", nil)
|
||||||
unpacked, err := (Arguments{{Type: typ}}).Unpack2(data[4:])
|
if err := (Arguments{{Type: typ}}).Unpack(&reason, data[4:]); err != nil {
|
||||||
if err != nil {
|
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
return unpacked[0].(string), nil
|
return reason, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ package abi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -113,17 +112,6 @@ func (arguments Arguments) Unpack(v interface{}, data []byte) error {
|
||||||
return arguments.unpackAtomic(v, marshalledValues[0])
|
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
|
// UnpackIntoMap performs the operation hexdata -> mapping of argument name to argument value
|
||||||
func (arguments Arguments) UnpackIntoMap(v map[string]interface{}, data []byte) error {
|
func (arguments Arguments) UnpackIntoMap(v map[string]interface{}, data []byte) error {
|
||||||
// Make sure map is not nil
|
// Make sure map is not nil
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue