Skip to content

Commit

Permalink
types fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bergarces committed Nov 17, 2022
1 parent 775c1cf commit 3a58b64
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 23 deletions.
4 changes: 0 additions & 4 deletions base-ledger-keyring.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ const NETWORK_API_URLS = {
mainnet: 'https://api.etherscan.io',
}

const CONNECTION_EVENT = 'ledger-connection-change'

class BaseLedgerKeyring extends EventEmitter {
constructor (opts = {}) {
super()
Expand Down Expand Up @@ -618,6 +616,4 @@ BaseLedgerKeyring.type = type

module.exports = {
BaseLedgerKeyring,
KEYRING_TYPE: type,
CONNECTION_EVENT,
}
3 changes: 1 addition & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const { BaseLedgerKeyring, KEYRING_TYPE } = require('./base-ledger-keyring')
const { BaseLedgerKeyring } = require('./base-ledger-keyring')
const LedgerKeyringMv2 = require('./ledger-keyring-mv2')

module.exports.LedgerKeyringMv2 = LedgerKeyringMv2

module.exports.BaseLedgerKeyring = BaseLedgerKeyring
module.exports.KEYRING_TYPE = KEYRING_TYPE
9 changes: 3 additions & 6 deletions ledger-keyring-mv2.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const {
BaseLedgerKeyring,
KEYRING_TYPE,
CONNECTION_EVENT,
} = require('./base-ledger-keyring')
const { BaseLedgerKeyring } = require('./base-ledger-keyring')

const CONNECTION_EVENT = 'ledger-connection-change'

class LedgerKeyringMv2 extends BaseLedgerKeyring {
init () {
Expand Down Expand Up @@ -194,5 +192,4 @@ class LedgerKeyringMv2 extends BaseLedgerKeyring {
}
}

LedgerKeyringMv2.type = KEYRING_TYPE
module.exports = LedgerKeyringMv2
27 changes: 16 additions & 11 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,36 @@
export const KEYRING_TYPE: string;

export type GetPublicKeyPayload = { hdPath: string };
export type GetPublicKeyResponse = {
publicKey: string;
address: string;
chainCode?: string | undefined;
};

export type LedgerSignatureResponse = {
v: string;
export type LedgerSignTransactionPayload = { hdPath: string; rawTxHex: string };
export type LedgerSignTransactionResponse = {
s: string;
v: string;
r: string;
};

export type LedgerSignTransactionPayload = { hdPath: string; rawTxHex: string };

export type LedgerSignMessagePayload = { hdPath: string; message: string };
export type LedgerSignMessageResponse = {
v: number;
s: string;
r: string;
};

export type LedgerSignTypedDataPayload = {
hdPath: string;
domainSeparatorHex: string;
hashStructMessageHex: string;
};
export type LedgerSignTypedDataResponse = {
v: number;
s: string;
r: string;
};

export class BaseLedgerKeyring {
static type: string;

public constructor(opts: Record<string, unknown>);

public init(): Promise<void>;
Expand All @@ -38,13 +43,13 @@ export class BaseLedgerKeyring {

protected _deviceSignTransaction(
payload: LedgerSignTransactionPayload
): Promise<LedgerSignatureResponse>;
): Promise<LedgerSignTransactionResponse>;

protected _deviceSignMessage(
payload: LedgerSignMessagePayload
): Promise<LedgerSignatureResponse>;
): Promise<LedgerSignMessageResponse>;

protected _deviceSignTypedData(
payload: LedgerSignTypedDataPayload
): Promise<LedgerSignatureResponse>;
): Promise<LedgerSignTypedDataResponse>;
}

0 comments on commit 3a58b64

Please sign in to comment.