diff --git a/dapp/.eslintrc b/dapp/.eslintrc index 3fd1b6e42..d3d678a39 100644 --- a/dapp/.eslintrc +++ b/dapp/.eslintrc @@ -3,7 +3,6 @@ "extends": ["@thesis-co"], "rules": { "import/no-extraneous-dependencies": "off", - "import/prefer-default-export": "off", // Regarding the fact that we are using Chakra UI lib let's disable this rule. // This will allow us to easily pass props from the parent component. "react/jsx-props-no-spreading": "off", diff --git a/dapp/src/DApp.tsx b/dapp/src/DApp.tsx index 51149f8f7..e4daa4638 100644 --- a/dapp/src/DApp.tsx +++ b/dapp/src/DApp.tsx @@ -9,18 +9,18 @@ import { AcreSdkProvider } from "./acre-react/contexts" import GlobalStyles from "./components/GlobalStyles" import { WalletConnectionAlertContextProvider } from "./contexts" import { useInitApp } from "./hooks" -import { router } from "./router" -import { store } from "./store" +import router from "./router" +import store from "./store" import getWagmiConfig from "./wagmiConfig" import queryClient from "./queryClient" import { delay, logPromiseFailure } from "./utils" -import { AcreLogo } from "./assets/icons" +import { AcreLogoIcon } from "./assets/icons" import PostHogProvider from "./posthog/PostHogProvider" function SplashPage() { return (
- +
) } diff --git a/dapp/src/acre-react/contexts/AcreSdkContext.tsx b/dapp/src/acre-react/contexts/AcreSdkContext.tsx index 914d01fa6..fa105ff94 100644 --- a/dapp/src/acre-react/contexts/AcreSdkContext.tsx +++ b/dapp/src/acre-react/contexts/AcreSdkContext.tsx @@ -1,6 +1,6 @@ import React, { useCallback, useMemo, useState } from "react" import { Acre, AcreBitcoinProvider } from "@acre-btc/sdk" -import { BITCOIN_NETWORK, env } from "#/constants" +import { chains, env } from "#/constants" const { TBTC_API_ENDPOINT, SUBGRAPH_API_KEY } = env const ETH_RPC_URL = env.ETH_HOSTNAME_HTTP @@ -28,7 +28,7 @@ export function AcreSdkProvider({ children }: { children: React.ReactNode }) { const init = useCallback( async (bitcoinProvider?: AcreBitcoinProvider) => { let sdk = await Acre.initialize( - BITCOIN_NETWORK, + chains.BITCOIN_NETWORK, TBTC_API_ENDPOINT, ETH_RPC_URL, GELATO_API_KEY, diff --git a/dapp/src/acre-react/hooks/index.ts b/dapp/src/acre-react/hooks/index.ts index 7589dc3a6..5efcf9e67 100644 --- a/dapp/src/acre-react/hooks/index.ts +++ b/dapp/src/acre-react/hooks/index.ts @@ -1,3 +1,3 @@ -export * from "./useAcreContext" export * from "./useStakeFlow" +export { default as useAcreContext } from "./useAcreContext" export { default as useInitializeWithdraw } from "./useInitializeWithdraw" diff --git a/dapp/src/acre-react/hooks/useAcreContext.ts b/dapp/src/acre-react/hooks/useAcreContext.ts index cd75354c8..98edf6808 100644 --- a/dapp/src/acre-react/hooks/useAcreContext.ts +++ b/dapp/src/acre-react/hooks/useAcreContext.ts @@ -1,7 +1,7 @@ import { useContext } from "react" import { AcreSdkContext } from "../contexts" -export function useAcreContext() { +export default function useAcreContext() { const context = useContext(AcreSdkContext) if (!context) { diff --git a/dapp/src/acre-react/hooks/useInitializeWithdraw.ts b/dapp/src/acre-react/hooks/useInitializeWithdraw.ts index c6863e23d..fe338dfde 100644 --- a/dapp/src/acre-react/hooks/useInitializeWithdraw.ts +++ b/dapp/src/acre-react/hooks/useInitializeWithdraw.ts @@ -4,7 +4,7 @@ import { MessageSignedStepCallback, OnSignMessageStepCallback, } from "@acre-btc/sdk/dist/src/lib/redeemer-proxy" -import { useAcreContext } from "./useAcreContext" +import useAcreContext from "./useAcreContext" export default function useInitializeWithdraw() { const { acre, isConnected } = useAcreContext() diff --git a/dapp/src/acre-react/hooks/useStakeFlow.ts b/dapp/src/acre-react/hooks/useStakeFlow.ts index 828e44ede..c22a728fb 100644 --- a/dapp/src/acre-react/hooks/useStakeFlow.ts +++ b/dapp/src/acre-react/hooks/useStakeFlow.ts @@ -1,6 +1,6 @@ import { useCallback, useState } from "react" import { StakeInitialization, DepositReceipt } from "@acre-btc/sdk" -import { useAcreContext } from "./useAcreContext" +import useAcreContext from "./useAcreContext" export type UseStakeFlowReturn = { initStake: ( diff --git a/dapp/src/assets/fonts/index.ts b/dapp/src/assets/fonts/index.ts new file mode 100644 index 000000000..d4e6ff4d6 --- /dev/null +++ b/dapp/src/assets/fonts/index.ts @@ -0,0 +1,13 @@ +import SegmentRegular from "./Segment-Regular.otf" +import SegmentMedium from "./Segment-Medium.otf" +import SegmentSemiBold from "./Segment-SemiBold.otf" +import SegmentBold from "./Segment-Bold.otf" +import SegmentBlack from "./Segment-Black.otf" + +export { + SegmentRegular, + SegmentMedium, + SegmentSemiBold, + SegmentBold, + SegmentBlack, +} diff --git a/dapp/src/assets/icons/AcreLogo.tsx b/dapp/src/assets/icons/AcreLogoIcon.tsx similarity index 98% rename from dapp/src/assets/icons/AcreLogo.tsx rename to dapp/src/assets/icons/AcreLogoIcon.tsx index 94059f58a..f478eb5b8 100644 --- a/dapp/src/assets/icons/AcreLogo.tsx +++ b/dapp/src/assets/icons/AcreLogoIcon.tsx @@ -1,7 +1,7 @@ import React from "react" import { createIcon } from "@chakra-ui/react" -export const AcreLogo = createIcon({ +export default createIcon({ displayName: "AcreLogo", viewBox: "0 0 120 71", path: ( diff --git a/dapp/src/assets/icons/AcreSignIcon.tsx b/dapp/src/assets/icons/AcreSignIcon.tsx index fc39a8700..30d116937 100644 --- a/dapp/src/assets/icons/AcreSignIcon.tsx +++ b/dapp/src/assets/icons/AcreSignIcon.tsx @@ -1,7 +1,7 @@ import React from "react" import { createIcon } from "@chakra-ui/react" -export const AcreSignIcon = createIcon({ +export default createIcon({ displayName: "AcreSignIcon", viewBox: "0 0 24 24", path: [ diff --git a/dapp/src/assets/icons/BitcoinIcon.tsx b/dapp/src/assets/icons/BitcoinIcon.tsx index d5c2f9aae..67ce414cb 100644 --- a/dapp/src/assets/icons/BitcoinIcon.tsx +++ b/dapp/src/assets/icons/BitcoinIcon.tsx @@ -1,7 +1,7 @@ import React from "react" import { createIcon } from "@chakra-ui/react" -export const BitcoinIcon = createIcon({ +export default createIcon({ displayName: "BitcoinIcon", viewBox: "0 0 28 28", path: [ diff --git a/dapp/src/assets/icons/BitcoinsStackErrorIcon.tsx b/dapp/src/assets/icons/BitcoinsStackErrorIcon.tsx index 450e7f347..de89c1e0c 100644 --- a/dapp/src/assets/icons/BitcoinsStackErrorIcon.tsx +++ b/dapp/src/assets/icons/BitcoinsStackErrorIcon.tsx @@ -1,7 +1,7 @@ import React from "react" import { createIcon } from "@chakra-ui/react" -export const BitcoinsStackErrorIcon = createIcon({ +export default createIcon({ displayName: "BitcoinsStackErrorIcon", viewBox: "0 0 57 49", defaultProps: { diff --git a/dapp/src/assets/icons/CableWithPlugIcon.tsx b/dapp/src/assets/icons/CableWithPlugIcon.tsx index b460a843c..29c4542b8 100644 --- a/dapp/src/assets/icons/CableWithPlugIcon.tsx +++ b/dapp/src/assets/icons/CableWithPlugIcon.tsx @@ -1,7 +1,7 @@ import React from "react" import { createIcon } from "@chakra-ui/react" -export const CableWithPlugIcon = createIcon({ +export default createIcon({ displayName: "CableWithPlugIcon", viewBox: "0 0 127 122", defaultProps: { diff --git a/dapp/src/assets/icons/MezoSignIcon.tsx b/dapp/src/assets/icons/MezoSignIcon.tsx index 9d8ca37ee..dedb9f6d4 100644 --- a/dapp/src/assets/icons/MezoSignIcon.tsx +++ b/dapp/src/assets/icons/MezoSignIcon.tsx @@ -1,7 +1,7 @@ import React from "react" import { createIcon } from "@chakra-ui/react" -export const MezoSignIcon = createIcon({ +export default createIcon({ displayName: "MezoSignIcon", viewBox: "0 0 88 88", path: [ diff --git a/dapp/src/assets/icons/Pause.tsx b/dapp/src/assets/icons/PauseIcon.tsx similarity index 88% rename from dapp/src/assets/icons/Pause.tsx rename to dapp/src/assets/icons/PauseIcon.tsx index 5bdd71bc0..8a0588234 100644 --- a/dapp/src/assets/icons/Pause.tsx +++ b/dapp/src/assets/icons/PauseIcon.tsx @@ -1,7 +1,7 @@ import React from "react" import { createIcon } from "@chakra-ui/react" -export const PauseIcon = createIcon({ +export default createIcon({ displayName: "PauseIcon", viewBox: "0 0 18 20", path: ( diff --git a/dapp/src/assets/icons/index.ts b/dapp/src/assets/icons/index.ts index eb50fc819..f4e5585cb 100644 --- a/dapp/src/assets/icons/index.ts +++ b/dapp/src/assets/icons/index.ts @@ -1,9 +1,9 @@ -export * from "./AcreLogo" -export * from "./Pause" +export { default as AcreLogoIcon } from "./AcreLogoIcon" +export { default as PauseIcon } from "./PauseIcon" export { default as LoadingSpinnerSuccessIcon } from "./LoadingSpinnerSuccessIcon" -export * from "./BitcoinIcon" -export * from "./CableWithPlugIcon" -export * from "./MezoSignIcon" -export * from "./AcreSignIcon" -export * from "./BitcoinsStackErrorIcon" +export { default as BitcoinIcon } from "./BitcoinIcon" +export { default as CableWithPlugIcon } from "./CableWithPlugIcon" +export { default as MezoSignIcon } from "./MezoSignIcon" +export { default as AcreSignIcon } from "./AcreSignIcon" +export { default as BitcoinsStackErrorIcon } from "./BitcoinsStackErrorIcon" export { default as MatsIcon } from "./MatsIcon" diff --git a/dapp/src/assets/images/index.ts b/dapp/src/assets/images/index.ts new file mode 100644 index 000000000..44f4fabb8 --- /dev/null +++ b/dapp/src/assets/images/index.ts @@ -0,0 +1,11 @@ +import acrePointsCardPlaceholder from "./acre-points-card-placeholder.png" +import acrePointsIllustration from "./acre-points-illustration.png" +import beehiveIllustration from "./beehive-illustration.svg" +import emptyState from "./empty-state.svg" + +export { + acrePointsCardPlaceholder, + acrePointsIllustration, + beehiveIllustration, + emptyState, +} diff --git a/dapp/src/assets/videos/welcome-steps/index.ts b/dapp/src/assets/videos/welcome-steps/index.ts new file mode 100644 index 000000000..073287854 --- /dev/null +++ b/dapp/src/assets/videos/welcome-steps/index.ts @@ -0,0 +1,5 @@ +import step1Video from "./welcome-step-1.mp4" +import step2Video from "./welcome-step-2.mp4" +import step3Video from "./welcome-step-3.mp4" + +export { step1Video, step2Video, step3Video } diff --git a/dapp/src/components/AcrePointsClaimModal.tsx b/dapp/src/components/AcrePointsClaimModal.tsx index bc3f045af..b7836c318 100644 --- a/dapp/src/components/AcrePointsClaimModal.tsx +++ b/dapp/src/components/AcrePointsClaimModal.tsx @@ -7,13 +7,13 @@ import { Transition, useAnimate, } from "framer-motion" -import { logPromiseFailure, numberToLocaleString } from "#/utils" -import { ONE_SEC_IN_MILLISECONDS } from "#/constants" +import { logPromiseFailure, numbersUtils } from "#/utils" +import { time } from "#/constants" import ConfettiExplosion from "react-confetti-explosion" import { BaseModalProps } from "#/types" -import { AnimatedNumber } from "./shared/AnimatedNumber" import { TextXl } from "./shared/Typography" import withBaseModal from "./ModalRoot/withBaseModal" +import AnimatedNumber from "./shared/AnimatedNumber" const MotionBox = motion(Box) @@ -28,8 +28,8 @@ const TRANSITION: Transition = { stiffness: 86, delay: 4, // step duration } -const AUTOCLOSE_DELAY = 12 * ONE_SEC_IN_MILLISECONDS -const CONFETTI_DURATION = 4 * ONE_SEC_IN_MILLISECONDS +const AUTOCLOSE_DELAY = 12 * time.ONE_SEC_IN_MILLISECONDS +const CONFETTI_DURATION = 4 * time.ONE_SEC_IN_MILLISECONDS const getStepOffsets = ( stepCount: number, @@ -54,8 +54,9 @@ function AcrePointsClaimModalBase({ totalAmount, closeModal, }: AcrePointsClaimModalBaseProps) { - const formattedClaimedAmount = numberToLocaleString(claimedAmount) - const formattedTotalAmount = numberToLocaleString(totalAmount) + const formattedClaimedAmount = + numbersUtils.numberToLocaleString(claimedAmount) + const formattedTotalAmount = numbersUtils.numberToLocaleString(totalAmount) const steps = useMemo<[string, ReactNode][]>( () => [ diff --git a/dapp/src/components/ConnectWalletModal/ConnectWalletAlert.tsx b/dapp/src/components/ConnectWalletModal/ConnectWalletAlert.tsx index 44a499d87..1315ba487 100644 --- a/dapp/src/components/ConnectWalletModal/ConnectWalletAlert.tsx +++ b/dapp/src/components/ConnectWalletModal/ConnectWalletAlert.tsx @@ -1,7 +1,7 @@ import React from "react" import { AlertStatus, Box, Link, VStack } from "@chakra-ui/react" import { AnimatePresence, Variants, motion } from "framer-motion" -import { EXTERNAL_HREF } from "#/constants" +import { externalHref } from "#/constants" import { Alert, AlertDescription, @@ -35,7 +35,7 @@ function ContactSupport() { // TODO: Define in the new color palette color="#0E61FE" textDecoration="underline" - href={EXTERNAL_HREF.DISCORD} + href={externalHref.DISCORD} isExternal > Acre support diff --git a/dapp/src/components/ConnectWalletModal/ConnectWalletButton.tsx b/dapp/src/components/ConnectWalletModal/ConnectWalletButton.tsx index b950b2b2c..7bb69424b 100644 --- a/dapp/src/components/ConnectWalletModal/ConnectWalletButton.tsx +++ b/dapp/src/components/ConnectWalletModal/ConnectWalletButton.tsx @@ -1,9 +1,10 @@ import React, { useCallback, useEffect, useRef, useState } from "react" -import { ONE_SEC_IN_MILLISECONDS } from "#/constants" +import { time } from "#/constants" import { useAppDispatch, useIsEmbed, useModal, + usePostHogIdentity, useSignMessageAndCreateSession, useWallet, useWalletConnectionAlert, @@ -24,7 +25,6 @@ import { } from "@chakra-ui/react" import { IconArrowNarrowRight } from "@tabler/icons-react" import { AnimatePresence, Variants, motion } from "framer-motion" -import { usePostHogIdentity } from "#/hooks/posthog" import ArrivingSoonTooltip from "../ArrivingSoonTooltip" import { TextLg, TextMd } from "../shared/Typography" import ConnectWalletStatusLabel from "./ConnectWalletStatusLabel" @@ -162,7 +162,7 @@ export default function ConnectWalletButton({ } setIsLoading(false) - }, ONE_SEC_IN_MILLISECONDS * 2) + }, time.ONE_SEC_IN_MILLISECONDS * 2) }, [connector]) const handleButtonClick = () => { diff --git a/dapp/src/components/Footer.tsx b/dapp/src/components/Footer.tsx index c32c4c7ed..e5898a100 100644 --- a/dapp/src/components/Footer.tsx +++ b/dapp/src/components/Footer.tsx @@ -9,7 +9,7 @@ import { Button, Icon, } from "@chakra-ui/react" -import { EXTERNAL_HREF } from "#/constants" +import { externalHref } from "#/constants" import { AcreSignIcon } from "#/assets/icons" import { useMobileMode } from "#/hooks" import { IconArrowUpRight } from "@tabler/icons-react" @@ -19,38 +19,38 @@ type FooterListItem = Pick const NAVIGATION: FooterListItem[] = [ { children: "Acre.fi", - href: EXTERNAL_HREF.WEBSITE, + href: externalHref.WEBSITE, }, { children: "Docs", - href: EXTERNAL_HREF.DOCS, + href: externalHref.DOCS, }, { children: "FAQ", - href: EXTERNAL_HREF.FAQ, + href: externalHref.FAQ, }, { children: "Blog", - href: EXTERNAL_HREF.BLOG, + href: externalHref.BLOG, }, { children: "Discord", - href: EXTERNAL_HREF.DISCORD, + href: externalHref.DISCORD, }, { children: "X", - href: EXTERNAL_HREF.X, + href: externalHref.X, }, ] const DOCUMENTS: FooterListItem[] = [ { children: "Privacy Policy", - href: EXTERNAL_HREF.PRIVACY_POLICY, + href: externalHref.PRIVACY_POLICY, }, { children: "Terms of Use", - href: EXTERNAL_HREF.TERMS_OF_USE, + href: externalHref.TERMS_OF_USE, }, ] diff --git a/dapp/src/components/GateModal.tsx b/dapp/src/components/GateModal.tsx index 34a79a2ee..21188b9e1 100644 --- a/dapp/src/components/GateModal.tsx +++ b/dapp/src/components/GateModal.tsx @@ -1,7 +1,7 @@ import React, { useCallback } from "react" import { Link, ModalBody, ModalFooter, ModalHeader } from "@chakra-ui/react" import { TextSm } from "#/components/shared/Typography" -import { EXTERNAL_HREF } from "#/constants" +import { externalHref } from "#/constants" import { BaseModalProps } from "#/types" import { useAccessCode } from "#/hooks" import withBaseModal from "./ModalRoot/withBaseModal" @@ -34,7 +34,7 @@ export function GateModalBase({ closeModal }: BaseModalProps) { Discord diff --git a/dapp/src/components/GlobalStyles.tsx b/dapp/src/components/GlobalStyles.tsx index e8b11945a..69d8986a7 100644 --- a/dapp/src/components/GlobalStyles.tsx +++ b/dapp/src/components/GlobalStyles.tsx @@ -1,11 +1,12 @@ import React from "react" import { Global } from "@emotion/react" - -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" +import { + SegmentRegular, + SegmentMedium, + SegmentSemiBold, + SegmentBold, + SegmentBlack, +} from "#/assets/fonts" export default function GlobalStyles() { return ( diff --git a/dapp/src/components/Header/ConnectWallet.tsx b/dapp/src/components/Header/ConnectWallet.tsx index 8040b47da..d880ebbbb 100644 --- a/dapp/src/components/Header/ConnectWallet.tsx +++ b/dapp/src/components/Header/ConnectWallet.tsx @@ -13,11 +13,17 @@ import { useClipboard, useMultiStyleConfig, } from "@chakra-ui/react" -import { useIsEmbed, useMobileMode, useModal, useWallet } from "#/hooks" -import { CurrencyBalance } from "#/components/shared/CurrencyBalance" +import { + useIsEmbed, + useMobileMode, + useModal, + usePostHogIdentity, + useWallet, +} from "#/hooks" +import CurrencyBalance from "#/components/shared/CurrencyBalance" import { TextMd } from "#/components/shared/Typography" import { BitcoinIcon } from "#/assets/icons" -import { referralProgram, truncateAddress } from "#/utils" +import { referralProgram, addressUtils } from "#/utils" import { motion } from "framer-motion" import { MODAL_TYPES } from "#/types" import { @@ -29,7 +35,6 @@ import { IconChevronUp, } from "@tabler/icons-react" import { useMatch } from "react-router-dom" -import { usePostHogIdentity } from "#/hooks/posthog" import Tooltip from "../shared/Tooltip" function isChangeAccountFeatureSupported(embeddedApp: string | undefined) { @@ -113,7 +118,9 @@ export default function ConnectWallet() { leftIcon={} rightIcon={isOpen ? : } > - {truncateAddress(address)} + + {addressUtils.truncateAddress(address)} + {options.map( @@ -159,7 +166,9 @@ export default function ConnectWallet() { spacing={3} > - {truncateAddress(address)} + + {addressUtils.truncateAddress(address)} + - - + + diff --git a/dapp/src/components/Layout.tsx b/dapp/src/components/Layout.tsx index d229f45cf..9435c945e 100644 --- a/dapp/src/components/Layout.tsx +++ b/dapp/src/components/Layout.tsx @@ -1,9 +1,8 @@ import React from "react" import { Outlet } from "react-router-dom" import { Flex, VStack } from "@chakra-ui/react" -import { useIsEmbed, useMobileMode } from "#/hooks" +import { useIsEmbed, useMobileMode, usePostHogPageViewCapture } from "#/hooks" import { DappMode } from "#/types" -import { usePostHogPageViewCapture } from "#/hooks/posthog" import Header from "./Header" import ModalRoot from "./ModalRoot" import MobileModeBanner from "./MobileModeBanner" diff --git a/dapp/src/components/MezoBeehiveModal.tsx b/dapp/src/components/MezoBeehiveModal.tsx index 18ca145d8..c9777c6c8 100644 --- a/dapp/src/components/MezoBeehiveModal.tsx +++ b/dapp/src/components/MezoBeehiveModal.tsx @@ -16,8 +16,8 @@ import { import { H6, TextLg, TextMd, TextXl } from "#/components/shared/Typography" import { AcreSignIcon, MatsIcon, MezoSignIcon } from "#/assets/icons" import { IconArrowUpRight, IconChartPieFilled } from "@tabler/icons-react" -import { EXTERNAL_HREF } from "#/constants" -import { numberToLocaleString } from "#/utils" +import { externalHref } from "#/constants" +import { numbersUtils } from "#/utils" import { useMats } from "#/hooks" import withBaseModal from "./ModalRoot/withBaseModal" @@ -46,7 +46,9 @@ function MezoBeehiveModalBase() { {data && ( -
{numberToLocaleString(data.totalMats)}
+
+ {numbersUtils.numberToLocaleString(data.totalMats)} +
MATS
)} @@ -111,7 +113,7 @@ function MezoBeehiveModalBase() {