mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
accounts/abi/bind: print error log when identifier collision
This commit is contained in:
parent
c166c8da0a
commit
8c77a09a59
1 changed files with 20 additions and 7 deletions
|
|
@ -74,12 +74,18 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]
|
||||||
transacts = make(map[string]*tmplMethod)
|
transacts = make(map[string]*tmplMethod)
|
||||||
events = make(map[string]*tmplEvent)
|
events = make(map[string]*tmplEvent)
|
||||||
structs = make(map[string]*tmplStruct)
|
structs = make(map[string]*tmplStruct)
|
||||||
|
identifiers = 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
|
||||||
normalized.Name = methodNormalizer[lang](alias(aliases, original.Name))
|
// Ensure there is no duplicated identifier
|
||||||
|
identifier := methodNormalizer[lang](alias(aliases, original.Name))
|
||||||
|
if identifiers[identifier] {
|
||||||
|
return "", fmt.Errorf("dupliated identifier \"%s\"(normalized \"%s\"), use --alias for renaming", original.Name, identifier)
|
||||||
|
}
|
||||||
|
identifiers[identifier] = true
|
||||||
|
normalized.Name = identifier
|
||||||
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)
|
||||||
for j, input := range normalized.Inputs {
|
for j, input := range normalized.Inputs {
|
||||||
|
|
@ -114,7 +120,14 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]
|
||||||
}
|
}
|
||||||
// Normalize the event for capital cases and non-anonymous outputs
|
// Normalize the event for capital cases and non-anonymous outputs
|
||||||
normalized := original
|
normalized := original
|
||||||
normalized.Name = methodNormalizer[lang](alias(aliases, original.Name))
|
|
||||||
|
// Ensure there is no duplicated identifier
|
||||||
|
identifier := methodNormalizer[lang](alias(aliases, original.Name))
|
||||||
|
if identifiers[identifier] {
|
||||||
|
return "", fmt.Errorf("dupliated identifier \"%s\"(normalized \"%s\"), use --alias for renaming", original.Name, identifier)
|
||||||
|
}
|
||||||
|
identifiers[identifier] = true
|
||||||
|
normalized.Name = identifier
|
||||||
|
|
||||||
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)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue