]> git.ardis.lu - 4-byte-gen/commitdiff
Recognize $ in function name
authorArdis Lu <ardisglu@gmail.com>
Sat, 8 Jul 2023 07:23:27 +0000 (00:23 -0700)
committerArdis Lu <ardisglu@gmail.com>
Sat, 8 Jul 2023 07:23:27 +0000 (00:23 -0700)
Identifier regex from Solidity docs: https://docs.soliditylang.org/en/latest/grammar.html#a4.SolidityLexer.Identifier

index.html

index fcf8c7a96778636f56d516e1be11b7038cd90373..a8b4613ea1dd828299235a93cd63dd8277409361 100644 (file)
 
     // 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 )(?<name>[\w]+)\((?<parameters>.*?)\)/;
+        functionRegex = /^(function )(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)/;
       }
       else {
         fn = fn.replaceAll(/[;'"]/g, ''); // Clean all characters that definitely do not affect the signature
-        functionRegex = /^(function )?(?<name>[\w]+)\((?<parameters>.*?)\)/;
+        functionRegex = /^(function )?(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)/;
       }
 
       const { name, parameters } = functionRegex.exec(fn).groups;
This page took 0.044848 seconds and 4 git commands to generate.