Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions execution/abi/abi.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func JSON(reader io.Reader) (ABI, error) {
// of 4 bytes and arguments are all 32 bytes.
// Method ids are created from the first 4 bytes of the hash of the
// methods string signature. (signature = baz(uint32,string32))
func (abi ABI) Pack(name string, args ...interface{}) ([]byte, error) {
func (abi ABI) Pack(name string, args ...any) ([]byte, error) {
// Fetch the ABI of the requested method
if name == "" {
// constructor
Expand Down Expand Up @@ -105,7 +105,7 @@ func (abi ABI) getArguments(name string, data []byte) (Arguments, error) {
}

// Unpack unpacks the output according to the abi specification.
func (abi ABI) Unpack(name string, data []byte) ([]interface{}, error) {
func (abi ABI) Unpack(name string, data []byte) ([]any, error) {
args, err := abi.getArguments(name, data)
if err != nil {
return nil, err
Expand All @@ -116,7 +116,7 @@ func (abi ABI) Unpack(name string, data []byte) ([]interface{}, error) {
// UnpackIntoInterface unpacks the output in v according to the abi specification.
// It performs an additional copy. Please only use, if you want to unpack into a
// structure that does not strictly conform to the abi structure (e.g. has additional arguments)
func (abi ABI) UnpackIntoInterface(v interface{}, name string, data []byte) error {
func (abi ABI) UnpackIntoInterface(v any, name string, data []byte) error {
args, err := abi.getArguments(name, data)
if err != nil {
return err
Expand All @@ -129,7 +129,7 @@ func (abi ABI) UnpackIntoInterface(v interface{}, name string, data []byte) erro
}

// UnpackIntoMap unpacks a log into the provided map[string]interface{}.
func (abi ABI) UnpackIntoMap(v map[string]interface{}, name string, data []byte) (err error) {
func (abi ABI) UnpackIntoMap(v map[string]any, name string, data []byte) (err error) {
args, err := abi.getArguments(name, data)
if err != nil {
return err
Expand Down
18 changes: 9 additions & 9 deletions execution/abi/abi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -780,8 +780,8 @@ func TestUnpackEventIntoMap(t *testing.T) {
t.Errorf("len(data) is %d, want a non-multiple of 32", len(data))
}

receivedMap := map[string]interface{}{}
expectedReceivedMap := map[string]interface{}{
receivedMap := map[string]any{}
expectedReceivedMap := map[string]any{
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
"amount": big.NewInt(1),
"memo": []byte{88},
Expand All @@ -802,7 +802,7 @@ func TestUnpackEventIntoMap(t *testing.T) {
t.Error("unpacked `received` map does not match expected map")
}

receivedAddrMap := map[string]interface{}{}
receivedAddrMap := map[string]any{}
if err = abi.UnpackIntoMap(receivedAddrMap, "receivedAddr", data); err != nil {
t.Error(err)
}
Expand Down Expand Up @@ -830,7 +830,7 @@ func TestUnpackMethodIntoMap(t *testing.T) {
}

// Tests a method with no outputs
receiveMap := map[string]interface{}{}
receiveMap := map[string]any{}
if err = abi.UnpackIntoMap(receiveMap, "receive", data); err != nil {
t.Error(err)
}
Expand All @@ -839,7 +839,7 @@ func TestUnpackMethodIntoMap(t *testing.T) {
}

// Tests a method with only outputs
sendMap := map[string]interface{}{}
sendMap := map[string]any{}
if err = abi.UnpackIntoMap(sendMap, "send", data); err != nil {
t.Error(err)
}
Expand All @@ -851,7 +851,7 @@ func TestUnpackMethodIntoMap(t *testing.T) {
}

// Tests a method with outputs and inputs
getMap := map[string]interface{}{}
getMap := map[string]any{}
if err = abi.UnpackIntoMap(getMap, "get", data); err != nil {
t.Error(err)
}
Expand Down Expand Up @@ -879,7 +879,7 @@ func TestUnpackIntoMapNamingConflict(t *testing.T) {
if len(data)%32 == 0 {
t.Errorf("len(data) is %d, want a non-multiple of 32", len(data))
}
getMap := map[string]interface{}{}
getMap := map[string]any{}
if err = abi.UnpackIntoMap(getMap, "get", data); err == nil {
t.Error("naming conflict between two methods; error expected")
}
Expand All @@ -898,7 +898,7 @@ func TestUnpackIntoMapNamingConflict(t *testing.T) {
if len(data)%32 == 0 {
t.Errorf("len(data) is %d, want a non-multiple of 32", len(data))
}
receivedMap := map[string]interface{}{}
receivedMap := map[string]any{}
if err = abi.UnpackIntoMap(receivedMap, "received", data); err != nil {
t.Error("naming conflict between two events; no error expected")
}
Expand All @@ -925,7 +925,7 @@ func TestUnpackIntoMapNamingConflict(t *testing.T) {
if len(data)%32 == 0 {
t.Errorf("len(data) is %d, want a non-multiple of 32", len(data))
}
expectedReceivedMap := map[string]interface{}{
expectedReceivedMap := map[string]any{
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
"amount": big.NewInt(1),
"memo": []byte{88},
Expand Down
6 changes: 3 additions & 3 deletions execution/abi/abifuzzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ var (
"bytes32", "bytes"}
)

func unpackPack(abi ABI, method string, input []byte) ([]interface{}, bool) {
func unpackPack(abi ABI, method string, input []byte) ([]any, bool) {
if out, err := abi.Unpack(method, input); err == nil {
_, err := abi.Pack(method, out...)
if err != nil {
Expand All @@ -80,9 +80,9 @@ func unpackPack(abi ABI, method string, input []byte) ([]interface{}, bool) {
return nil, false
}

func packUnpack(abi ABI, method string, input *[]interface{}) bool {
func packUnpack(abi ABI, method string, input *[]any) bool {
if packed, err := abi.Pack(method, input); err == nil {
outptr := reflect.New(reflect.TypeFor[*[]interface{}]())
outptr := reflect.New(reflect.TypeFor[*[]any]())
err := abi.UnpackIntoInterface(outptr.Interface(), method, packed)
if err != nil {
panic(err)
Expand Down
20 changes: 10 additions & 10 deletions execution/abi/argument.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ func (arguments Arguments) isTuple() bool {
}

// Unpack performs the operation hexdata -> Go format.
func (arguments Arguments) Unpack(data []byte) ([]interface{}, error) {
func (arguments Arguments) Unpack(data []byte) ([]any, error) {
if len(data) == 0 {
if len(arguments) != 0 {
return nil, errors.New("abi: attempting to unmarshall an empty string while arguments are expected")
}
// Nothing to unmarshal, return default variables
nonIndexedArgs := arguments.NonIndexed()
defaultVars := make([]interface{}, len(nonIndexedArgs))
defaultVars := make([]any, len(nonIndexedArgs))
for index, arg := range nonIndexedArgs {
defaultVars[index] = reflect.New(arg.Type.GetType())
}
Expand All @@ -97,7 +97,7 @@ func (arguments Arguments) Unpack(data []byte) ([]interface{}, error) {
}

// 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]any, data []byte) error {
// Make sure map is not nil
if v == nil {
return errors.New("abi: cannot unpack into a nil map")
Expand All @@ -119,7 +119,7 @@ func (arguments Arguments) UnpackIntoMap(v map[string]interface{}, data []byte)
}

// Copy performs the operation go format -> provided struct.
func (arguments Arguments) Copy(v interface{}, values []interface{}) error {
func (arguments Arguments) Copy(v any, values []any) error {
// make sure the passed value is arguments pointer
if reflect.Ptr != reflect.ValueOf(v).Kind() {
return fmt.Errorf("abi: Unpack(non-pointer %T)", v)
Expand All @@ -137,7 +137,7 @@ func (arguments Arguments) Copy(v interface{}, values []interface{}) error {
}

// unpackAtomic unpacks ( hexdata -> go ) a single value
func (arguments Arguments) copyAtomic(v interface{}, marshalledValues interface{}) error {
func (arguments Arguments) copyAtomic(v any, marshalledValues any) error {
dst := reflect.ValueOf(v).Elem()
src := reflect.ValueOf(marshalledValues)

Expand All @@ -148,7 +148,7 @@ func (arguments Arguments) copyAtomic(v interface{}, marshalledValues interface{
}

// copyTuple copies a batch of values from marshalledValues to v.
func (arguments Arguments) copyTuple(v interface{}, marshalledValues []interface{}) error {
func (arguments Arguments) copyTuple(v any, marshalledValues []any) error {
value := reflect.ValueOf(v).Elem()
nonIndexedArgs := arguments.NonIndexed()

Expand Down Expand Up @@ -190,9 +190,9 @@ func (arguments Arguments) copyTuple(v interface{}, marshalledValues []interface
// UnpackValues can be used to unpack ABI-encoded hexdata according to the ABI-specification,
// without supplying a struct to unpack into. Instead, this method returns a list containing the
// values. An atomic argument will be a list with one element.
func (arguments Arguments) UnpackValues(data []byte) ([]interface{}, error) {
func (arguments Arguments) UnpackValues(data []byte) ([]any, error) {
nonIndexedArgs := arguments.NonIndexed()
retval := make([]interface{}, 0, len(nonIndexedArgs))
retval := make([]any, 0, len(nonIndexedArgs))
virtualArgs := 0
for index, arg := range nonIndexedArgs {
marshalledValue, err := toGoType((index+virtualArgs)*32, arg.Type, data)
Expand Down Expand Up @@ -223,12 +223,12 @@ func (arguments Arguments) UnpackValues(data []byte) ([]interface{}, error) {

// PackValues performs the operation Go format -> Hexdata.
// It is the semantic opposite of UnpackValues.
func (arguments Arguments) PackValues(args []interface{}) ([]byte, error) {
func (arguments Arguments) PackValues(args []any) ([]byte, error) {
return arguments.Pack(args...)
}

// Pack performs the operation Go format -> Hexdata.
func (arguments Arguments) Pack(args ...interface{}) ([]byte, error) {
func (arguments Arguments) Pack(args ...any) ([]byte, error) {
// Make sure arguments match up and pack them
abiArgs := arguments
if len(args) != len(abiArgs) {
Expand Down
2 changes: 1 addition & 1 deletion execution/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ func (e *revertError) ErrorCode() int {
}

// ErrorData returns the hex encoded revert reason.
func (e *revertError) ErrorData() interface{} {
func (e *revertError) ErrorData() any {
return e.reason
}

Expand Down
4 changes: 2 additions & 2 deletions execution/abi/bind/backends/simulated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ func TestSimulatedBackend_EstimateGas(t *testing.T) {
message ethereum.CallMsg
expect uint64
expectError error
expectData interface{}
expectData any
}{
{"plain transfer(valid)", ethereum.CallMsg{
From: addr,
Expand Down Expand Up @@ -1067,7 +1067,7 @@ func TestSimulatedBackend_CallContractRevert(t *testing.T) {
t.Errorf("could not deploy contract: %v", err)
}

inputs := make(map[string]interface{}, 3)
inputs := make(map[string]any, 3)
inputs["revertASM"] = nil
inputs["revertNoString"] = ""
inputs["revertString"] = "some error"
Expand Down
20 changes: 10 additions & 10 deletions execution/abi/bind/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func NewBoundContract(address common.Address, abi abi.ABI, caller ContractCaller

// DeployContract deploys a contract onto the Ethereum blockchain and binds the
// deployment address with a Go wrapper.
func DeployContract(opts *TransactOpts, abi abi.ABI, bytecode []byte, backend ContractBackend, params ...interface{}) (common.Address, types.Transaction, *BoundContract, error) {
func DeployContract(opts *TransactOpts, abi abi.ABI, bytecode []byte, backend ContractBackend, params ...any) (common.Address, types.Transaction, *BoundContract, error) {
// Otherwise try to deploy the contract
c := NewBoundContract(common.Address{}, abi, backend, backend, backend)

Expand All @@ -121,13 +121,13 @@ func DeployContract(opts *TransactOpts, abi abi.ABI, bytecode []byte, backend Co
// sets the output to result. The result type might be a single field for simple
// returns, a slice of interfaces for anonymous returns and a struct for named
// returns.
func (c *BoundContract) Call(opts *CallOpts, results *[]interface{}, method string, params ...interface{}) error {
func (c *BoundContract) Call(opts *CallOpts, results *[]any, method string, params ...any) error {
// Don't crash on a lazy user
if opts == nil {
opts = new(CallOpts)
}
if results == nil {
results = new([]interface{})
results = new([]any)
}
// Pack the input, call and unpack the results
input, err := c.abi.Pack(method, params...)
Expand Down Expand Up @@ -179,7 +179,7 @@ func (c *BoundContract) Call(opts *CallOpts, results *[]interface{}, method stri
}

// Transact invokes the (paid) contract method with params as input values.
func (c *BoundContract) Transact(opts *TransactOpts, method string, params ...interface{}) (types.Transaction, error) {
func (c *BoundContract) Transact(opts *TransactOpts, method string, params ...any) (types.Transaction, error) {
// Otherwise pack up the parameters and invoke the contract
input, err := c.abi.Pack(method, params...)
if err != nil {
Expand Down Expand Up @@ -279,13 +279,13 @@ func (c *BoundContract) transact(opts *TransactOpts, contract *common.Address, i

// FilterLogs filters contract logs for past blocks, returning the necessary
// channels to construct a strongly typed bound iterator on top of them.
func (c *BoundContract) FilterLogs(opts *FilterOpts, name string, query ...[]interface{}) (chan types.Log, event.Subscription, error) {
func (c *BoundContract) FilterLogs(opts *FilterOpts, name string, query ...[]any) (chan types.Log, event.Subscription, error) {
// Don't crash on a lazy user
if opts == nil {
opts = new(FilterOpts)
}
// Append the event selector to the query parameters and construct the topic set
query = append([][]interface{}{{c.abi.Events[name].ID}}, query...)
query = append([][]any{{c.abi.Events[name].ID}}, query...)

topics, err := abi.MakeTopics(query...)
if err != nil {
Expand Down Expand Up @@ -325,13 +325,13 @@ func (c *BoundContract) FilterLogs(opts *FilterOpts, name string, query ...[]int

// WatchLogs filters subscribes to contract logs for future blocks, returning a
// subscription object that can be used to tear down the watcher.
func (c *BoundContract) WatchLogs(opts *WatchOpts, name string, query ...[]interface{}) (chan types.Log, event.Subscription, error) {
func (c *BoundContract) WatchLogs(opts *WatchOpts, name string, query ...[]any) (chan types.Log, event.Subscription, error) {
// Don't crash on a lazy user
if opts == nil {
opts = new(WatchOpts)
}
// Append the event selector to the query parameters and construct the topic set
query = append([][]interface{}{{c.abi.Events[name].ID}}, query...)
query = append([][]any{{c.abi.Events[name].ID}}, query...)

topics, err := abi.MakeTopics(query...)
if err != nil {
Expand All @@ -355,7 +355,7 @@ func (c *BoundContract) WatchLogs(opts *WatchOpts, name string, query ...[]inter
}

// UnpackLog unpacks a retrieved log into the provided output structure.
func (c *BoundContract) UnpackLog(out interface{}, event string, log types.Log) error {
func (c *BoundContract) UnpackLog(out any, event string, log types.Log) error {
if len(log.Data) > 0 {
if err := c.abi.UnpackIntoInterface(out, event, log.Data); err != nil {
return err
Expand All @@ -371,7 +371,7 @@ func (c *BoundContract) UnpackLog(out interface{}, event string, log types.Log)
}

// UnpackLogIntoMap unpacks a retrieved log into the provided map.
func (c *BoundContract) UnpackLogIntoMap(out map[string]interface{}, event string, log types.Log) error {
func (c *BoundContract) UnpackLogIntoMap(out map[string]any, event string, log types.Log) error {
if len(log.Data) > 0 {
if err := c.abi.UnpackIntoMap(out, event, log.Data); err != nil {
return err
Expand Down
14 changes: 7 additions & 7 deletions execution/abi/bind/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func TestUnpackIndexedStringTyLogIntoMap(t *testing.T) {
parsedAbi, _ := abi.JSON(strings.NewReader(abiString))
bc := bind.NewBoundContract(common.HexToAddress("0x0"), parsedAbi, nil, nil, nil)

expectedReceivedMap := map[string]interface{}{
expectedReceivedMap := map[string]any{
"name": hash,
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
"amount": big.NewInt(1),
Expand All @@ -148,7 +148,7 @@ func TestUnpackIndexedSliceTyLogIntoMap(t *testing.T) {
parsedAbi, _ := abi.JSON(strings.NewReader(abiString))
bc := bind.NewBoundContract(common.HexToAddress("0x0"), parsedAbi, nil, nil, nil)

expectedReceivedMap := map[string]interface{}{
expectedReceivedMap := map[string]any{
"names": hash,
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
"amount": big.NewInt(1),
Expand All @@ -173,7 +173,7 @@ func TestUnpackIndexedArrayTyLogIntoMap(t *testing.T) {
parsedAbi, _ := abi.JSON(strings.NewReader(abiString))
bc := bind.NewBoundContract(common.HexToAddress("0x0"), parsedAbi, nil, nil, nil)

expectedReceivedMap := map[string]interface{}{
expectedReceivedMap := map[string]any{
"addresses": hash,
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
"amount": big.NewInt(1),
Expand All @@ -199,7 +199,7 @@ func TestUnpackIndexedFuncTyLogIntoMap(t *testing.T) {
parsedAbi, _ := abi.JSON(strings.NewReader(abiString))
bc := bind.NewBoundContract(common.HexToAddress("0x0"), parsedAbi, nil, nil, nil)

expectedReceivedMap := map[string]interface{}{
expectedReceivedMap := map[string]any{
"function": functionTy,
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
"amount": big.NewInt(1),
Expand All @@ -221,7 +221,7 @@ func TestUnpackIndexedBytesTyLogIntoMap(t *testing.T) {
parsedAbi, _ := abi.JSON(strings.NewReader(abiString))
bc := bind.NewBoundContract(common.HexToAddress("0x0"), parsedAbi, nil, nil, nil)

expectedReceivedMap := map[string]interface{}{
expectedReceivedMap := map[string]any{
"content": hash,
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
"amount": big.NewInt(1),
Expand All @@ -230,8 +230,8 @@ func TestUnpackIndexedBytesTyLogIntoMap(t *testing.T) {
unpackAndCheck(t, bc, expectedReceivedMap, mockLog)
}

func unpackAndCheck(t *testing.T, bc *bind.BoundContract, expected map[string]interface{}, mockLog types.Log) {
received := make(map[string]interface{})
func unpackAndCheck(t *testing.T, bc *bind.BoundContract, expected map[string]any, mockLog types.Log) {
received := make(map[string]any)
if err := bc.UnpackLogIntoMap(received, "received", mockLog); err != nil {
t.Error(err)
}
Expand Down
2 changes: 1 addition & 1 deletion execution/abi/bind/bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]
}
buffer := new(bytes.Buffer)

funcs := map[string]interface{}{
funcs := map[string]any{
"bindtype": bindType[lang],
"bindtopictype": bindTopicType[lang],
"namedtype": namedType[lang],
Expand Down
Loading
Loading