From 760d30c270d33ce414d3e3be3ade15b836e8407c Mon Sep 17 00:00:00 2001 From: Nicolas Di Prima Date: Wed, 31 Oct 2018 15:20:21 +0000 Subject: [PATCH 1/2] add test to show what is happening with issue #39 --- js/tests/from-seed.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 js/tests/from-seed.js diff --git a/js/tests/from-seed.js b/js/tests/from-seed.js new file mode 100644 index 0000000..2b5e6f7 --- /dev/null +++ b/js/tests/from-seed.js @@ -0,0 +1,24 @@ +const expect = require('chai').expect; +const CardanoCrypto = require('../../dist/index.js'); + +const SEED = Array(32).fill(0); + +describe('Wallet FromSeed', async function() { + let xprv = null; + let wallet = null; + let account = null; + + before(async () => { + await CardanoCrypto.loadRustModule() + }); + + it("check seed size", function() { + expect(SEED.length).equals(CardanoCrypto.HdWallet.SEED_SIZE); + }); + it("create a wallet", function() { + const result = CardanoCrypto.Wallet.fromSeed(SEED); + console.log(result); + expect(result.failed).equals(false); + wallet = result.result; + }); +}); From 5d4528d79556cb25782effa72e8be93a60f309ca Mon Sep 17 00:00:00 2001 From: Nicolas Di Prima Date: Wed, 31 Oct 2018 15:19:39 +0000 Subject: [PATCH 2/2] fix the issue where we compare the SEED.length to undefined fix #39 --- js/HdWallet.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/js/HdWallet.js b/js/HdWallet.js index 838a877..e5e3437 100644 --- a/js/HdWallet.js +++ b/js/HdWallet.js @@ -3,10 +3,10 @@ import RustModule from './RustModule'; import { newArray, newArray0, copyArray } from './utils/arrays'; import { apply } from './utils/functions'; -const SEED_SIZE = 32; -const XPRV_SIZE = 96; -const XPUB_SIZE = 64; -const SIGNATURE_SIZE = 64; +export const SEED_SIZE = 32; +export const XPRV_SIZE = 96; +export const XPUB_SIZE = 64; +export const SIGNATURE_SIZE = 64; /** @@ -167,5 +167,9 @@ export default { derivePublic: apply(derivePublic, RustModule), sign: apply(sign, RustModule), publicKeyToAddress: apply(publicKeyToAddress, RustModule), - addressGetPayload: apply(addressGetPayload, RustModule) + addressGetPayload: apply(addressGetPayload, RustModule), + SEED_SIZE: SEED_SIZE, + XPRV_SIZE: XPRV_SIZE, + XPUB_SIZE: XPUB_SIZE, + SIGNATURE_SIZE: SIGNATURE_SIZE, };