Skip to content
This repository was archived by the owner on Oct 7, 2024. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ const type = 'HD Key Tree';

class HdKeyring extends SimpleKeyring {
/* PUBLIC METHODS */
constructor(opts = {}) {
super();
constructor(opts) {
super(opts);
this.type = type;
this.deserialize(opts);
// this.deserialize(opts);
}

generateRandomMnemonic() {
Expand All @@ -32,24 +32,26 @@ class HdKeyring extends SimpleKeyring {
});
}

deserialize(opts = {}) {
deserialize(opts) {
if (this.root) {
throw new Error(
'Eth-Hd-Keyring: Secret recovery phrase already provided',
);
}
this.opts = opts;
this.opts = opts || {};
this.wallets = [];
this.mnemonic = null;
this.root = null;
this.hdPath = opts.hdPath || hdPathString;
this.hdPath = this.opts.hdPath || hdPathString;

if (opts.mnemonic) {
this._initFromMnemonic(opts.mnemonic);
if (this.opts.mnemonic) {
this._initFromMnemonic(this.opts.mnemonic);
} else {
this.generateRandomMnemonic();
}
Comment on lines +49 to 51
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need this?


if (opts.numberOfAccounts) {
return this.addAccounts(opts.numberOfAccounts);
if (this.opts.numberOfAccounts) {
return this.addAccounts(this.opts.numberOfAccounts);
}

return Promise.resolve([]);
Expand Down
6 changes: 3 additions & 3 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ const secondAcct = '0x1b00aed43a693f3a957f9feb5cc08afa031e37a0';

describe('hd-keyring', () => {
let keyring;
beforeEach(() => {
keyring = new HdKeyring();
});
// beforeEach(() => {
// keyring = new HdKeyring();
// });

describe('constructor', () => {
it('constructs with a typeof string mnemonic', async () => {
Expand Down