Skip to content

Commit 0beaae5

Browse files
committed
fix: type constraint
1 parent 2940a89 commit 0beaae5

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

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

Lines changed: 8 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,21 @@ export type TrezorKeyringV2Options = {
5151
type?: KeyringType.Trezor | KeyringType.OneKey;
5252
};
5353

54+
// TrezorKeyring.signTransaction returns `TypedTransaction | EthereumTx` 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<TrezorKeyringAsEthKeyring, Bip44Account<KeyringAccount>>
5661
implements KeyringV2
5762
{
5863
readonly entropySource: EntropySourceId;
5964

6065
constructor(options: TrezorKeyringV2Options) {
6166
super({
6267
type: options.type ?? KeyringType.Trezor,
63-
inner: options.legacyKeyring,
68+
inner: options.legacyKeyring as TrezorKeyringAsEthKeyring,
6469
capabilities: trezorKeyringV2Capabilities,
6570
});
6671
this.entropySource = options.entropySource;

0 commit comments

Comments
 (0)