diff --git a/apps/embed-iframe/src/ClientsPermissions.ts b/apps/embed-iframe/src/ClientsPermissions.ts index b50013ff86..418d712aab 100644 --- a/apps/embed-iframe/src/ClientsPermissions.ts +++ b/apps/embed-iframe/src/ClientsPermissions.ts @@ -24,3 +24,13 @@ export const getPermissionsForOrigin = (origin: string): Permissions | null => { } return null; }; + +export const getDAppByOrigin = (origin: string): string | null => { + for (const key in clientPermissions) { + const permissions = clientPermissions[key]; + if (permissions.origins.includes(origin)) { + return key; + } + } + return null; +}; diff --git a/apps/embed-iframe/src/LoginButtonComponent.tsx b/apps/embed-iframe/src/LoginButtonComponent.tsx index c0a6bf66a3..ca2a3f9d4f 100644 --- a/apps/embed-iframe/src/LoginButtonComponent.tsx +++ b/apps/embed-iframe/src/LoginButtonComponent.tsx @@ -6,9 +6,11 @@ import { FacebookLogoIcon, GoogleLogoIcon, RedditLogoIcon, TwitterLogoIcon } fro export const LoginButtonComponent = ({ onClick, loginType, + prefix, }: { onClick: () => void; loginType: TypeOfLogin; + prefix?: string; }) => ( ); @@ -55,7 +57,7 @@ const LogoIcon = ({ loginType }: { loginType: TypeOfLogin }) => { } }; -const buttonLabel = (loginType: TypeOfLogin) => { +const socialLabel = (loginType: TypeOfLogin) => { switch (loginType) { case "facebook": return "Facebook"; diff --git a/apps/embed-iframe/src/OperationModalContent.tsx b/apps/embed-iframe/src/OperationModalContent.tsx index 1e5f49d4e5..392595f397 100644 --- a/apps/embed-iframe/src/OperationModalContent.tsx +++ b/apps/embed-iframe/src/OperationModalContent.tsx @@ -5,7 +5,6 @@ import { AccordionItem, AccordionPanel, Box, - Center, Flex, Heading, Text, @@ -13,7 +12,6 @@ import { } from "@chakra-ui/react"; import * as Auth from "@umami/social-auth"; -import { TezosLogoIcon } from "./assets/icons/TezosLogo"; import { UmamiLogoIcon } from "./assets/icons/UmamiLogo"; import { JsValueWrap } from "./imported/JsValueWrap"; @@ -23,20 +21,19 @@ import { sendOperationErrorResponse, sendResponse, toTezosNetwork } from "./util import { makeToolkit, prettyTezAmount } from "@umami/tezos"; import { useEmbedApp } from "./EmbedAppContext"; import { useColor } from "./imported/style/useColor"; -import { - executeOperations, - totalFee, -} from "@umami/core"; +import { executeOperations, totalFee } from "@umami/core"; import { LoginButtonComponent } from "./LoginButtonComponent"; import { useOperationModalContext } from "./OperationModalContext"; +import { getDAppByOrigin } from "./ClientsPermissions"; const SIGN_TIMEOUT = 5 * 60 * 1000; // 5 minutes export const OperationModalContent = () => { const { onClose, isLoading, setIsLoading, estimatedOperations } = useOperationModalContext(); - const { getNetwork, getUserData } = useEmbedApp(); + const { getNetwork, getUserData, getDAppOrigin } = useEmbedApp(); const color = useColor(); + const dAppName = getDAppByOrigin(getDAppOrigin()); const onClick = async () => { setIsLoading(true); @@ -74,57 +71,70 @@ export const OperationModalContent = () => { Confirm Operation - - - Network: - - - {getNetwork()} + + + {dAppName ? dAppName : getDAppOrigin()} + + is requesting permission to sign this operation + - - + + - Operations + Show Details - - + + + + + + + + Count: + + + {estimatedOperations!.operations.length} + + + + + + Fee: + + + {isLoading ? "..." : prettyTezAmount(totalFee(estimatedOperations!.estimates))} + + + + + + + Network: + + + {getNetwork()} + + - - - - Count: - - - {estimatedOperations!.operations.length} - - - - - - Fee: - - - {isLoading ? "..." : prettyTezAmount(totalFee(estimatedOperations!.estimates))} - - - - - - -
- - Powered by - - -
+ ); }; diff --git a/apps/embed-iframe/src/OperationModalContext.tsx b/apps/embed-iframe/src/OperationModalContext.tsx index 6bfbca8292..093d8ba483 100644 --- a/apps/embed-iframe/src/OperationModalContext.tsx +++ b/apps/embed-iframe/src/OperationModalContext.tsx @@ -8,8 +8,8 @@ interface OperationModalContextState { onClose: () => void; isLoading: boolean; setIsLoading: (isLoading: boolean) => void; - estimatedOperations: EstimatedAccountOperations | null; - setEstimatedOperations: (estimatedOperations: EstimatedAccountOperations | null) => void; + estimatedOperations: EstimatedAccountOperations | null; + setEstimatedOperations: (estimatedOperations: EstimatedAccountOperations | null) => void; } const OperationModalContext = createContext(undefined); @@ -23,7 +23,15 @@ export const OperationModalProvider = ({ children }: PropsWithChildren) => { return ( {children}