-
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor keyring to split bridge logic (#156)
- Loading branch information
Showing
7 changed files
with
1,114 additions
and
605 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export * from './ledger-bridge-keyring'; | ||
export * from './ledger-keyring'; | ||
export * from './ledger-iframe-bridge'; | ||
export * from './ledger-bridge'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import type LedgerHwAppEth from '@ledgerhq/hw-app-eth'; | ||
|
||
export type GetPublicKeyParams = { hdPath: string }; | ||
export type GetPublicKeyResponse = Awaited< | ||
ReturnType<LedgerHwAppEth['getAddress']> | ||
> & { | ||
chainCode: string; | ||
}; | ||
|
||
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; | ||
domainSeparatorHex: string; | ||
hashStructMessageHex: string; | ||
}; | ||
export type LedgerSignTypedDataResponse = Awaited< | ||
ReturnType<LedgerHwAppEth['signEIP712HashedMessage']> | ||
>; | ||
|
||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions | ||
export interface LedgerBridge { | ||
isDeviceConnected: boolean; | ||
|
||
init(bridgeUrl: string): Promise<void>; | ||
|
||
destroy(): Promise<void>; | ||
|
||
attemptMakeApp(): Promise<boolean>; | ||
|
||
updateTransportMethod(transportType: string): Promise<boolean>; | ||
|
||
getPublicKey(params: GetPublicKeyParams): Promise<GetPublicKeyResponse>; | ||
|
||
deviceSignTransaction( | ||
params: LedgerSignTransactionParams, | ||
): Promise<LedgerSignTransactionResponse>; | ||
|
||
deviceSignMessage( | ||
params: LedgerSignMessageParams, | ||
): Promise<LedgerSignMessageResponse>; | ||
|
||
deviceSignTypedData( | ||
params: LedgerSignTypedDataParams, | ||
): Promise<LedgerSignTypedDataResponse>; | ||
} |
Oops, something went wrong.