Skip to content

Commit d3c7707

Browse files
authored
Revert "accounts/abi: resolve name conflict for methods starting with a number (ethereum#26999)"
This reverts commit 5b6fa97.
1 parent 003e5b2 commit d3c7707

File tree

2 files changed

+1
-39
lines changed

2 files changed

+1
-39
lines changed

accounts/abi/bind/bind.go

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -133,19 +133,12 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]
133133
// Normalize the method for capital cases and non-anonymous inputs/outputs
134134
normalized := original
135135
normalizedName := methodNormalizer[lang](alias(aliases, original.Name))
136+
136137
// Ensure there is no duplicated identifier
137138
var identifiers = callIdentifiers
138139
if !original.IsConstant() {
139140
identifiers = transactIdentifiers
140141
}
141-
// Name shouldn't start with a digit. It will make the generated code invalid.
142-
if len(normalizedName) > 0 && unicode.IsDigit(rune(normalizedName[0])) {
143-
normalizedName = fmt.Sprintf("M%s", normalizedName)
144-
normalizedName = abi.ResolveNameConflict(normalizedName, func(name string) bool {
145-
_, ok := identifiers[name]
146-
return ok
147-
})
148-
}
149142
if identifiers[normalizedName] {
150143
return "", fmt.Errorf("duplicated identifier \"%s\"(normalized \"%s\"), use --alias for renaming", original.Name, normalizedName)
151144
}
@@ -189,14 +182,6 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]
189182

190183
// Ensure there is no duplicated identifier
191184
normalizedName := methodNormalizer[lang](alias(aliases, original.Name))
192-
// Name shouldn't start with a digit. It will make the generated code invalid.
193-
if len(normalizedName) > 0 && unicode.IsDigit(rune(normalizedName[0])) {
194-
normalizedName = fmt.Sprintf("E%s", normalizedName)
195-
normalizedName = abi.ResolveNameConflict(normalizedName, func(name string) bool {
196-
_, ok := eventIdentifiers[name]
197-
return ok
198-
})
199-
}
200185
if eventIdentifiers[normalizedName] {
201186
return "", fmt.Errorf("duplicated identifier \"%s\"(normalized \"%s\"), use --alias for renaming", original.Name, normalizedName)
202187
}

accounts/abi/bind/bind_test.go

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2038,29 +2038,6 @@ var bindTests = []struct {
20382038
t.Errorf("error deploying the contract: %v", err)
20392039
}
20402040
`,
2041-
}, {
2042-
name: "NumericMethodName",
2043-
contract: `
2044-
// SPDX-License-Identifier: GPL-3.0
2045-
pragma solidity >=0.4.22 <0.9.0;
2046-
2047-
contract NumericMethodName {
2048-
event _1TestEvent(address _param);
2049-
function _1test() public pure {}
2050-
function __1test() public pure {}
2051-
function __2test() public pure {}
2052-
}
2053-
`,
2054-
bytecode: []string{"0x6080604052348015600f57600080fd5b5060958061001e6000396000f3fe6080604052348015600f57600080fd5b5060043610603c5760003560e01c80639d993132146041578063d02767c7146049578063ffa02795146051575b600080fd5b60476059565b005b604f605b565b005b6057605d565b005b565b565b56fea26469706673582212200382ca602dff96a7e2ba54657985e2b4ac423a56abe4a1f0667bc635c4d4371f64736f6c63430008110033"},
2055-
abi: []string{`[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_param","type":"address"}],"name":"_1TestEvent","type":"event"},{"inputs":[],"name":"_1test","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"__1test","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"__2test","outputs":[],"stateMutability":"pure","type":"function"}]`},
2056-
imports: `
2057-
"github.com/ethereum/go-ethereum/common"
2058-
`,
2059-
tester: `
2060-
if b, err := NewNumericMethodName(common.Address{}, nil); b == nil || err != nil {
2061-
t.Fatalf("combined binding (%v) nil or error (%v) not nil", b, nil)
2062-
}
2063-
`,
20642041
},
20652042
}
20662043

0 commit comments

Comments
 (0)