Skip to content

Commit 9d07ffc

Browse files
committed
fix: type constraint
1 parent 2940a89 commit 9d07ffc

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
KeyringType,
1313
type EntropySourceId,
1414
} from '@metamask/keyring-api';
15-
import type { AccountId } from '@metamask/keyring-utils';
15+
import type { AccountId, EthKeyring } from '@metamask/keyring-utils';
1616
import type { Hex } from '@metamask/utils';
1717

1818
import type { TrezorKeyring } from './trezor-keyring';
@@ -51,16 +51,24 @@ export type TrezorKeyringV2Options = {
5151
type?: KeyringType.Trezor | KeyringType.OneKey;
5252
};
5353

54+
// TrezorKeyring.signTransaction returns `TypedTransaction | OldEthJsTransaction` for
55+
// backwards compatibility with old ethereumjs-tx, but EthKeyring expects `TypedTxData`.
56+
// The runtime behavior is correct - we cast the type to satisfy the constraint.
57+
type TrezorKeyringAsEthKeyring = TrezorKeyring & EthKeyring;
58+
5459
export class TrezorKeyringV2
55-
extends EthKeyringWrapper<TrezorKeyring, Bip44Account<KeyringAccount>>
60+
extends EthKeyringWrapper<
61+
TrezorKeyringAsEthKeyring,
62+
Bip44Account<KeyringAccount>
63+
>
5664
implements KeyringV2
5765
{
5866
readonly entropySource: EntropySourceId;
5967

6068
constructor(options: TrezorKeyringV2Options) {
6169
super({
6270
type: options.type ?? KeyringType.Trezor,
63-
inner: options.legacyKeyring,
71+
inner: options.legacyKeyring as TrezorKeyringAsEthKeyring,
6472
capabilities: trezorKeyringV2Capabilities,
6573
});
6674
this.entropySource = options.entropySource;

0 commit comments

Comments
 (0)