mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-15 00:13:46 +00:00
simplify vars naming in normalizeArgs
This commit is contained in:
parent
ec0b3e52fe
commit
ddc897e52c
1 changed files with 10 additions and 10 deletions
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||||
"go/format"
|
"go/format"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
@ -134,25 +135,24 @@ func (cb *contractBinder) bindMethod(original abi.Method) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func normalizeArgs(inp abi.Arguments) abi.Arguments {
|
func normalizeArgs(args abi.Arguments) abi.Arguments {
|
||||||
normalizedArguments := make([]abi.Argument, len(inp))
|
args = slices.Clone(args)
|
||||||
copy(normalizedArguments, inp)
|
|
||||||
used := make(map[string]bool)
|
used := make(map[string]bool)
|
||||||
|
|
||||||
for i, input := range normalizedArguments {
|
for i, input := range args {
|
||||||
if input.Name == "" || isKeyWord(input.Name) {
|
if input.Name == "" || isKeyWord(input.Name) {
|
||||||
normalizedArguments[i].Name = fmt.Sprintf("arg%d", i)
|
args[i].Name = fmt.Sprintf("arg%d", i)
|
||||||
}
|
}
|
||||||
normalizedArguments[i].Name = capitalise(normalizedArguments[i].Name)
|
args[i].Name = capitalise(args[i].Name)
|
||||||
for index := 0; ; index++ {
|
for index := 0; ; index++ {
|
||||||
if !used[normalizedArguments[i].Name] {
|
if !used[args[i].Name] {
|
||||||
used[normalizedArguments[i].Name] = true
|
used[args[i].Name] = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
normalizedArguments[i].Name = fmt.Sprintf("%s%d", normalizedArguments[i].Name, index)
|
args[i].Name = fmt.Sprintf("%s%d", args[i].Name, index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return normalizedArguments
|
return args
|
||||||
}
|
}
|
||||||
|
|
||||||
// normalizeErrorOrEventFields normalizes errors/events for emitting through bindings:
|
// normalizeErrorOrEventFields normalizes errors/events for emitting through bindings:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue