'use strict';

var b58 = require('bs58');
var utils_types_string = require('../types/string.cjs');
var utils_types_bytes = require('../types/bytes.cjs');
var utils_error = require('../error.cjs');
require('crypto');
require('../interfaces.cjs');
require('../assert.cjs');
require('../types/iterable.cjs');
require('../types/object.cjs');
require('../inheritance.cjs');
require('../types/set.cjs');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var b58__default = /*#__PURE__*/_interopDefault(b58);

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

exports.decodeFromBase58 = decodeFromBase58;
exports.encodeAsBase58 = encodeAsBase58;
//# sourceMappingURL=base-58.cjs.map
