fix: a token symbol read off a contract is never stored cut mid-emoji (closes #458)
check / check (push) Successful in 5m33s
e2e / e2e-chrome (push) Successful in 5m20s
e2e / e2e-firefox (push) Successful in 2m52s

lookupTokenInfo() cut the symbol at 12 and the name at 64 UTF-16 units,
so an emoji outside the Basic Multilingual Plane could be cut between its
two halves and the half left over stored and shown as U+FFFD. Both are
now cut on code points, as displaySymbol() does. A symbol already stored
broken is not repaired.

Model: opus-5-5
This commit is contained in:
2026-10-06 20:41:52 +00:00
parent ad1b4f0557
commit cc9fdfac99
3 changed files with 63 additions and 3 deletions
+6 -3
View File
@@ -334,9 +334,12 @@ async function lookupTokenInfo(contractAddress, rpcUrl, networkId, signal) {
name = symbol;
}
// Truncate to prevent storage of excessively long values from RPC
name = String(name).slice(0, 64);
symbol = String(symbol).slice(0, 12);
// Truncate to prevent storage of excessively long values from RPC.
// Counted in code points, as displaySymbol() counts them, so the cut never
// falls between the two halves of an emoji and stores a half that renders
// as U+FFFD.
name = Array.from(String(name)).slice(0, 64).join("");
symbol = Array.from(String(symbol)).slice(0, 12).join("");
log.infof("Token resolved:", symbol, "decimals", Number(decimals));
return { name, symbol, decimals: Number(decimals) };