-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into bitcoin-native-experience
- Loading branch information
Showing
13 changed files
with
69 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import React from "react" | ||
import { ActionFlowType } from "#/types" | ||
import { ACTION_FLOW_TYPES, ActionFlowType } from "#/types" | ||
import StakingErrorModal from "./ActiveStakingStep/StakingErrorModal" | ||
|
||
export default function ErrorModal({ type }: { type: ActionFlowType }) { | ||
if (type === "stake") return <StakingErrorModal /> | ||
if (type === ACTION_FLOW_TYPES.STAKE) return <StakingErrorModal /> | ||
// TODO: Handle the case of unstake action | ||
return null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { ActionFlowType, MODAL_TYPES } from "#/types" | ||
import { useCallback, useEffect } from "react" | ||
import { logPromiseFailure } from "#/utils" | ||
import { useModal } from "./useModal" | ||
import { useWalletContext } from "./useWalletContext" | ||
import { useRequestBitcoinAccount } from "./useRequestBitcoinAccount" | ||
|
||
export function useTransactionModal(type: ActionFlowType) { | ||
const { btcAccount } = useWalletContext() | ||
const { account, requestAccount } = useRequestBitcoinAccount() | ||
const { openModal } = useModal() | ||
|
||
const handleOpenModal = useCallback(() => { | ||
openModal(MODAL_TYPES[type], { type }) | ||
}, [openModal, type]) | ||
|
||
useEffect(() => { | ||
// We should check the `account` here from `useRequestBitcoinAccount`. | ||
// This will allow us to check there whether the account request action | ||
// called earlier was successful. | ||
// Checking the `btcAccount` may trigger a not needed modal opening. | ||
if (account) { | ||
handleOpenModal() | ||
} | ||
}, [account, handleOpenModal]) | ||
|
||
return useCallback(() => { | ||
if (btcAccount) { | ||
handleOpenModal() | ||
} else { | ||
logPromiseFailure(requestAccount()) | ||
} | ||
}, [btcAccount, handleOpenModal, requestAccount]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import { WalletAPIClient } from "@ledgerhq/wallet-api-client" | ||
import { Account, WalletAPIClient } from "@ledgerhq/wallet-api-client" | ||
|
||
export type RequestAccountParams = Parameters< | ||
WalletAPIClient["account"]["request"] | ||
> | ||
|
||
export type UseRequestAccountReturn = { | ||
account: Account | null | ||
requestAccount: (...params: RequestAccountParams) => Promise<void> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters