@mysten/sui
Version:
Sui TypeScript API(Work in Progress)
48 lines (47 loc) • 1.73 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var mnemonics_exports = {};
__export(mnemonics_exports, {
isValidBIP32Path: () => isValidBIP32Path,
isValidHardenedPath: () => isValidHardenedPath,
mnemonicToSeed: () => mnemonicToSeed,
mnemonicToSeedHex: () => mnemonicToSeedHex
});
module.exports = __toCommonJS(mnemonics_exports);
var import_bcs = require("@mysten/bcs");
var import_bip39 = require("@scure/bip39");
function isValidHardenedPath(path) {
if (!new RegExp("^m\\/44'\\/784'\\/[0-9]+'\\/[0-9]+'\\/[0-9]+'+$").test(path)) {
return false;
}
return true;
}
function isValidBIP32Path(path) {
if (!new RegExp("^m\\/(54|74)'\\/784'\\/[0-9]+'\\/[0-9]+\\/[0-9]+$").test(path)) {
return false;
}
return true;
}
function mnemonicToSeed(mnemonics) {
return (0, import_bip39.mnemonicToSeedSync)(mnemonics, "");
}
function mnemonicToSeedHex(mnemonics) {
return (0, import_bcs.toHex)(mnemonicToSeed(mnemonics));
}
//# sourceMappingURL=mnemonics.js.map
;