-
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 subgraph_activity_details
- Loading branch information
Showing
91 changed files
with
2,989 additions
and
4,939 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
44 changes: 34 additions & 10 deletions
44
dapp/src/components/TransactionModal/ActiveStakingStep/SignMessageModal.tsx
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,34 +1,58 @@ | ||
import React, { useCallback, useEffect } from "react" | ||
import React, { useCallback, useEffect, useState } from "react" | ||
import { | ||
useExecuteFunction, | ||
useModalFlowContext, | ||
useStakeFlowContext, | ||
useToast, | ||
} from "#/hooks" | ||
import { logPromiseFailure } from "#/utils" | ||
import AlertReceiveSTBTC from "#/components/shared/AlertReceiveSTBTC" | ||
import { PROCESS_STATUSES } from "#/types" | ||
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 handleSignMessage = useExecuteFunction(signMessage, goNext) | ||
|
||
const handleSignMessageWrapper = useCallback(() => { | ||
logPromiseFailure(handleSignMessage()) | ||
}, [handleSignMessage]) | ||
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 ( | ||
<StakingStepsModalContent | ||
buttonText="Sign now" | ||
buttonText={buttonText} | ||
activeStep={0} | ||
onClick={handleSignMessageWrapper} | ||
> | ||
<AlertReceiveSTBTC /> | ||
<ReceiveSTBTCAlert /> | ||
</StakingStepsModalContent> | ||
) | ||
} |
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
Oops, something went wrong.