You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
constPrecisionLossWarning='Warning: Using type `number` with values that are large or contain many decimals may cause loss of precision, it is recommended to use type `string` or `BigInt` when using conversion methods';
82
+
constPrecisionLossWarning=
83
+
'Warning: Using type `number` with values that are large or contain many decimals may cause loss of precision, it is recommended to use type `string` or `BigInt` when using conversion methods';
83
84
84
85
exporttypeEtherUnits=keyoftypeofethUnitMap;
85
86
/**
@@ -366,7 +367,7 @@ export const toHex = (
366
367
returnreturnType ? 'bigint' : numberToHex(value);
367
368
}
368
369
369
-
if(isUint8Array(value)){
370
+
if(isUint8Array(value)){
370
371
returnreturnType ? 'bytes' : bytesToHex(value);
371
372
}
372
373
@@ -386,6 +387,15 @@ export const toHex = (
386
387
returnreturnType ? 'bytes' : `0x${value}`;
387
388
}
388
389
if(isHex(value)&&!isInt(value)&&isUInt(value)){
390
+
// This condition seems problematic because meeting
391
+
// both conditions `!isInt(value) && isUInt(value)` should be impossible.
392
+
// But a value pass for those conditions: "101611154195520776335741463917853444671577865378275924493376429267637792638729"
393
+
// Note that according to the docs: it is supposed to be treated as a string (https://docs.web3js.org/guides/web3_upgrade_guide/x/web3_utils_migration_guide#conversion-to-hex)
394
+
// In short, the strange is that isInt(value) is false but isUInt(value) is true for the value above.
395
+
// TODO: isUInt(value) should be investigated.
396
+
397
+
// However, if `toHex('101611154195520776335741463917853444671577865378275924493376429267637792638729', true)` is called, it will return `true`.
398
+
// But, if `toHex('101611154195520776335741463917853444671577865378275924493376429267637792638729')` is called, it will throw inside `numberToHex`.
0 commit comments