Skip to content

Commit

Permalink
fix: throw error if fn sig has whitespaces (#3509)
Browse files Browse the repository at this point in the history
Fix #3055
  • Loading branch information
rahul-kothari committed Dec 1, 2023
1 parent f021041 commit 7671063
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions yarn-project/foundation/src/abi/function_selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ export class FunctionSelector {
* @returns Function selector.
*/
static fromSignature(signature: string): FunctionSelector {
// throw if signature contains whitespace
if (/\s/.test(signature)) {
throw new Error('Function Signature cannot contain whitespace');
}
return FunctionSelector.fromBuffer(keccak(Buffer.from(signature)).subarray(0, FunctionSelector.SIZE));
}

Expand Down

0 comments on commit 7671063

Please sign in to comment.