diff --git a/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/account-abstraction/settings/SponsorshipPolicies/index.tsx b/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/account-abstraction/settings/SponsorshipPolicies/index.tsx index 0aab8312db0..b340e320880 100644 --- a/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/account-abstraction/settings/SponsorshipPolicies/index.tsx +++ b/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/account-abstraction/settings/SponsorshipPolicies/index.tsx @@ -1,23 +1,9 @@ "use client"; -import { - Box, - Divider, - Flex, - FormControl, - IconButton, - Input, - Select, - Switch, - Textarea, -} from "@chakra-ui/react"; import { zodResolver } from "@hookform/resolvers/zod"; import { useMutation } from "@tanstack/react-query"; import type { ProjectBundlerService } from "@thirdweb-dev/service-utils"; -import { Button } from "chakra/button"; -import { FormErrorMessage, FormLabel } from "chakra/form"; -import { Text } from "chakra/text"; -import { TrashIcon } from "lucide-react"; +import { PlusIcon, TrashIcon } from "lucide-react"; import { useMemo } from "react"; import { useFieldArray, useForm } from "react-hook-form"; import { isAddress, type ThirdwebClient } from "thirdweb"; @@ -26,6 +12,26 @@ import type { Project } from "@/api/projects"; import type { Team } from "@/api/team"; import { GatedSwitch } from "@/components/blocks/GatedSwitch"; import { MultiNetworkSelector } from "@/components/blocks/NetworkSelectors"; +import { Button } from "@/components/ui/button"; +import { DynamicHeight } from "@/components/ui/DynamicHeight"; +import { + Form, + FormField, + FormItem, + FormLabel, + FormMessage, +} from "@/components/ui/form"; +import { Input } from "@/components/ui/input"; +import { Spinner } from "@/components/ui/Spinner/Spinner"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; +import { Switch } from "@/components/ui/switch"; +import { Textarea } from "@/components/ui/textarea"; import { UnderlineLink } from "@/components/ui/UnderlineLink"; import { updateProjectClient } from "@/hooks/useApi"; import { useTxNotifications } from "@/hooks/useTxNotifications"; @@ -175,45 +181,25 @@ export function AccountAbstractionSettingsPage( ); return ( - - - - - Configure the rules for your sponsored transactions.{" "} - - View documentation - - . - - - - { - const limits: ProjectBundlerService["limits"] | null = - values.globalLimit - ? { - global: { - maxSpend: values.globalLimit.maxSpend, - maxSpendUnit: values.globalLimit.maxSpendUnit, - }, - } - : null; - - const parsedValues: Omit = - { +
+
+ { + const limits: ProjectBundlerService["limits"] | null = + values.globalLimit + ? { + global: { + maxSpend: values.globalLimit.maxSpend, + maxSpendUnit: values.globalLimit.maxSpendUnit, + }, + } + : null; + + const parsedValues: Omit< + ProjectBundlerService, + "name" | "actions" + > = { // don't set null - `updateProject` API adds chainId 0 to the list if its null and makes it `[0]` allowedChainIds: values.allowedChainIds || [], allowedContractAddresses: values.allowedContractAddresses @@ -245,454 +231,493 @@ export function AccountAbstractionSettingsPage( : null, }; - const newServices = props.project.services.map((service) => { - if (service.name === "bundler") { - const bundlerService: ProjectBundlerService = { - ...service, - actions: [], - ...parsedValues, - }; - - return bundlerService; - } - - return service; - }); - - updateProject.mutate( - { - services: newServices, - }, - { - onError, - onSuccess, - }, - ); - })} - > - - -
-
- Global spend limits - - Maximum gas cost (in USD) that you want to sponsor.
{" "} - This applies for the duration of the billing period (monthly). - Once this limit is reached, your users will have to fund their - own gas costs. -
-
- - { - form.setValue( - "globalLimit", - !form.watch("globalLimit") - ? { - maxSpend: "0", - maxSpendUnit: "usd", - } - : null, - ); - }} - /> -
- {form.watch("globalLimit") && ( -
- - Spend limit -
- - - per month -
- - { - form.getFieldState("globalLimit.maxSpend", form.formState) - .error?.message - } - -
-
- )} -
-
- - - -
-
- - Restrict to specific chains - - - Only sponsor transactions on the specified chains.
By - default, transactions can be sponsored on any of the{" "} - - supported chains. - -
-
- - { - form.setValue( - "allowedChainIds", - !form.watch("allowedChainIds") ? [] : null, - ); - }} - /> -
- {form.watch("allowedChainIds") && ( - - - form.setValue("allowedChainIds", chainIds) - } - selectedChainIds={form.watch("allowedChainIds") || []} - /> - - { - form.getFieldState("allowedChainIds", form.formState).error - ?.message - } - - - )} -
-
- - { + if (service.name === "bundler") { + const bundlerService: ProjectBundlerService = { + ...service, + actions: [], + ...parsedValues, + }; + + return bundlerService; + } + + return service; + }); + + updateProject.mutate( + { + services: newServices, + }, + { + onError, + onSuccess, + }, + ); + })} > - -
-
- - Restrict to specific contract addresses - - - Only sponsor transactions for the specified contracts. - -
- - { - form.setValue( - "allowedContractAddresses", - form.watch("allowedContractAddresses") === null ? "" : null, - ); - }} - /> -
- {form.watch("allowedContractAddresses") !== null && ( - -