Skip to content

Commit

Permalink
Move types for ledger live app to a separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
kkosiorowska committed Nov 17, 2023
1 parent 404d3c9 commit 10715fd
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 26 deletions.
14 changes: 1 addition & 13 deletions dapp/src/hooks/useRequestBitcoinAccount.ts
Original file line number Diff line number Diff line change
@@ -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<WalletAPIClient["account"]["request"]>

type UseRequestAccountReturn = {
requestAccount: (...params: RequestAccountParams) => Promise<void>
} & UseRequestAccount
import { UseRequestAccountReturn } from "../types"

export function useRequestBitcoinAccount(): UseRequestAccountReturn {
const { setBtcAccount } = useContext(LedgerLiveAppContext)
Expand Down
14 changes: 1 addition & 13 deletions dapp/src/hooks/useRequestEthereumAccount.ts
Original file line number Diff line number Diff line change
@@ -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<WalletAPIClient["account"]["request"]>

type UseRequestAccountReturn = {
requestAccount: (...params: RequestAccountParams) => Promise<void>
} & UseRequestAccount
import { UseRequestAccountReturn } from "../types"

export function useRequestEthereumAccount(): UseRequestAccountReturn {
const { setEthAccount } = useContext(LedgerLiveAppContext)
Expand Down
1 change: 1 addition & 0 deletions dapp/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./ledger-live-app"
13 changes: 13 additions & 0 deletions dapp/src/types/ledger-live-app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Account, WalletAPIClient } from "@ledgerhq/wallet-api-client"

type UseRequestAccount = {
pending: boolean
account: Account | null
error: unknown
}

type RequestAccountParams = Parameters<WalletAPIClient["account"]["request"]>

export type UseRequestAccountReturn = {
requestAccount: (...params: RequestAccountParams) => Promise<void>
} & UseRequestAccount

0 comments on commit 10715fd

Please sign in to comment.