Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(keyring-eth-ledger-bridge): device id should be cleared up when forgetting a device #86

Merged
merged 1 commit into from
Nov 6, 2024
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-ledger-bridge/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: 90.14,
functions: 95.95,
lines: 94.76,
statements: 94.81,
lines: 94.77,
statements: 94.83,
},
},
});
11 changes: 11 additions & 0 deletions packages/keyring-eth-ledger-bridge/src/ledger-keyring.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,17 @@ describe('LedgerKeyring', function () {
expect(keyring.isUnlocked()).toBe(false);
expect(accounts).toHaveLength(0);
});

it('deviceId should be cleared after forgetting the device', async function () {
// Add an account
keyring.setAccountToUnlock(0);
await keyring.addAccounts();
keyring.setDeviceId('device-id');

// Wipe the keyring
keyring.forgetDevice();
expect(keyring.getDeviceId()).toBe('');
});
});

describe('attemptMakeApp', function () {
Expand Down
1 change: 1 addition & 0 deletions packages/keyring-eth-ledger-bridge/src/ledger-keyring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ export class LedgerKeyring extends EventEmitter {
}

forgetDevice(): void {
this.deviceId = '';
this.accounts = [];
this.page = 0;
this.unlockedAccount = 0;
Expand Down