Skip to content

Commit

Permalink
Merge pull request #1801 from trilitech/send-message-when-estimation-…
Browse files Browse the repository at this point in the history
…completed

Send message to Embed Component when fee estimation completed
  • Loading branch information
asiia-trilitech authored Sep 5, 2024
2 parents 149ce37 + 997446b commit 5e732fa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
4 changes: 2 additions & 2 deletions apps/embed-iframe/src/OperationModalContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { getDAppByOrigin } from "./ClientsPermissions";
const SIGN_TIMEOUT = 5 * 60 * 1000; // 5 minutes

export const OperationModalContent = () => {
const { onClose, isLoading, setIsLoading, estimatedOperations } = useOperationModalContext();
const { onClose, setIsLoading, estimatedOperations } = useOperationModalContext();
const { getNetwork, getUserData, getDAppOrigin } = useEmbedApp();

const color = useColor();
Expand Down Expand Up @@ -113,7 +113,7 @@ export const OperationModalContent = () => {
Fee:
</Text>
<Text color={color("900")} data-testid="fee" size="xs">
{isLoading ? "..." : prettyTezAmount(totalFee(estimatedOperations!.estimates))}
{prettyTezAmount(totalFee(estimatedOperations!.estimates))}
</Text>
</Flex>
</Flex>
Expand Down
12 changes: 9 additions & 3 deletions apps/embed-iframe/src/operationModalHooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import type { PartialTezosOperation } from "@airgap/beacon-types";
import { Center, Modal, ModalCloseButton, ModalContent } from "@chakra-ui/react";

import { OperationModalContent } from "./OperationModalContent";
import { sendOperationErrorResponse, toSocialAccount, toTezosNetwork } from "./utils";
import {
sendComputationErrorResponse,
sendOperationErrorResponse,
sendResponse,
toSocialAccount,
toTezosNetwork,
} from "./utils";
import { useOperationModalContext } from "./OperationModalContext";
import { ModalLoadingOverlay } from "./ModalLoadingOverlay";
import { estimate, getErrorContext, toAccountOperations } from "@umami/core";
Expand Down Expand Up @@ -42,11 +48,11 @@ export const useOperationModal = () => {
accountOperations,
toTezosNetwork(getNetwork()!)
);

setEstimatedOperations(estimatedOperations);
onOpen();
sendResponse({ type: "computation_completed_response" });
} catch (error) {
sendOperationErrorResponse(getErrorContext(error).description);
sendComputationErrorResponse(getErrorContext(error).description);
onClose();
}
},
Expand Down
8 changes: 8 additions & 0 deletions apps/embed-iframe/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ export const sendLoginErrorResponse = (errorMessage: string) => {
});
};

export const sendComputationErrorResponse = (errorMessage: string) => {
sendResponse({
type: "computation_completed_response",
error: "operation_failed",
errorMessage,
});
};

export const sendOperationErrorResponse = (errorMessage: string) => {
sendResponse({
type: "operation_response",
Expand Down

1 comment on commit 5e732fa

@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: 84%
83.95% (1789/2131) 79.09% (840/1062) 78.57% (451/574)
apps/web Coverage: 84%
83.95% (1789/2131) 79.09% (840/1062) 78.57% (451/574)
packages/components Coverage: 96%
96.89% (125/129) 98.07% (51/52) 84.21% (32/38)
packages/core Coverage: 82%
83.05% (196/236) 73.55% (89/121) 82.14% (46/56)
packages/crypto Coverage: 100%
100% (28/28) 100% (3/3) 100% (5/5)
packages/data-polling Coverage: 98%
96.55% (140/145) 95.45% (21/22) 92.85% (39/42)
packages/multisig Coverage: 98%
98.4% (123/125) 89.47% (17/19) 100% (33/33)
packages/social-auth Coverage: 100%
100% (21/21) 100% (11/11) 100% (3/3)
packages/state Coverage: 84%
83.98% (771/918) 80.78% (164/203) 78.86% (291/369)
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.