From 850d4c4161924b8d6bfd1c64a27b804af09dacb5 Mon Sep 17 00:00:00 2001 From: Bernardo Garces Chapero Date: Thu, 17 Nov 2022 13:34:59 +0000 Subject: [PATCH] types fix --- base-ledger-keyring.js | 4 ---- index.js | 3 +-- ledger-keyring-mv2.js | 10 ++++------ types/index.d.ts | 27 ++++++++++++++++----------- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/base-ledger-keyring.js b/base-ledger-keyring.js index 2c0985ae..2b2310b6 100644 --- a/base-ledger-keyring.js +++ b/base-ledger-keyring.js @@ -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() @@ -618,6 +616,4 @@ BaseLedgerKeyring.type = type module.exports = { BaseLedgerKeyring, - KEYRING_TYPE: type, - CONNECTION_EVENT, } diff --git a/index.js b/index.js index 6d9489eb..d4016b63 100644 --- a/index.js +++ b/index.js @@ -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 diff --git a/ledger-keyring-mv2.js b/ledger-keyring-mv2.js index 8a5ab5bb..aeda66c7 100644 --- a/ledger-keyring-mv2.js +++ b/ledger-keyring-mv2.js @@ -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 () { @@ -194,5 +192,5 @@ class LedgerKeyringMv2 extends BaseLedgerKeyring { } } -LedgerKeyringMv2.type = KEYRING_TYPE +LedgerKeyringMv2.type = BaseLedgerKeyring.type module.exports = LedgerKeyringMv2 diff --git a/types/index.d.ts b/types/index.d.ts index cd662132..a6cac62b 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,5 +1,3 @@ -export const KEYRING_TYPE: string; - export type GetPublicKeyPayload = { hdPath: string }; export type GetPublicKeyResponse = { publicKey: string; @@ -7,25 +5,32 @@ export type GetPublicKeyResponse = { 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); public init(): Promise; @@ -38,13 +43,13 @@ export class BaseLedgerKeyring { protected _deviceSignTransaction( payload: LedgerSignTransactionPayload - ): Promise; + ): Promise; protected _deviceSignMessage( payload: LedgerSignMessagePayload - ): Promise; + ): Promise; protected _deviceSignTypedData( payload: LedgerSignTypedDataPayload - ): Promise; + ): Promise; }