We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f6d155c commit ccac24aCopy full SHA for ccac24a
src.ts/utils/base58.ts
@@ -42,12 +42,21 @@ const BN_58 = BigInt(58);
42
* Encode %%value%% as a Base58-encoded string.
43
*/
44
export function encodeBase58(_value: BytesLike): string {
45
- let value = toBigInt(getBytes(_value));
+ const bytes = getBytes(_value);
46
+
47
+ let value = toBigInt(bytes);
48
let result = "";
49
while (value) {
50
result = Alphabet[Number(value % BN_58)] + result;
51
value /= BN_58;
52
}
53
54
+ // Account for leading padding zeros
55
+ for (let i = 0; i < bytes.length; i++) {
56
+ if (bytes[i]) { break; }
57
+ result = Alphabet[0] + result;
58
+ }
59
60
return result;
61
62
0 commit comments