From 10715fdb2bdcdf8fd9e28d925f2eb8a4c3ec581e Mon Sep 17 00:00:00 2001 From: Karolina Kosiorowska Date: Fri, 17 Nov 2023 12:28:14 +0100 Subject: [PATCH] Move types for ledger live app to a separate file --- dapp/src/hooks/useRequestBitcoinAccount.ts | 14 +------------- dapp/src/hooks/useRequestEthereumAccount.ts | 14 +------------- dapp/src/types/index.ts | 1 + dapp/src/types/ledger-live-app.ts | 13 +++++++++++++ 4 files changed, 16 insertions(+), 26 deletions(-) create mode 100644 dapp/src/types/index.ts create mode 100644 dapp/src/types/ledger-live-app.ts diff --git a/dapp/src/hooks/useRequestBitcoinAccount.ts b/dapp/src/hooks/useRequestBitcoinAccount.ts index 9d31aced8..3f7a0d120 100644 --- a/dapp/src/hooks/useRequestBitcoinAccount.ts +++ b/dapp/src/hooks/useRequestBitcoinAccount.ts @@ -1,20 +1,8 @@ -import { Account, WalletAPIClient } from "@ledgerhq/wallet-api-client" import { useRequestAccount } from "@ledgerhq/wallet-api-client-react" import { useCallback, useContext, useEffect } from "react" import { LedgerLiveAppContext } from "../contexts/LedgerLiveAppContext" import { CURRENCY_ID_BITCOIN } from "../constants" - -type UseRequestAccount = { - pending: boolean - account: Account | null - error: unknown -} - -type RequestAccountParams = Parameters - -type UseRequestAccountReturn = { - requestAccount: (...params: RequestAccountParams) => Promise -} & UseRequestAccount +import { UseRequestAccountReturn } from "../types" export function useRequestBitcoinAccount(): UseRequestAccountReturn { const { setBtcAccount } = useContext(LedgerLiveAppContext) diff --git a/dapp/src/hooks/useRequestEthereumAccount.ts b/dapp/src/hooks/useRequestEthereumAccount.ts index a9e7bc929..b3c674d4c 100644 --- a/dapp/src/hooks/useRequestEthereumAccount.ts +++ b/dapp/src/hooks/useRequestEthereumAccount.ts @@ -1,20 +1,8 @@ -import { Account, WalletAPIClient } from "@ledgerhq/wallet-api-client" import { useRequestAccount } from "@ledgerhq/wallet-api-client-react" import { useCallback, useContext, useEffect } from "react" import { LedgerLiveAppContext } from "../contexts/LedgerLiveAppContext" import { CURRENCY_ID_ETHEREUM } from "../constants" - -type UseRequestAccount = { - pending: boolean - account: Account | null - error: unknown -} - -type RequestAccountParams = Parameters - -type UseRequestAccountReturn = { - requestAccount: (...params: RequestAccountParams) => Promise -} & UseRequestAccount +import { UseRequestAccountReturn } from "../types" export function useRequestEthereumAccount(): UseRequestAccountReturn { const { setEthAccount } = useContext(LedgerLiveAppContext) diff --git a/dapp/src/types/index.ts b/dapp/src/types/index.ts new file mode 100644 index 000000000..96cd9d44f --- /dev/null +++ b/dapp/src/types/index.ts @@ -0,0 +1 @@ +export * from "./ledger-live-app" diff --git a/dapp/src/types/ledger-live-app.ts b/dapp/src/types/ledger-live-app.ts new file mode 100644 index 000000000..84dc9fec8 --- /dev/null +++ b/dapp/src/types/ledger-live-app.ts @@ -0,0 +1,13 @@ +import { Account, WalletAPIClient } from "@ledgerhq/wallet-api-client" + +type UseRequestAccount = { + pending: boolean + account: Account | null + error: unknown +} + +type RequestAccountParams = Parameters + +export type UseRequestAccountReturn = { + requestAccount: (...params: RequestAccountParams) => Promise +} & UseRequestAccount