diff --git a/apps/dashboard/src/@/components/blocks/FormFieldSetup.tsx b/apps/dashboard/src/@/components/blocks/FormFieldSetup.tsx index 6e9fe8d2068..1c704b098c2 100644 --- a/apps/dashboard/src/@/components/blocks/FormFieldSetup.tsx +++ b/apps/dashboard/src/@/components/blocks/FormFieldSetup.tsx @@ -7,7 +7,7 @@ export function FormFieldSetup(props: { label: string; errorMessage: React.ReactNode | undefined; children: React.ReactNode; - tooltip: React.ReactNode | undefined; + tooltip?: React.ReactNode; isRequired: boolean; }) { return ( diff --git a/apps/dashboard/src/@/components/ui/input.tsx b/apps/dashboard/src/@/components/ui/input.tsx index fee90047907..421d7f27625 100644 --- a/apps/dashboard/src/@/components/ui/input.tsx +++ b/apps/dashboard/src/@/components/ui/input.tsx @@ -11,7 +11,7 @@ const Input = React.forwardRef( = ({ htmlFor="name" label="Name" errorMessage={networkNameErrorMessage} - tooltip={undefined} isRequired > = ({ isRequired label="Currency Symbol" errorMessage={form.formState.errors.currencySymbol?.message} - tooltip={undefined} htmlFor="currency-symbol" > = ({ errorMessage={form.formState.errors.icon?.message} htmlFor="network-icon" label="Icon" - tooltip={undefined} >
diff --git a/apps/dashboard/src/components/configure-networks/Form/ChainIdInput.tsx b/apps/dashboard/src/components/configure-networks/Form/ChainIdInput.tsx index 758cc9f40b9..566a1e089a8 100644 --- a/apps/dashboard/src/components/configure-networks/Form/ChainIdInput.tsx +++ b/apps/dashboard/src/components/configure-networks/Form/ChainIdInput.tsx @@ -17,7 +17,6 @@ export const ChainIdInput: React.FC<{ ? form.formState.errors.chainId?.message : undefined } - tooltip={undefined} > = ({ instanceUrl }) => { - const { isOpen, onOpen, onClose } = useDisclosure(); +}) { + const { instanceUrl } = props; + const [isOpen, setIsOpen] = useState(false); const { data: walletConfig } = useEngineWalletConfig(instanceUrl); - const { mutate: createBackendWallet } = - useEngineCreateBackendWallet(instanceUrl); - const { onSuccess, onError } = useTxNotifications( - "Wallet created successfully.", - "Failed to create wallet.", - ); + const createWallet = useEngineCreateBackendWallet(instanceUrl); const trackEvent = useTrack(); const form = useForm(); const onSubmit = async (data: CreateBackendWalletInput) => { - createBackendWallet(data, { + const promise = createWallet.mutateAsync(data, { onSuccess: () => { - onSuccess(); - onClose(); + setIsOpen(false); trackEvent({ category: "engine", action: "create-backend-wallet", @@ -52,7 +44,6 @@ export const CreateBackendWalletButton: React.FC< }); }, onError: (error) => { - onError(error); trackEvent({ category: "engine", action: "create-backend-wallet", @@ -62,6 +53,11 @@ export const CreateBackendWalletButton: React.FC< }); }, }); + + toast.promise(promise, { + success: "Wallet created successfully", + error: "Failed to create wallet", + }); }; const walletType = @@ -73,43 +69,58 @@ export const CreateBackendWalletButton: React.FC< return ( <> - - - - + + +
- Create {walletType} wallet - - +
+ + + Create {walletType} wallet + + +
- - Wallet Type - {walletType} - - - Label +
+

Wallet Type

+ + {walletType} + +
+ + -
+
- +
- - - - + -
-
+ + ); -}; +} diff --git a/apps/dashboard/src/components/engine/overview/engine-overview.tsx b/apps/dashboard/src/components/engine/overview/engine-overview.tsx index 6948f16f4bf..ce956b4c4fa 100644 --- a/apps/dashboard/src/components/engine/overview/engine-overview.tsx +++ b/apps/dashboard/src/components/engine/overview/engine-overview.tsx @@ -1,16 +1,17 @@ "use client"; import { Badge } from "@/components/ui/badge"; +import { Label } from "@/components/ui/label"; +import { Switch } from "@/components/ui/switch"; import { ToolTipLabel } from "@/components/ui/tooltip"; import { useEngineBackendWallets, useEngineTransactions, useEngineWalletConfig, } from "@3rdweb-sdk/react/hooks/useEngine"; -import { Flex, FormControl, Switch } from "@chakra-ui/react"; import { NetworkSelectorButton } from "components/selects/NetworkSelectorButton"; +import Link from "next/link"; import { useState } from "react"; -import { FormLabel, Heading, Link, Text } from "tw-components"; import { BackendWalletsTable } from "./backend-wallets-table"; import { CreateBackendWalletButton } from "./create-backend-wallet-button"; import { ImportBackendWalletButton } from "./import-backend-wallet-button"; @@ -23,107 +24,135 @@ interface EngineOverviewProps { export const EngineOverview: React.FC = ({ instanceUrl, }) => { + return ( +
+ +
+ +
+ ); +}; + +function BackendWalletsSection(props: { + instanceUrl: string; +}) { + const { instanceUrl } = props; const backendWallets = useEngineBackendWallets(instanceUrl); const { data: walletConfig } = useEngineWalletConfig(instanceUrl); - const [autoUpdate, setAutoUpdate] = useState(true); - const transactionsQuery = useEngineTransactions(instanceUrl, autoUpdate); return ( - - - - - - - Backend Wallets - {walletConfig?.type && ( - - This engine is configured to use{" "} - {walletConfig.type === "aws-kms" - ? "backend wallets secured by AWS KMS" - : walletConfig.type === "gcp-kms" - ? "backend wallets secured by GCP KMS" - : "local backend wallets"} - . You can change this in the Configuration tab. - - } - > -
- - {walletConfig.type.replace("-", " ")} - -
-
- )} -
- - Engine performs blockchain actions using backend wallets you own - and manage.{" "} - - Learn more - - -
- -
- - -
-
+
+
+
+
+

+ Backend Wallets +

+ {walletConfig?.type && ( + + This engine is configured to use{" "} + {walletConfig.type === "aws-kms" + ? "backend wallets secured by AWS KMS" + : walletConfig.type === "gcp-kms" + ? "backend wallets secured by GCP KMS" + : "local backend wallets"} + . You can change this in the Configuration tab. + + } + > +
+ + {walletConfig.type.replace("-", " ")} + +
+
+ )} +
+

+ Engine performs blockchain actions using backend wallets you own and + manage.{" "} + + Learn more + +

+
- - - Show balance for -
- -
-
-
- +
+ + +
+
- - - - - - Transactions - - View transactions sent from your backend wallets in the past 24 - hours. - - +
+
+
+ Show balance for + {/* TODO - Replace with simple network selector - there's no need for user to switch chain */}
- - - Auto-Update - - setAutoUpdate((val) => !val)} - id="auto-update" - /> - +
- - - - +
+
+ +
+ + +
); -}; +} + +function TransactionsSection(props: { + instanceUrl: string; +}) { + const { instanceUrl } = props; + const [autoUpdate, setAutoUpdate] = useState(true); + const transactionsQuery = useEngineTransactions(instanceUrl, autoUpdate); + + return ( +
+
+
+

+ Transactions +

+

+ View transactions sent from your backend wallets in the past 24 + hours. +

+
+ +
+
+ + setAutoUpdate(!!v)} + id="auto-update" + /> +
+
+
+ +
+ + +
+ ); +} diff --git a/apps/dashboard/src/components/engine/overview/import-backend-wallet-button.tsx b/apps/dashboard/src/components/engine/overview/import-backend-wallet-button.tsx index 77a8de8de33..c0b0c31acad 100644 --- a/apps/dashboard/src/components/engine/overview/import-backend-wallet-button.tsx +++ b/apps/dashboard/src/components/engine/overview/import-backend-wallet-button.tsx @@ -1,41 +1,33 @@ +"use client"; + +import { FormFieldSetup } from "@/components/blocks/FormFieldSetup"; +import { Spinner } from "@/components/ui/Spinner/Spinner"; +import { Button } from "@/components/ui/button"; +import { + Dialog, + DialogContent, + DialogFooter, + DialogHeader, + DialogTitle, +} from "@/components/ui/dialog"; +import { Input } from "@/components/ui/input"; import { type ImportBackendWalletInput, useEngineImportBackendWallet, useEngineWalletConfig, } from "@3rdweb-sdk/react/hooks/useEngine"; -import { - Flex, - FormControl, - Input, - Modal, - ModalBody, - ModalCloseButton, - ModalContent, - ModalFooter, - ModalHeader, - ModalOverlay, - useDisclosure, -} from "@chakra-ui/react"; import { useTrack } from "hooks/analytics/useTrack"; -import { useTxNotifications } from "hooks/useTxNotifications"; +import { useState } from "react"; import { useForm } from "react-hook-form"; -import { Button, FormLabel } from "tw-components"; +import { toast } from "sonner"; -interface ImportBackendWalletButtonProps { +export function ImportBackendWalletButton(props: { instanceUrl: string; -} - -export const ImportBackendWalletButton: React.FC< - ImportBackendWalletButtonProps -> = ({ instanceUrl }) => { - const { isOpen, onOpen, onClose } = useDisclosure(); +}) { + const { instanceUrl } = props; + const [isModalOpen, setIsModalOpen] = useState(false); const { data: walletConfig } = useEngineWalletConfig(instanceUrl); - const { mutate: importBackendWallet } = - useEngineImportBackendWallet(instanceUrl); - const { onSuccess, onError } = useTxNotifications( - "Wallet imported successfully.", - "Failed to import wallet.", - ); + const importWallet = useEngineImportBackendWallet(instanceUrl); const trackEvent = useTrack(); const form = useForm(); @@ -48,111 +40,174 @@ export const ImportBackendWalletButton: React.FC< return ( <> - - - - { - importBackendWallet(data, { - onSuccess: () => { - onSuccess(); - onClose(); - trackEvent({ - category: "engine", - action: "import-backend-wallet", - label: "success", - type: walletConfig?.type, - instance: instanceUrl, - }); - }, - onError: (error) => { - onError(error); - trackEvent({ - category: "engine", - action: "import-backend-wallet", - label: "error", - type: walletConfig?.type, - instance: instanceUrl, - error, - }); - }, - }); - })} + + - Import {walletType} wallet - - - {walletConfig?.type === "local" && ( - - Private key - - - )} - {walletConfig?.type === "aws-kms" && ( - - - AWS KMS Key ID - - - - AWS KMS ARN - - - - )} - {walletConfig?.type === "gcp-kms" && ( - - - GCP KMS Key ID - - - - GCP KMS Version ID +
{ + const promise = importWallet.mutateAsync(data, { + onSuccess: () => { + setIsModalOpen(false); + trackEvent({ + category: "engine", + action: "import-backend-wallet", + label: "success", + type: walletConfig?.type, + instance: instanceUrl, + }); + }, + onError: (error) => { + trackEvent({ + category: "engine", + action: "import-backend-wallet", + label: "error", + type: walletConfig?.type, + instance: instanceUrl, + error, + }); + }, + }); + + toast.promise(promise, { + success: "Wallet imported successfully", + error: "Failed to import wallet", + }); + })} + > +
+ + + Import {walletType} wallet + + + + {walletConfig?.type === "local" && ( + - - - )} - + + )} + + {walletConfig?.type === "aws-kms" && ( +
+ + + + + + + +
+ )} - - - - - - + {walletConfig?.type === "gcp-kms" && ( +
+ + + + + + + +
+ )} +
+ + + + + +
+
+
); -}; +}