Skip to content

Commit 3a51d54

Browse files
committed
fix: cursor feedback
1 parent 07cebae commit 3a51d54

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

packages/keyring-eth-qr/src/qr-keyring-v2.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,20 @@ describe('QrKeyringV2', () => {
628628
type: KeyringAccountEntropyTypeOption.Custom,
629629
});
630630
});
631+
632+
it('throws error in Account mode when address is not in paths map', async () => {
633+
const { wrapper, inner } = await createAccountModeWrapper();
634+
635+
// Mock serialize to return an inconsistent state
636+
jest.spyOn(inner, 'serialize').mockResolvedValue({
637+
...ACCOUNT_SERIALIZED_KEYRING_WITH_ACCOUNTS,
638+
paths: {}, // Empty paths - inconsistent with accounts
639+
});
640+
641+
await expect(wrapper.getAccounts()).rejects.toThrow(
642+
/not found in device paths/u,
643+
);
644+
});
631645
});
632646

633647
describe('createAccounts', () => {

packages/keyring-eth-qr/src/qr-keyring-v2.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,13 @@ export class QrKeyringV2
275275
return this.#createHdModeAccount(address, addressIndex);
276276
}
277277

278-
// Account mode: treat as private key import
278+
// Account mode: validate address exists in paths map
279+
const { paths } = deviceState as { paths: Record<Hex, string> };
280+
if (paths[address] === undefined) {
281+
throw new Error(
282+
`Address ${address} not found in device paths. This indicates an inconsistent keyring state.`,
283+
);
284+
}
279285
return this.#createAccountModeAccount(address);
280286
});
281287
}

0 commit comments

Comments
 (0)