mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
accounts/abi/bind: address comment
This commit is contained in:
parent
e4ddff2aad
commit
522e478f9e
1 changed files with 11 additions and 14 deletions
|
|
@ -79,25 +79,23 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]
|
||||||
// and event. For all calls, transacts and events, abigen will generate
|
// and event. For all calls, transacts and events, abigen will generate
|
||||||
// corresponding bindings. However we have to ensure there is no
|
// corresponding bindings. However we have to ensure there is no
|
||||||
// identifier coliision in the bindings of these categories.
|
// identifier coliision in the bindings of these categories.
|
||||||
//
|
callIdentifiers = make(map[string]bool)
|
||||||
// The key of identifiers map is the concat of function name and function type.
|
transactIdentifiers = make(map[string]bool)
|
||||||
identifiers = make(map[string]bool)
|
eventIdentifiers = make(map[string]bool)
|
||||||
)
|
)
|
||||||
for _, original := range evmABI.Methods {
|
for _, original := range evmABI.Methods {
|
||||||
// Normalize the method for capital cases and non-anonymous inputs/outputs
|
// Normalize the method for capital cases and non-anonymous inputs/outputs
|
||||||
normalized := original
|
normalized := original
|
||||||
// Ensure there is no duplicated identifier
|
|
||||||
normalizedName := methodNormalizer[lang](alias(aliases, original.Name))
|
normalizedName := methodNormalizer[lang](alias(aliases, original.Name))
|
||||||
id := normalizedName
|
// Ensure there is no duplicated identifier
|
||||||
if original.Const {
|
var identifiers = callIdentifiers
|
||||||
id += "call"
|
if !original.Const {
|
||||||
} else {
|
identifiers = transactIdentifiers
|
||||||
id += "transact"
|
|
||||||
}
|
}
|
||||||
if identifiers[id] {
|
if identifiers[normalizedName] {
|
||||||
return "", fmt.Errorf("duplicated identifier \"%s\"(normalized \"%s\"), use --alias for renaming", original.Name, normalizedName)
|
return "", fmt.Errorf("duplicated identifier \"%s\"(normalized \"%s\"), use --alias for renaming", original.Name, normalizedName)
|
||||||
}
|
}
|
||||||
identifiers[id] = true
|
identifiers[normalizedName] = true
|
||||||
normalized.Name = normalizedName
|
normalized.Name = normalizedName
|
||||||
normalized.Inputs = make([]abi.Argument, len(original.Inputs))
|
normalized.Inputs = make([]abi.Argument, len(original.Inputs))
|
||||||
copy(normalized.Inputs, original.Inputs)
|
copy(normalized.Inputs, original.Inputs)
|
||||||
|
|
@ -136,11 +134,10 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]
|
||||||
|
|
||||||
// Ensure there is no duplicated identifier
|
// Ensure there is no duplicated identifier
|
||||||
normalizedName := methodNormalizer[lang](alias(aliases, original.Name))
|
normalizedName := methodNormalizer[lang](alias(aliases, original.Name))
|
||||||
id := normalizedName + "event"
|
if eventIdentifiers[normalizedName] {
|
||||||
if identifiers[id] {
|
|
||||||
return "", fmt.Errorf("duplicated identifier \"%s\"(normalized \"%s\"), use --alias for renaming", original.Name, normalizedName)
|
return "", fmt.Errorf("duplicated identifier \"%s\"(normalized \"%s\"), use --alias for renaming", original.Name, normalizedName)
|
||||||
}
|
}
|
||||||
identifiers[id] = true
|
eventIdentifiers[normalizedName] = true
|
||||||
normalized.Name = normalizedName
|
normalized.Name = normalizedName
|
||||||
|
|
||||||
normalized.Inputs = make([]abi.Argument, len(original.Inputs))
|
normalized.Inputs = make([]abi.Argument, len(original.Inputs))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue