Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions packages/keyring-eth-trezor/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ module.exports = merge(baseConfig, {
global: {
branches: 48.27,
functions: 91.22,
lines: 88.35,
statements: 88.6,
lines: 89.89,
statements: 90.1,
},
},
});
26 changes: 19 additions & 7 deletions packages/keyring-eth-trezor/src/trezor-keyring.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,9 @@ describe('TrezorKeyring', function () {
keyring.setAccountToUnlock(0);
await keyring.addAccounts();
keyring.setAccountToUnlock(2);
const accounts = await keyring.addAccounts();
await keyring.addAccounts();

const accounts = await keyring.getAccounts();
expect(accounts[0]).toBe(fakeAccounts[0]);
expect(accounts[1]).toBe(fakeAccounts[2]);
});
Expand All @@ -246,16 +248,26 @@ describe('TrezorKeyring', function () {
describe('with a numeric argument', function () {
it('returns that number of accounts', async function () {
keyring.setAccountToUnlock(0);
const accounts = await keyring.addAccounts(5);
expect(accounts).toHaveLength(5);
const firstBatch = await keyring.addAccounts(3);
keyring.setAccountToUnlock(3);
const secondBatch = await keyring.addAccounts(2);

expect(firstBatch).toHaveLength(3);
expect(secondBatch).toHaveLength(2);
});

it('returns the expected accounts', async function () {
keyring.setAccountToUnlock(0);
const accounts = await keyring.addAccounts(3);
expect(accounts[0]).toBe(fakeAccounts[0]);
expect(accounts[1]).toBe(fakeAccounts[1]);
expect(accounts[2]).toBe(fakeAccounts[2]);
const firstBatch = await keyring.addAccounts(3);
keyring.setAccountToUnlock(3);
const secondBatch = await keyring.addAccounts(2);

expect(firstBatch).toStrictEqual([
fakeAccounts[0],
fakeAccounts[1],
fakeAccounts[2],
]);
expect(secondBatch).toStrictEqual([fakeAccounts[3], fakeAccounts[4]]);
});
});
});
Expand Down
4 changes: 3 additions & 1 deletion packages/keyring-eth-trezor/src/trezor-keyring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,17 @@ export class TrezorKeyring extends EventEmitter {
.then((_) => {
const from = this.unlockedAccount;
const to = from + n;
const newAccounts = [];

for (let i = from; i < to; i++) {
const address = this.#addressFromIndex(pathBase, i);
if (!this.accounts.includes(address)) {
this.accounts = [...this.accounts, address];
newAccounts.push(address);
}
this.page = 0;
}
resolve(this.accounts);
resolve(newAccounts);
})
.catch((e: Error) => {
reject(e);
Expand Down