Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
ruixhuang committed Sep 13, 2024
1 parent 7ff26db commit 3ec1343
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
13 changes: 4 additions & 9 deletions v4-client-js/__native__/__ios__/v4-native-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -207121,16 +207121,11 @@ const helpers_1 = __webpack_require__(/*! ./helpers */ "./src/lib/helpers.ts");
*/
const exportMnemonicAndPrivateKey = (entropy, path = "m/44'/118'/0'/0/0") => {
const mnemonic = (0, bip39_1.entropyToMnemonic)(entropy, english_1.wordlist);
const seed = (0, bip39_1.mnemonicToSeedSync)(mnemonic);
const hdkey = bip32_1.HDKey.fromMasterSeed(seed);
const derivedHdkey = hdkey.derive(path);
if (!hdkey.privateKey) {
throw new Error('null hd key');
}
const { privateKey, publicKey } = (0, exports.deriveHDKeyFromMnemonic)(mnemonic, path);
return {
mnemonic,
privateKey: derivedHdkey.privateKey,
publicKey: derivedHdkey.publicKey,
privateKey,
publicKey,
};
};
exports.exportMnemonicAndPrivateKey = exportMnemonicAndPrivateKey;
Expand Down Expand Up @@ -207177,7 +207172,7 @@ const deriveHDKeyFromMnemonic = (mnemonic, path = "m/44'/118'/0'/0/0") => {
};
};
exports.deriveHDKeyFromMnemonic = deriveHDKeyFromMnemonic;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib25ib2FyZGluZy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9saWIvb25ib2FyZGluZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSx3Q0FBcUM7QUFDckMsd0NBQXFFO0FBQ3JFLDREQUEwRDtBQUMxRCx5REFBeUQ7QUFFekQsdUNBQTJDO0FBRTNDOzs7Ozs7Ozs7Ozs7R0FZRztBQUNJLE1BQU0sMkJBQTJCLEdBQUcsQ0F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0FBQyxDQUFDO0FBQzlDLENBQUMsQ0FBQztBQWxCVyxRQUFBLGdDQUFnQyxvQ0FrQjNDO0FBRUY7Ozs7Ozs7Ozs7OztHQVlHO0FBQ0ksTUFBTSx1QkFBdUIsR0FBRyxDQUNyQyxRQUFnQixFQUNoQixPQUFlLG1CQUFtQixFQUlsQyxFQUFFO0lBQ0YsTUFBTSxJQUFJLEdBQUcsSUFBQSwwQkFBa0IsRUFBQyxRQUFRLENBQUMsQ0FBQztJQUUxQyxNQUFNLEtBQUssR0FBRyxhQUFLLENBQUMsY0FBYyxDQUFDLElBQUksQ0FBQyxDQUFDO0lBQ3pDLE1BQU0sWUFBWSxHQUFHLEtBQUssQ0FBQyxNQUFNLENBQUMsSUFBSSxDQUFDLENBQUM7SUFFeEMsSUFBSSxDQUFDLEtBQUssQ0FBQyxVQUFVLEVBQUU7UUFDckIsTUFBTSxJQUFJLEtBQUssQ0FBQyxhQUFhLENBQUMsQ0FBQztLQUNoQztJQUVELE9BQU87UUFDTCxVQUFVLEVBQUUsWUFBWSxDQUFDLFVBQVU7UUFDbkMsU0FBUyxFQUFFLFlBQVksQ0FBQyxTQUFTO0tBQ2xDLENBQUM7QUFDSixDQUFDLENBQUM7QUFwQlcsUUFBQSx1QkFBdUIsMkJBb0JsQyJ9

/***/ }),

Expand Down
14 changes: 3 additions & 11 deletions v4-client-js/src/lib/onboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,11 @@ export const exportMnemonicAndPrivateKey = (
publicKey: Uint8Array | null;
} => {
const mnemonic = entropyToMnemonic(entropy, wordlist);
const seed = mnemonicToSeedSync(mnemonic);

const hdkey = HDKey.fromMasterSeed(seed);
const derivedHdkey = hdkey.derive(path);

if (!hdkey.privateKey) {
throw new Error('null hd key');
}

const { privateKey, publicKey } = deriveHDKeyFromMnemonic(mnemonic, path);
return {
mnemonic,
privateKey: derivedHdkey.privateKey,
publicKey: derivedHdkey.publicKey,
privateKey,
publicKey,
};
};

Expand Down

0 comments on commit 3ec1343

Please sign in to comment.