Skip to content

Commit c5c27eb

Browse files
authored
fix invalid safeguard for solidity types (#122)
### TL;DR Fixed Solidity type checking by using string prefix matching for integer types. ### What changed? Replaced explicit mapping of integer types (uint8, int16, etc.) with a prefix check for "uint" and "int". Non-integer types like address, bool, and string remain in the map. ### How to test? 1. Test type checking with various integer types (uint8, int256, etc.) 2. Verify that non-integer types (address, bool, string) are still correctly identified 3. Ensure negative cases (non-types) return false ### Why make this change? The previous implementation listed every possible integer type explicitly, which was verbose and harder to maintain. Uints and ints can be in 8 byte increments.
2 parents fa85f6b + 1618c92 commit c5c27eb

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

internal/common/utils.go

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -143,21 +143,10 @@ func cleanType(param string) string {
143143

144144
// isType checks if a word is a Solidity type
145145
func isType(word string) bool {
146+
if strings.HasPrefix(word, "uint") || strings.HasPrefix(word, "int") {
147+
return true
148+
}
146149
types := map[string]bool{
147-
"uint": true,
148-
"int": true,
149-
"uint8": true,
150-
"int8": true,
151-
"uint16": true,
152-
"int16": true,
153-
"uint32": true,
154-
"int32": true,
155-
"uint64": true,
156-
"int64": true,
157-
"uint128": true,
158-
"int128": true,
159-
"uint256": true,
160-
"int256": true,
161150
"address": true,
162151
"bool": true,
163152
"string": true,

0 commit comments

Comments
 (0)