diff --git a/dapp/src/assets/icons/ShieldPlus.tsx b/dapp/src/assets/icons/ShieldPlus.tsx
deleted file mode 100644
index b3fbea2bc..000000000
--- a/dapp/src/assets/icons/ShieldPlus.tsx
+++ /dev/null
@@ -1,17 +0,0 @@
-import React from "react"
-import { createIcon } from "@chakra-ui/react"
-
-export const ShieldPlusIcon = createIcon({
- displayName: "ShieldPlusIcon",
- viewBox: "0 0 20 20",
- path: (
-
- ),
-})
diff --git a/dapp/src/assets/icons/index.ts b/dapp/src/assets/icons/index.ts
index 62d802cf8..e2832df45 100644
--- a/dapp/src/assets/icons/index.ts
+++ b/dapp/src/assets/icons/index.ts
@@ -5,7 +5,6 @@ export * from "./ArrowRight"
export * from "./AcreLogo"
export * from "./stBTC"
export * from "./BTC"
-export * from "./ShieldPlus"
export * from "./Pending"
export * from "./Syncing"
export * from "./Complete"
diff --git a/dapp/src/assets/images/gamification-placeholder.svg b/dapp/src/assets/images/gamification-placeholder.svg
new file mode 100644
index 000000000..22847cb95
--- /dev/null
+++ b/dapp/src/assets/images/gamification-placeholder.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/dapp/src/assets/images/rewards-boost-arrow.svg b/dapp/src/assets/images/rewards-boost-arrow.svg
new file mode 100644
index 000000000..b8cb985cf
--- /dev/null
+++ b/dapp/src/assets/images/rewards-boost-arrow.svg
@@ -0,0 +1,68 @@
+
diff --git a/dapp/src/assets/images/right-sidebar-bg.png b/dapp/src/assets/images/right-sidebar-bg.png
deleted file mode 100644
index 540134e58..000000000
Binary files a/dapp/src/assets/images/right-sidebar-bg.png and /dev/null differ
diff --git a/dapp/src/components/Layout.tsx b/dapp/src/components/Layout.tsx
index 08c738b2b..43a0bc2d3 100644
--- a/dapp/src/components/Layout.tsx
+++ b/dapp/src/components/Layout.tsx
@@ -1,10 +1,10 @@
-import React from "react"
+import React, { useState } from "react"
import { AnimatePresence, motion, Variants } from "framer-motion"
-import { useState } from "react"
import { useLocation, useOutlet } from "react-router-dom"
import DocsDrawer from "./DocsDrawer"
import Header from "./Header"
import Sidebar from "./Sidebar"
+import ModalRoot from "./ModalRoot"
const wrapperVariants: Variants = {
in: { opacity: 0, y: 48 },
@@ -39,6 +39,7 @@ function Layout() {
+
>
)
}
diff --git a/dapp/src/components/ModalRoot/index.tsx b/dapp/src/components/ModalRoot/index.tsx
new file mode 100644
index 000000000..22e6187f5
--- /dev/null
+++ b/dapp/src/components/ModalRoot/index.tsx
@@ -0,0 +1,19 @@
+import React, { ElementType } from "react"
+import { useModal } from "#/hooks"
+import { ModalType } from "#/types"
+import TransactionModal from "../TransactionModal"
+
+const MODALS: Record = {
+ STAKE: TransactionModal,
+ UNSTAKE: TransactionModal,
+} as const
+
+export default function ModalRoot() {
+ const { modalType, modalProps, closeModal } = useModal()
+
+ if (!modalType) {
+ return null
+ }
+ const SpecificModal = MODALS[modalType]
+ return
+}
diff --git a/dapp/src/components/ModalRoot/withBaseModal.tsx b/dapp/src/components/ModalRoot/withBaseModal.tsx
new file mode 100644
index 000000000..de804ca0d
--- /dev/null
+++ b/dapp/src/components/ModalRoot/withBaseModal.tsx
@@ -0,0 +1,29 @@
+import React, { ComponentType } from "react"
+import { Modal, ModalContent, ModalOverlay } from "@chakra-ui/react"
+import { BaseModalProps } from "#/types"
+
+export const MODAL_BASE_SIZE = "lg"
+
+function withBaseModal(
+ WrappedModalContent: ComponentType,
+) {
+ return function ModalBase(props: T) {
+ const { closeModal } = props
+ return (
+
+
+
+
+
+
+ )
+ }
+}
+
+export default withBaseModal
diff --git a/dapp/src/components/Sidebar.tsx b/dapp/src/components/Sidebar.tsx
new file mode 100644
index 000000000..3dfc36915
--- /dev/null
+++ b/dapp/src/components/Sidebar.tsx
@@ -0,0 +1,81 @@
+import React from "react"
+import {
+ Box,
+ Card,
+ CardBody,
+ Flex,
+ useMultiStyleConfig,
+ Image,
+} from "@chakra-ui/react"
+import { useSidebar, useDocsDrawer } from "#/hooks"
+import rewardsBoostArrow from "#/assets/images/rewards-boost-arrow.svg"
+import mysteryBoxIcon from "#/assets/images/mystery-box.svg"
+import seasonKeyIcon from "#/assets/images/season-key.svg"
+import ButtonLink from "./shared/ButtonLink"
+import { TextSm } from "./shared/Typography"
+
+const BUTTONS = [
+ { label: "Docs", variant: "solid" },
+ { label: "FAQ", colorScheme: "gold" },
+ { label: "Token Contract", colorScheme: "gold" },
+ { label: "Bridge Contract", colorScheme: "gold" },
+]
+
+const BENEFITS = [
+ { label: "1x Rewards Boost", iconSrc: rewardsBoostArrow },
+ { label: "1x Mystery Box", iconSrc: mysteryBoxIcon },
+ { label: "1x Season Key", iconSrc: seasonKeyIcon },
+]
+
+export default function Sidebar() {
+ const { isOpen } = useSidebar()
+ const { onOpen: openDocsDrawer } = useDocsDrawer()
+ const styles = useMultiStyleConfig("Sidebar")
+
+ return (
+
+
+ Rewards you’ll unlock
+
+
+ {BENEFITS.map(({ label, iconSrc }) => (
+
+
+ {label}
+
+
+
+ ))}
+
+
+ {BUTTONS.map(({ label, variant, colorScheme }) => (
+
+ {label}
+
+ ))}
+
+
+ )
+}
diff --git a/dapp/src/components/Sidebar/index.tsx b/dapp/src/components/Sidebar/index.tsx
deleted file mode 100644
index 0b485b142..000000000
--- a/dapp/src/components/Sidebar/index.tsx
+++ /dev/null
@@ -1,84 +0,0 @@
-import React from "react"
-import {
- Box,
- Icon,
- useMultiStyleConfig,
- Image,
- Card,
- CardBody,
- CardHeader,
- CardFooter,
- HStack,
- Link,
-} from "@chakra-ui/react"
-import RightSidebar from "#/assets/images/right-sidebar-bg.png"
-import { useSidebar, useDocsDrawer } from "#/hooks"
-import { ShieldPlusIcon } from "#/assets/icons"
-import { TextMd, TextSm } from "../shared/Typography"
-import ButtonLink from "../shared/ButtonLink"
-
-const readMoreEarnings = "https://#"
-
-const BUTTONS = [
- { label: "FAQ" },
- { label: "Token Contract" },
- { label: "Bridge Contract" },
-]
-
-export default function Sidebar() {
- const { isOpen } = useSidebar()
- const { onOpen: openDocsDrawer } = useDocsDrawer()
- const styles = useMultiStyleConfig("Sidebar")
-
- return (
-
-
-
- Docs
-
-
-
-
-
-
-
-
- Maximize your earnings by using tBTC to deposit and redeem BTC in
- DeFi!
-
-
-
-
-
- Read more
-
-
-
-
-
-
- How we calculate fees
-
-
-
-
-
- Fees is software empowered by the Threshold DAO.
-
-
-
-
- {BUTTONS.map(({ label }) => (
-
- {label}
-
- ))}
-
-
- )
-}
diff --git a/dapp/src/components/TransactionModal/ActionFormModal.tsx b/dapp/src/components/TransactionModal/ActionFormModal.tsx
index 0f7c824c9..3c1cbed37 100644
--- a/dapp/src/components/TransactionModal/ActionFormModal.tsx
+++ b/dapp/src/components/TransactionModal/ActionFormModal.tsx
@@ -1,35 +1,39 @@
-import React, { useCallback, useState } from "react"
-import {
- ModalBody,
- Tabs,
- TabList,
- Tab,
- TabPanels,
- TabPanel,
- ModalCloseButton,
-} from "@chakra-ui/react"
-import {
- useModalFlowContext,
- useStakeFlowContext,
- useTransactionContext,
- useWalletContext,
-} from "#/hooks"
-import { ACTION_FLOW_TYPES, ActionFlowType } from "#/types"
+import React, { ReactNode, useCallback, useState } from "react"
+import { Box, ModalBody, ModalCloseButton, ModalHeader } from "@chakra-ui/react"
+import { useAppDispatch, useStakeFlowContext, useWalletContext } from "#/hooks"
+import { ACTION_FLOW_TYPES, ActionFlowType, BaseFormProps } from "#/types"
import { TokenAmountFormValues } from "#/components/shared/TokenAmountForm/TokenAmountFormBase"
import { logPromiseFailure } from "#/utils"
+import { setTokenAmount } from "#/store/action-flow"
import StakeFormModal from "./ActiveStakingStep/StakeFormModal"
import UnstakeFormModal from "./ActiveUnstakingStep/UnstakeFormModal"
-const TABS = Object.values(ACTION_FLOW_TYPES)
+const FORM_DATA: Record<
+ ActionFlowType,
+ {
+ heading: string
+ renderComponent: (props: BaseFormProps) => ReactNode
+ }
+> = {
+ stake: {
+ heading: "Deposit",
+ renderComponent: StakeFormModal,
+ },
+ unstake: {
+ heading: "Withdraw",
+ renderComponent: UnstakeFormModal,
+ },
+}
-function ActionFormModal({ defaultType }: { defaultType: ActionFlowType }) {
+function ActionFormModal({ type }: { type: ActionFlowType }) {
const { btcAccount, ethAccount } = useWalletContext()
- const { type, setType } = useModalFlowContext()
- const { setTokenAmount } = useTransactionContext()
const { initStake } = useStakeFlowContext()
+ const dispatch = useAppDispatch()
const [isLoading, setIsLoading] = useState(false)
+ const { heading, renderComponent } = FORM_DATA[type]
+
const handleInitStake = useCallback(async () => {
const btcAddress = btcAccount?.address
const ethAddress = ethAccount?.address
@@ -48,14 +52,14 @@ function ActionFormModal({ defaultType }: { defaultType: ActionFlowType }) {
// TODO: Init unstake flow
if (type === ACTION_FLOW_TYPES.STAKE) await handleInitStake()
- setTokenAmount({ amount: values.amount, currency: "bitcoin" })
+ dispatch(setTokenAmount({ amount: values.amount, currency: "bitcoin" }))
} catch (error) {
console.error(error)
} finally {
setIsLoading(false)
}
},
- [handleInitStake, setTokenAmount, type],
+ [dispatch, handleInitStake, type],
)
const handleSubmitFormWrapper = useCallback(
@@ -67,34 +71,13 @@ function ActionFormModal({ defaultType }: { defaultType: ActionFlowType }) {
return (
<>
{!isLoading && }
+ {heading}
-
-
- {TABS.map((actionFlowType) => (
- setType(actionFlowType)}
- isDisabled={actionFlowType !== type && isLoading}
- >
- {actionFlowType}
-
- ))}
-
-
-
-
-
-
-
-
-
-
+
+ {renderComponent({
+ onSubmitForm: handleSubmitFormWrapper,
+ })}
+
>
)
diff --git a/dapp/src/components/TransactionModal/ActiveFlowStep.tsx b/dapp/src/components/TransactionModal/ActiveFlowStep.tsx
index 0e27f2f74..bf8e5eafa 100644
--- a/dapp/src/components/TransactionModal/ActiveFlowStep.tsx
+++ b/dapp/src/components/TransactionModal/ActiveFlowStep.tsx
@@ -1,5 +1,5 @@
import React, { ReactElement, useEffect } from "react"
-import { useModalFlowContext } from "#/hooks"
+import { useActionFlowActiveStep, useActionFlowType, useModal } from "#/hooks"
import {
ACTION_FLOW_STEPS_TYPES,
ActionFlowType,
@@ -18,14 +18,17 @@ const FLOW: Record ReactElement> = {
}
export function ActiveFlowStep() {
- const { activeStep, type, onClose } = useModalFlowContext()
+ const { closeModal } = useModal()
+ const activeStep = useActionFlowActiveStep()
+ const type = useActionFlowType()
+
const numberOfSteps = Object.keys(ACTION_FLOW_STEPS_TYPES[type]).length
useEffect(() => {
if (activeStep > numberOfSteps) {
- onClose()
+ closeModal()
}
- }, [activeStep, numberOfSteps, onClose])
+ }, [activeStep, closeModal, numberOfSteps])
return FLOW[type](activeStep)
}
diff --git a/dapp/src/components/TransactionModal/ActiveStakingStep/DepositBTCModal.tsx b/dapp/src/components/TransactionModal/ActiveStakingStep/DepositBTCModal.tsx
index 4b68afa54..f3fb591e5 100644
--- a/dapp/src/components/TransactionModal/ActiveStakingStep/DepositBTCModal.tsx
+++ b/dapp/src/components/TransactionModal/ActiveStakingStep/DepositBTCModal.tsx
@@ -1,43 +1,44 @@
-import React, { useCallback, useState } from "react"
+import React, { useCallback } from "react"
import {
+ useActionFlowTokenAmount,
+ useAppDispatch,
useDepositBTCTransaction,
useDepositTelemetry,
useExecuteFunction,
- useModalFlowContext,
useStakeFlowContext,
useToast,
- useTransactionContext,
useWalletContext,
} from "#/hooks"
-import { TextMd } from "#/components/shared/Typography"
import { logPromiseFailure } from "#/utils"
import { PROCESS_STATUSES } from "#/types"
-import { CardAlert } from "#/components/shared/alerts"
import { TOASTS, TOAST_IDS } from "#/types/toast"
-import StakingStepsModalContent from "./StakingStepsModalContent"
+import { ModalBody, ModalHeader, Highlight, useTimeout } from "@chakra-ui/react"
+import Spinner from "#/components/shared/Spinner"
+import { TextMd } from "#/components/shared/Typography"
+import { CardAlert } from "#/components/shared/alerts"
+import { ONE_SEC_IN_MILLISECONDS } from "#/constants"
+import { setStatus } from "#/store/action-flow"
+const DELAY = ONE_SEC_IN_MILLISECONDS
const TOAST_ID = TOAST_IDS.DEPOSIT_TRANSACTION_ERROR
const TOAST = TOASTS[TOAST_ID]
export default function DepositBTCModal() {
const { ethAccount } = useWalletContext()
- const { tokenAmount } = useTransactionContext()
- const { setStatus } = useModalFlowContext()
+ const tokenAmount = useActionFlowTokenAmount()
const { btcAddress, depositReceipt, stake } = useStakeFlowContext()
const depositTelemetry = useDepositTelemetry()
const { closeToast, openToast } = useToast()
-
- const [isLoading, setIsLoading] = useState(false)
- const [buttonText, setButtonText] = useState("Deposit BTC")
+ const dispatch = useAppDispatch()
const onStakeBTCSuccess = useCallback(
- () => setStatus(PROCESS_STATUSES.SUCCEEDED),
- [setStatus],
+ () => dispatch(setStatus(PROCESS_STATUSES.SUCCEEDED)),
+ [dispatch],
)
const onStakeBTCError = useCallback(() => {
- setStatus(PROCESS_STATUSES.FAILED)
- }, [setStatus])
+ dispatch(setStatus(PROCESS_STATUSES.FAILED))
+ }, [dispatch])
const handleStake = useExecuteFunction(
stake,
@@ -47,17 +48,16 @@ export default function DepositBTCModal() {
const onDepositBTCSuccess = useCallback(() => {
closeToast(TOAST_ID)
- setStatus(PROCESS_STATUSES.LOADING)
+ dispatch(setStatus(PROCESS_STATUSES.LOADING))
logPromiseFailure(handleStake())
- }, [closeToast, setStatus, handleStake])
+ }, [closeToast, dispatch, handleStake])
const showError = useCallback(() => {
openToast({
id: TOAST_ID,
render: TOAST,
})
- setButtonText("Try again")
}, [openToast])
const onDepositBTCError = useCallback(() => showError(), [showError])
@@ -71,13 +71,11 @@ export default function DepositBTCModal() {
if (!tokenAmount?.amount || !btcAddress || !depositReceipt || !ethAccount)
return
- setIsLoading(true)
const response = await depositTelemetry(
depositReceipt,
btcAddress,
ethAccount.address,
)
- setIsLoading(false)
if (response.verificationStatus === "valid") {
logPromiseFailure(sendBitcoinTransaction(tokenAmount?.amount, btcAddress))
@@ -98,18 +96,23 @@ export default function DepositBTCModal() {
logPromiseFailure(handledDepositBTC())
}, [handledDepositBTC])
+ useTimeout(handledDepositBTCWrapper, DELAY)
+
return (
-
-
-
- Make a Bitcoin transaction to deposit and stake your BTC.
-
-
-
+ <>
+ Waiting transaction...
+
+
+ Please complete the transaction in your wallet.
+
+
+
+ You will receive your Rewards once the deposit transaction is
+ completed.
+
+
+
+
+ >
)
}
diff --git a/dapp/src/components/TransactionModal/ActiveStakingStep/OverviewModal/index.tsx b/dapp/src/components/TransactionModal/ActiveStakingStep/OverviewModal/index.tsx
deleted file mode 100644
index c5806b663..000000000
--- a/dapp/src/components/TransactionModal/ActiveStakingStep/OverviewModal/index.tsx
+++ /dev/null
@@ -1,36 +0,0 @@
-import React from "react"
-import {
- Button,
- ModalBody,
- ModalFooter,
- ModalHeader,
- StepNumber,
-} from "@chakra-ui/react"
-import StepperBase from "#/components/shared/StepperBase"
-import { useModalFlowContext } from "#/hooks"
-import { STEPS } from "./steps"
-
-export default function OverviewModal() {
- const { goNext } = useModalFlowContext()
-
- return (
- <>
- Staking steps overview
-
- }
- steps={STEPS}
- />
-
-
-
-
- >
- )
-}
diff --git a/dapp/src/components/TransactionModal/ActiveStakingStep/OverviewModal/steps.tsx b/dapp/src/components/TransactionModal/ActiveStakingStep/OverviewModal/steps.tsx
deleted file mode 100644
index 899fc7960..000000000
--- a/dapp/src/components/TransactionModal/ActiveStakingStep/OverviewModal/steps.tsx
+++ /dev/null
@@ -1,25 +0,0 @@
-import React from "react"
-import { StepBase } from "#/components/shared/StepperBase"
-import { Description, Title } from "../StakingStepsModalContent"
-
-export const STEPS: StepBase[] = [
- {
- id: "sign-message",
- title: Sign message,
- description: (
-
- You will sign a gas-free Ethereum message to indicate the address where
- you'd like to get your stBTC liquid staking token.
-
- ),
- },
- {
- id: "deposit-btc",
- title: Deposit BTC,
- description: (
-
- You will make a Bitcoin transaction to deposit and stake your BTC.
-
- ),
- },
-]
diff --git a/dapp/src/components/TransactionModal/ActiveStakingStep/SignMessageModal.tsx b/dapp/src/components/TransactionModal/ActiveStakingStep/SignMessageModal.tsx
deleted file mode 100644
index 37bba6883..000000000
--- a/dapp/src/components/TransactionModal/ActiveStakingStep/SignMessageModal.tsx
+++ /dev/null
@@ -1,58 +0,0 @@
-import React, { useCallback, useEffect, useState } from "react"
-import {
- useExecuteFunction,
- useModalFlowContext,
- useStakeFlowContext,
- useToast,
-} from "#/hooks"
-import { logPromiseFailure } from "#/utils"
-import { PROCESS_STATUSES, TOASTS, TOAST_IDS } from "#/types"
-import { ReceiveSTBTCAlert } from "#/components/shared/alerts"
-import StakingStepsModalContent from "./StakingStepsModalContent"
-
-const TOAST_ID = TOAST_IDS.SIGNING_ERROR
-const TOAST = TOASTS[TOAST_ID]
-
-export default function SignMessageModal() {
- const { goNext, setStatus } = useModalFlowContext()
- const { signMessage } = useStakeFlowContext()
- const [buttonText, setButtonText] = useState("Sign now")
- const { closeToast, openToast } = useToast()
-
- useEffect(() => {
- setStatus(PROCESS_STATUSES.PENDING)
- }, [setStatus])
-
- const onSignMessageSuccess = useCallback(() => {
- closeToast(TOAST_ID)
- goNext()
- }, [closeToast, goNext])
-
- const onSignMessageError = useCallback(() => {
- openToast({
- id: TOAST_ID,
- render: TOAST,
- })
- setButtonText("Try again")
- }, [openToast])
-
- const handleSignMessage = useExecuteFunction(
- signMessage,
- onSignMessageSuccess,
- onSignMessageError,
- )
-
- const handleSignMessageWrapper = useCallback(() => {
- logPromiseFailure(handleSignMessage())
- }, [handleSignMessage])
-
- return (
-
-
-
- )
-}
diff --git a/dapp/src/components/TransactionModal/ActiveStakingStep/StakeFormModal/StakeDetails.tsx b/dapp/src/components/TransactionModal/ActiveStakingStep/StakeFormModal/StakeDetails.tsx
index 6fc73f611..416d691b0 100644
--- a/dapp/src/components/TransactionModal/ActiveStakingStep/StakeFormModal/StakeDetails.tsx
+++ b/dapp/src/components/TransactionModal/ActiveStakingStep/StakeFormModal/StakeDetails.tsx
@@ -50,7 +50,6 @@ function StakeDetails({
/>
void
-}) {
+}: BaseFormProps) {
const minDepositAmount = useMinDepositAmount()
const { btcAccount } = useWalletContext()
const tokenBalance = BigInt(btcAccount?.balance.toString() ?? "0")
@@ -18,6 +17,7 @@ function StakeFormModal({
- Stake
+ Stake
)
}
diff --git a/dapp/src/components/TransactionModal/ActiveStakingStep/StakingErrorModal/RetryModal.tsx b/dapp/src/components/TransactionModal/ActiveStakingStep/StakingErrorModal/RetryModal.tsx
index b1a33e03e..c1c144eae 100644
--- a/dapp/src/components/TransactionModal/ActiveStakingStep/StakingErrorModal/RetryModal.tsx
+++ b/dapp/src/components/TransactionModal/ActiveStakingStep/StakingErrorModal/RetryModal.tsx
@@ -41,8 +41,10 @@ export default function RetryModal({ retry }: { retry: () => void }) {
return (
<>
- Oops! There was an error.
-
+
+ Oops! There was an error.
+
+
@@ -66,7 +68,7 @@ export default function RetryModal({ retry }: { retry: () => void }) {
-
+
diff --git a/dapp/src/components/TransactionModal/ActiveStakingStep/StakingErrorModal/ServerErrorModal.tsx b/dapp/src/components/TransactionModal/ActiveStakingStep/StakingErrorModal/ServerErrorModal.tsx
index ff4cc6b5e..e83409338 100644
--- a/dapp/src/components/TransactionModal/ActiveStakingStep/StakingErrorModal/ServerErrorModal.tsx
+++ b/dapp/src/components/TransactionModal/ActiveStakingStep/StakingErrorModal/ServerErrorModal.tsx
@@ -15,7 +15,7 @@ import { CableWithPlugIcon, Info } from "#/assets/icons"
import { TextMd } from "#/components/shared/Typography"
import { EXTERNAL_HREF } from "#/constants"
import IconWrapper from "#/components/shared/IconWrapper"
-import { MODAL_BASE_SIZE } from "#/components/shared/ModalBase"
+import { MODAL_BASE_SIZE } from "#/components/ModalRoot/withBaseModal"
import {
IconBrandDiscordFilled,
IconReload,
@@ -32,10 +32,10 @@ export default function ServerErrorModal({
return (
<>
-
+
We're currently facing system issues.
-
+
@@ -56,7 +56,6 @@ export default function ServerErrorModal({
diff --git a/dapp/src/components/TransactionModal/ActiveStakingStep/StakingErrorModal/index.tsx b/dapp/src/components/TransactionModal/ActiveStakingStep/StakingErrorModal/index.tsx
index 6ae4e1276..969a4e145 100644
--- a/dapp/src/components/TransactionModal/ActiveStakingStep/StakingErrorModal/index.tsx
+++ b/dapp/src/components/TransactionModal/ActiveStakingStep/StakingErrorModal/index.tsx
@@ -1,25 +1,26 @@
import React, { useCallback, useState } from "react"
import {
+ useAppDispatch,
useExecuteFunction,
- useModalFlowContext,
useStakeFlowContext,
} from "#/hooks"
import { PROCESS_STATUSES } from "#/types"
import { logPromiseFailure } from "#/utils"
+import { setStatus } from "#/store/action-flow"
import ServerErrorModal from "./ServerErrorModal"
import RetryModal from "./RetryModal"
import LoadingModal from "../../LoadingModal"
export default function StakingErrorModal() {
- const { setStatus } = useModalFlowContext()
const { stake } = useStakeFlowContext()
+ const dispatch = useAppDispatch()
const [isLoading, setIsLoading] = useState(false)
const [isServerError, setIsServerError] = useState(false)
const onStakeBTCSuccess = useCallback(
- () => setStatus(PROCESS_STATUSES.SUCCEEDED),
- [setStatus],
+ () => dispatch(setStatus(PROCESS_STATUSES.SUCCEEDED)),
+ [dispatch],
)
const onStakeBTCError = useCallback(() => setIsServerError(true), [])
diff --git a/dapp/src/components/TransactionModal/ActiveStakingStep/index.tsx b/dapp/src/components/TransactionModal/ActiveStakingStep/index.tsx
index 6776365f4..d03576d31 100644
--- a/dapp/src/components/TransactionModal/ActiveStakingStep/index.tsx
+++ b/dapp/src/components/TransactionModal/ActiveStakingStep/index.tsx
@@ -1,17 +1,11 @@
import React from "react"
import { ACTION_FLOW_STEPS_TYPES, ACTION_FLOW_TYPES } from "#/types"
-import SignMessageModal from "./SignMessageModal"
import DepositBTCModal from "./DepositBTCModal"
-import OverviewModal from "./OverviewModal"
const STEPS = ACTION_FLOW_STEPS_TYPES[ACTION_FLOW_TYPES.STAKE]
export function ActiveStakingStep({ activeStep }: { activeStep: number }) {
switch (activeStep) {
- case STEPS.OVERVIEW:
- return
- case STEPS.SIGN_MESSAGE:
- return
case STEPS.DEPOSIT_BTC:
return
default: {
diff --git a/dapp/src/components/TransactionModal/ActiveUnstakingStep/SignMessageModal.tsx b/dapp/src/components/TransactionModal/ActiveUnstakingStep/SignMessageModal.tsx
index d462cab94..3a8950325 100644
--- a/dapp/src/components/TransactionModal/ActiveUnstakingStep/SignMessageModal.tsx
+++ b/dapp/src/components/TransactionModal/ActiveUnstakingStep/SignMessageModal.tsx
@@ -1,26 +1,22 @@
-import React, { useCallback, useEffect } from "react"
-import { useExecuteFunction, useModalFlowContext } from "#/hooks"
+import React, { useCallback } from "react"
+import { useAppDispatch, useExecuteFunction } from "#/hooks"
import { PROCESS_STATUSES } from "#/types"
import { Button, ModalBody, ModalFooter, ModalHeader } from "@chakra-ui/react"
import { TextMd } from "#/components/shared/Typography"
import { logPromiseFailure } from "#/utils"
-import { ReceiveSTBTCAlert } from "#/components/shared/alerts"
+import { setStatus } from "#/store/action-flow"
export default function SignMessageModal() {
- const { setStatus } = useModalFlowContext()
-
- useEffect(() => {
- setStatus(PROCESS_STATUSES.PENDING)
- }, [setStatus])
+ const dispatch = useAppDispatch()
const onSignMessageSuccess = useCallback(() => {
- setStatus(PROCESS_STATUSES.SUCCEEDED)
- }, [setStatus])
+ dispatch(setStatus(PROCESS_STATUSES.SUCCEEDED))
+ }, [dispatch])
// TODO: After a failed attempt, we should display the message
const onSignMessageError = useCallback(() => {
- setStatus(PROCESS_STATUSES.FAILED)
- }, [setStatus])
+ dispatch(setStatus(PROCESS_STATUSES.FAILED))
+ }, [dispatch])
const handleSignMessage = useExecuteFunction(
// TODO: Use a correct function from the SDK
@@ -30,13 +26,13 @@ export default function SignMessageModal() {
)
const handleSignMessageWrapper = useCallback(() => {
- setStatus(PROCESS_STATUSES.LOADING)
+ dispatch(setStatus(PROCESS_STATUSES.LOADING))
// TODO: Remove when SDK is ready
setTimeout(() => {
logPromiseFailure(handleSignMessage())
}, 5000)
- }, [setStatus, handleSignMessage])
+ }, [dispatch, handleSignMessage])
return (
<>
@@ -46,7 +42,6 @@ export default function SignMessageModal() {
You will sign a gas-free Ethereum message to indicate the address
where you'd like to get your stBTC liquid staking token.
-