Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor keyring to split bridge logic #156

Merged
merged 24 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ module.exports = {
// An object that configures minimum threshold enforcement for coverage results
coverageThreshold: {
global: {
branches: 59.25,
functions: 81.94,
lines: 78.54,
statements: 78.49,
branches: 65.09,
functions: 88.57,
lines: 81.57,
statements: 81.49,
},
},

Expand Down
4 changes: 3 additions & 1 deletion src/index.ts
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';
54 changes: 54 additions & 0 deletions src/ledger-bridge.ts
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>;
}
Loading