import b58 from 'bs58';
import { ensureString } from '../types/string.js';
import { normalizeToU8a } from '../types/bytes.js';
import { catchFnErrorWith } from '../error.js';
import 'crypto';
import '../interfaces.js';
import '../assert.js';
import '../types/iterable.js';
import '../types/object.js';
import '../inheritance.js';
import '../types/set.js';

/**
 * Encodes supplied bytes as base58 string.
 * @param {Uint8Array} bytes
 * @returns {string}
 */
const encodeAsBase58 = (bytes) => b58.encode(normalizeToU8a(bytes));
/**
 * Decodes bytes of the supplied base58 string.
 * @param {string} string
 * @returns {Uint8Array}
 */
const decodeFromBase58 = catchFnErrorWith(
  'Invalid base58btc string',
  (string) => b58.decode(ensureString(string)),
);

export { decodeFromBase58, encodeAsBase58 };
//# sourceMappingURL=base-58.js.map
