diff --git a/dapp/.eslintrc b/dapp/.eslintrc index 35437e4ed..c87013b23 100644 --- a/dapp/.eslintrc +++ b/dapp/.eslintrc @@ -17,63 +17,6 @@ ], "react/require-default-props": [0], }, - // FIXME: - // This is temporary solution after changes of the eslint-config version: @thesis-co/eslint-config: "github:thesis/eslint-config#7b9bc8c" - // Overrides rules should be fixed file by file. - "overrides": [ - { - "files": [ - "src/components/Header/ConnectWallet.tsx", - "src/components/Modals/Support/MissingAccount.tsx", - "src/components/Modals/Staking/SignMessage.tsx", - "src/hooks/useDepositBTCTransaction.ts", - "src/components/shared/Form/FormTokenBalanceInput.tsx" - ], - "rules": { - "@typescript-eslint/no-misused-promises": "off" - } - }, - { - "files": [ - "src/hooks/useSignMessage.ts" - ], - "rules": { - "@typescript-eslint/no-floating-promises": "off" - } - }, - { - "files": [ - "src/theme/*" - ], - "rules": { - "@typescript-eslint/unbound-method": "off" - } - }, - { - "files": [ - "src/theme/Alert.ts" - ], - "rules": { - "@typescript-eslint/no-unsafe-member-access": "off" - } - }, - { - "files": [ - "src/components/shared/Form/FormTokenBalanceInput.tsx" - ], - "rules": { - "@typescript-eslint/no-unsafe-assignment": "off" - } - }, - { - "files": [ - "src/components/shared/TokenAmountForm/index.tsx" - ], - "rules": { - "@typescript-eslint/require-await": "off" - } - } - ], "settings": { "import/resolver": { "alias": { diff --git a/dapp/src/fonts/Segment-Black.otf b/dapp/src/assets/fonts/Segment-Black.otf similarity index 100% rename from dapp/src/fonts/Segment-Black.otf rename to dapp/src/assets/fonts/Segment-Black.otf diff --git a/dapp/src/fonts/Segment-Bold.otf b/dapp/src/assets/fonts/Segment-Bold.otf similarity index 100% rename from dapp/src/fonts/Segment-Bold.otf rename to dapp/src/assets/fonts/Segment-Bold.otf diff --git a/dapp/src/fonts/Segment-Medium.otf b/dapp/src/assets/fonts/Segment-Medium.otf similarity index 100% rename from dapp/src/fonts/Segment-Medium.otf rename to dapp/src/assets/fonts/Segment-Medium.otf diff --git a/dapp/src/fonts/Segment-Regular.otf b/dapp/src/assets/fonts/Segment-Regular.otf similarity index 100% rename from dapp/src/fonts/Segment-Regular.otf rename to dapp/src/assets/fonts/Segment-Regular.otf diff --git a/dapp/src/fonts/Segment-SemiBold.otf b/dapp/src/assets/fonts/Segment-SemiBold.otf similarity index 100% rename from dapp/src/fonts/Segment-SemiBold.otf rename to dapp/src/assets/fonts/Segment-SemiBold.otf diff --git a/dapp/src/static/icons/AcreLogo.tsx b/dapp/src/assets/icons/AcreLogo.tsx similarity index 100% rename from dapp/src/static/icons/AcreLogo.tsx rename to dapp/src/assets/icons/AcreLogo.tsx diff --git a/dapp/src/static/icons/AlertInfo.tsx b/dapp/src/assets/icons/AlertInfo.tsx similarity index 100% rename from dapp/src/static/icons/AlertInfo.tsx rename to dapp/src/assets/icons/AlertInfo.tsx diff --git a/dapp/src/static/icons/ArrowLeft.tsx b/dapp/src/assets/icons/ArrowLeft.tsx similarity index 100% rename from dapp/src/static/icons/ArrowLeft.tsx rename to dapp/src/assets/icons/ArrowLeft.tsx diff --git a/dapp/src/static/icons/ArrowRight.tsx b/dapp/src/assets/icons/ArrowRight.tsx similarity index 100% rename from dapp/src/static/icons/ArrowRight.tsx rename to dapp/src/assets/icons/ArrowRight.tsx diff --git a/dapp/src/static/icons/ArrowUpRight.tsx b/dapp/src/assets/icons/ArrowUpRight.tsx similarity index 100% rename from dapp/src/static/icons/ArrowUpRight.tsx rename to dapp/src/assets/icons/ArrowUpRight.tsx diff --git a/dapp/src/static/icons/BTC.tsx b/dapp/src/assets/icons/BTC.tsx similarity index 100% rename from dapp/src/static/icons/BTC.tsx rename to dapp/src/assets/icons/BTC.tsx diff --git a/dapp/src/static/icons/Bitcoin.tsx b/dapp/src/assets/icons/Bitcoin.tsx similarity index 100% rename from dapp/src/static/icons/Bitcoin.tsx rename to dapp/src/assets/icons/Bitcoin.tsx diff --git a/dapp/src/static/icons/Complete.tsx b/dapp/src/assets/icons/Complete.tsx similarity index 100% rename from dapp/src/static/icons/Complete.tsx rename to dapp/src/assets/icons/Complete.tsx diff --git a/dapp/src/static/icons/ConnectBTCAccount.tsx b/dapp/src/assets/icons/ConnectBTCAccount.tsx similarity index 100% rename from dapp/src/static/icons/ConnectBTCAccount.tsx rename to dapp/src/assets/icons/ConnectBTCAccount.tsx diff --git a/dapp/src/static/icons/ConnectETHAccount.tsx b/dapp/src/assets/icons/ConnectETHAccount.tsx similarity index 100% rename from dapp/src/static/icons/ConnectETHAccount.tsx rename to dapp/src/assets/icons/ConnectETHAccount.tsx diff --git a/dapp/src/static/icons/Ethereum.tsx b/dapp/src/assets/icons/Ethereum.tsx similarity index 100% rename from dapp/src/static/icons/Ethereum.tsx rename to dapp/src/assets/icons/Ethereum.tsx diff --git a/dapp/src/static/icons/Info.tsx b/dapp/src/assets/icons/Info.tsx similarity index 100% rename from dapp/src/static/icons/Info.tsx rename to dapp/src/assets/icons/Info.tsx diff --git a/dapp/src/static/icons/Pending.tsx b/dapp/src/assets/icons/Pending.tsx similarity index 100% rename from dapp/src/static/icons/Pending.tsx rename to dapp/src/assets/icons/Pending.tsx diff --git a/dapp/src/static/icons/ShieldPlus.tsx b/dapp/src/assets/icons/ShieldPlus.tsx similarity index 100% rename from dapp/src/static/icons/ShieldPlus.tsx rename to dapp/src/assets/icons/ShieldPlus.tsx diff --git a/dapp/src/static/icons/Syncing.tsx b/dapp/src/assets/icons/Syncing.tsx similarity index 100% rename from dapp/src/static/icons/Syncing.tsx rename to dapp/src/assets/icons/Syncing.tsx diff --git a/dapp/src/static/icons/index.ts b/dapp/src/assets/icons/index.ts similarity index 100% rename from dapp/src/static/icons/index.ts rename to dapp/src/assets/icons/index.ts diff --git a/dapp/src/static/icons/stBTC.tsx b/dapp/src/assets/icons/stBTC.tsx similarity index 100% rename from dapp/src/static/icons/stBTC.tsx rename to dapp/src/assets/icons/stBTC.tsx diff --git a/dapp/src/components/GlobalStyles/index.tsx b/dapp/src/components/GlobalStyles/index.tsx index 352fe7af0..e8b11945a 100644 --- a/dapp/src/components/GlobalStyles/index.tsx +++ b/dapp/src/components/GlobalStyles/index.tsx @@ -1,11 +1,11 @@ import React from "react" import { Global } from "@emotion/react" -import SegmentRegular from "#/fonts/Segment-Regular.otf" -import SegmentMedium from "#/fonts/Segment-Medium.otf" -import SegmentSemiBold from "#/fonts/Segment-SemiBold.otf" -import SegmentBold from "#/fonts/Segment-Bold.otf" -import SegmentBlack from "#/fonts/Segment-Black.otf" +import SegmentRegular from "#/assets/fonts/Segment-Regular.otf" +import SegmentMedium from "#/assets/fonts/Segment-Medium.otf" +import SegmentSemiBold from "#/assets/fonts/Segment-SemiBold.otf" +import SegmentBold from "#/assets/fonts/Segment-Bold.otf" +import SegmentBlack from "#/assets/fonts/Segment-Black.otf" export default function GlobalStyles() { return ( diff --git a/dapp/src/components/Header/ConnectWallet.tsx b/dapp/src/components/Header/ConnectWallet.tsx index 5319a04ca..5e2445406 100644 --- a/dapp/src/components/Header/ConnectWallet.tsx +++ b/dapp/src/components/Header/ConnectWallet.tsx @@ -8,8 +8,8 @@ import { } from "#/hooks" import { CurrencyBalance } from "#/components/shared/CurrencyBalance" import { TextMd } from "#/components/shared/Typography" -import { Bitcoin, Ethereum } from "#/static/icons" -import { truncateAddress } from "#/utils" +import { Bitcoin, Ethereum } from "#/assets/icons" +import { truncateAddress, asyncWrapper } from "#/utils" export type ConnectButtonsProps = { leftIcon: typeof Icon @@ -24,12 +24,16 @@ function ConnectButton({ }: ConnectButtonsProps) { const colorScheme = !account ? "error" : undefined + const handleClick = () => { + asyncWrapper(requestAccount()) + } + return ( diff --git a/dapp/src/components/Header/index.tsx b/dapp/src/components/Header/index.tsx index 480cb502e..df0a2eb53 100644 --- a/dapp/src/components/Header/index.tsx +++ b/dapp/src/components/Header/index.tsx @@ -1,6 +1,6 @@ import React from "react" import { Flex, HStack, Icon } from "@chakra-ui/react" -import { AcreLogo } from "#/static/icons" +import { AcreLogo } from "#/assets/icons" import ConnectWallet from "./ConnectWallet" export default function Header() { diff --git a/dapp/src/components/Modals/Staking/SignMessage.tsx b/dapp/src/components/Modals/Staking/SignMessage.tsx index e3cda7886..d653ba781 100644 --- a/dapp/src/components/Modals/Staking/SignMessage.tsx +++ b/dapp/src/components/Modals/Staking/SignMessage.tsx @@ -3,14 +3,19 @@ import { Highlight } from "@chakra-ui/react" import { useModalFlowContext, useSignMessage } from "#/hooks" import Alert from "#/components/shared/Alert" import { TextMd } from "#/components/shared/Typography" +import { asyncWrapper } from "#/utils" import StakingSteps from "./components/StakingSteps" export default function SignMessage() { const { goNext } = useModalFlowContext() const { signMessage } = useSignMessage(goNext) + const handleClick = () => { + asyncWrapper(signMessage()) + } + return ( - + {/* TODO: Add the correct action after click */} {}}> diff --git a/dapp/src/components/Modals/Support/MissingAccount.tsx b/dapp/src/components/Modals/Support/MissingAccount.tsx index 89ca3effd..861cb7c63 100644 --- a/dapp/src/components/Modals/Support/MissingAccount.tsx +++ b/dapp/src/components/Modals/Support/MissingAccount.tsx @@ -9,7 +9,7 @@ import { } from "@chakra-ui/react" import { TextMd } from "#/components/shared/Typography" import Alert from "#/components/shared/Alert" -import { getCurrencyByType } from "#/utils" +import { asyncWrapper, getCurrencyByType } from "#/utils" import { CurrencyType, RequestAccountParams } from "#/types" type MissingAccountProps = { @@ -25,6 +25,10 @@ export default function MissingAccount({ }: MissingAccountProps) { const { name, symbol } = getCurrencyByType(currency) + const handleClick = () => { + asyncWrapper(requestAccount()) + } + return ( <> {name} account not installed @@ -44,13 +48,7 @@ export default function MissingAccount({ - diff --git a/dapp/src/components/Modals/Support/index.tsx b/dapp/src/components/Modals/Support/index.tsx index ae5aa98eb..47689622a 100644 --- a/dapp/src/components/Modals/Support/index.tsx +++ b/dapp/src/components/Modals/Support/index.tsx @@ -4,7 +4,7 @@ import { useRequestEthereumAccount, useWalletContext, } from "#/hooks" -import { ConnectBTCAccount, ConnectETHAccount } from "#/static/icons" +import { ConnectBTCAccount, ConnectETHAccount } from "#/assets/icons" import MissingAccount from "./MissingAccount" export default function SupportWrapper({ diff --git a/dapp/src/components/Overview/PositionDetails.tsx b/dapp/src/components/Overview/PositionDetails.tsx index 0555c3ddf..290c7c52a 100644 --- a/dapp/src/components/Overview/PositionDetails.tsx +++ b/dapp/src/components/Overview/PositionDetails.tsx @@ -12,7 +12,7 @@ import { } from "@chakra-ui/react" import { CurrencyBalanceWithConversion } from "#/components/shared/CurrencyBalanceWithConversion" import { TextMd } from "#/components/shared/Typography" -import { Info } from "#/static/icons" +import { Info } from "#/assets/icons" import StakingModal from "../Modals/Staking" export default function PositionDetails(props: CardProps) { diff --git a/dapp/src/components/Overview/index.tsx b/dapp/src/components/Overview/index.tsx index 31764618f..c2c07064f 100644 --- a/dapp/src/components/Overview/index.tsx +++ b/dapp/src/components/Overview/index.tsx @@ -2,7 +2,7 @@ import React from "react" import { Button, Flex, Grid, HStack, Icon, Switch } from "@chakra-ui/react" import { useDocsDrawer } from "#/hooks" import { TextSm } from "#/components/shared/Typography" -import { ArrowUpRight } from "#/static/icons" +import { ArrowUpRight } from "#/assets/icons" import { USD } from "#/constants" import PositionDetails from "./PositionDetails" import Statistics from "./Statistics" diff --git a/dapp/src/components/Sidebar/index.tsx b/dapp/src/components/Sidebar/index.tsx index b0e46f3e5..0b485b142 100644 --- a/dapp/src/components/Sidebar/index.tsx +++ b/dapp/src/components/Sidebar/index.tsx @@ -13,7 +13,7 @@ import { } from "@chakra-ui/react" import RightSidebar from "#/assets/images/right-sidebar-bg.png" import { useSidebar, useDocsDrawer } from "#/hooks" -import { ShieldPlusIcon } from "#/static/icons" +import { ShieldPlusIcon } from "#/assets/icons" import { TextMd, TextSm } from "../shared/Typography" import ButtonLink from "../shared/ButtonLink" diff --git a/dapp/src/components/TransactionHistory/Table/utils/pagination.tsx b/dapp/src/components/TransactionHistory/Table/utils/pagination.tsx index 11dc7f697..b0bb99ef5 100644 --- a/dapp/src/components/TransactionHistory/Table/utils/pagination.tsx +++ b/dapp/src/components/TransactionHistory/Table/utils/pagination.tsx @@ -1,6 +1,6 @@ import React from "react" import { UseTransactionHistoryTableResult } from "#/types" -import { ArrowLeft, ArrowRight } from "#/static/icons" +import { ArrowLeft, ArrowRight } from "#/assets/icons" export const PAGINATION_BUTTONS = [ { diff --git a/dapp/src/components/shared/Alert/index.tsx b/dapp/src/components/shared/Alert/index.tsx index 687e0599b..c5a10f0eb 100644 --- a/dapp/src/components/shared/Alert/index.tsx +++ b/dapp/src/components/shared/Alert/index.tsx @@ -7,7 +7,7 @@ import { Icon, useMultiStyleConfig, } from "@chakra-ui/react" -import { AlertInfo, ArrowUpRight } from "#/static/icons" +import { AlertInfo, ArrowUpRight } from "#/assets/icons" const ICONS = { info: AlertInfo, diff --git a/dapp/src/components/shared/ButtonLink/index.tsx b/dapp/src/components/shared/ButtonLink/index.tsx index 32aa81907..88d44e3e1 100644 --- a/dapp/src/components/shared/ButtonLink/index.tsx +++ b/dapp/src/components/shared/ButtonLink/index.tsx @@ -1,6 +1,6 @@ import React from "react" import { Button, ButtonProps, Icon } from "@chakra-ui/react" -import { ArrowUpRight } from "#/static/icons" +import { ArrowUpRight } from "#/assets/icons" type ButtonLinkProps = ButtonProps & { icon?: typeof Icon diff --git a/dapp/src/components/shared/CurrencyIcon/index.tsx b/dapp/src/components/shared/CurrencyIcon/index.tsx index 9524acae6..f0571e425 100644 --- a/dapp/src/components/shared/CurrencyIcon/index.tsx +++ b/dapp/src/components/shared/CurrencyIcon/index.tsx @@ -1,7 +1,7 @@ import React from "react" import { Box, Icon, useMultiStyleConfig } from "@chakra-ui/react" import { CurrencyType } from "#/types" -import { BTC, stBTC } from "#/static/icons" +import { BTC, stBTC } from "#/assets/icons" import { getCurrencyByType } from "#/utils" const ICONS: Partial> = { diff --git a/dapp/src/components/shared/Form/FormTokenBalanceInput.tsx b/dapp/src/components/shared/Form/FormTokenBalanceInput.tsx index 5f88f8bec..5eefb5933 100644 --- a/dapp/src/components/shared/Form/FormTokenBalanceInput.tsx +++ b/dapp/src/components/shared/Form/FormTokenBalanceInput.tsx @@ -1,5 +1,6 @@ import React from "react" import { useField } from "formik" +import { asyncWrapper } from "#/utils" import TokenBalanceInput, { TokenBalanceInputProps } from "../TokenBalanceInput" export type FormTokenBalanceInputProps = { @@ -11,12 +12,16 @@ export function FormTokenBalanceInput({ }: FormTokenBalanceInputProps) { const [field, meta, helpers] = useField(name) + const setAmount = (value?: bigint) => { + asyncWrapper(helpers.setValue(value)) + } + return ( diff --git a/dapp/src/components/shared/StatusInfo/index.tsx b/dapp/src/components/shared/StatusInfo/index.tsx index ef7338311..88abc7b1f 100644 --- a/dapp/src/components/shared/StatusInfo/index.tsx +++ b/dapp/src/components/shared/StatusInfo/index.tsx @@ -1,7 +1,7 @@ import React from "react" import { TransactionInfoStatus } from "#/types" import { Box, Icon, TextProps, useMultiStyleConfig } from "@chakra-ui/react" -import { Complete, Pending, Syncing } from "#/static/icons" +import { Complete, Pending, Syncing } from "#/assets/icons" const DATA: Record< TransactionInfoStatus, diff --git a/dapp/src/components/shared/TokenAmountForm/index.tsx b/dapp/src/components/shared/TokenAmountForm/index.tsx index c4b8dfec7..d8c6fabf0 100644 --- a/dapp/src/components/shared/TokenAmountForm/index.tsx +++ b/dapp/src/components/shared/TokenAmountForm/index.tsx @@ -15,10 +15,7 @@ const TokenAmountForm = withFormik( mapPropsToValues: () => ({ amount: undefined, }), - validate: async ( - { amount }, - { tokenBalance, currency, minTokenAmount }, - ) => { + validate: ({ amount }, { tokenBalance, currency, minTokenAmount }) => { const errors: FormikErrors = {} errors.amount = validateTokenAmount( diff --git a/dapp/src/components/shared/TokenBalanceInput/index.tsx b/dapp/src/components/shared/TokenBalanceInput/index.tsx index 68975da92..de55b64dd 100644 --- a/dapp/src/components/shared/TokenBalanceInput/index.tsx +++ b/dapp/src/components/shared/TokenBalanceInput/index.tsx @@ -17,7 +17,7 @@ import { getCurrencyByType, userAmountToBigInt, } from "#/utils" -import { AlertInfo } from "#/static/icons" +import { AlertInfo } from "#/assets/icons" import { CurrencyType } from "#/types" import NumberFormatInput, { NumberFormatInputValues, diff --git a/dapp/src/theme/Alert.ts b/dapp/src/theme/Alert.ts index ebd2f882a..c3b42c09f 100644 --- a/dapp/src/theme/Alert.ts +++ b/dapp/src/theme/Alert.ts @@ -8,9 +8,6 @@ import { const KEYS = [...parts.keys, "rightIconContainer"] as const -const { defineMultiStyleConfig, definePartsStyle } = - createMultiStyleConfigHelpers(KEYS) - const baseStyleDialog = defineStyle({ py: 5, pl: 5, @@ -39,13 +36,15 @@ const baseStyleRightIconContainer = defineStyle({ w: 14, }) -const baseStyle = definePartsStyle({ +const multiStyleConfig = createMultiStyleConfigHelpers(KEYS) + +const baseStyle = multiStyleConfig.definePartsStyle({ container: baseStyleDialog, icon: baseStyleIcon, rightIconContainer: baseStyleRightIconContainer, }) -const statusInfo = definePartsStyle({ +const statusInfo = multiStyleConfig.definePartsStyle({ container: { bg: "gold.200", }, @@ -63,13 +62,18 @@ const statusStyles = (props: StyleFunctionProps) => { info: statusInfo, } - return styleMap[status] || {} + return styleMap[status as string] || {} } -const variantSubtle = definePartsStyle((props) => statusStyles(props)) +const variantSubtle = multiStyleConfig.definePartsStyle((props) => + statusStyles(props), +) const variants = { subtle: variantSubtle, } -export const alertTheme = defineMultiStyleConfig({ baseStyle, variants }) +export const alertTheme = multiStyleConfig.defineMultiStyleConfig({ + baseStyle, + variants, +}) diff --git a/dapp/src/theme/CurrencyBalance.ts b/dapp/src/theme/CurrencyBalance.ts index 787af78f3..e5897592d 100644 --- a/dapp/src/theme/CurrencyBalance.ts +++ b/dapp/src/theme/CurrencyBalance.ts @@ -2,9 +2,6 @@ import { createMultiStyleConfigHelpers, defineStyle } from "@chakra-ui/react" const PARTS = ["balance", "symbol"] -const { defineMultiStyleConfig, definePartsStyle } = - createMultiStyleConfigHelpers(PARTS) - const baseStyleBalance = defineStyle({ fontWeight: "bold", fontSize: "md", @@ -18,12 +15,14 @@ const baseStyleSymbol = defineStyle({ lineHeight: "md", }) -const baseStyle = definePartsStyle({ +const multiStyleConfig = createMultiStyleConfigHelpers(PARTS) + +const baseStyle = multiStyleConfig.definePartsStyle({ balance: baseStyleBalance, symbol: baseStyleSymbol, }) -const variantGreaterBalance = definePartsStyle({ +const variantGreaterBalance = multiStyleConfig.definePartsStyle({ balance: { fontSize: "4xl", lineHeight: "4xl", @@ -38,7 +37,7 @@ const variants = { "greater-balance": variantGreaterBalance, } -const sizeXs = definePartsStyle({ +const sizeXs = multiStyleConfig.definePartsStyle({ balance: { fontSize: "xs", lineHeight: "xs", @@ -49,7 +48,7 @@ const sizeXs = definePartsStyle({ }, }) -const sizeSm = definePartsStyle({ +const sizeSm = multiStyleConfig.definePartsStyle({ balance: { fontSize: "sm", lineHeight: "sm", @@ -60,7 +59,7 @@ const sizeSm = definePartsStyle({ }, }) -const sizeMd = definePartsStyle({ +const sizeMd = multiStyleConfig.definePartsStyle({ balance: { fontSize: "md", lineHeight: "md", @@ -71,7 +70,7 @@ const sizeMd = definePartsStyle({ }, }) -const sizeLg = definePartsStyle({ +const sizeLg = multiStyleConfig.definePartsStyle({ balance: { fontSize: "lg", lineHeight: "lg", @@ -82,7 +81,7 @@ const sizeLg = definePartsStyle({ }, }) -const sizeXl = definePartsStyle({ +const sizeXl = multiStyleConfig.definePartsStyle({ balance: { fontSize: "xl", lineHeight: "xl", @@ -101,7 +100,7 @@ const sizes = { xl: sizeXl, } -export const currencyBalanceTheme = defineMultiStyleConfig({ +export const currencyBalanceTheme = multiStyleConfig.defineMultiStyleConfig({ baseStyle, variants, sizes, diff --git a/dapp/src/theme/Drawer.ts b/dapp/src/theme/Drawer.ts index accc24ffc..b904c74c0 100644 --- a/dapp/src/theme/Drawer.ts +++ b/dapp/src/theme/Drawer.ts @@ -1,9 +1,6 @@ import { drawerAnatomy as parts } from "@chakra-ui/anatomy" import { createMultiStyleConfigHelpers, defineStyle } from "@chakra-ui/react" -const { defineMultiStyleConfig, definePartsStyle } = - createMultiStyleConfigHelpers(parts.keys) - const baseStyleDialogContainer = defineStyle({ zIndex: "drawer", }) @@ -23,10 +20,14 @@ const baseStyleOverlay = defineStyle({ backdropBlur: "8px", }) -const baseStyle = definePartsStyle({ +const multiStyleConfig = createMultiStyleConfigHelpers(parts.keys) + +const baseStyle = multiStyleConfig.definePartsStyle({ dialogContainer: baseStyleDialogContainer, dialog: baseStyleDialog, overlay: baseStyleOverlay, }) -export const drawerTheme = defineMultiStyleConfig({ baseStyle }) +export const drawerTheme = multiStyleConfig.defineMultiStyleConfig({ + baseStyle, +}) diff --git a/dapp/src/theme/Form.ts b/dapp/src/theme/Form.ts index b2aaec332..f195c872d 100644 --- a/dapp/src/theme/Form.ts +++ b/dapp/src/theme/Form.ts @@ -1,9 +1,6 @@ import { formAnatomy as parts } from "@chakra-ui/anatomy" import { createMultiStyleConfigHelpers, defineStyle } from "@chakra-ui/react" -const { defineMultiStyleConfig, definePartsStyle } = - createMultiStyleConfigHelpers(parts.keys) - const baseStyleHelperText = defineStyle({ display: "flex", alignItems: "center", @@ -12,8 +9,10 @@ const baseStyleHelperText = defineStyle({ color: "grey.500", }) -const baseStyle = definePartsStyle({ +const multiStyleConfig = createMultiStyleConfigHelpers(parts.keys) + +const baseStyle = multiStyleConfig.definePartsStyle({ helperText: baseStyleHelperText, }) -export const formTheme = defineMultiStyleConfig({ baseStyle }) +export const formTheme = multiStyleConfig.defineMultiStyleConfig({ baseStyle }) diff --git a/dapp/src/theme/FormError.ts b/dapp/src/theme/FormError.ts index 605ba36ff..d9a52b265 100644 --- a/dapp/src/theme/FormError.ts +++ b/dapp/src/theme/FormError.ts @@ -2,16 +2,17 @@ import { defineStyle, createMultiStyleConfigHelpers } from "@chakra-ui/react" import { formErrorAnatomy as parts } from "@chakra-ui/anatomy" -const { defineMultiStyleConfig, definePartsStyle } = - createMultiStyleConfigHelpers(parts.keys) - const baseStyleText = defineStyle({ fontWeight: "medium", color: "red.400", }) -const baseStyle = definePartsStyle({ +const multiStyleConfig = createMultiStyleConfigHelpers(parts.keys) + +const baseStyle = multiStyleConfig.definePartsStyle({ text: baseStyleText, }) -export const formErrorTheme = defineMultiStyleConfig({ baseStyle }) +export const formErrorTheme = multiStyleConfig.defineMultiStyleConfig({ + baseStyle, +}) diff --git a/dapp/src/theme/Input.ts b/dapp/src/theme/Input.ts index a45e27b7b..e6e9d8695 100644 --- a/dapp/src/theme/Input.ts +++ b/dapp/src/theme/Input.ts @@ -1,9 +1,6 @@ import { inputAnatomy as parts } from "@chakra-ui/anatomy" import { createMultiStyleConfigHelpers, defineStyle } from "@chakra-ui/react" -const { definePartsStyle, defineMultiStyleConfig } = - createMultiStyleConfigHelpers(parts.keys) - const variantBalanceField = defineStyle({ border: "1px solid", borderColor: "gold.300", @@ -30,7 +27,9 @@ const variantBalanceElement = defineStyle({ mr: 2, }) -const variantBalance = definePartsStyle({ +const multiStyleConfig = createMultiStyleConfigHelpers(parts.keys) + +const variantBalance = multiStyleConfig.definePartsStyle({ field: variantBalanceField, element: variantBalanceElement, }) @@ -39,4 +38,4 @@ const variants = { balance: variantBalance, } -export const inputTheme = defineMultiStyleConfig({ variants }) +export const inputTheme = multiStyleConfig.defineMultiStyleConfig({ variants }) diff --git a/dapp/src/theme/Modal.ts b/dapp/src/theme/Modal.ts index 271c725ca..027c9946b 100644 --- a/dapp/src/theme/Modal.ts +++ b/dapp/src/theme/Modal.ts @@ -1,9 +1,6 @@ import { modalAnatomy as parts } from "@chakra-ui/anatomy" import { createMultiStyleConfigHelpers, defineStyle } from "@chakra-ui/react" -const { defineMultiStyleConfig, definePartsStyle } = - createMultiStyleConfigHelpers(parts.keys) - const baseStyleDialog = defineStyle({ p: 4, border: "2px", @@ -43,7 +40,9 @@ const baseStyleBody = defineStyle({ gap: 6, }) -const baseStyle = definePartsStyle({ +const multiStyleConfig = createMultiStyleConfigHelpers(parts.keys) + +const baseStyle = multiStyleConfig.definePartsStyle({ dialog: baseStyleDialog, closeButton: baseCloseButton, overlay: baseStyleOverlay, @@ -51,4 +50,4 @@ const baseStyle = definePartsStyle({ body: baseStyleBody, }) -export const modalTheme = defineMultiStyleConfig({ baseStyle }) +export const modalTheme = multiStyleConfig.defineMultiStyleConfig({ baseStyle }) diff --git a/dapp/src/theme/Sidebar.ts b/dapp/src/theme/Sidebar.ts index 64191d4c4..1b1a431b1 100644 --- a/dapp/src/theme/Sidebar.ts +++ b/dapp/src/theme/Sidebar.ts @@ -2,9 +2,6 @@ import { createMultiStyleConfigHelpers, defineStyle } from "@chakra-ui/react" const PARTS = ["sidebarContainer", "sidebar"] -const { defineMultiStyleConfig, definePartsStyle } = - createMultiStyleConfigHelpers(PARTS) - const baseStyleSidebarContainer = defineStyle({ top: 0, right: 0, @@ -29,9 +26,13 @@ const baseStyleSidebar = defineStyle({ gap: 3, }) -const baseStyle = definePartsStyle({ +const multiStyleConfig = createMultiStyleConfigHelpers(PARTS) + +const baseStyle = multiStyleConfig.definePartsStyle({ sidebarContainer: baseStyleSidebarContainer, sidebar: baseStyleSidebar, }) -export const sidebarTheme = defineMultiStyleConfig({ baseStyle }) +export const sidebarTheme = multiStyleConfig.defineMultiStyleConfig({ + baseStyle, +}) diff --git a/dapp/src/theme/Stepper.ts b/dapp/src/theme/Stepper.ts index 1ddffe553..1ac1c501b 100644 --- a/dapp/src/theme/Stepper.ts +++ b/dapp/src/theme/Stepper.ts @@ -1,9 +1,6 @@ import { stepperAnatomy as parts } from "@chakra-ui/anatomy" import { createMultiStyleConfigHelpers, defineStyle } from "@chakra-ui/react" -const { defineMultiStyleConfig, definePartsStyle } = - createMultiStyleConfigHelpers(parts.keys) - const baseStyleStepper = defineStyle({ _vertical: { gap: 0, @@ -64,7 +61,9 @@ const baseStyleSeparator = defineStyle(({ colorScheme }) => ({ }, })) -const baseStyle = definePartsStyle((props) => ({ +const multiStyleConfig = createMultiStyleConfigHelpers(parts.keys) + +const baseStyle = multiStyleConfig.definePartsStyle((props) => ({ stepper: baseStyleStepper, step: baseStyleStep, title: baseStyleTitle, @@ -73,4 +72,6 @@ const baseStyle = definePartsStyle((props) => ({ separator: baseStyleSeparator(props), })) -export const stepperTheme = defineMultiStyleConfig({ baseStyle }) +export const stepperTheme = multiStyleConfig.defineMultiStyleConfig({ + baseStyle, +}) diff --git a/dapp/src/theme/Tabs.ts b/dapp/src/theme/Tabs.ts index 31879430e..9cecdd4d9 100644 --- a/dapp/src/theme/Tabs.ts +++ b/dapp/src/theme/Tabs.ts @@ -1,16 +1,6 @@ import { tabsAnatomy as parts } from "@chakra-ui/anatomy" import { createMultiStyleConfigHelpers, defineStyle } from "@chakra-ui/react" -const { definePartsStyle, defineMultiStyleConfig } = - createMultiStyleConfigHelpers(parts.keys) - -const baseStyle = definePartsStyle({ - tab: { - fontWeight: "bold", - color: "grey.400", - }, -}) - const variantUnderlineTab = defineStyle({ px: 0, pb: 2, @@ -36,7 +26,9 @@ const variantUnderlineTabPanel = defineStyle({ px: 0, }) -const variantUnderline = definePartsStyle({ +const multiStyleConfig = createMultiStyleConfigHelpers(parts.keys) + +const variantUnderline = multiStyleConfig.definePartsStyle({ tab: variantUnderlineTab, tablist: variantUnderlineTabList, tabpanel: variantUnderlineTabPanel, @@ -46,4 +38,14 @@ const variants = { underline: variantUnderline, } -export const tabsTheme = defineMultiStyleConfig({ baseStyle, variants }) +const baseStyle = multiStyleConfig.definePartsStyle({ + tab: { + fontWeight: "bold", + color: "grey.400", + }, +}) + +export const tabsTheme = multiStyleConfig.defineMultiStyleConfig({ + baseStyle, + variants, +}) diff --git a/dapp/src/theme/TokenBalanceInput.ts b/dapp/src/theme/TokenBalanceInput.ts index a79e81f2e..cea039b38 100644 --- a/dapp/src/theme/TokenBalanceInput.ts +++ b/dapp/src/theme/TokenBalanceInput.ts @@ -2,9 +2,6 @@ import { createMultiStyleConfigHelpers, defineStyle } from "@chakra-ui/react" const PARTS = ["labelContainer", "balanceContainer", "balance"] -const { defineMultiStyleConfig, definePartsStyle } = - createMultiStyleConfigHelpers(PARTS) - const baseStyleLabelContainer = defineStyle({ display: "flex", justifyContent: "space-between", @@ -20,10 +17,14 @@ const baseStyleBalance = defineStyle({ color: "grey.500", }) -const baseStyle = definePartsStyle({ +const multiStyleConfig = createMultiStyleConfigHelpers(PARTS) + +const baseStyle = multiStyleConfig.definePartsStyle({ labelContainer: baseStyleLabelContainer, balanceContainer: baseStyleBalanceContainer, balance: baseStyleBalance, }) -export const tokenBalanceInputTheme = defineMultiStyleConfig({ baseStyle }) +export const tokenBalanceInputTheme = multiStyleConfig.defineMultiStyleConfig({ + baseStyle, +}) diff --git a/dapp/src/types/callback.ts b/dapp/src/types/callback.ts index 526705388..0c047f7c5 100644 --- a/dapp/src/types/callback.ts +++ b/dapp/src/types/callback.ts @@ -1 +1 @@ -export type OnSuccessCallback = () => void | Promise +export type OnSuccessCallback = () => void diff --git a/dapp/src/utils/async.ts b/dapp/src/utils/async.ts new file mode 100644 index 000000000..df3657065 --- /dev/null +++ b/dapp/src/utils/async.ts @@ -0,0 +1,8 @@ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export function asyncWrapper(func: Promise) { + return () => { + func.catch((error) => { + throw error + }) + } +} diff --git a/dapp/src/utils/index.ts b/dapp/src/utils/index.ts index 0288bcad6..40f6c0899 100644 --- a/dapp/src/utils/index.ts +++ b/dapp/src/utils/index.ts @@ -5,3 +5,4 @@ export * from "./currency" export * from "./chain" export * from "./text" export * from "./time" +export * from "./async"