Skip to content

Commit

Permalink
[embed] Fix decodeBeaconPayload call
Browse files Browse the repository at this point in the history
  • Loading branch information
asiia-trilitech committed Sep 26, 2024
1 parent df2ece2 commit 2f17736
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions apps/embed-iframe/src/SignPayloadModalContent.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, Flex, Heading, Text, VStack } from "@chakra-ui/react";
import { Box, Flex, Heading, Switch, Text, VStack } from "@chakra-ui/react";
import * as Auth from "@umami/social-auth";

import { UmamiLogoIcon } from "./assets/icons/UmamiLogo";
Expand All @@ -13,13 +13,23 @@ import { LoginButtonComponent } from "./LoginButtonComponent";
import { getDAppByOrigin } from "./ClientsPermissions";
import { useSignPayloadModalContext } from "./SignPayloadModalContext";
import { decodeBeaconPayload } from "@umami/core";
import { useState } from "react";

import { WarningIcon } from "@chakra-ui/icons";

const SIGN_TIMEOUT = 5 * 60 * 1000; // 5 minutes

export const SignPayloadModalContent = () => {
const [showRaw, setShowRaw] = useState(false);

const { onClose, setIsLoading, signingType, payload } = useSignPayloadModalContext();
const { getNetwork, getUserData, getDAppOrigin } = useEmbedApp();

const { result: parsedPayload, error: parsingError } = decodeBeaconPayload(
payload!,
signingType!
);

const color = useColor();
const dAppName = getDAppByOrigin(getDAppOrigin());

Expand Down Expand Up @@ -79,9 +89,24 @@ export const SignPayloadModalContent = () => {
borderRadius="5px"
backgroundColor={color("100")}
>
<Text size="sm">{decodeBeaconPayload(payload!)}</Text>
<Text size="sm">{showRaw ? payload! : parsedPayload.trim()}</Text>
{parsingError && (
<Flex alignItems="center" gap="4px" marginTop="4px">
<WarningIcon width="15px" height="15px" />
<Text color="red" size="xs">
Raw Payload. Parsing failed
</Text>
</Flex>
)}
</Box>

{!parsingError && (
<Flex alignItems="center" justifyContent="flex-end" gap="4px" marginBottom="20px" ml="auto">
<Text>Raw</Text>
<Switch onChange={() => setShowRaw(val => !val)} />
</Flex>
)}

<LoginButtonComponent
loginType={getUserData()!.typeOfLogin}
prefix="Sign with"
Expand Down

1 comment on commit 2f17736

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Title Lines Statements Branches Functions
apps/desktop Coverage: 83%
83.57% (1760/2106) 78.67% (830/1055) 78.18% (448/573)
apps/web Coverage: 83%
83.57% (1760/2106) 78.67% (830/1055) 78.18% (448/573)
packages/components Coverage: 97%
97.1% (134/138) 96.49% (55/57) 82.92% (34/41)
packages/core Coverage: 81%
82.22% (222/270) 71.73% (99/138) 81.96% (50/61)
packages/crypto Coverage: 100%
100% (28/28) 100% (3/3) 100% (5/5)
packages/data-polling Coverage: 97%
95.27% (141/148) 87.5% (21/24) 92.85% (39/42)
packages/multisig Coverage: 98%
98.47% (129/131) 85.71% (18/21) 100% (35/35)
packages/social-auth Coverage: 100%
100% (21/21) 100% (11/11) 100% (3/3)
packages/state Coverage: 85%
84.59% (791/935) 80.97% (166/205) 78.72% (296/376)
packages/tezos Coverage: 86%
85.57% (89/104) 89.47% (17/19) 82.75% (24/29)
packages/tzkt Coverage: 86%
84.05% (58/69) 81.25% (13/16) 76.92% (30/39)

Please sign in to comment.