Skip to content

Commit

Permalink
Merge pull request #618 from o1-labs/fix-length-check
Browse files Browse the repository at this point in the history
check for byte size instead of char length
  • Loading branch information
mitschabaude committed Dec 1, 2022
2 parents ff887a7 + c265eef commit 84b15fc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/lib/hash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,11 @@ class TokenSymbol extends Struct(TokenSymbolPure) {
}

static from(symbol: string): TokenSymbol {
if (symbol.length > 6)
throw Error('Token symbol length should be a maximum of 6');
let bytesLength = new TextEncoder().encode(symbol).length;
if (bytesLength > 6)
throw Error(
`Token symbol ${symbol} should be a maximum of 6 bytes, but is ${bytesLength}`
);
let field = prefixToField(symbol);
return { symbol, field };
}
Expand Down

0 comments on commit 84b15fc

Please sign in to comment.