@sidhujag/sysweb3-keyring 2.1.7 → 2.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/cjs/hardware-transaction-authority.js +15 -11
- package/cjs/hardware-transaction-authority.js.map +1 -1
- package/cjs/hardware-wallet-manager.js +74 -119
- package/cjs/hardware-wallet-manager.js.map +1 -1
- package/cjs/hardware-wallet-types.js +16 -0
- package/cjs/hardware-wallet-types.js.map +1 -0
- package/cjs/host-keyring.js +32 -0
- package/cjs/host-keyring.js.map +1 -0
- package/cjs/index.js +1 -0
- package/cjs/index.js.map +1 -1
- package/cjs/keyring-core.js +96 -61
- package/cjs/keyring-core.js.map +1 -1
- package/cjs/keyring-manager.js +15 -16
- package/cjs/keyring-manager.js.map +1 -1
- package/cjs/ledger/host-types.js.map +1 -1
- package/cjs/ledger/index.js +24 -4
- package/cjs/ledger/index.js.map +1 -1
- package/cjs/ledger-hardware.js +15 -0
- package/cjs/ledger-hardware.js.map +1 -0
- package/cjs/software.js +6 -25
- package/cjs/software.js.map +1 -1
- package/cjs/transactions/ethereum.js +371 -494
- package/cjs/transactions/ethereum.js.map +1 -1
- package/cjs/transactions/evm-submission-failure.js +73 -0
- package/cjs/transactions/evm-submission-failure.js.map +1 -0
- package/cjs/transactions/evm-submission.js +35 -61
- package/cjs/transactions/evm-submission.js.map +1 -1
- package/cjs/transactions/ledger-signing.js +52 -0
- package/cjs/transactions/ledger-signing.js.map +1 -0
- package/cjs/transactions/prepared-evm.js +24 -1
- package/cjs/transactions/prepared-evm.js.map +1 -1
- package/cjs/transactions/trezor-signing.js +90 -0
- package/cjs/transactions/trezor-signing.js.map +1 -0
- package/cjs/trezor/connect.js +238 -243
- package/cjs/trezor/connect.js.map +1 -1
- package/cjs/trezor/host-types.js +19 -0
- package/cjs/trezor/host-types.js.map +1 -0
- package/cjs/trezor/index.js +75 -23
- package/cjs/trezor/index.js.map +1 -1
- package/cjs/trezor/webextension-host.js +118 -0
- package/cjs/trezor/webextension-host.js.map +1 -0
- package/cjs/trezor-hardware.js +16 -0
- package/cjs/trezor-hardware.js.map +1 -0
- package/cjs/types.js.map +1 -1
- package/esm/hardware-transaction-authority.js +14 -11
- package/esm/hardware-transaction-authority.js.map +1 -1
- package/esm/hardware-wallet-manager.js +20 -32
- package/esm/hardware-wallet-manager.js.map +1 -1
- package/esm/hardware-wallet-types.js +13 -0
- package/esm/hardware-wallet-types.js.map +1 -0
- package/esm/keyring-core.js +98 -63
- package/esm/keyring-core.js.map +1 -1
- package/esm/ledger/dmk-host.js +2 -0
- package/esm/ledger/dmk-host.js.map +1 -1
- package/esm/ledger/dmk-session.js +73 -8
- package/esm/ledger/dmk-session.js.map +1 -1
- package/esm/ledger/host-types.js.map +1 -1
- package/esm/ledger/index.js +22 -2
- package/esm/ledger/index.js.map +1 -1
- package/esm/transactions/ethereum.js +372 -495
- package/esm/transactions/ethereum.js.map +1 -1
- package/esm/transactions/evm-submission-failure.js +68 -0
- package/esm/transactions/evm-submission-failure.js.map +1 -0
- package/esm/transactions/evm-submission.js +32 -59
- package/esm/transactions/evm-submission.js.map +1 -1
- package/esm/transactions/ledger-signing.js +49 -0
- package/esm/transactions/ledger-signing.js.map +1 -0
- package/esm/transactions/prepared-evm.js +23 -1
- package/esm/transactions/prepared-evm.js.map +1 -1
- package/esm/transactions/trezor-signing.js +87 -0
- package/esm/transactions/trezor-signing.js.map +1 -0
- package/esm/trezor/connect.js +236 -209
- package/esm/trezor/connect.js.map +1 -1
- package/esm/trezor/host-types.js +16 -0
- package/esm/trezor/host-types.js.map +1 -0
- package/esm/trezor/index.js +74 -22
- package/esm/trezor/index.js.map +1 -1
- package/esm/types.js.map +1 -1
- package/package.json +61 -1
- package/types/hardware-transaction-authority.d.ts +1 -0
- package/types/hardware-wallet-manager.d.ts +6 -22
- package/types/hardware-wallet-types.d.ts +21 -0
- package/types/host-keyring.d.ts +16 -0
- package/types/index.d.ts +1 -0
- package/types/keyring-core.d.ts +12 -4
- package/types/keyring-manager.d.ts +5 -3
- package/types/ledger/dmk-host.d.ts +2 -0
- package/types/ledger/dmk-session.d.ts +9 -0
- package/types/ledger/host-types.d.ts +2 -0
- package/types/ledger/index.d.ts +3 -1
- package/types/ledger-hardware.d.ts +5 -0
- package/types/software.d.ts +2 -16
- package/types/transactions/ethereum.d.ts +11 -1
- package/types/transactions/evm-submission-failure.d.ts +11 -0
- package/types/transactions/evm-submission.d.ts +6 -8
- package/types/transactions/ledger-signing.d.ts +13 -0
- package/types/transactions/prepared-evm.d.ts +12 -0
- package/types/transactions/trezor-signing.d.ts +13 -0
- package/types/trezor/connect.d.ts +11 -9
- package/types/trezor/host-types.d.ts +25 -0
- package/types/trezor/index.d.ts +7 -7
- package/types/trezor/webextension-host.d.ts +7 -0
- package/types/trezor-hardware.d.ts +6 -0
- package/types/types.d.ts +16 -4
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { HardwareWalletManager } from './hardware-wallet-manager';
|
|
2
|
-
import {
|
|
2
|
+
import { HostKeyring } from './host-keyring';
|
|
3
3
|
import { LedgerKeyring } from './ledger';
|
|
4
4
|
import { TrezorKeyring } from './trezor';
|
|
5
5
|
import type { KeyringHost, KeyringOptions } from './keyring-host';
|
|
6
6
|
import type { LedgerHost } from './ledger/host-types';
|
|
7
7
|
import type { CaptureEvmSubmission } from './transactions/evm-submission';
|
|
8
|
+
import type { TrezorHost } from './trezor/host-types';
|
|
8
9
|
import type { IKeyringManager } from './types';
|
|
9
10
|
export type { ISysAccount } from './keyring-core';
|
|
10
|
-
export type { DeviceUnlockControls, DeviceUnlockPort, DeviceUnlockVaultPair, KeyringStoragePort, } from './keyring-core';
|
|
11
|
+
export type { DeviceUnlockControls, DeviceUnlockPort, DeviceUnlockVaultPair, KeyringStoragePort, PreparedSessionTransfer, } from './keyring-core';
|
|
11
12
|
export type KeyringManagerOptions = Omit<KeyringOptions, 'captureEvmSubmission'> & {
|
|
12
13
|
captureEvmSubmission: CaptureEvmSubmission;
|
|
14
|
+
trezorHost: TrezorHost;
|
|
13
15
|
} & ({
|
|
14
16
|
ledgerHost: LedgerHost;
|
|
15
17
|
hardwareManager?: never;
|
|
@@ -18,7 +20,7 @@ export type KeyringManagerOptions = Omit<KeyringOptions, 'captureEvmSubmission'>
|
|
|
18
20
|
hardwareManager: HardwareWalletManager;
|
|
19
21
|
});
|
|
20
22
|
/** Browser keyring with an explicit wallet authority and hardware adapter. */
|
|
21
|
-
export declare class KeyringManager extends
|
|
23
|
+
export declare class KeyringManager extends HostKeyring<LedgerKeyring, TrezorKeyring> implements IKeyringManager {
|
|
22
24
|
constructor(host: KeyringHost, options: KeyringManagerOptions);
|
|
23
25
|
static createInitialized(host: KeyringHost, seed: string, password: string, vaultStateGetter: () => any, options: KeyringManagerOptions): Promise<KeyringManager>;
|
|
24
26
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type LedgerEvmConfig, type LedgerHost } from './host-types';
|
|
2
2
|
export interface LedgerDmkHost extends LedgerHost {
|
|
3
|
+
/** Observe connection changes; read getStatus() in the callback. */
|
|
4
|
+
subscribeStatus(listener: () => void): () => void;
|
|
3
5
|
/** Start before enumerating. The returned capability is single use. */
|
|
4
6
|
beginDeviceSelection(signal?: AbortSignal): (candidate: object) => Promise<void>;
|
|
5
7
|
}
|
|
@@ -37,16 +37,22 @@ export declare class LedgerDmkSession {
|
|
|
37
37
|
private activeCancel;
|
|
38
38
|
private activeAbort;
|
|
39
39
|
private closing;
|
|
40
|
+
private closingResult;
|
|
41
|
+
private readonly closeObservers;
|
|
40
42
|
private stateSubscription;
|
|
41
43
|
private connectionAttempt;
|
|
42
44
|
private connectionAbort;
|
|
43
45
|
private deviceSelection;
|
|
44
46
|
private readonly invalidationListeners;
|
|
47
|
+
private readonly statusListeners;
|
|
48
|
+
private reportedConnected;
|
|
45
49
|
constructor(dmk: DeviceManagementKit, requireDeviceSelection?: boolean);
|
|
46
50
|
private get readyConnection();
|
|
47
51
|
getStatus(): {
|
|
48
52
|
connected: boolean;
|
|
49
53
|
};
|
|
54
|
+
subscribeStatus(listener: () => void): () => void;
|
|
55
|
+
private publishStatus;
|
|
50
56
|
onInvalidated(listener: () => void): () => void;
|
|
51
57
|
private invalidate;
|
|
52
58
|
/** The platform passes one candidate from its own current DMK picker. */
|
|
@@ -61,6 +67,9 @@ export declare class LedgerDmkSession {
|
|
|
61
67
|
private connectDevice;
|
|
62
68
|
/** Cancel revokes the result and closes I/O; it cannot undo on-device approval. */
|
|
63
69
|
disconnect(): Promise<void>;
|
|
70
|
+
private closeSession;
|
|
71
|
+
/** Join late vendor admission and its cleanup after immediate revocation. */
|
|
72
|
+
retire(): Promise<() => void>;
|
|
64
73
|
runExclusive<Output>(operation: (session: LedgerDmkOperation) => Promise<Output>, options?: LedgerOperationOptions): Promise<Output>;
|
|
65
74
|
runAction<Output>(createAction: (session: LedgerDmkOperation) => Action<Output>, options?: LedgerOperationOptions): Promise<Output>;
|
|
66
75
|
private awaitAction;
|
|
@@ -120,6 +120,8 @@ export interface LedgerHost {
|
|
|
120
120
|
useGrantedDevices?: boolean;
|
|
121
121
|
}, options?: LedgerOperationOptions): Promise<void>;
|
|
122
122
|
disconnect(): Promise<void>;
|
|
123
|
+
/** Complete cleanup and return a guard invalidated by any subsequent reopen. */
|
|
124
|
+
retire(): Promise<() => void>;
|
|
123
125
|
getStatus(): {
|
|
124
126
|
connected: boolean;
|
|
125
127
|
};
|
package/types/ledger/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConnectionStatus, HardwareWalletType } from '../hardware-wallet-
|
|
1
|
+
import { ConnectionStatus, HardwareWalletType } from '../hardware-wallet-types';
|
|
2
2
|
import type { HardwareWalletManager } from '../hardware-wallet-manager';
|
|
3
3
|
import type { LedgerHost, LedgerUtxoHost } from './host-types';
|
|
4
4
|
import type { IEvmMethods, IUTXOMethods } from './types';
|
|
@@ -22,4 +22,6 @@ export declare class LedgerKeyring {
|
|
|
22
22
|
status: ConnectionStatus;
|
|
23
23
|
};
|
|
24
24
|
destroy(): Promise<void>;
|
|
25
|
+
/** Complete teardown and prove that no shared-host operation has reopened it. */
|
|
26
|
+
retire(): Promise<() => void>;
|
|
25
27
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { LedgerKeyring } from './ledger';
|
|
2
|
+
import type { KeyringHardware } from './keyring-core';
|
|
3
|
+
import type { LedgerHost } from './ledger/host-types';
|
|
4
|
+
/** Use the same Ledger account and transaction adapters on every host. */
|
|
5
|
+
export declare function createLedgerHardware(host: LedgerHost): KeyringHardware<LedgerKeyring, undefined>;
|
package/types/software.d.ts
CHANGED
|
@@ -1,22 +1,8 @@
|
|
|
1
1
|
/** Software-only entry: explicit host storage, no browser/device initialization. */
|
|
2
|
-
import {
|
|
2
|
+
import { HostKeyring } from './host-keyring';
|
|
3
3
|
import type { KeyringHost, KeyringOptions } from './keyring-host';
|
|
4
|
-
|
|
5
|
-
import type { PreparedEvmSigningOptions, PreparedSoftwareEvmSigningRequest, SignedPreparedEvmTransaction } from './transactions/prepared-evm';
|
|
6
|
-
export declare class SoftwareKeyring extends KeyringCore<undefined, undefined> {
|
|
4
|
+
export declare class SoftwareKeyring extends HostKeyring<undefined, undefined> {
|
|
7
5
|
constructor(host: KeyringHost, options: KeyringOptions);
|
|
8
|
-
/**
|
|
9
|
-
* Derive a fixed-path Ethereum HD runtime account without network or storage
|
|
10
|
-
* writes. The returned password-encrypted xprv is internal runtime state,
|
|
11
|
-
* never a public account/catalogue DTO. The host owns index allocation.
|
|
12
|
-
*/
|
|
13
|
-
deriveEvmHdRuntimeAccount(request: EvmHdRuntimeAccountRequest, options: EvmHdRuntimeAccountOptions): Promise<EncryptedEvmHdRuntimeAccount>;
|
|
14
|
-
/**
|
|
15
|
-
* Sign exactly the prepared envelope without RPC, fee/nonce discovery or
|
|
16
|
-
* broadcasting. The host must journal the result before submitting it.
|
|
17
|
-
* A later lock cannot revoke already returned signed bytes.
|
|
18
|
-
*/
|
|
19
|
-
signPreparedEvmTransaction(request: PreparedSoftwareEvmSigningRequest, options: PreparedEvmSigningOptions): SignedPreparedEvmTransaction;
|
|
20
6
|
static createInitialized(host: KeyringHost, seed: string, password: string, vaultStateGetter: () => any, options: KeyringOptions): Promise<SoftwareKeyring>;
|
|
21
7
|
}
|
|
22
8
|
export { createKeyringHost } from './keyring-host';
|
|
@@ -4,7 +4,9 @@ import { BigNumber, TransactionResponse } from '../ethers-v6';
|
|
|
4
4
|
import { type EvmFeeReader } from '../evm-fees';
|
|
5
5
|
import { CustomJsonRpcProvider } from '../providers';
|
|
6
6
|
import { IResponseFromSendErcSignedTransaction, ISendSignedErc20TransactionProps, ISendSignedErc721TransactionProps, ISendSignedErc1155TransactionProps, IReviewedEvmTokenApproval, IEthereumTransactions, IEvmCancellationOptions, IEvmReplacementOptions, EvmFormattedSendArguments, SimpleTransactionRequest, KeyringAccountType, accountType, IGasParams } from '../types';
|
|
7
|
+
import { type PreparedEvmTransaction } from './evm-envelope';
|
|
7
8
|
import { type CaptureEvmSubmission } from './evm-submission';
|
|
9
|
+
import { type EvmDigestSignOptions, type PreparedSoftwareEvmSigningRequest, type PreparedEvmSigningOptions } from './prepared-evm';
|
|
8
10
|
import type { LedgerKeyring } from '../ledger';
|
|
9
11
|
import type { TrezorKeyring } from '../trezor';
|
|
10
12
|
/** Minimal trusted device capabilities used by EVM transaction routing. */
|
|
@@ -43,6 +45,7 @@ export declare class EthereumTransactions<TLedger extends EthereumLedgerSigner |
|
|
|
43
45
|
private requireTrezorSigner;
|
|
44
46
|
private assertHardwareSignerAvailable;
|
|
45
47
|
private captureSessionGuard;
|
|
48
|
+
private captureEvmAccountContext;
|
|
46
49
|
private captureEvmSigningContext;
|
|
47
50
|
private captureSubmission;
|
|
48
51
|
private authorizeHardwareTransaction;
|
|
@@ -52,7 +55,14 @@ export declare class EthereumTransactions<TLedger extends EthereumLedgerSigner |
|
|
|
52
55
|
signTypedData: (addr: string, typedData: TypedDataV1 | TypedMessage<any>, version: SignTypedDataVersion) => Promise<string>;
|
|
53
56
|
verifyUtxoAddress: (accountIndex: number, currency: string, slip44: number) => Promise<string | undefined>;
|
|
54
57
|
verifyTypedSignature: (data: TypedDataV1 | TypedMessage<any>, signature: string, version: SignTypedDataVersion) => string;
|
|
55
|
-
|
|
58
|
+
signPreparedEvmTransaction(input: PreparedSoftwareEvmSigningRequest, options: PreparedEvmSigningOptions): Readonly<{
|
|
59
|
+
rawTransaction: string;
|
|
60
|
+
hash: string;
|
|
61
|
+
unsignedHash: string;
|
|
62
|
+
from: string;
|
|
63
|
+
transaction: PreparedEvmTransaction;
|
|
64
|
+
}>;
|
|
65
|
+
ethSign: (params: string[], input: EvmDigestSignOptions) => Promise<string>;
|
|
56
66
|
signPersonalMessage: (params: string[]) => Promise<string>;
|
|
57
67
|
parsePersonalMessage: (hexMsg: string) => string;
|
|
58
68
|
verifyPersonalMessage: (message: string, sign: string) => string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type EvmSubmissionFailure = Readonly<{
|
|
2
|
+
transactionNotBroadcast: boolean;
|
|
3
|
+
signedTransactionHash?: string;
|
|
4
|
+
}>;
|
|
5
|
+
/** Return owned stage evidence only; unrecognized errors carry no classification. */
|
|
6
|
+
export declare function evmSubmissionFailure(error: unknown): EvmSubmissionFailure | undefined;
|
|
7
|
+
/** Preserve local evidence when an existing public API wraps its Error object. */
|
|
8
|
+
export declare function copyEvmSubmissionFailure(source: unknown, target: Error): void;
|
|
9
|
+
/** Internal callers supply observed stage facts, never provider error fields. */
|
|
10
|
+
export declare function annotateEvmSubmissionFailure(cause: unknown, observed: EvmSubmissionFailure): Error;
|
|
11
|
+
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Transaction } from 'ethers/transaction';
|
|
2
|
+
export { copyEvmSubmissionFailure, evmSubmissionFailure, } from './evm-submission-failure';
|
|
2
3
|
import type { EvmRetainedCancellationOrigin, EvmWalletNonce } from '../types';
|
|
3
4
|
export type EvmSubmissionContext = Readonly<{
|
|
4
5
|
account: Readonly<{
|
|
@@ -15,6 +16,11 @@ export type EvmSubmissionContext = Readonly<{
|
|
|
15
16
|
operation: 'send' | 'cancel' | 'speed-up' | 'erc20' | 'erc721' | 'erc1155';
|
|
16
17
|
originalHash?: string;
|
|
17
18
|
origin?: EvmRetainedCancellationOrigin;
|
|
19
|
+
/** Transient identity of the live host fee review, bound to these signed bytes. */
|
|
20
|
+
review?: Readonly<{
|
|
21
|
+
id: string;
|
|
22
|
+
unsignedHash: string;
|
|
23
|
+
}>;
|
|
18
24
|
walletNonce?: EvmWalletNonce;
|
|
19
25
|
}>;
|
|
20
26
|
/** Signed wire bytes only; never a key, password or mutable transaction request. */
|
|
@@ -54,17 +60,9 @@ export type EvmSubmissionBoundary = Readonly<{
|
|
|
54
60
|
export declare function captureEvmSubmission(input: EvmSubmissionContext, assertCurrent: () => void, capture: CaptureEvmSubmission): EvmSubmissionBoundary;
|
|
55
61
|
/** Refuse any new signature or dispatch without a captured durable port. */
|
|
56
62
|
export declare function assertDurableEvmSubmission(boundary: EvmSubmissionBoundary): void;
|
|
57
|
-
/** Only local stage evidence can label an error as a possibly dispatched send. */
|
|
58
|
-
export declare function evmSubmissionFailure(error: unknown): Readonly<{
|
|
59
|
-
transactionNotBroadcast: boolean;
|
|
60
|
-
signedTransactionHash?: string;
|
|
61
|
-
}>;
|
|
62
|
-
/** Preserve local evidence when an existing public API wraps its Error object. */
|
|
63
|
-
export declare function copyEvmSubmissionFailure(source: unknown, target: Error): void;
|
|
64
63
|
/** Compare signed wire bytes with the complete envelope captured before signing. */
|
|
65
64
|
export declare function assertSignedEvmTransactionMatches(rawTransaction: string, expectedUnsignedTransaction: string, expectedFrom?: string): Transaction;
|
|
66
65
|
/** Submit software-signed bytes through the captured durable boundary. */
|
|
67
66
|
export declare function submitSignedEvmTransaction<T>(rawTransaction: string, broadcast: EvmSignedBroadcast<T>, boundary: EvmSubmissionBoundary, beforeBroadcast: (() => void) | undefined, expectedUnsignedTransaction: string): Promise<T>;
|
|
68
67
|
/** @internal Device signatures always require a fresh live chain probe after persistence. */
|
|
69
68
|
export declare function submitSignedHardwareEvmTransaction<T>(rawTransaction: string, broadcast: EvmSignedBroadcast<T>, boundary: EvmSubmissionBoundary, beforeBroadcast: (() => void) | undefined, expectedUnsignedTransaction: string, verifyCurrentChain: () => Promise<void>): Promise<T>;
|
|
70
|
-
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { HardwareTransactionAuthority } from '../hardware-transaction-authority';
|
|
2
|
+
import type { IEvmMethods } from '../ledger/types';
|
|
3
|
+
/** Sign the reviewed bytes through the shared Ledger adapter without changing fees or nonce. */
|
|
4
|
+
export declare function signLedgerEvmTransaction(signer: {
|
|
5
|
+
evm: Pick<IEvmMethods, 'signEVMTransaction'>;
|
|
6
|
+
}, request: Readonly<{
|
|
7
|
+
accountIndex: number;
|
|
8
|
+
expectedAddress: string;
|
|
9
|
+
unsignedTransaction: string;
|
|
10
|
+
}>, authority: HardwareTransactionAuthority): Promise<Readonly<{
|
|
11
|
+
rawTransaction: string;
|
|
12
|
+
hash: string;
|
|
13
|
+
}>>;
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import type { PreparedEvmTransaction } from './evm-envelope';
|
|
2
|
+
export type EvmSigningIdentity = Readonly<{
|
|
3
|
+
id: number;
|
|
4
|
+
type: 'HDAccount' | 'Imported' | 'Ledger' | 'Trezor' | 'SmartAccount';
|
|
5
|
+
expectedAddress: string;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function snapshotEvmSigningIdentity(input: unknown): EvmSigningIdentity;
|
|
8
|
+
export type EvmDigestSignOptions = Readonly<{
|
|
9
|
+
selectedAccount: EvmSigningIdentity;
|
|
10
|
+
targetAccount: EvmSigningIdentity;
|
|
11
|
+
assertCurrent(): void;
|
|
12
|
+
}>;
|
|
2
13
|
export type PreparedSoftwareEvmSigningRequest = Readonly<{
|
|
14
|
+
selectedAccount: EvmSigningIdentity;
|
|
3
15
|
account: Readonly<{
|
|
4
16
|
id: number;
|
|
5
17
|
type: 'HDAccount' | 'Imported';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { HardwareTransactionAuthority } from '../hardware-transaction-authority';
|
|
2
|
+
import type { TrezorKeyring } from '../trezor';
|
|
3
|
+
/** Sign reviewed bytes through an explicitly hosted Trezor keyring. */
|
|
4
|
+
export declare function signTrezorEvmTransaction(signer: Pick<TrezorKeyring, 'signEthTransaction'>, request: Readonly<{
|
|
5
|
+
accountIndex: number;
|
|
6
|
+
coin: string;
|
|
7
|
+
expectedAddress: string;
|
|
8
|
+
slip44: number;
|
|
9
|
+
unsignedTransaction: string;
|
|
10
|
+
}>, authority: HardwareTransactionAuthority): Promise<Readonly<{
|
|
11
|
+
rawTransaction: string;
|
|
12
|
+
hash: string;
|
|
13
|
+
}>>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { HardwareTransactionAuthority } from '../hardware-transaction-authority';
|
|
2
|
-
import type {
|
|
3
|
-
type Client =
|
|
4
|
-
|
|
5
|
-
type ForwardedMethod =
|
|
2
|
+
import type { TrezorCalls, TrezorHost, TrezorMethod } from './host-types';
|
|
3
|
+
type Client = TrezorCalls;
|
|
4
|
+
type TransactionMethod = 'ethereumSignTransaction' | 'signTransaction';
|
|
5
|
+
type ForwardedMethod = Exclude<TrezorMethod, TransactionMethod>;
|
|
6
6
|
type Compatible<T> = T extends {
|
|
7
7
|
success: false;
|
|
8
8
|
} ? T & {
|
|
@@ -23,23 +23,25 @@ type CompatibleCall<FunctionType> = FunctionType extends {
|
|
|
23
23
|
type Calls = {
|
|
24
24
|
[Name in ForwardedMethod]: CompatibleCall<Client[Name]>;
|
|
25
25
|
};
|
|
26
|
-
type ConnectionEvent = {
|
|
26
|
+
export type ConnectionEvent = {
|
|
27
27
|
type: 'disconnected';
|
|
28
28
|
} | {
|
|
29
29
|
type: 'model';
|
|
30
30
|
model: string;
|
|
31
31
|
};
|
|
32
|
-
export
|
|
33
|
-
declare const TrezorConnect: Calls & {
|
|
32
|
+
export type TrezorConnection = Calls & {
|
|
34
33
|
ethereumSignTransactionOwned: (request: Parameters<Client['ethereumSignTransaction']>[0], authority: HardwareTransactionAuthority) => ReturnType<CompatibleCall<Client['ethereumSignTransaction']>>;
|
|
35
34
|
signTransactionOwned: (request: Parameters<Client['signTransaction']>[0], authority: HardwareTransactionAuthority) => ReturnType<CompatibleCall<Client['signTransaction']>>;
|
|
36
|
-
init:
|
|
35
|
+
init: () => Promise<void>;
|
|
37
36
|
dispose: () => Promise<void>;
|
|
37
|
+
retire: () => Promise<() => void>;
|
|
38
|
+
subscribe(listener: (event: ConnectionEvent) => void): () => void;
|
|
38
39
|
};
|
|
40
|
+
export declare function createTrezorConnection(host: TrezorHost): TrezorConnection;
|
|
39
41
|
export declare const trezorResponseError: (response: {
|
|
40
42
|
payload?: {
|
|
41
43
|
error?: string;
|
|
42
44
|
code?: string;
|
|
43
45
|
};
|
|
44
46
|
}, prefix?: string) => Error;
|
|
45
|
-
export
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ConnectDynamicSettings, TrezorConnectPublicAPI } from '@trezor/connect-webextension';
|
|
2
|
+
export declare const TREZOR_METHODS: readonly ["getFeatures", "getAccountInfo", "ethereumGetAddress", "ethereumGetPublicKey", "getPublicKey", "getAddress", "signMessage", "ethereumSignMessage", "ethereumSignTypedData", "verifyMessage", "ethereumVerifyMessage", "ethereumSignTransaction", "signTransaction"];
|
|
3
|
+
export type TrezorMethod = (typeof TREZOR_METHODS)[number];
|
|
4
|
+
export type TrezorCalls = Pick<TrezorConnectPublicAPI<ConnectDynamicSettings>, TrezorMethod>;
|
|
5
|
+
type GuardedCall<Call> = Call extends {
|
|
6
|
+
(...args: infer A): infer R;
|
|
7
|
+
(...args: infer B): infer S;
|
|
8
|
+
(...args: infer C): infer T;
|
|
9
|
+
} ? {
|
|
10
|
+
(assertCurrent: () => void, ...args: A): R;
|
|
11
|
+
(assertCurrent: () => void, ...args: B): S;
|
|
12
|
+
(assertCurrent: () => void, ...args: C): T;
|
|
13
|
+
} : never;
|
|
14
|
+
/** Recheck after asynchronous preparation and immediately before device I/O. */
|
|
15
|
+
export type TrezorHostCalls = {
|
|
16
|
+
[Method in TrezorMethod]: GuardedCall<TrezorCalls[Method]>;
|
|
17
|
+
};
|
|
18
|
+
/** One explicitly owned client. This contract imports no platform runtime. */
|
|
19
|
+
export type TrezorHost = TrezorHostCalls & {
|
|
20
|
+
/** Check after asynchronous preparation and immediately before prompting. */
|
|
21
|
+
init(assertCurrent: () => void): Promise<void>;
|
|
22
|
+
/** Retire this host's client according to its platform cleanup requirements. */
|
|
23
|
+
dispose(pendingCalls: readonly Promise<unknown>[]): Promise<void>;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
package/types/trezor/index.d.ts
CHANGED
|
@@ -2,17 +2,14 @@ import { TypedMessage, SignTypedDataVersion, TypedDataV1 } from '@metamask/eth-s
|
|
|
2
2
|
import { Psbt } from 'bitcoinjs-lib';
|
|
3
3
|
import { Buffer } from 'buffer';
|
|
4
4
|
import type { HardwareTransactionAuthority } from '../hardware-transaction-authority';
|
|
5
|
+
import type { TrezorConnection } from './connect';
|
|
5
6
|
import type { AccountInfo, EthereumTransaction, EthereumTransactionEIP1559 } from '@trezor/connect-webextension';
|
|
6
7
|
export interface TrezorControllerState {
|
|
7
8
|
hdPath: string;
|
|
8
9
|
paths: Record<string, number>;
|
|
9
10
|
}
|
|
10
|
-
declare global {
|
|
11
|
-
interface Window {
|
|
12
|
-
TrezorConnect: any;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
11
|
export declare class TrezorKeyring {
|
|
12
|
+
private readonly connection;
|
|
16
13
|
hdPath: string;
|
|
17
14
|
publicKey: Buffer;
|
|
18
15
|
chainCode: Buffer;
|
|
@@ -21,10 +18,11 @@ export declare class TrezorKeyring {
|
|
|
21
18
|
private hardwareWalletManager;
|
|
22
19
|
private initialized;
|
|
23
20
|
private lifecycleGeneration;
|
|
21
|
+
private retirementEpoch;
|
|
24
22
|
private unsubscribeTrezor?;
|
|
25
23
|
private readonly onTrezorConnected;
|
|
26
24
|
private readonly onTrezorDisconnected;
|
|
27
|
-
constructor();
|
|
25
|
+
constructor(connection: TrezorConnection);
|
|
28
26
|
private observeTrezor;
|
|
29
27
|
/**
|
|
30
28
|
* Initialize Trezor script.
|
|
@@ -177,9 +175,11 @@ export declare class TrezorKeyring {
|
|
|
177
175
|
/**
|
|
178
176
|
* Check Trezor status
|
|
179
177
|
*/
|
|
180
|
-
getStatus(): import("../hardware-wallet-
|
|
178
|
+
getStatus(): import("../hardware-wallet-types").HardwareWalletStatus | undefined;
|
|
181
179
|
/**
|
|
182
180
|
* Clean up resources
|
|
183
181
|
*/
|
|
184
182
|
destroy(): Promise<void>;
|
|
183
|
+
/** Wait for the old device call and transport ownership to be fully retired. */
|
|
184
|
+
retire(): Promise<() => void>;
|
|
185
185
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TrezorHost } from './host-types';
|
|
2
|
+
import type { ConnectDynamicSettings, TrezorConnectPublicAPI } from '@trezor/connect-webextension';
|
|
3
|
+
type Client = TrezorConnectPublicAPI<ConnectDynamicSettings>;
|
|
4
|
+
export type TrezorWebExtensionSettings = Parameters<Client['init']>[0];
|
|
5
|
+
/** Explicit browser composition. The shared signer never loads this module. */
|
|
6
|
+
export declare function createTrezorWebExtensionHost(settings: TrezorWebExtensionSettings): TrezorHost;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { TrezorKeyring } from './trezor';
|
|
2
|
+
import type { KeyringHardware } from './keyring-core';
|
|
3
|
+
import type { TrezorHost } from './trezor/host-types';
|
|
4
|
+
/** Use the same Trezor account and transaction adapters on every host. */
|
|
5
|
+
export declare function createTrezorHardware(host: TrezorHost): KeyringHardware<undefined, TrezorKeyring>;
|
|
6
|
+
export type { TrezorHost } from './trezor/host-types';
|
package/types/types.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { LedgerKeyring } from './ledger';
|
|
|
7
7
|
import { IDecryptPrivateRecordParams, IEncryptedPrivateRecord, IEncryptPrivateRecordParams } from './private-records';
|
|
8
8
|
import { SyscoinHDSigner } from './signers';
|
|
9
9
|
import { TrezorKeyring } from './trezor';
|
|
10
|
-
import type { KeyringCore } from './keyring-core';
|
|
10
|
+
import type { KeyringCore, PreparedSessionTransfer } from './keyring-core';
|
|
11
11
|
import type { PreparedEvmTransaction } from './transactions/evm-envelope';
|
|
12
12
|
import type { OwnedUtxoRpcVerification } from '@sidhujag/sysweb3-network';
|
|
13
13
|
export type AccessListish = Array<{
|
|
@@ -43,12 +43,22 @@ export type EvmWalletNonce = Readonly<{
|
|
|
43
43
|
source: 'automatic' | 'manual';
|
|
44
44
|
}>;
|
|
45
45
|
export interface IEvmSendOptions {
|
|
46
|
+
selectedAccount: import('./transactions/prepared-evm').EvmSigningIdentity;
|
|
47
|
+
targetAccount: import('./transactions/prepared-evm').EvmSigningIdentity;
|
|
46
48
|
/** Synchronous host admission, rechecked immediately before signing and broadcast. */
|
|
47
49
|
assertCurrent: () => void;
|
|
48
|
-
mode: 'reviewed-native' | 'specialized';
|
|
50
|
+
mode: 'reviewed-native' | 'reviewed-generic' | 'specialized';
|
|
49
51
|
walletNonce?: EvmWalletNonce;
|
|
50
52
|
}
|
|
51
53
|
export type EvmFormattedSendArguments = [
|
|
54
|
+
approvedTransaction: PreparedEvmTransaction,
|
|
55
|
+
isLegacy: boolean | undefined,
|
|
56
|
+
options: IEvmSendOptions & {
|
|
57
|
+
mode: 'reviewed-generic';
|
|
58
|
+
reviewId: string;
|
|
59
|
+
walletNonce: EvmWalletNonce;
|
|
60
|
+
}
|
|
61
|
+
] | [
|
|
52
62
|
approvedTransaction: PreparedEvmTransaction,
|
|
53
63
|
isLegacy: boolean | undefined,
|
|
54
64
|
options: IEvmSendOptions & {
|
|
@@ -115,7 +125,8 @@ export interface IEthereumTransactions {
|
|
|
115
125
|
transaction?: TransactionResponse;
|
|
116
126
|
}>;
|
|
117
127
|
decryptMessage: (msgParams: string[]) => string;
|
|
118
|
-
ethSign: (params: string[]) => Promise<string>;
|
|
128
|
+
ethSign: (params: string[], options: import('./transactions/prepared-evm').EvmDigestSignOptions) => Promise<string>;
|
|
129
|
+
signPreparedEvmTransaction: (request: import('./transactions/prepared-evm').PreparedSoftwareEvmSigningRequest, options: import('./transactions/prepared-evm').PreparedEvmSigningOptions) => import('./transactions/prepared-evm').SignedPreparedEvmTransaction;
|
|
119
130
|
getBalance: (address: string) => Promise<number>;
|
|
120
131
|
getEncryptedPubKey: () => string;
|
|
121
132
|
getErc20TokensByAddress?: (address: string, isSupported: boolean, apiUrl: string) => Promise<any[]>;
|
|
@@ -233,6 +244,7 @@ export interface IKeyringManager {
|
|
|
233
244
|
needsAccountCreation?: boolean;
|
|
234
245
|
}>;
|
|
235
246
|
isUnlocked: () => boolean;
|
|
247
|
+
captureUnlockedSessionGuard: () => () => void;
|
|
236
248
|
logout: () => void;
|
|
237
249
|
ledgerSigner: LedgerKeyring;
|
|
238
250
|
trezorSigner: TrezorKeyring;
|
|
@@ -283,7 +295,7 @@ export interface IKeyringManager {
|
|
|
283
295
|
initializeWalletSecurely: (seedPhrase: string, password: string, prvPassword?: string) => Promise<IKeyringAccountState>;
|
|
284
296
|
initializeSession: (seedPhrase: string, password: string) => Promise<void>;
|
|
285
297
|
createFirstAccount: (label?: string) => Promise<IKeyringAccountState>;
|
|
286
|
-
|
|
298
|
+
prepareSessionTransfer: (targetKeyring: KeyringCore, assertCurrent: () => void) => Promise<PreparedSessionTransfer>;
|
|
287
299
|
lockWallet: () => Promise<void>;
|
|
288
300
|
setVaultStateGetter: (getter: () => any) => void;
|
|
289
301
|
}
|