diff --git a/package-commonjs.json b/output/post-build/lib.commonjs/package-commonjs.json similarity index 100% rename from package-commonjs.json rename to output/post-build/lib.commonjs/package-commonjs.json diff --git a/src.ts/abi/fragments.ts b/src.ts/abi/fragments.ts index e72654d90d..c7dc1ccd91 100644 --- a/src.ts/abi/fragments.ts +++ b/src.ts/abi/fragments.ts @@ -137,10 +137,13 @@ const SimpleTokens: Record = { }; // Parser regexes to consume the next token -const regexWhitespace = new RegExp("^(\\s*)"); -const regexNumber = new RegExp("^([0-9]+)"); -const regexIdentifier = new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"); -const regexType = new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))"); +const regexWhitespacePrefix = new RegExp("^(\\s*)"); +const regexNumberPrefix = new RegExp("^([0-9]+)"); +const regexIdPrefix = new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"); + +// Parser regexs to check validity +const regexId = new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"); +const regexType = new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$"); /** * @ignore: @@ -293,7 +296,7 @@ function lex(text: string): TokenString { // Strip off any leading whitespace let cur = text.substring(offset); - let match = cur.match(regexWhitespace); + let match = cur.match(regexWhitespacePrefix); if (match) { offset += match[1].length; cur = text.substring(offset); @@ -347,7 +350,7 @@ function lex(text: string): TokenString { continue; } - match = cur.match(regexIdentifier); + match = cur.match(regexIdPrefix); if (match) { token.text = match[1]; offset += token.text.length; @@ -366,7 +369,7 @@ function lex(text: string): TokenString { continue; } - match = cur.match(regexNumber); + match = cur.match(regexNumberPrefix); if (match) { token.text = match[1]; token.type = "NUMBER"; @@ -841,7 +844,7 @@ export class ParamType { } const name = obj.name; - assertArgument(!name || (typeof(name) === "string" && name.match(regexIdentifier)), + assertArgument(!name || (typeof(name) === "string" && name.match(regexId)), "invalid name", "obj.name", name); let indexed = obj.indexed; @@ -1019,7 +1022,7 @@ export abstract class NamedFragment extends Fragment { */ constructor(guard: any, type: FragmentType, name: string, inputs: ReadonlyArray) { super(guard, type, inputs); - assertArgument(typeof(name) === "string" && name.match(regexIdentifier), + assertArgument(typeof(name) === "string" && name.match(regexId), "invalid identifier", "name", name); inputs = Object.freeze(inputs.slice()); defineProperties(this, { name });