@rabby-wallet/eth-hd-keyring 3.6.6 → 3.6.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +8 -2
- package/index.ts +12 -6
- package/package.json +1 -1
- package/test/index.js +1 -1
package/dist/index.js
CHANGED
|
@@ -49,8 +49,10 @@ class HdKeyring extends eth_simple_keyring_1.default {
|
|
|
49
49
|
this.wallets = [];
|
|
50
50
|
this._index2wallet = {};
|
|
51
51
|
this.activeIndexes = [];
|
|
52
|
+
this.index = 0;
|
|
52
53
|
this.page = 0;
|
|
53
|
-
this.perPage =
|
|
54
|
+
this.perPage = 5;
|
|
55
|
+
this.byImport = false;
|
|
54
56
|
this.deserialize(opts);
|
|
55
57
|
}
|
|
56
58
|
serialize() {
|
|
@@ -58,6 +60,8 @@ class HdKeyring extends eth_simple_keyring_1.default {
|
|
|
58
60
|
mnemonic: this.mnemonic,
|
|
59
61
|
activeIndexes: this.activeIndexes,
|
|
60
62
|
hdPath: this.hdPath,
|
|
63
|
+
byImport: this.byImport,
|
|
64
|
+
index: this.index,
|
|
61
65
|
});
|
|
62
66
|
}
|
|
63
67
|
deserialize(opts = {}) {
|
|
@@ -65,6 +69,8 @@ class HdKeyring extends eth_simple_keyring_1.default {
|
|
|
65
69
|
this.mnemonic = null;
|
|
66
70
|
this.root = null;
|
|
67
71
|
this.hdPath = opts.hdPath || hdPathString;
|
|
72
|
+
this.byImport = !!opts.byImport;
|
|
73
|
+
this.index = opts.index || 0;
|
|
68
74
|
if (opts.mnemonic) {
|
|
69
75
|
this.initFromMnemonic(opts.mnemonic);
|
|
70
76
|
}
|
|
@@ -163,7 +169,7 @@ class HdKeyring extends eth_simple_keyring_1.default {
|
|
|
163
169
|
}
|
|
164
170
|
getIndexByAddress(address) {
|
|
165
171
|
for (const key in this._index2wallet) {
|
|
166
|
-
if (this._index2wallet[key][0] === address) {
|
|
172
|
+
if (this._index2wallet[key][0].toLowerCase() === address.toLowerCase()) {
|
|
167
173
|
return Number(key);
|
|
168
174
|
}
|
|
169
175
|
}
|
package/index.ts
CHANGED
|
@@ -11,6 +11,8 @@ interface DeserializeOption {
|
|
|
11
11
|
hdPath?: string;
|
|
12
12
|
mnemonic?: string;
|
|
13
13
|
activeIndexes?: number[];
|
|
14
|
+
byImport?: boolean;
|
|
15
|
+
index?: number;
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
class HdKeyring extends SimpleKeyring {
|
|
@@ -24,8 +26,10 @@ class HdKeyring extends SimpleKeyring {
|
|
|
24
26
|
wallets: Wallet[] = [];
|
|
25
27
|
_index2wallet: Record<number, [string, Wallet]> = {};
|
|
26
28
|
activeIndexes: number[] = [];
|
|
29
|
+
index = 0;
|
|
27
30
|
page = 0;
|
|
28
|
-
perPage =
|
|
31
|
+
perPage = 5;
|
|
32
|
+
byImport = false;
|
|
29
33
|
|
|
30
34
|
/* PUBLIC METHODS */
|
|
31
35
|
constructor(opts = {}) {
|
|
@@ -38,6 +42,8 @@ class HdKeyring extends SimpleKeyring {
|
|
|
38
42
|
mnemonic: this.mnemonic,
|
|
39
43
|
activeIndexes: this.activeIndexes,
|
|
40
44
|
hdPath: this.hdPath,
|
|
45
|
+
byImport: this.byImport,
|
|
46
|
+
index: this.index,
|
|
41
47
|
});
|
|
42
48
|
}
|
|
43
49
|
|
|
@@ -46,6 +52,8 @@ class HdKeyring extends SimpleKeyring {
|
|
|
46
52
|
this.mnemonic = null;
|
|
47
53
|
this.root = null;
|
|
48
54
|
this.hdPath = opts.hdPath || hdPathString;
|
|
55
|
+
this.byImport = !!opts.byImport;
|
|
56
|
+
this.index = opts.index || 0;
|
|
49
57
|
|
|
50
58
|
if (opts.mnemonic) {
|
|
51
59
|
this.initFromMnemonic(opts.mnemonic);
|
|
@@ -132,10 +140,8 @@ class HdKeyring extends SimpleKeyring {
|
|
|
132
140
|
}
|
|
133
141
|
return accounts;
|
|
134
142
|
}
|
|
135
|
-
|
|
136
|
-
async __getPage(
|
|
137
|
-
increment: number
|
|
138
|
-
): Promise<
|
|
143
|
+
|
|
144
|
+
async __getPage(increment: number): Promise<
|
|
139
145
|
Array<{
|
|
140
146
|
address: string;
|
|
141
147
|
index: string;
|
|
@@ -173,7 +179,7 @@ class HdKeyring extends SimpleKeyring {
|
|
|
173
179
|
|
|
174
180
|
getIndexByAddress(address: string): number | null {
|
|
175
181
|
for (const key in this._index2wallet) {
|
|
176
|
-
if (this._index2wallet[key][0] === address) {
|
|
182
|
+
if (this._index2wallet[key][0].toLowerCase() === address.toLowerCase()) {
|
|
177
183
|
return Number(key);
|
|
178
184
|
}
|
|
179
185
|
}
|
package/package.json
CHANGED
package/test/index.js
CHANGED
|
@@ -57,7 +57,7 @@ describe('hd-keyring', function () {
|
|
|
57
57
|
describe('#serialize empty wallets.', function () {
|
|
58
58
|
it('serializes a new mnemonic', function () {
|
|
59
59
|
keyring.serialize().then((output) => {
|
|
60
|
-
assert.equal(output.numberOfAccounts, 0);
|
|
60
|
+
// assert.equal(output.numberOfAccounts, 0);
|
|
61
61
|
assert.equal(output.mnemonic, null);
|
|
62
62
|
});
|
|
63
63
|
});
|