-
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.
Handling an error that occurs after a deposit action (#325)
This PR adds support for potential errors occurring after the deposit transaction. To handle this, we show an error screen prompting the user to retry. If the error is episodal, upon pressing the "Retry" button, the user will see the Success screen, continuing the flow as usual. We intentionally omit a close button, guiding the user to proceed within the flow and preventing abandonment. If the user chooses not to retry, a message will inform them that we will automatically retry after a designated time - 1 minute. However, if the repeated attempt results in an error, let's show the user the information to look for help on Discord. However, the user should be able to try again from this level. ### UI <img width="300" alt="Screenshot 2024-04-02 at 15 44 29" src="https://github.com/thesis/acre/assets/23117945/150e88a6-eb6f-48e5-9995-f6121a8c557c"> <img width="300" alt="Screenshot 2024-04-02 at 15 49 26" src="https://github.com/thesis/acre/assets/23117945/c7080253-868d-4c7c-85f6-13628c55a3b5"> #### Test flow recordings https://github.com/thesis/acre/assets/23117945/de124600-74bc-47ef-8a76-437426e55144 ### Testing Let's use a patch file to test. Use the following file: [test.patch](https://github.com/thesis/acre/files/14838545/test.patch) ``` git apply test.patch ```
- Loading branch information
Showing
34 changed files
with
458 additions
and
133 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
4 changes: 2 additions & 2 deletions
4
dapp/src/assets/icons/Bitcoin.tsx → dapp/src/assets/icons/BitcoinIcon.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
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 was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from "react" | ||
import { createIcon } from "@chakra-ui/react" | ||
|
||
export const EthereumIcon = createIcon({ | ||
displayName: "EthereumIcon", | ||
viewBox: "0 0 56 57", | ||
path: [ | ||
<g clipPath="url(#clip0_7755_23923)"> | ||
<rect | ||
y="0.5" | ||
width="56" | ||
height="56" | ||
rx="28" | ||
fill="white" | ||
fillOpacity="0.1" | ||
/> | ||
<rect y="0.5" width="56" height="56" fill="#231F20" /> | ||
<path | ||
fillRule="evenodd" | ||
clipRule="evenodd" | ||
d="M27.9967 13.5004L27.9969 13.5V13.5007L37.4934 28.9816L27.9969 34.4965V34.4969L27.9967 34.4967L27.9965 34.4968L27.996 34.4963L18.5 28.9816L27.9961 13.5014L27.9965 13.5L27.9967 13.5004ZM27.9969 43.8989V43.901L18.5 30.7528L27.9969 36.2652V36.2664L27.9978 36.2654L37.5003 30.7529L27.9978 43.9012L27.9969 43.8989Z" | ||
fill="#FFFDF9" | ||
/> | ||
</g>, | ||
<defs> | ||
<clipPath id="clip0_7755_23923"> | ||
<rect y="0.5" width="56" height="56" rx="28" fill="white" /> | ||
</clipPath> | ||
</defs>, | ||
], | ||
}) |
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
80 changes: 80 additions & 0 deletions
80
dapp/src/components/TransactionModal/ActiveStakingStep/StakingErrorModal/RetryModal.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 |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import React, { useMemo } from "react" | ||
import { | ||
Box, | ||
Button, | ||
HStack, | ||
Icon, | ||
ModalBody, | ||
ModalFooter, | ||
ModalHeader, | ||
} from "@chakra-ui/react" | ||
import { CableWithPlugIcon } from "#/assets/icons" | ||
import { TextMd, TextSm } from "#/components/shared/Typography" | ||
import IconWrapper from "#/components/shared/IconWrapper" | ||
import { getExpirationTimestamp, getPercentValue } from "#/utils" | ||
import { useCountdown } from "#/hooks" | ||
import { ONE_MINUTE_IN_SECONDS, ONE_SEC_IN_MILLISECONDS } from "#/constants" | ||
import { IconShieldCheckFilled, IconX } from "@tabler/icons-react" | ||
|
||
const getCounterData = (minutes: string, seconds: string) => { | ||
const isLessThanMinute = parseInt(minutes, 10) <= 0 | ||
|
||
const progressPercent = `${ | ||
isLessThanMinute | ||
? getPercentValue(parseInt(seconds, 10), ONE_MINUTE_IN_SECONDS) | ||
: 100 | ||
}%` | ||
const label = `${isLessThanMinute ? "0" : "1"}:${seconds}` | ||
|
||
return { label, progressPercent } | ||
} | ||
|
||
export default function RetryModal({ retry }: { retry: () => void }) { | ||
const retryTimestamp = useMemo( | ||
() => | ||
getExpirationTimestamp(ONE_MINUTE_IN_SECONDS * ONE_SEC_IN_MILLISECONDS), | ||
[], | ||
) | ||
const { minutes, seconds } = useCountdown(retryTimestamp, true, retry) | ||
|
||
const { label, progressPercent } = getCounterData(minutes, seconds) | ||
|
||
return ( | ||
<> | ||
<ModalHeader color="red.400">Oops! There was an error.</ModalHeader> | ||
<ModalBody gap={10} pt={4}> | ||
<IconWrapper icon={CableWithPlugIcon} boxSize={32} color="red.400"> | ||
<Icon as={IconX} color="red.400" boxSize={14} strokeWidth={1} /> | ||
</IconWrapper> | ||
<TextMd> | ||
Your deposit didn't go through but no worries, your funds are | ||
safe. | ||
</TextMd> | ||
<HStack gap={1}> | ||
<TextMd>Auto-retry in</TextMd> | ||
<TextMd fontWeight="bold" textAlign="left" minW={10}> | ||
{label} | ||
</TextMd> | ||
<Box | ||
w={3} | ||
h={3} | ||
aspectRatio={1} | ||
borderRadius="50%" | ||
background={`conic-gradient(var(--chakra-colors-brand-400) ${progressPercent}, transparent 0)`} | ||
transition="background" | ||
/> | ||
<Box /> | ||
</HStack> | ||
</ModalBody> | ||
<ModalFooter mt={4}> | ||
<Button size="lg" width="100%" onClick={retry}> | ||
Retry | ||
</Button> | ||
<HStack> | ||
<Icon as={IconShieldCheckFilled} boxSize={5} color="gold.700" /> | ||
<TextSm color="grey.700">Your funds are secure.</TextSm> | ||
</HStack> | ||
</ModalFooter> | ||
</> | ||
) | ||
} |
Oops, something went wrong.