This commit is contained in:
Jared Wasinger 2024-12-20 17:57:36 +07:00 committed by Felix Lange
parent 5eb7271f0b
commit 6a007cac18
16 changed files with 331 additions and 66 deletions

View file

@ -134,11 +134,9 @@ func (cb *contractBinder) bindMethod(original abi.Method) error {
return nil
}
// normalizeErrorOrEventFields normalizes errors/events for emitting through bindings:
// Any anonymous fields are given generated names.
func (cb *contractBinder) normalizeErrorOrEventFields(originalInputs abi.Arguments) abi.Arguments {
normalizedArguments := make([]abi.Argument, len(originalInputs))
copy(normalizedArguments, originalInputs)
func normalizeArgs(inp abi.Arguments) abi.Arguments {
normalizedArguments := make([]abi.Argument, len(inp))
copy(normalizedArguments, inp)
used := make(map[string]bool)
for i, input := range normalizedArguments {
@ -152,6 +150,15 @@ func (cb *contractBinder) normalizeErrorOrEventFields(originalInputs abi.Argumen
}
normalizedArguments[i].Name = fmt.Sprintf("%s%d", normalizedArguments[i].Name, index)
}
}
return normalizedArguments
}
// normalizeErrorOrEventFields normalizes errors/events for emitting through bindings:
// Any anonymous fields are given generated names.
func (cb *contractBinder) normalizeErrorOrEventFields(originalInputs abi.Arguments) abi.Arguments {
normalizedArguments := normalizeArgs(originalInputs)
for _, input := range normalizedArguments {
if hasStruct(input.Type) {
cb.binder.BindStructType(input.Type)
}

File diff suppressed because one or more lines are too long

View file

@ -19,6 +19,9 @@ package v2
import (
"context"
"encoding/json"
"github.com/ethereum/go-ethereum/accounts/abi/bind/v2/internal/contracts/events"
"github.com/ethereum/go-ethereum/accounts/abi/bind/v2/internal/contracts/nested_libraries"
"github.com/ethereum/go-ethereum/accounts/abi/bind/v2/internal/contracts/solc_errors"
"io"
"math/big"
"os"
@ -30,9 +33,6 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
"github.com/ethereum/go-ethereum/accounts/abi/bind/v2/internal/events"
"github.com/ethereum/go-ethereum/accounts/abi/bind/v2/internal/nested_libraries"
"github.com/ethereum/go-ethereum/accounts/abi/bind/v2/internal/solc_errors"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/compiler"
@ -474,3 +474,5 @@ func TestBindingGeneration(t *testing.T) {
}
}
}
// contract test ideas (from the v1 bind tests): error that takes struct argument. constructor that takes struct arg.