-
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathledger-bridge.ts
More file actions
93 lines (73 loc) · 2.64 KB
/
Copy pathledger-bridge.ts
File metadata and controls
93 lines (73 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import type LedgerHwAppEth from '@ledgerhq/hw-app-eth';
import type Transport from '@ledgerhq/hw-transport';
import type { EIP712Message } from '@ledgerhq/types-live';
export type GetPublicKeyParams = { hdPath: string };
export type GetPublicKeyResponse = Awaited<
ReturnType<LedgerHwAppEth['getAddress']>
>;
export type LedgerSignTransactionParams = { hdPath: string; tx: string };
export type LedgerSignTransactionResponse = Awaited<
ReturnType<LedgerHwAppEth['signTransaction']>
>;
export type LedgerSignMessageParams = { hdPath: string; message: string };
export type LedgerSignMessageResponse = Awaited<
ReturnType<LedgerHwAppEth['signPersonalMessage']>
>;
export type LedgerSignTypedDataParams = {
hdPath: string;
message: EIP712Message;
};
export type LedgerSignTypedDataResponse = Awaited<
ReturnType<LedgerHwAppEth['signEIP712HashedMessage']>
>;
export type GetAppNameAndVersionResponse = {
appName: string;
version: string;
};
export type AppConfigurationResponse = {
arbitraryDataEnabled: number; // this is the blind signing support
erc20ProvisioningNecessary: number;
starkEnabled: number;
starkv2Supported: number;
version: string;
};
export type LedgerBridgeOptions = Record<string, unknown>;
export type LedgerBridge<T extends LedgerBridgeOptions> = {
isDeviceConnected: boolean;
init(): Promise<void>;
destroy(): Promise<void>;
/**
* Method to get the current configuration of the ledger bridge keyring.
*/
getOptions(): Promise<T>;
/**
* Method to set the current configuration of the ledger bridge keyring.
*
* @param opts - An object contains configuration of the bridge.
*/
setOptions(opts: T): Promise<void>;
attemptMakeApp(): Promise<boolean>;
updateTransportMethod(transportType: string | Transport): Promise<boolean>;
getPublicKey(params: GetPublicKeyParams): Promise<GetPublicKeyResponse>;
deviceSignTransaction(
params: LedgerSignTransactionParams,
): Promise<LedgerSignTransactionResponse>;
deviceSignMessage(
params: LedgerSignMessageParams,
): Promise<LedgerSignMessageResponse>;
deviceSignTypedData(
params: LedgerSignTypedDataParams,
): Promise<LedgerSignTypedDataResponse>;
/**
* Method to retrieve the name and version of the running application on the Ledger device.
*
* @returns An object containing appName and version.
*/
getAppNameAndVersion(): Promise<GetAppNameAndVersionResponse>;
/**
* Method to retrieve the configuration of the running application on the Ledger device.
*
* @returns An object containing the configuration of the running application.
*/
getAppConfiguration(): Promise<AppConfigurationResponse>;
};