@rabby-wallet/eth-hd-keyring 3.6.2 → 3.6.6

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.
Files changed (3) hide show
  1. package/dist/index.js +23 -2
  2. package/index.ts +12 -3
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -50,7 +50,7 @@ class HdKeyring extends eth_simple_keyring_1.default {
50
50
  this._index2wallet = {};
51
51
  this.activeIndexes = [];
52
52
  this.page = 0;
53
- this.perPage = 5;
53
+ this.perPage = 10;
54
54
  this.deserialize(opts);
55
55
  }
56
56
  serialize() {
@@ -124,6 +124,19 @@ class HdKeyring extends eth_simple_keyring_1.default {
124
124
  getPreviousPage() {
125
125
  return this.__getPage(-1);
126
126
  }
127
+ getAddresses(start, end) {
128
+ const from = start;
129
+ const to = end;
130
+ const accounts = [];
131
+ for (let i = from; i < to; i++) {
132
+ const [address] = this._addressFromIndex(i);
133
+ accounts.push({
134
+ address,
135
+ index: i + 1,
136
+ });
137
+ }
138
+ return accounts;
139
+ }
127
140
  __getPage(increment) {
128
141
  return __awaiter(this, void 0, void 0, function* () {
129
142
  this.page += increment;
@@ -137,7 +150,7 @@ class HdKeyring extends eth_simple_keyring_1.default {
137
150
  const [address] = this._addressFromIndex(i);
138
151
  accounts.push({
139
152
  address,
140
- index: i,
153
+ index: i + 1,
141
154
  });
142
155
  }
143
156
  return accounts;
@@ -148,6 +161,14 @@ class HdKeyring extends eth_simple_keyring_1.default {
148
161
  return sigUtil.normalize(w.getAddress().toString('hex'));
149
162
  }));
150
163
  }
164
+ getIndexByAddress(address) {
165
+ for (const key in this._index2wallet) {
166
+ if (this._index2wallet[key][0] === address) {
167
+ return Number(key);
168
+ }
169
+ }
170
+ return null;
171
+ }
151
172
  /* PRIVATE METHODS */
152
173
  _addressFromIndex(i) {
153
174
  if (!this._index2wallet[i]) {
package/index.ts CHANGED
@@ -127,7 +127,7 @@ class HdKeyring extends SimpleKeyring {
127
127
  const [address] = this._addressFromIndex(i);
128
128
  accounts.push({
129
129
  address,
130
- index: i,
130
+ index: i + 1,
131
131
  });
132
132
  }
133
133
  return accounts;
@@ -156,7 +156,7 @@ class HdKeyring extends SimpleKeyring {
156
156
  const [address] = this._addressFromIndex(i);
157
157
  accounts.push({
158
158
  address,
159
- index: i,
159
+ index: i + 1,
160
160
  });
161
161
  }
162
162
 
@@ -167,10 +167,19 @@ class HdKeyring extends SimpleKeyring {
167
167
  return Promise.resolve(
168
168
  this.wallets.map((w) => {
169
169
  return sigUtil.normalize(w.getAddress().toString('hex'));
170
- })
170
+ }),
171
171
  );
172
172
  }
173
173
 
174
+ getIndexByAddress(address: string): number | null {
175
+ for (const key in this._index2wallet) {
176
+ if (this._index2wallet[key][0] === address) {
177
+ return Number(key);
178
+ }
179
+ }
180
+ return null;
181
+ }
182
+
174
183
  /* PRIVATE METHODS */
175
184
 
176
185
  _addressFromIndex(i: number): [string, Wallet] {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rabby-wallet/eth-hd-keyring",
3
- "version": "3.6.2",
3
+ "version": "3.6.6",
4
4
  "description": "A simple standard interface for a seed phrase generated set of Ethereum accounts.",
5
5
  "keywords": [
6
6
  "ethereum",