Skip to content

Commit

Permalink
Add a new step for the withdrawal flow
Browse files Browse the repository at this point in the history
  • Loading branch information
kkosiorowska committed Oct 30, 2024
1 parent 51a3965 commit d0c0418
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import WalletInteractionModal from "../WalletInteractionModal"

const { userKeys } = queryKeysFactory

type WithdrawalStatus = "building-data" | "signature" | "transaction"
type WithdrawalStatus = "building-data" | "built-data" | "signature"

const sessionIdToPromise: Record<
number,
Expand Down Expand Up @@ -62,7 +62,10 @@ export default function SignMessageModal() {
}
}, [])

const builtDataStepCallback = useCallback(() => Promise.resolve(), [])
const builtDataStepCallback = useCallback(() => {
setWaitingStatus("built-data")
return Promise.resolve()
}, [])

const onSignMessageCallback = useCallback(async () => {
setWaitingStatus("signature")
Expand All @@ -72,12 +75,6 @@ export default function SignMessageModal() {
])
}, [])

const messageSignedCallback = useCallback(() => {
setWaitingStatus("transaction")
dispatch(setStatus(PROCESS_STATUSES.LOADING))
return Promise.resolve()
}, [dispatch])

const onSignMessageSuccess = useCallback(() => {
handleBitcoinPositionInvalidation()
dispatch(setStatus(PROCESS_STATUSES.SUCCEEDED))
Expand Down Expand Up @@ -108,7 +105,6 @@ export default function SignMessageModal() {
amount,
builtDataStepCallback,
onSignMessageCallback,
messageSignedCallback,
)

dispatch(
Expand Down Expand Up @@ -169,9 +165,11 @@ export default function SignMessageModal() {

useTimeout(handleInitWithdrawAndSignMessageWrapper, ONE_SEC_IN_MILLISECONDS)

// TODO: This step should be split into several steps (building data and opening a wallet).
if (status === "building-data")
return <BuildTransactionModal onClose={onClose} />

if (status === "built-data")
return <WalletInteractionModal step="opening-wallet" />

return <WalletInteractionModal step="awaiting-transaction" />
}

0 comments on commit d0c0418

Please sign in to comment.