From a6e128f5cc566d291b722cca1734ba41aae6c548 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Thu, 10 Jun 2021 17:47:17 -0400 Subject: [PATCH] Match Solidity identifier regex (#1657). --- packages/abi/src.ts/fragments.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/abi/src.ts/fragments.ts b/packages/abi/src.ts/fragments.ts index d66ac601d..5feff220c 100644 --- a/packages/abi/src.ts/fragments.ts +++ b/packages/abi/src.ts/fragments.ts @@ -1029,7 +1029,8 @@ function verifyType(type: string): string { return type; } -const regexIdentifier = new RegExp("^[A-Za-z_][A-Za-z0-9_]*$"); +// See: https://github.com/ethereum/solidity/blob/1f8f1a3db93a548d0555e3e14cfc55a10e25b60e/docs/grammar/SolidityLexer.g4#L234 +const regexIdentifier = new RegExp("^[a-zA-Z$_][a-zA-Z0-9$_]*$"); function verifyIdentifier(value: string): string { if (!value || !value.match(regexIdentifier)) { logger.throwArgumentError(`invalid identifier "${ value }"`, "value", value);