1 | import { base58 } from '@scure/base';
|
2 | import { createDecode, createEncode, createIs, createValidate } from '../base32/helpers.js';
|
3 | const config = {
|
4 | chars: '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz',
|
5 | coder: base58,
|
6 | ipfs: 'z',
|
7 | type: 'base58'
|
8 | };
|
9 | /**
|
10 | * @name base58Validate
|
11 | * @summary Validates a base58 value.
|
12 | * @description
|
13 | * Validates that the supplied value is valid base58, throwing exceptions if not
|
14 | */
|
15 | export const base58Validate = /*#__PURE__*/ createValidate(config);
|
16 | /**
|
17 | * @name base58Decode
|
18 | * @summary Decodes a base58 value.
|
19 | * @description
|
20 | * From the provided input, decode the base58 and return the result as an `Uint8Array`.
|
21 | */
|
22 | export const base58Decode = /*#__PURE__*/ createDecode(config, base58Validate);
|
23 | /**
|
24 | * @name base58Encode
|
25 | * @summary Creates a base58 value.
|
26 | * @description
|
27 | * From the provided input, create the base58 and return the result as a string.
|
28 | */
|
29 | export const base58Encode = /*#__PURE__*/ createEncode(config);
|
30 | /**
|
31 | * @name isBase58
|
32 | * @description Checks if the input is in base58, returning true/false
|
33 | */
|
34 | export const isBase58 = /*#__PURE__*/ createIs(base58Validate);
|