From fd40efd5a1722d2f4a03de3c36625fa846a86d95 Mon Sep 17 00:00:00 2001 From: Monte Lai Date: Thu, 5 Mar 2026 09:57:11 +0800 Subject: [PATCH] feat: add new hardware entropy type option --- .../src/api/account-options.test.ts | 23 +++++++++++++++++++ .../keyring-api/src/api/account-options.ts | 5 ++++ 2 files changed, 28 insertions(+) diff --git a/packages/keyring-api/src/api/account-options.test.ts b/packages/keyring-api/src/api/account-options.test.ts index 1dd556860..b6c8f1284 100644 --- a/packages/keyring-api/src/api/account-options.test.ts +++ b/packages/keyring-api/src/api/account-options.test.ts @@ -99,4 +99,27 @@ describe('api', () => { `At path: entropy.type -- Expected the literal \`"mnemonic"\`, but received: "${options.entropy.type}"`, ); }); + + it('throws if options.entropy.type is Hardware (not implemented)', () => { + const options = { + entropy: { type: KeyringAccountEntropyTypeOption.Hardware }, + }; + + expect(() => assert(options, KeyringAccountOptionsStruct)).toThrow( + `At path: entropy.type -- Expected the literal \`"mnemonic"\`, but received: "${KeyringAccountEntropyTypeOption.Hardware}"`, + ); + }); + + it('throws if options.entropy.type is Hardware with additional fields', () => { + const options = { + entropy: { + type: KeyringAccountEntropyTypeOption.Hardware, + deviceId: 'some-device-id', + }, + }; + + expect(() => assert(options, KeyringAccountOptionsStruct)).toThrow( + `At path: entropy.type -- Expected the literal \`"mnemonic"\`, but received: "${KeyringAccountEntropyTypeOption.Hardware}"`, + ); + }); }); diff --git a/packages/keyring-api/src/api/account-options.ts b/packages/keyring-api/src/api/account-options.ts index a8fbbeb26..cc9c0270f 100644 --- a/packages/keyring-api/src/api/account-options.ts +++ b/packages/keyring-api/src/api/account-options.ts @@ -25,6 +25,11 @@ export enum KeyringAccountEntropyTypeOption { */ PrivateKey = 'private-key', + /** + * Indicates that the account was created from a hardware wallet. + */ + Hardware = 'hardware', + /** * Indicates that the account was created with custom, keyring-specific entropy. * This is an opaque type where the entropy source is managed internally by the keyring.