accounts/abi: remove function Unpack2 (#20830)

This commit is contained in:
Daniel Liu 2025-01-14 10:56:10 +08:00
parent 56f9c17817
commit 91f6259135
2 changed files with 3 additions and 15 deletions

View file

@ -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
}

View file

@ -18,7 +18,6 @@ package abi
import (
"encoding/json"
"errors"
"fmt"
"reflect"
"strings"
@ -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