From: Ardis Lu Date: Sat, 8 Jul 2023 07:23:27 +0000 (-0700) Subject: Recognize $ in function name X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=65854363c9422648d729af9968f777babbbfcd26;p=4-byte-gen Recognize $ in function name Identifier regex from Solidity docs: https://docs.soliditylang.org/en/latest/grammar.html#a4.SolidityLexer.Identifier --- diff --git a/index.html b/index.html index fcf8c7a..a8b4613 100644 --- a/index.html +++ b/index.html @@ -382,16 +382,13 @@ // Normalize and extract the function name and parameter types function splitFunction(fn, strict = false) { - // Extract the function name and parameters - // Original regex is from wagmi-dev/abitype - // https://github.com/wagmi-dev/abitype/blob/main/src/human-readable/runtime/signatures.ts#L31 let functionRegex; if (strict) { - functionRegex = /^(function )(?[\w]+)\((?.*?)\)/; + functionRegex = /^(function )(?[a-zA-Z$_][a-zA-Z0-9$_]*)\((?.*?)\)/; } else { fn = fn.replaceAll(/[;'"]/g, ''); // Clean all characters that definitely do not affect the signature - functionRegex = /^(function )?(?[\w]+)\((?.*?)\)/; + functionRegex = /^(function )?(?[a-zA-Z$_][a-zA-Z0-9$_]*)\((?.*?)\)/; } const { name, parameters } = functionRegex.exec(fn).groups;