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() {
X
@@ -108,7 +108,7 @@ function MobileModeBanner(props: MobileModeBannerProps) {
and join our{" "}
Discord
diff --git a/dapp/src/components/TransactionModal/ActionDurationEstimation.tsx b/dapp/src/components/TransactionModal/ActionDurationEstimation.tsx
index cb076e733..6be471b7b 100644
--- a/dapp/src/components/TransactionModal/ActionDurationEstimation.tsx
+++ b/dapp/src/components/TransactionModal/ActionDurationEstimation.tsx
@@ -1,6 +1,6 @@
import React from "react"
import { ActivityType } from "#/types"
-import { getEstimatedDuration } from "#/utils"
+import { activitiesUtils } from "#/utils"
import { useFormField } from "#/hooks"
import { TextMd } from "../shared/Typography"
import { TOKEN_AMOUNT_FIELD_NAME } from "../shared/TokenAmountForm/TokenAmountFormBase"
@@ -18,7 +18,7 @@ export default function ActionDurationEstimation({
Estimated duration
- ~ {getEstimatedDuration(amount, type)}
+ ~ {activitiesUtils.getEstimatedDuration(amount, type)}
)
diff --git a/dapp/src/components/TransactionModal/ActiveFlowStep.tsx b/dapp/src/components/TransactionModal/ActiveFlowStep.tsx
index bf8e5eafa..9656c7103 100644
--- a/dapp/src/components/TransactionModal/ActiveFlowStep.tsx
+++ b/dapp/src/components/TransactionModal/ActiveFlowStep.tsx
@@ -5,8 +5,8 @@ import {
ActionFlowType,
ACTION_FLOW_TYPES,
} from "#/types"
-import { ActiveUnstakingStep } from "./ActiveUnstakingStep"
-import { ActiveStakingStep } from "./ActiveStakingStep"
+import ActiveUnstakingStep from "./ActiveUnstakingStep"
+import ActiveStakingStep from "./ActiveStakingStep"
const FLOW: Record ReactElement> = {
[ACTION_FLOW_TYPES.STAKE]: (activeStep) => (
@@ -17,7 +17,7 @@ const FLOW: Record ReactElement> = {
),
}
-export function ActiveFlowStep() {
+export default function ActiveFlowStep() {
const { closeModal } = useModal()
const activeStep = useActionFlowActiveStep()
const type = useActionFlowType()
diff --git a/dapp/src/components/TransactionModal/ActiveStakingStep/DepositBTCModal.tsx b/dapp/src/components/TransactionModal/ActiveStakingStep/DepositBTCModal.tsx
index c6eaae8a2..8587fa3b4 100644
--- a/dapp/src/components/TransactionModal/ActiveStakingStep/DepositBTCModal.tsx
+++ b/dapp/src/components/TransactionModal/ActiveStakingStep/DepositBTCModal.tsx
@@ -6,13 +6,13 @@ import {
useBitcoinBalance,
useCancelPromise,
useDepositBTCTransaction,
+ usePostHogCapture,
useStakeFlowContext,
useVerifyDepositAddress,
} from "#/hooks"
-import { usePostHogCapture } from "#/hooks/posthog/usePostHogCapture"
-import { PostHogEvent } from "#/posthog/events"
+import PostHogEvent from "#/posthog/events"
import { setStatus, setTxHash } from "#/store/action-flow"
-import { ONE_SEC_IN_MILLISECONDS } from "#/constants"
+import { time } from "#/constants"
import { PROCESS_STATUSES } from "#/types"
import { eip1193, logPromiseFailure } from "#/utils"
import { useTimeout } from "@chakra-ui/react"
@@ -116,7 +116,7 @@ export default function DepositBTCModal() {
logPromiseFailure(handledDepositBTC())
}, [handledDepositBTC])
- useTimeout(handledDepositBTCWrapper, ONE_SEC_IN_MILLISECONDS)
+ useTimeout(handledDepositBTCWrapper, time.ONE_SEC_IN_MILLISECONDS)
if (status === "pending" || status === "success")
return
diff --git a/dapp/src/components/TransactionModal/ActiveStakingStep/StakeFormModal/AcrePointsRewardEstimation.tsx b/dapp/src/components/TransactionModal/ActiveStakingStep/StakeFormModal/AcrePointsRewardEstimation.tsx
index 242664a3d..a8b318714 100644
--- a/dapp/src/components/TransactionModal/ActiveStakingStep/StakeFormModal/AcrePointsRewardEstimation.tsx
+++ b/dapp/src/components/TransactionModal/ActiveStakingStep/StakeFormModal/AcrePointsRewardEstimation.tsx
@@ -10,7 +10,7 @@ import {
VStack,
} from "@chakra-ui/react"
import { H4, TextMd } from "#/components/shared/Typography"
-import { numberToLocaleString } from "#/utils"
+import { numbersUtils } from "#/utils"
import { IconChevronDown } from "@tabler/icons-react"
import { TOKEN_AMOUNT_FIELD_NAME } from "#/components/shared/TokenAmountForm/TokenAmountFormBase"
import {
@@ -18,7 +18,7 @@ import {
useMinDepositAmount,
useTransactionDetails,
} from "#/hooks"
-import { ONE_MONTH_IN_DAYS, ONE_WEEK_IN_DAYS } from "#/constants"
+import { time } from "#/constants"
const ACRE_POINTS_DATA = {
day: {
@@ -27,11 +27,11 @@ const ACRE_POINTS_DATA = {
},
week: {
label: "per week",
- multipler: ONE_WEEK_IN_DAYS,
+ multipler: time.ONE_WEEK_IN_DAYS,
},
month: {
label: "per month",
- multipler: ONE_MONTH_IN_DAYS,
+ multipler: time.ONE_MONTH_IN_DAYS,
},
}
@@ -129,7 +129,7 @@ function AcrePointsRewardEstimation(props: StackProps) {
- +{numberToLocaleString(estimatedReward)} PTS
+ +{numbersUtils.numberToLocaleString(estimatedReward)} PTS
)
}
diff --git a/dapp/src/components/TransactionModal/ActiveStakingStep/StakeFormModal/StakeDetails.tsx b/dapp/src/components/TransactionModal/ActiveStakingStep/StakeFormModal/StakeDetails.tsx
index 05fb8ad5c..631d5c217 100644
--- a/dapp/src/components/TransactionModal/ActiveStakingStep/StakeFormModal/StakeDetails.tsx
+++ b/dapp/src/components/TransactionModal/ActiveStakingStep/StakeFormModal/StakeDetails.tsx
@@ -3,14 +3,14 @@ import { List } from "@chakra-ui/react"
import TransactionDetailsAmountItem from "#/components/shared/TransactionDetails/TransactionDetailsAmountItem"
import FeesDetailsAmountItem from "#/components/shared/FeesDetails/FeesDetailsAmountItem"
import { TOKEN_AMOUNT_FIELD_NAME } from "#/components/shared/TokenAmountForm/TokenAmountFormBase"
-import { FeesTooltip } from "#/components/TransactionModal/FeesTooltip"
import {
useFormField,
useMinDepositAmount,
useTransactionDetails,
} from "#/hooks"
import { CurrencyType } from "#/types"
-import { DESIRED_DECIMALS_FOR_FEE } from "#/constants"
+import { currencies } from "#/constants"
+import FeesTooltip from "../../FeesTooltip"
function StakeDetails({ currency }: { currency: CurrencyType }) {
const { value = 0n } = useFormField(
@@ -31,7 +31,7 @@ function StakeDetails({ currency }: { currency: CurrencyType }) {
from={{
currency,
amount: total,
- desiredDecimals: DESIRED_DECIMALS_FOR_FEE,
+ desiredDecimals: currencies.DESIRED_DECIMALS_FOR_FEE,
withRoundUp: true,
}}
to={{
diff --git a/dapp/src/components/TransactionModal/ActiveStakingStep/StakeFormModal/index.tsx b/dapp/src/components/TransactionModal/ActiveStakingStep/StakeFormModal/index.tsx
index 466283099..a8ec51413 100644
--- a/dapp/src/components/TransactionModal/ActiveStakingStep/StakeFormModal/index.tsx
+++ b/dapp/src/components/TransactionModal/ActiveStakingStep/StakeFormModal/index.tsx
@@ -4,7 +4,7 @@ import { TokenAmountFormValues } from "#/components/shared/TokenAmountForm/Token
import { useMinDepositAmount, useWallet } from "#/hooks"
import { FormSubmitButton } from "#/components/shared/Form"
import { ACTION_FLOW_TYPES, BaseFormProps } from "#/types"
-import { fixedPointNumberToString, getCurrencyByType } from "#/utils"
+import { numbersUtils, currencyUtils } from "#/utils"
import { featureFlags } from "#/constants"
import StakeDetails from "./StakeDetails"
import AcrePointsRewardEstimation from "./AcrePointsRewardEstimation"
@@ -16,8 +16,8 @@ function StakeFormModal({
const minDepositAmount = useMinDepositAmount()
const { balance: tokenBalance } = useWallet()
- const { decimals } = getCurrencyByType("bitcoin")
- const inputPlaceholder = `Minimum ${fixedPointNumberToString(minDepositAmount, decimals)} BTC`
+ const { decimals } = currencyUtils.getCurrencyByType("bitcoin")
+ const inputPlaceholder = `Minimum ${numbersUtils.fixedPointNumberToString(minDepositAmount, decimals)} BTC`
const tokenAmountLabel = "Wallet balance"
return (
diff --git a/dapp/src/components/TransactionModal/ActiveStakingStep/StakingErrorModal/RetryModal.tsx b/dapp/src/components/TransactionModal/ActiveStakingStep/StakingErrorModal/RetryModal.tsx
index fca445db6..f5b84cce0 100644
--- a/dapp/src/components/TransactionModal/ActiveStakingStep/StakingErrorModal/RetryModal.tsx
+++ b/dapp/src/components/TransactionModal/ActiveStakingStep/StakingErrorModal/RetryModal.tsx
@@ -12,9 +12,9 @@ import {
import { CableWithPlugIcon } from "#/assets/icons"
import { TextMd, TextSm } from "#/components/shared/Typography"
import IconWrapper from "#/components/shared/IconWrapper"
-import { getExpirationTimestamp, getPercentValue } from "#/utils"
+import { timeUtils, numbersUtils } from "#/utils"
import { useCountdown } from "#/hooks"
-import { ONE_MINUTE_IN_SECONDS, ONE_SEC_IN_MILLISECONDS } from "#/constants"
+import { time } from "#/constants"
import { IconShieldCheckFilled, IconX } from "@tabler/icons-react"
import Skeleton from "#/components/shared/Skeleton"
@@ -23,7 +23,10 @@ const getCounterData = (minutes: string, seconds: string) => {
const progressPercent = `${
isLessThanMinute
- ? getPercentValue(parseInt(seconds, 10), ONE_MINUTE_IN_SECONDS)
+ ? numbersUtils.getPercentValue(
+ parseInt(seconds, 10),
+ time.ONE_MINUTE_IN_SECONDS,
+ )
: 100
}%`
const label = `${isLessThanMinute ? "0" : "1"}:${seconds}`
@@ -36,7 +39,9 @@ type RetryModalProps = { isLoading: boolean; retry: () => void }
export default function RetryModal({ isLoading, retry }: RetryModalProps) {
const retryTimestamp = useMemo(
() =>
- getExpirationTimestamp(ONE_MINUTE_IN_SECONDS * ONE_SEC_IN_MILLISECONDS),
+ timeUtils.getExpirationTimestamp(
+ time.ONE_MINUTE_IN_SECONDS * time.ONE_SEC_IN_MILLISECONDS,
+ ),
[],
)
const { minutes, seconds } = useCountdown(retryTimestamp, true, retry)
diff --git a/dapp/src/components/TransactionModal/ActiveStakingStep/StakingErrorModal/ServerErrorModal.tsx b/dapp/src/components/TransactionModal/ActiveStakingStep/StakingErrorModal/ServerErrorModal.tsx
index 25e0bd84b..27056f206 100644
--- a/dapp/src/components/TransactionModal/ActiveStakingStep/StakingErrorModal/ServerErrorModal.tsx
+++ b/dapp/src/components/TransactionModal/ActiveStakingStep/StakingErrorModal/ServerErrorModal.tsx
@@ -12,7 +12,7 @@ import {
} from "@chakra-ui/react"
import { CableWithPlugIcon } from "#/assets/icons"
import { TextMd } from "#/components/shared/Typography"
-import { EXTERNAL_HREF } from "#/constants"
+import { externalHref } from "#/constants"
import IconWrapper from "#/components/shared/IconWrapper"
import {
IconBrandDiscordFilled,
@@ -48,7 +48,7 @@ export default function ServerErrorModal({
width="100%"
variant="outline"
rightIcon={ }
- href={EXTERNAL_HREF.DISCORD}
+ href={externalHref.DISCORD}
isExternal
>
Get help on Discord
diff --git a/dapp/src/components/TransactionModal/ActiveStakingStep/index.tsx b/dapp/src/components/TransactionModal/ActiveStakingStep/index.tsx
index d03576d31..37c884421 100644
--- a/dapp/src/components/TransactionModal/ActiveStakingStep/index.tsx
+++ b/dapp/src/components/TransactionModal/ActiveStakingStep/index.tsx
@@ -4,7 +4,11 @@ import DepositBTCModal from "./DepositBTCModal"
const STEPS = ACTION_FLOW_STEPS_TYPES[ACTION_FLOW_TYPES.STAKE]
-export function ActiveStakingStep({ activeStep }: { activeStep: number }) {
+export default function ActiveStakingStep({
+ activeStep,
+}: {
+ activeStep: number
+}) {
switch (activeStep) {
case STEPS.DEPOSIT_BTC:
return
diff --git a/dapp/src/components/TransactionModal/ActiveUnstakingStep/NotEnoughFundsModal.tsx b/dapp/src/components/TransactionModal/ActiveUnstakingStep/NotEnoughFundsModal.tsx
index 1131119cd..f1bab86e9 100644
--- a/dapp/src/components/TransactionModal/ActiveUnstakingStep/NotEnoughFundsModal.tsx
+++ b/dapp/src/components/TransactionModal/ActiveUnstakingStep/NotEnoughFundsModal.tsx
@@ -13,7 +13,7 @@ import { PROCESS_STATUSES } from "#/types"
import { BitcoinsStackErrorIcon } from "#/assets/icons"
import { TextMd, TextXl } from "../../shared/Typography"
import { Alert, AlertIcon } from "../../shared/Alert"
-import { CurrencyBalance } from "../../shared/CurrencyBalance"
+import CurrencyBalance from "../../shared/CurrencyBalance"
export default function NotEnoughFundsModal() {
const dispatch = useAppDispatch()
diff --git a/dapp/src/components/TransactionModal/ActiveUnstakingStep/SignMessageModal.tsx b/dapp/src/components/TransactionModal/ActiveUnstakingStep/SignMessageModal.tsx
index 53784597f..01deb3fd3 100644
--- a/dapp/src/components/TransactionModal/ActiveUnstakingStep/SignMessageModal.tsx
+++ b/dapp/src/components/TransactionModal/ActiveUnstakingStep/SignMessageModal.tsx
@@ -6,17 +6,17 @@ import {
useBitcoinPosition,
useCancelPromise,
useModal,
+ usePostHogCapture,
useTimeout,
useTransactionDetails,
} from "#/hooks"
import { ACTION_FLOW_TYPES, Activity, PROCESS_STATUSES } from "#/types"
-import { dateToUnixTimestamp, eip1193, logPromiseFailure } from "#/utils"
+import { timeUtils, eip1193, logPromiseFailure } from "#/utils"
import { setStatus } from "#/store/action-flow"
import { useInitializeWithdraw } from "#/acre-react/hooks"
-import { ONE_SEC_IN_MILLISECONDS, queryKeysFactory } from "#/constants"
+import { time, queryKeysFactory } from "#/constants"
import { useMutation, useQueryClient } from "@tanstack/react-query"
-import { PostHogEvent } from "#/posthog/events"
-import { usePostHogCapture } from "#/hooks/posthog/usePostHogCapture"
+import PostHogEvent from "#/posthog/events"
import BuildTransactionModal from "./BuildTransactionModal"
import WalletInteractionModal from "../WalletInteractionModal"
@@ -130,9 +130,9 @@ export default function SignMessageModal() {
// This is a requested amount. The amount of BTC received will be
// around: `amount - transactionFee.total`.
amount: amount - transactionFee.acre,
- initializedAt: dateToUnixTimestamp(),
+ initializedAt: timeUtils.dateToUnixTimestamp(),
// The message is signed immediately after the initialization.
- finalizedAt: dateToUnixTimestamp(),
+ finalizedAt: timeUtils.dateToUnixTimestamp(),
}
if (oldData) return [newActivity, ...oldData]
@@ -149,7 +149,7 @@ export default function SignMessageModal() {
closeModal()
}
- useTimeout(handleSignMessage, ONE_SEC_IN_MILLISECONDS)
+ useTimeout(handleSignMessage, time.ONE_SEC_IN_MILLISECONDS)
if (status === "building-data")
return
diff --git a/dapp/src/components/TransactionModal/ActiveUnstakingStep/UnstakeFormModal/UnstakeDetails.tsx b/dapp/src/components/TransactionModal/ActiveUnstakingStep/UnstakeFormModal/UnstakeDetails.tsx
index 4ac3b86ad..9196890c2 100644
--- a/dapp/src/components/TransactionModal/ActiveUnstakingStep/UnstakeFormModal/UnstakeDetails.tsx
+++ b/dapp/src/components/TransactionModal/ActiveUnstakingStep/UnstakeFormModal/UnstakeDetails.tsx
@@ -7,10 +7,10 @@ import {
useTransactionDetails,
} from "#/hooks"
import { ACTION_FLOW_TYPES, CurrencyType } from "#/types"
-import { DESIRED_DECIMALS_FOR_FEE } from "#/constants"
+import { currencies } from "#/constants"
import FeesDetailsAmountItem from "#/components/shared/FeesDetails/FeesDetailsAmountItem"
import TransactionDetailsAmountItem from "#/components/shared/TransactionDetails/TransactionDetailsAmountItem"
-import { FeesTooltip } from "../../FeesTooltip"
+import FeesTooltip from "../../FeesTooltip"
function UnstakeDetails({ currency }: { currency: CurrencyType }) {
const { value = 0n } = useFormField(
@@ -32,7 +32,7 @@ function UnstakeDetails({ currency }: { currency: CurrencyType }) {
from={{
currency,
amount: total,
- desiredDecimals: DESIRED_DECIMALS_FOR_FEE,
+ desiredDecimals: currencies.DESIRED_DECIMALS_FOR_FEE,
withRoundUp: true,
}}
to={{
diff --git a/dapp/src/components/TransactionModal/ActiveUnstakingStep/UnstakeFormModal/index.tsx b/dapp/src/components/TransactionModal/ActiveUnstakingStep/UnstakeFormModal/index.tsx
index a27f677d1..19e0c6636 100644
--- a/dapp/src/components/TransactionModal/ActiveUnstakingStep/UnstakeFormModal/index.tsx
+++ b/dapp/src/components/TransactionModal/ActiveUnstakingStep/UnstakeFormModal/index.tsx
@@ -8,7 +8,7 @@ import {
useBitcoinPosition,
useMinWithdrawAmount,
} from "#/hooks"
-import { fixedPointNumberToString, getCurrencyByType } from "#/utils"
+import { numbersUtils, currencyUtils } from "#/utils"
import UnstakeDetails from "./UnstakeDetails"
import ActionDurationEstimation from "../../ActionDurationEstimation"
@@ -20,8 +20,8 @@ function UnstakeFormModal({
const minTokenAmount = useMinWithdrawAmount()
const status = useActionFlowStatus()
- const { decimals } = getCurrencyByType("bitcoin")
- const inputPlaceholder = `Minimum ${fixedPointNumberToString(minTokenAmount, decimals)} BTC`
+ const { decimals } = currencyUtils.getCurrencyByType("bitcoin")
+ const inputPlaceholder = `Minimum ${numbersUtils.fixedPointNumberToString(minTokenAmount, decimals)} BTC`
const tokenAmountLabel = "Acre balance"
const defaultAmount =
status === PROCESS_STATUSES.REFINE_AMOUNT ? balance : undefined
diff --git a/dapp/src/components/TransactionModal/ActiveUnstakingStep/index.tsx b/dapp/src/components/TransactionModal/ActiveUnstakingStep/index.tsx
index 496937f38..669ece364 100644
--- a/dapp/src/components/TransactionModal/ActiveUnstakingStep/index.tsx
+++ b/dapp/src/components/TransactionModal/ActiveUnstakingStep/index.tsx
@@ -4,7 +4,11 @@ import SignMessageModal from "./SignMessageModal"
const STEPS = ACTION_FLOW_STEPS_TYPES[ACTION_FLOW_TYPES.UNSTAKE]
-export function ActiveUnstakingStep({ activeStep }: { activeStep: number }) {
+export default function ActiveUnstakingStep({
+ activeStep,
+}: {
+ activeStep: number
+}) {
switch (activeStep) {
case STEPS.SIGN_MESSAGE:
return
diff --git a/dapp/src/components/TransactionModal/FeesTooltip/FeesTooltipItem.tsx b/dapp/src/components/TransactionModal/FeesTooltip/FeesTooltipItem.tsx
index 4cbd38acd..52650b44a 100644
--- a/dapp/src/components/TransactionModal/FeesTooltip/FeesTooltipItem.tsx
+++ b/dapp/src/components/TransactionModal/FeesTooltip/FeesTooltipItem.tsx
@@ -1,17 +1,20 @@
import React from "react"
import { ListItem } from "@chakra-ui/react"
-import {
- CurrencyBalance,
+import CurrencyBalance, {
CurrencyBalanceProps,
} from "#/components/shared/CurrencyBalance"
import { TextSm } from "#/components/shared/Typography"
-import { DESIRED_DECIMALS_FOR_FEE } from "#/constants"
+import { currencies } from "#/constants"
-export type FeesItemType = CurrencyBalanceProps & {
+type FeesItemType = CurrencyBalanceProps & {
label: string
}
-export function FeesTooltipItem({ label, amount, ...props }: FeesItemType) {
+export default function FeesTooltipItem({
+ label,
+ amount,
+ ...props
+}: FeesItemType) {
return (
{label}
@@ -20,7 +23,7 @@ export function FeesTooltipItem({ label, amount, ...props }: FeesItemType) {
amount={amount}
color="gold.300"
fontWeight="semibold"
- desiredDecimals={DESIRED_DECIMALS_FOR_FEE}
+ desiredDecimals={currencies.DESIRED_DECIMALS_FOR_FEE}
withRoundUp
{...props}
/>
diff --git a/dapp/src/components/TransactionModal/FeesTooltip/index.ts b/dapp/src/components/TransactionModal/FeesTooltip/index.ts
deleted file mode 100644
index 9d08672e3..000000000
--- a/dapp/src/components/TransactionModal/FeesTooltip/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./FeesTooltip"
diff --git a/dapp/src/components/TransactionModal/FeesTooltip/FeesTooltip.tsx b/dapp/src/components/TransactionModal/FeesTooltip/index.tsx
similarity index 84%
rename from dapp/src/components/TransactionModal/FeesTooltip/FeesTooltip.tsx
rename to dapp/src/components/TransactionModal/FeesTooltip/index.tsx
index 4c630bbbd..c805d8817 100644
--- a/dapp/src/components/TransactionModal/FeesTooltip/FeesTooltip.tsx
+++ b/dapp/src/components/TransactionModal/FeesTooltip/index.tsx
@@ -1,8 +1,8 @@
import React from "react"
import { List } from "@chakra-ui/react"
import TooltipIcon from "#/components/shared/TooltipIcon"
-import { FeesTooltipItem } from "./FeesTooltipItem"
-import { Fee as AcreFee } from "../../../types/fee"
+import { Fee as AcreFee } from "#/types"
+import FeesTooltipItem from "./FeesTooltipItem"
type Props = {
fees: Omit
@@ -19,7 +19,7 @@ const mapFeeToLabel = (feeId: keyof AcreFee) => {
}
}
-export function FeesTooltip({ fees }: Props) {
+export default function FeesTooltip({ fees }: Props) {
return (
The process will continue in the background.
Estimated duration ~{" "}
- {getEstimatedDuration(tokenAmount?.amount ?? 0n, activityType)}
+ {activitiesUtils.getEstimatedDuration(
+ tokenAmount?.amount ?? 0n,
+ activityType,
+ )}
diff --git a/dapp/src/components/TransactionModal/index.tsx b/dapp/src/components/TransactionModal/index.tsx
index 92d805380..96d14a501 100644
--- a/dapp/src/components/TransactionModal/index.tsx
+++ b/dapp/src/components/TransactionModal/index.tsx
@@ -10,7 +10,7 @@ import { ActionFlowType, BaseModalProps } from "#/types"
import { resetState, setType } from "#/store/action-flow"
import { logPromiseFailure } from "#/utils"
import ModalContentWrapper from "./ModalContentWrapper"
-import { ActiveFlowStep } from "./ActiveFlowStep"
+import ActiveFlowStep from "./ActiveFlowStep"
import withBaseModal from "../ModalRoot/withBaseModal"
import { ConnectWalletModalBase } from "../ConnectWalletModal"
diff --git a/dapp/src/components/UnexpectedErrorModal.tsx b/dapp/src/components/UnexpectedErrorModal.tsx
index 69890b84f..4ed214df5 100644
--- a/dapp/src/components/UnexpectedErrorModal.tsx
+++ b/dapp/src/components/UnexpectedErrorModal.tsx
@@ -9,7 +9,7 @@ import {
ModalHeader,
} from "@chakra-ui/react"
import { TextMd } from "#/components/shared/Typography"
-import { EXTERNAL_HREF } from "#/constants"
+import { externalHref } from "#/constants"
import { IconBrandDiscordFilled } from "@tabler/icons-react"
import { BaseModalProps } from "#/types"
import withBaseModal from "./ModalRoot/withBaseModal"
@@ -31,7 +31,7 @@ export function UnexpectedErrorModalBase({ withCloseButton }: BaseModalProps) {
width="100%"
variant="outline"
rightIcon={ }
- href={EXTERNAL_HREF.DISCORD}
+ href={externalHref.DISCORD}
isExternal
>
Get help on Discord
diff --git a/dapp/src/components/WelcomeModal.tsx b/dapp/src/components/WelcomeModal.tsx
index b68a6ce75..c5ab40177 100644
--- a/dapp/src/components/WelcomeModal.tsx
+++ b/dapp/src/components/WelcomeModal.tsx
@@ -18,10 +18,12 @@ import { H3, TextSm } from "#/components/shared/Typography"
import { BaseModalProps, DappMode } from "#/types"
import { EmbedApp } from "#/utils/referralProgram"
import { useIsEmbed, useMobileMode } from "#/hooks"
+import {
+ step1Video,
+ step2Video,
+ step3Video,
+} from "#/assets/videos/welcome-steps"
import withBaseModal from "./ModalRoot/withBaseModal"
-import step1Video from "../assets/videos/welcome-steps/welcome-step-1.mp4"
-import step2Video from "../assets/videos/welcome-steps/welcome-step-2.mp4"
-import step3Video from "../assets/videos/welcome-steps/welcome-step-3.mp4"
const dappModeToContent: Record ReactElement> = {
standalone: () => (
diff --git a/dapp/src/components/shared/AnimatedNumber/index.ts b/dapp/src/components/shared/AnimatedNumber/index.ts
deleted file mode 100644
index 70f801b32..000000000
--- a/dapp/src/components/shared/AnimatedNumber/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { default as AnimatedNumber } from "./AnimatedNumber"
diff --git a/dapp/src/components/shared/AnimatedNumber/AnimatedNumber.tsx b/dapp/src/components/shared/AnimatedNumber/index.tsx
similarity index 100%
rename from dapp/src/components/shared/AnimatedNumber/AnimatedNumber.tsx
rename to dapp/src/components/shared/AnimatedNumber/index.tsx
diff --git a/dapp/src/components/shared/BlockExplorerLink.tsx b/dapp/src/components/shared/BlockExplorerLink.tsx
index bc7900753..aeb28a083 100644
--- a/dapp/src/components/shared/BlockExplorerLink.tsx
+++ b/dapp/src/components/shared/BlockExplorerLink.tsx
@@ -1,7 +1,7 @@
import React from "react"
import { Chain, ExplorerDataType } from "#/types"
import { Link, LinkProps } from "@chakra-ui/react"
-import { createLinkToBlockExplorerForChain } from "#/utils"
+import { chainUtils } from "#/utils"
type BlockExplorerLinkProps = {
id: string
@@ -16,7 +16,11 @@ function BlockExplorerLink({
children,
...restProps
}: BlockExplorerLinkProps) {
- const { link, title } = createLinkToBlockExplorerForChain(chain, id, type)
+ const { link, title } = chainUtils.createLinkToBlockExplorerForChain(
+ chain,
+ id,
+ type,
+ )
// TODO: Update when ButtonLink is ready
return (
diff --git a/dapp/src/components/shared/CurrencyBalance.tsx b/dapp/src/components/shared/CurrencyBalance.tsx
index 1b5aa3be7..e2d83d3b3 100644
--- a/dapp/src/components/shared/CurrencyBalance.tsx
+++ b/dapp/src/components/shared/CurrencyBalance.tsx
@@ -5,12 +5,7 @@ import {
TextProps,
ResponsiveValue,
} from "@chakra-ui/react"
-import {
- fixedPointNumberToString,
- formatTokenAmount,
- getCurrencyByType,
- numberToLocaleString,
-} from "#/utils"
+import { numbersUtils, currencyUtils } from "#/utils"
import { CurrencyType, AmountType } from "#/types"
import Tooltip from "./Tooltip"
@@ -34,7 +29,7 @@ export type CurrencyBalanceProps = {
withTooltip?: boolean
} & TextProps
-export function CurrencyBalance({
+export default function CurrencyBalance({
currency,
amount,
shouldBeFormatted = true,
@@ -60,7 +55,7 @@ export function CurrencyBalance({
symbol,
decimals,
desiredDecimals: currencyDesiredDecimals,
- } = getCurrencyByType(currency)
+ } = currencyUtils.getCurrencyByType(currency)
const desiredDecimals = customDesiredDecimals ?? currencyDesiredDecimals
const getBalance = useCallback(
@@ -71,12 +66,24 @@ export function CurrencyBalance({
if (shouldBeFormatted || typeof value === "bigint") {
if (withFullPrecision)
- return fixedPointNumberToString(BigInt(value), decimals, withRoundUp)
+ return numbersUtils.fixedPointNumberToString(
+ BigInt(value),
+ decimals,
+ withRoundUp,
+ )
- return formatTokenAmount(value, decimals, desiredDecimals, withRoundUp)
+ return numbersUtils.formatTokenAmount(
+ value,
+ decimals,
+ desiredDecimals,
+ withRoundUp,
+ )
}
- return numberToLocaleString(value.toString(), desiredDecimals)
+ return numbersUtils.numberToLocaleString(
+ value.toString(),
+ desiredDecimals,
+ )
},
[amount, decimals, desiredDecimals, shouldBeFormatted, withRoundUp],
)
diff --git a/dapp/src/components/shared/CurrencyBalanceWithConversion.tsx b/dapp/src/components/shared/CurrencyBalanceWithConversion.tsx
index ea9f64850..f3c53d98e 100644
--- a/dapp/src/components/shared/CurrencyBalanceWithConversion.tsx
+++ b/dapp/src/components/shared/CurrencyBalanceWithConversion.tsx
@@ -1,8 +1,8 @@
import React from "react"
import { useCurrencyConversion } from "#/hooks"
-import { CurrencyBalance, CurrencyBalanceProps } from "./CurrencyBalance"
+import CurrencyBalance, { CurrencyBalanceProps } from "./CurrencyBalance"
-export function CurrencyBalanceWithConversion({
+export default function CurrencyBalanceWithConversion({
from,
to,
}: {
diff --git a/dapp/src/components/shared/FeesDetails/FeesDetailsAmountItem.tsx b/dapp/src/components/shared/FeesDetails/FeesDetailsAmountItem.tsx
index 5917dd76e..20b463e8d 100644
--- a/dapp/src/components/shared/FeesDetails/FeesDetailsAmountItem.tsx
+++ b/dapp/src/components/shared/FeesDetails/FeesDetailsAmountItem.tsx
@@ -1,7 +1,7 @@
import React, { ComponentProps } from "react"
import { Flex } from "@chakra-ui/react"
import FeesDetailsItem, { FeesDetailsItemProps } from "."
-import { CurrencyBalanceWithConversion } from "../CurrencyBalanceWithConversion"
+import CurrencyBalanceWithConversion from "../CurrencyBalanceWithConversion"
type FeesDetailsItemAmountItemProps = ComponentProps<
typeof CurrencyBalanceWithConversion
diff --git a/dapp/src/components/shared/Form/Form.tsx b/dapp/src/components/shared/Form/Form.tsx
index 8b3cbc2b1..870121927 100644
--- a/dapp/src/components/shared/Form/Form.tsx
+++ b/dapp/src/components/shared/Form/Form.tsx
@@ -1,4 +1,4 @@
import { chakra } from "@chakra-ui/react"
import { Form as FormikForm } from "formik"
-export const Form = chakra(FormikForm)
+export default chakra(FormikForm)
diff --git a/dapp/src/components/shared/Form/FormSubmitButton.tsx b/dapp/src/components/shared/Form/FormSubmitButton.tsx
index 727f4c3bb..f108fe945 100644
--- a/dapp/src/components/shared/Form/FormSubmitButton.tsx
+++ b/dapp/src/components/shared/Form/FormSubmitButton.tsx
@@ -1,9 +1,9 @@
import React from "react"
import { useFormikContext } from "formik"
import { ButtonProps } from "@chakra-ui/react"
-import { LoadingButton } from "../LoadingButton"
+import LoadingButton from "../LoadingButton"
-export function FormSubmitButton({ children, ...props }: ButtonProps) {
+export default function FormSubmitButton({ children, ...props }: ButtonProps) {
const { isSubmitting, isValid } = useFormikContext()
return (
diff --git a/dapp/src/components/shared/Form/index.tsx b/dapp/src/components/shared/Form/index.tsx
index 6a360b4a2..37d72248b 100644
--- a/dapp/src/components/shared/Form/index.tsx
+++ b/dapp/src/components/shared/Form/index.tsx
@@ -1,3 +1,3 @@
-export * from "./Form"
+export { default as Form } from "./Form"
export * from "./FormTokenBalanceInput"
-export * from "./FormSubmitButton"
+export { default as FormSubmitButton } from "./FormSubmitButton"
diff --git a/dapp/src/components/shared/LiveTag.tsx b/dapp/src/components/shared/LiveTag.tsx
index 84c7cf452..c81e62501 100644
--- a/dapp/src/components/shared/LiveTag.tsx
+++ b/dapp/src/components/shared/LiveTag.tsx
@@ -4,7 +4,7 @@ import { motion } from "framer-motion"
const MotionBox = motion(Box)
-export function LiveTag(props: TagProps) {
+export default function LiveTag(props: TagProps) {
return (
({
validate: async ({ password }) => {
const errors: FormikErrors = {}
- errors.password = await validatePassword(password)
+ errors.password = await forms.validatePassword(password)
- return getErrorsObj(errors)
+ return forms.getErrorsObj(errors)
},
handleSubmit: (values, { props }) => {
props.onSubmitForm(values)
diff --git a/dapp/src/components/shared/TokenAmountForm/index.tsx b/dapp/src/components/shared/TokenAmountForm/index.tsx
index a1360ed8e..509831f30 100644
--- a/dapp/src/components/shared/TokenAmountForm/index.tsx
+++ b/dapp/src/components/shared/TokenAmountForm/index.tsx
@@ -1,5 +1,5 @@
import { FormikErrors, withFormik } from "formik"
-import { getErrorsObj, validateTokenAmount } from "#/utils"
+import { forms } from "#/utils"
import { ActionFlowType, BaseFormProps } from "#/types"
import TokenAmountFormBase, {
TokenAmountFormBaseProps,
@@ -23,7 +23,7 @@ const TokenAmountForm = withFormik(
) => {
const errors: FormikErrors = {}
- errors.amount = validateTokenAmount(
+ errors.amount = forms.validateTokenAmount(
actionType,
amount,
tokenBalance,
@@ -31,7 +31,7 @@ const TokenAmountForm = withFormik(
currency,
)
- return getErrorsObj(errors)
+ return forms.getErrorsObj(errors)
},
handleSubmit: (values, { props }) => {
props.onSubmitForm(values)
diff --git a/dapp/src/components/shared/TokenBalanceInput.tsx b/dapp/src/components/shared/TokenBalanceInput.tsx
index 69067f35d..15cdc7c86 100644
--- a/dapp/src/components/shared/TokenBalanceInput.tsx
+++ b/dapp/src/components/shared/TokenBalanceInput.tsx
@@ -10,19 +10,14 @@ import {
InputRightElement,
useMultiStyleConfig,
} from "@chakra-ui/react"
-import {
- fixedPointNumberToString,
- getCurrencyByType,
- isFormError,
- userAmountToBigInt,
-} from "#/utils"
+import { numbersUtils, currencyUtils, forms } from "#/utils"
import { CurrencyType } from "#/types"
import { useCurrencyConversion } from "#/hooks"
import NumberFormatInput, {
NumberFormatInputValues,
NumberFormatInputProps,
} from "./NumberFormatInput"
-import { CurrencyBalance } from "./CurrencyBalance"
+import CurrencyBalance from "./CurrencyBalance"
import HelperErrorText, { HelperErrorTextProps } from "./Form/HelperErrorText"
type FiatCurrencyBalanceProps = {
@@ -94,12 +89,14 @@ export default function TokenBalanceInput({
const [displayedValue, setDisplayedValue] = useState()
const styles = useMultiStyleConfig("TokenBalanceInput", { size })
- const { decimals, symbol } = getCurrencyByType(currency)
+ const { decimals, symbol } = currencyUtils.getCurrencyByType(currency)
const onValueChange = (values: NumberFormatInputValues) => {
const { value } = values
- valueRef.current = value ? userAmountToBigInt(value, decimals) : undefined
+ valueRef.current = value
+ ? numbersUtils.userAmountToBigInt(value, decimals)
+ : undefined
setDisplayedValue(value)
}
@@ -109,15 +106,17 @@ export default function TokenBalanceInput({
const onClickMaxButton = () => {
setAmount(tokenBalance)
- setDisplayedValue(fixedPointNumberToString(tokenBalance, decimals))
+ setDisplayedValue(
+ numbersUtils.fixedPointNumberToString(tokenBalance, decimals),
+ )
}
const isBalanceExceeded =
typeof errorMsgText === "string" &&
- isFormError("EXCEEDED_VALUE", errorMsgText)
+ forms.isFormError("EXCEEDED_VALUE", errorMsgText)
const defaultValue = defaultAmount
- ? fixedPointNumberToString(defaultAmount, decimals)
+ ? numbersUtils.fixedPointNumberToString(defaultAmount, decimals)
: undefined
useEffect(() => {
diff --git a/dapp/src/components/shared/TransactionDetails/TransactionDetailsAmountItem.tsx b/dapp/src/components/shared/TransactionDetails/TransactionDetailsAmountItem.tsx
index c40c35c59..6b1280a1f 100644
--- a/dapp/src/components/shared/TransactionDetails/TransactionDetailsAmountItem.tsx
+++ b/dapp/src/components/shared/TransactionDetails/TransactionDetailsAmountItem.tsx
@@ -2,8 +2,8 @@ import React, { ComponentProps } from "react"
import { Flex } from "@chakra-ui/react"
import { Optional } from "#/types"
import TransactionDetailsItem, { TransactionDetailsItemProps } from "."
-import { CurrencyBalanceWithConversion } from "../CurrencyBalanceWithConversion"
-import { CurrencyBalance } from "../CurrencyBalance"
+import CurrencyBalanceWithConversion from "../CurrencyBalanceWithConversion"
+import CurrencyBalance from "../CurrencyBalance"
type TransactionDetailsAmountItemProps = Optional<
ComponentProps,
diff --git a/dapp/src/components/shared/UserDataSkeleton.tsx b/dapp/src/components/shared/UserDataSkeleton.tsx
index 2219f460b..b1d3cb710 100644
--- a/dapp/src/components/shared/UserDataSkeleton.tsx
+++ b/dapp/src/components/shared/UserDataSkeleton.tsx
@@ -1,6 +1,6 @@
import React from "react"
import { SkeletonProps } from "@chakra-ui/react"
-import useIsFetchedWalletData from "#/hooks/useIsFetchedWalletData"
+import { useIsFetchedWalletData } from "#/hooks"
import Skeleton from "./Skeleton"
export default function UserDataSkeleton({ ...props }: SkeletonProps) {
diff --git a/dapp/src/constants/chains.ts b/dapp/src/constants/chains.ts
index 6aed4e376..f83f4346a 100644
--- a/dapp/src/constants/chains.ts
+++ b/dapp/src/constants/chains.ts
@@ -10,9 +10,14 @@ const BLOCK_EXPLORER_MAINNET = {
bitcoin: { title: "Mempool", url: "https://mempool.space" },
}
-export const BLOCK_EXPLORER: Record =
+const BLOCK_EXPLORER: Record =
env.USE_TESTNET ? BLOCK_EXPLORER_TESTNET : BLOCK_EXPLORER_MAINNET
-export const BITCOIN_NETWORK: BitcoinNetwork = env.USE_TESTNET
+const BITCOIN_NETWORK: BitcoinNetwork = env.USE_TESTNET
? BitcoinNetwork.Testnet
: BitcoinNetwork.Mainnet
+
+export default {
+ BLOCK_EXPLORER,
+ BITCOIN_NETWORK,
+}
diff --git a/dapp/src/constants/currency.ts b/dapp/src/constants/currencies.ts
similarity index 52%
rename from dapp/src/constants/currency.ts
rename to dapp/src/constants/currencies.ts
index 6c82e4f42..7401268f8 100644
--- a/dapp/src/constants/currency.ts
+++ b/dapp/src/constants/currencies.ts
@@ -1,9 +1,9 @@
import { Currency, CurrencyType } from "#/types"
import env from "./env"
-export const DESIRED_DECIMALS_FOR_FEE = 5
+const DESIRED_DECIMALS_FOR_FEE = 5
-export const BITCOIN: Currency = {
+const BITCOIN: Currency = {
name: "Bitcoin",
symbol: "BTC",
decimals: 8,
@@ -11,25 +11,32 @@ export const BITCOIN: Currency = {
desiredDecimals: 4,
}
-export const STBTC: Currency = {
+const STBTC: Currency = {
...BITCOIN,
name: "stBTC",
symbol: "stBTC",
}
-export const USD: Currency = {
+const USD: Currency = {
name: "United States Dollar",
symbol: "USD",
decimals: 10,
desiredDecimals: 2,
}
-export const CURRENCY_ID_BITCOIN = env.USE_TESTNET
- ? "bitcoin_testnet"
- : "bitcoin"
+const CURRENCY_ID_BITCOIN = env.USE_TESTNET ? "bitcoin_testnet" : "bitcoin"
-export const CURRENCIES_BY_TYPE: Record = {
+const CURRENCIES_BY_TYPE: Record = {
bitcoin: BITCOIN,
usd: USD,
stbtc: STBTC,
}
+
+export default {
+ BITCOIN,
+ STBTC,
+ USD,
+ CURRENCY_ID_BITCOIN,
+ CURRENCIES_BY_TYPE,
+ DESIRED_DECIMALS_FOR_FEE,
+}
diff --git a/dapp/src/constants/errors.ts b/dapp/src/constants/errorMessages.ts
similarity index 79%
rename from dapp/src/constants/errors.ts
rename to dapp/src/constants/errorMessages.ts
index d3be0916d..91626ed10 100644
--- a/dapp/src/constants/errors.ts
+++ b/dapp/src/constants/errorMessages.ts
@@ -1,6 +1,6 @@
import { ACTION_FLOW_TYPES } from "#/types"
-export const TOKEN_FORM_ERRORS = {
+const TOKEN_FORM_ERRORS = {
REQUIRED: "Please enter an amount.",
EXCEEDED_VALUE:
"The amount exceeds your current wallet balance. Add more funds to your wallet or lower the deposit amount.",
@@ -8,16 +8,22 @@ export const TOKEN_FORM_ERRORS = {
`The amount is below the minimum required ${formType} of ${minValue} BTC.`,
}
-export const PASSWORD_FORM_ERRORS = {
+const PASSWORD_FORM_ERRORS = {
REQUIRED: "Please enter a password.",
INCORRECT_VALUE: "Incorrect password. Please try again.",
DEFAULT: "Something went wrong...",
}
-export const ACTION_FORM_ERRORS = {
+const ACTION_FORM_ERRORS = {
[ACTION_FLOW_TYPES.STAKE]: TOKEN_FORM_ERRORS,
[ACTION_FLOW_TYPES.UNSTAKE]: {
...TOKEN_FORM_ERRORS,
EXCEEDED_VALUE: "Your Acre balance is insufficient.",
},
}
+
+export default {
+ TOKEN_FORM_ERRORS,
+ PASSWORD_FORM_ERRORS,
+ ACTION_FORM_ERRORS,
+}
diff --git a/dapp/src/constants/externalHref.ts b/dapp/src/constants/externalHref.ts
index 76d742637..900737a7b 100644
--- a/dapp/src/constants/externalHref.ts
+++ b/dapp/src/constants/externalHref.ts
@@ -1,4 +1,4 @@
-export const EXTERNAL_HREF = {
+export default {
DISCORD: "https://discord.gg/acre",
DOCS: "https://docs.acre.fi",
FAQ: "https://docs.acre.fi/faq",
diff --git a/dapp/src/constants/index.ts b/dapp/src/constants/index.ts
index a5e49268c..32a3ee5b7 100644
--- a/dapp/src/constants/index.ts
+++ b/dapp/src/constants/index.ts
@@ -1,11 +1,11 @@
-export * from "./chains"
-export * from "./currency"
+export { default as chains } from "./chains"
+export { default as currencies } from "./currencies"
export { default as env } from "./env"
-export * from "./errors"
-export * from "./externalHref"
+export { default as errorMessages } from "./errorMessages"
+export { default as externalHref } from "./externalHref"
export { default as featureFlags } from "./featureFlags"
export { default as queryKeysFactory } from "./queryKeysFactory"
export { default as screen } from "./screen"
export { default as tbtc } from "./tbtc"
-export * from "./time"
+export { default as time } from "./time"
export { default as wallets } from "./wallets"
diff --git a/dapp/src/constants/tbtc.ts b/dapp/src/constants/tbtc.ts
index 5b5bcfdd4..5569aad1d 100644
--- a/dapp/src/constants/tbtc.ts
+++ b/dapp/src/constants/tbtc.ts
@@ -1,5 +1,5 @@
import { BitcoinNetwork } from "@acre-btc/sdk"
-import { BITCOIN_NETWORK } from "./chains"
+import chains from "./chains"
const NETWORK_TO_TBTC_DEPOSIT_BITCOIN_RECOVERY_ADDRESS: Record<
BitcoinNetwork,
@@ -10,7 +10,7 @@ const NETWORK_TO_TBTC_DEPOSIT_BITCOIN_RECOVERY_ADDRESS: Record<
}
const DEPOSIT_BITCOIN_RECOVERY_ADDRESS =
- NETWORK_TO_TBTC_DEPOSIT_BITCOIN_RECOVERY_ADDRESS[BITCOIN_NETWORK]
+ NETWORK_TO_TBTC_DEPOSIT_BITCOIN_RECOVERY_ADDRESS[chains.BITCOIN_NETWORK]
export default {
DEPOSIT_BITCOIN_RECOVERY_ADDRESS,
diff --git a/dapp/src/constants/time.ts b/dapp/src/constants/time.ts
index 15c538665..69d56c3e9 100644
--- a/dapp/src/constants/time.ts
+++ b/dapp/src/constants/time.ts
@@ -1,20 +1,36 @@
-export const ONE_SEC_IN_MILLISECONDS = 1000
-export const ONE_MINUTE_IN_SECONDS = 60
-export const ONE_HOUR_IN_SECONDS = ONE_MINUTE_IN_SECONDS * 60
-export const ONE_DAY_IN_SECONDS = ONE_HOUR_IN_SECONDS * 24
-export const ONE_WEEK_IN_SECONDS = ONE_DAY_IN_SECONDS * 7
-export const ONE_MONTH_IN_SECONDS = ONE_DAY_IN_SECONDS * 30
-export const ONE_YEAR_IN_SECONDS = ONE_DAY_IN_SECONDS * 365
+const ONE_SEC_IN_MILLISECONDS = 1000
+const ONE_MINUTE_IN_SECONDS = 60
+const ONE_HOUR_IN_SECONDS = ONE_MINUTE_IN_SECONDS * 60
+const ONE_DAY_IN_SECONDS = ONE_HOUR_IN_SECONDS * 24
+const ONE_WEEK_IN_SECONDS = ONE_DAY_IN_SECONDS * 7
+const ONE_MONTH_IN_SECONDS = ONE_DAY_IN_SECONDS * 30
+const ONE_YEAR_IN_SECONDS = ONE_DAY_IN_SECONDS * 365
-export const ONE_WEEK_IN_DAYS = 7
-export const ONE_MONTH_IN_DAYS = 30
-export const ONE_YEAR_IN_DAYS = 365
+const ONE_WEEK_IN_DAYS = 7
+const ONE_MONTH_IN_DAYS = 30
+const ONE_YEAR_IN_DAYS = 365
-export const REFETCH_INTERVAL_IN_MILLISECONDS =
+const REFETCH_INTERVAL_IN_MILLISECONDS =
ONE_SEC_IN_MILLISECONDS * ONE_MINUTE_IN_SECONDS * 5
-export const DATE_FORMAT_LOCALE_TAG = "us-US"
+const DATE_FORMAT_LOCALE_TAG = "us-US"
// 7 days
-export const ACRE_SESSION_EXPIRATION_TIME =
+const ACRE_SESSION_EXPIRATION_TIME =
ONE_WEEK_IN_SECONDS * ONE_SEC_IN_MILLISECONDS
+
+export default {
+ ONE_SEC_IN_MILLISECONDS,
+ ONE_MINUTE_IN_SECONDS,
+ ONE_HOUR_IN_SECONDS,
+ ONE_DAY_IN_SECONDS,
+ ONE_WEEK_IN_SECONDS,
+ ONE_MONTH_IN_SECONDS,
+ ONE_YEAR_IN_SECONDS,
+ ONE_WEEK_IN_DAYS,
+ ONE_MONTH_IN_DAYS,
+ ONE_YEAR_IN_DAYS,
+ REFETCH_INTERVAL_IN_MILLISECONDS,
+ DATE_FORMAT_LOCALE_TAG,
+ ACRE_SESSION_EXPIRATION_TIME,
+}
diff --git a/dapp/src/contexts/PaginationContext.ts b/dapp/src/contexts/PaginationContext.ts
index 170b4121f..472b3d862 100644
--- a/dapp/src/contexts/PaginationContext.ts
+++ b/dapp/src/contexts/PaginationContext.ts
@@ -8,5 +8,4 @@ type PaginationContextType = {
pageData: T[]
} | null
-export const PaginationContext =
- React.createContext(null)
+export default React.createContext(null)
diff --git a/dapp/src/contexts/index.tsx b/dapp/src/contexts/index.tsx
index e3f7fa1aa..c2b24da2a 100644
--- a/dapp/src/contexts/index.tsx
+++ b/dapp/src/contexts/index.tsx
@@ -1,3 +1,3 @@
export * from "./StakeFlowContext"
-export * from "./PaginationContext"
export * from "./WalletConnectionAlertContext"
+export { default as PaginationContext } from "./PaginationContext"
diff --git a/dapp/src/hooks/index.ts b/dapp/src/hooks/index.ts
index 03882703f..6db8be3b8 100644
--- a/dapp/src/hooks/index.ts
+++ b/dapp/src/hooks/index.ts
@@ -1,23 +1,23 @@
export * from "./store"
export * from "./sdk"
export * from "./orangeKit"
-export * from "./useDetectThemeMode"
-export * from "./useTransactionDetails"
-export * from "./useStakeFlowContext"
-export * from "./useInitApp"
-export * from "./useCurrencyConversion"
-export * from "./useFetchBTCPriceUSD"
-export * from "./useWallet"
-export * from "./useTimeout"
-export * from "./useCountdown"
-export * from "./router"
-export * from "./useTransactionFee"
-export * from "./usePagination"
-export * from "./useModal"
-export * from "./useTransactionModal"
-export * from "./useVerifyDepositAddress"
+export * from "./posthog"
+export { default as useDetectThemeMode } from "./useDetectThemeMode"
+export { default as useTransactionDetails } from "./useTransactionDetails"
+export { default as useStakeFlowContext } from "./useStakeFlowContext"
+export { default as useInitApp } from "./useInitApp"
+export { default as useCurrencyConversion } from "./useCurrencyConversion"
+export { default as useFetchBTCPriceUSD } from "./useFetchBTCPriceUSD"
+export { default as useWallet } from "./useWallet"
+export { default as useTimeout } from "./useTimeout"
+export { default as useCountdown } from "./useCountdown"
+export { default as useTransactionFee } from "./useTransactionFee"
+export { default as usePagination } from "./usePagination"
+export { default as useModal } from "./useModal"
+export { default as useTransactionModal } from "./useTransactionModal"
+export { default as useVerifyDepositAddress } from "./useVerifyDepositAddress"
export { default as useStatistics } from "./useStatistics"
-export * from "./useDisconnectWallet"
+export { default as useDisconnectWallet } from "./useDisconnectWallet"
export { default as useWalletConnectionAlert } from "./useWalletConnectionAlert"
export { default as useResetWalletState } from "./useResetWalletState"
export { default as useMobileMode } from "./useMobileMode"
@@ -39,3 +39,5 @@ export { default as useActivities } from "./useActivities"
export { default as useBitcoinBalance } from "./useBitcoinBalance"
export { default as useBitcoinPosition } from "./useBitcoinPosition"
export { default as useMats } from "./useMats"
+export { default as useDebounce } from "./useDebounce"
+export { default as useAppNavigate } from "./useAppNavigate"
diff --git a/dapp/src/hooks/orangeKit/index.ts b/dapp/src/hooks/orangeKit/index.ts
index dcc5160a5..b363eb007 100644
--- a/dapp/src/hooks/orangeKit/index.ts
+++ b/dapp/src/hooks/orangeKit/index.ts
@@ -1,6 +1,6 @@
-export * from "./useBitcoinProvider"
-export * from "./useConnector"
-export * from "./useConnectors"
-export * from "./useAccountsChangedUnisat"
-export * from "./useAccountsChangedOKX"
-export * from "./useAccountChangedOKX"
+export { default as useBitcoinProvider } from "./useBitcoinProvider"
+export { default as useConnector } from "./useConnector"
+export { default as useConnectors } from "./useConnectors"
+export { default as useAccountsChangedUnisat } from "./useAccountsChangedUnisat"
+export { default as useAccountsChangedOKX } from "./useAccountsChangedOKX"
+export { default as useAccountChangedOKX } from "./useAccountChangedOKX"
diff --git a/dapp/src/hooks/orangeKit/useAccountChangedOKX.ts b/dapp/src/hooks/orangeKit/useAccountChangedOKX.ts
index abaf49bc3..b02584f70 100644
--- a/dapp/src/hooks/orangeKit/useAccountChangedOKX.ts
+++ b/dapp/src/hooks/orangeKit/useAccountChangedOKX.ts
@@ -1,10 +1,10 @@
import { useEffect } from "react"
import { MODAL_TYPES } from "#/types"
import { featureFlags } from "#/constants"
-import { useWallet } from "../useWallet"
-import { useModal } from "../useModal"
+import useWallet from "../useWallet"
+import useModal from "../useModal"
-export function useAccountChangedOKX() {
+export default function useAccountChangedOKX() {
const { isConnected, address, onDisconnect } = useWallet()
const { openModal } = useModal()
diff --git a/dapp/src/hooks/orangeKit/useAccountsChangedOKX.ts b/dapp/src/hooks/orangeKit/useAccountsChangedOKX.ts
index 48ffcebe6..05b2f938d 100644
--- a/dapp/src/hooks/orangeKit/useAccountsChangedOKX.ts
+++ b/dapp/src/hooks/orangeKit/useAccountsChangedOKX.ts
@@ -1,8 +1,8 @@
import { useEffect } from "react"
import { featureFlags } from "#/constants"
-import { useWallet } from "../useWallet"
+import useWallet from "../useWallet"
-export function useAccountsChangedOKX() {
+export default function useAccountsChangedOKX() {
const { isConnected, onDisconnect } = useWallet()
useEffect(() => {
diff --git a/dapp/src/hooks/orangeKit/useAccountsChangedUnisat.ts b/dapp/src/hooks/orangeKit/useAccountsChangedUnisat.ts
index dda36353c..235975b76 100644
--- a/dapp/src/hooks/orangeKit/useAccountsChangedUnisat.ts
+++ b/dapp/src/hooks/orangeKit/useAccountsChangedUnisat.ts
@@ -1,9 +1,9 @@
import { useEffect } from "react"
import { MODAL_TYPES } from "#/types"
-import { useWallet } from "../useWallet"
-import { useModal } from "../useModal"
+import useWallet from "../useWallet"
+import useModal from "../useModal"
-export function useAccountsChangedUnisat() {
+export default function useAccountsChangedUnisat() {
const { isConnected, address, onDisconnect } = useWallet()
const { openModal } = useModal()
diff --git a/dapp/src/hooks/orangeKit/useBitcoinProvider.ts b/dapp/src/hooks/orangeKit/useBitcoinProvider.ts
index 34c413c45..f73d6010c 100644
--- a/dapp/src/hooks/orangeKit/useBitcoinProvider.ts
+++ b/dapp/src/hooks/orangeKit/useBitcoinProvider.ts
@@ -1,10 +1,10 @@
import { useMemo } from "react"
import { OrangeKitBitcoinWalletProvider } from "@orangekit/react/dist/src/wallet/bitcoin-wallet-provider"
-import { useConnector } from "./useConnector"
+import useConnector from "./useConnector"
type UseBitcoinProviderReturn = OrangeKitBitcoinWalletProvider | undefined
-export function useBitcoinProvider(): UseBitcoinProviderReturn {
+export default function useBitcoinProvider(): UseBitcoinProviderReturn {
const connector = useConnector()
return useMemo(() => {
diff --git a/dapp/src/hooks/orangeKit/useConnector.ts b/dapp/src/hooks/orangeKit/useConnector.ts
index b533ed648..2dba95174 100644
--- a/dapp/src/hooks/orangeKit/useConnector.ts
+++ b/dapp/src/hooks/orangeKit/useConnector.ts
@@ -5,7 +5,7 @@ import { OrangeKitConnector } from "#/types"
type UseConnectorReturn = OrangeKitConnector | undefined
-export function useConnector(): UseConnectorReturn {
+export default function useConnector(): UseConnectorReturn {
const { connector, status } = useAccount()
return useMemo(() => {
diff --git a/dapp/src/hooks/orangeKit/useConnectors.ts b/dapp/src/hooks/orangeKit/useConnectors.ts
index 42354638f..eb21f39f0 100644
--- a/dapp/src/hooks/orangeKit/useConnectors.ts
+++ b/dapp/src/hooks/orangeKit/useConnectors.ts
@@ -4,7 +4,7 @@ import { useConnectors as useWagmiConnectors } from "wagmi"
const { isOrangeKitConnector, typeConversionToOrangeKitConnector } = orangeKit
-export function useConnectors() {
+export default function useConnectors() {
const connectors = useWagmiConnectors()
return connectors.reduce((acc, connector) => {
diff --git a/dapp/src/hooks/posthog/index.ts b/dapp/src/hooks/posthog/index.ts
index 1b0317599..bfd928c64 100644
--- a/dapp/src/hooks/posthog/index.ts
+++ b/dapp/src/hooks/posthog/index.ts
@@ -1,3 +1,3 @@
-export * from "./usePostHogIdentity"
-export * from "./usePostHogCapture"
-export * from "./usePostHogPageViewCapture"
+export { default as usePostHogIdentity } from "./usePostHogIdentity"
+export { default as usePostHogCapture } from "./usePostHogCapture"
+export { default as usePostHogPageViewCapture } from "./usePostHogPageViewCapture"
diff --git a/dapp/src/hooks/posthog/usePostHogCapture.ts b/dapp/src/hooks/posthog/usePostHogCapture.ts
index d789691cf..d8b6c503b 100644
--- a/dapp/src/hooks/posthog/usePostHogCapture.ts
+++ b/dapp/src/hooks/posthog/usePostHogCapture.ts
@@ -1,4 +1,4 @@
-import { PostHogEvent } from "#/posthog/events"
+import PostHogEvent from "#/posthog/events"
import { PostHog, usePostHog } from "posthog-js/react"
import { useCallback } from "react"
@@ -9,7 +9,7 @@ type CaptureArgs = [
: never,
]
-export const usePostHogCapture = () => {
+const usePostHogCapture = () => {
const posthog = usePostHog()
const handleCapture = useCallback(
@@ -38,3 +38,5 @@ export const usePostHogCapture = () => {
return { handleCapture, handleCaptureWithCause }
}
+
+export default usePostHogCapture
diff --git a/dapp/src/hooks/posthog/usePostHogIdentity.ts b/dapp/src/hooks/posthog/usePostHogIdentity.ts
index d4d977d21..64a76b2ae 100644
--- a/dapp/src/hooks/posthog/usePostHogIdentity.ts
+++ b/dapp/src/hooks/posthog/usePostHogIdentity.ts
@@ -4,7 +4,7 @@ import { sha256, toUtf8Bytes } from "ethers"
type IdentifyArgs = Parameters
-export const usePostHogIdentity = () => {
+const usePostHogIdentity = () => {
const posthog = usePostHog()
const handleIdentification = useCallback(
@@ -25,3 +25,5 @@ export const usePostHogIdentity = () => {
return { handleIdentification, resetIdentity }
}
+
+export default usePostHogIdentity
diff --git a/dapp/src/hooks/posthog/usePostHogPageViewCapture.ts b/dapp/src/hooks/posthog/usePostHogPageViewCapture.ts
index f1cae87e1..8cfb7df34 100644
--- a/dapp/src/hooks/posthog/usePostHogPageViewCapture.ts
+++ b/dapp/src/hooks/posthog/usePostHogPageViewCapture.ts
@@ -1,9 +1,9 @@
-import { PostHogEvent } from "#/posthog/events"
+import PostHogEvent from "#/posthog/events"
import { useEffect } from "react"
import { useLocation } from "react-router-dom"
-import { usePostHogCapture } from "./usePostHogCapture"
+import usePostHogCapture from "./usePostHogCapture"
-export const usePostHogPageViewCapture = () => {
+const usePostHogPageViewCapture = () => {
const { handleCapture } = usePostHogCapture()
const location = useLocation()
@@ -13,3 +13,5 @@ export const usePostHogPageViewCapture = () => {
return handleCapture
}
+
+export default usePostHogPageViewCapture
diff --git a/dapp/src/hooks/router/index.ts b/dapp/src/hooks/router/index.ts
deleted file mode 100644
index c8edda5c3..000000000
--- a/dapp/src/hooks/router/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { default as useAppNavigate } from "./useAppNavigate"
diff --git a/dapp/src/hooks/sdk/index.ts b/dapp/src/hooks/sdk/index.ts
index dca3d2ffa..bd9833ae7 100644
--- a/dapp/src/hooks/sdk/index.ts
+++ b/dapp/src/hooks/sdk/index.ts
@@ -1,4 +1,4 @@
-export * from "./useInitializeAcreSdk"
-export * from "./useFetchMinDepositAmount"
-export * from "./useInitDataFromSdk"
-export * from "./useMinWithdrawAmount"
+export { default as useInitializeAcreSdk } from "./useInitializeAcreSdk"
+export { default as useFetchMinDepositAmount } from "./useFetchMinDepositAmount"
+export { default as useInitDataFromSdk } from "./useInitDataFromSdk"
+export { default as useMinWithdrawAmount } from "./useMinWithdrawAmount"
diff --git a/dapp/src/hooks/sdk/useFetchMinDepositAmount.ts b/dapp/src/hooks/sdk/useFetchMinDepositAmount.ts
index 825e3c6a7..3caf90cc6 100644
--- a/dapp/src/hooks/sdk/useFetchMinDepositAmount.ts
+++ b/dapp/src/hooks/sdk/useFetchMinDepositAmount.ts
@@ -2,9 +2,9 @@ import { useEffect } from "react"
import { setMinDepositAmount } from "#/store/btc"
import { logPromiseFailure } from "#/utils"
import { useAcreContext } from "#/acre-react/hooks"
-import { useAppDispatch } from "../store/useAppDispatch"
+import useAppDispatch from "../store/useAppDispatch"
-export function useFetchMinDepositAmount() {
+export default function useFetchMinDepositAmount() {
const { acre, isInitialized } = useAcreContext()
const dispatch = useAppDispatch()
diff --git a/dapp/src/hooks/sdk/useInitDataFromSdk.ts b/dapp/src/hooks/sdk/useInitDataFromSdk.ts
index f912be723..0cea2e20b 100644
--- a/dapp/src/hooks/sdk/useInitDataFromSdk.ts
+++ b/dapp/src/hooks/sdk/useInitDataFromSdk.ts
@@ -1,5 +1,5 @@
-import { useFetchMinDepositAmount } from "./useFetchMinDepositAmount"
+import useFetchMinDepositAmount from "./useFetchMinDepositAmount"
-export function useInitDataFromSdk() {
+export default function useInitDataFromSdk() {
useFetchMinDepositAmount()
}
diff --git a/dapp/src/hooks/sdk/useInitializeAcreSdk.ts b/dapp/src/hooks/sdk/useInitializeAcreSdk.ts
index 05cd359b8..ff6df10ad 100644
--- a/dapp/src/hooks/sdk/useInitializeAcreSdk.ts
+++ b/dapp/src/hooks/sdk/useInitializeAcreSdk.ts
@@ -2,10 +2,10 @@ import { useEffect } from "react"
import { logPromiseFailure } from "#/utils"
import { useAcreContext } from "#/acre-react/hooks"
import { AcreBitcoinProvider } from "@acre-btc/sdk"
-import { useBitcoinProvider } from "../orangeKit/useBitcoinProvider"
-import { useWallet } from "../useWallet"
+import useBitcoinProvider from "../orangeKit/useBitcoinProvider"
+import useWallet from "../useWallet"
-export function useInitializeAcreSdk() {
+export default function useInitializeAcreSdk() {
const { init } = useAcreContext()
const bitcoinProvider = useBitcoinProvider()
const { address } = useWallet()
diff --git a/dapp/src/hooks/sdk/useMinWithdrawAmount.ts b/dapp/src/hooks/sdk/useMinWithdrawAmount.ts
index b1f4a045c..7832ba021 100644
--- a/dapp/src/hooks/sdk/useMinWithdrawAmount.ts
+++ b/dapp/src/hooks/sdk/useMinWithdrawAmount.ts
@@ -1,4 +1,4 @@
-export function useMinWithdrawAmount() {
+export default function useMinWithdrawAmount() {
// TODO: Fetch this amount from SDK.
return 1000000n // 0.01 BTC
}
diff --git a/dapp/src/hooks/sentry/index.ts b/dapp/src/hooks/sentry/index.ts
deleted file mode 100644
index 20f65be38..000000000
--- a/dapp/src/hooks/sentry/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./useSentry"
diff --git a/dapp/src/hooks/store/index.ts b/dapp/src/hooks/store/index.ts
index b88527385..a42496708 100644
--- a/dapp/src/hooks/store/index.ts
+++ b/dapp/src/hooks/store/index.ts
@@ -1,11 +1,11 @@
-export * from "./useAppDispatch"
-export * from "./useAppSelector"
-export * from "./useMinDepositAmount"
-export * from "./useActionFlowType"
-export * from "./useActionFlowStatus"
-export * from "./useActionFlowActiveStep"
-export * from "./useActionFlowTokenAmount"
-export * from "./useActionFlowTxHash"
-export * from "./useActionFlowPause"
-export * from "./useIsSignedMessage"
+export { default as useAppDispatch } from "./useAppDispatch"
+export { default as useAppSelector } from "./useAppSelector"
+export { default as useMinDepositAmount } from "./useMinDepositAmount"
+export { default as useActionFlowType } from "./useActionFlowType"
+export { default as useActionFlowStatus } from "./useActionFlowStatus"
+export { default as useActionFlowActiveStep } from "./useActionFlowActiveStep"
+export { default as useActionFlowTokenAmount } from "./useActionFlowTokenAmount"
+export { default as useActionFlowTxHash } from "./useActionFlowTxHash"
+export { default as useActionFlowPause } from "./useActionFlowPause"
+export { default as useIsSignedMessage } from "./useIsSignedMessage"
export { default as useWalletAddress } from "./useWalletAddress"
diff --git a/dapp/src/hooks/store/useActionFlowActiveStep.ts b/dapp/src/hooks/store/useActionFlowActiveStep.ts
index f59e88bf4..3c74c9880 100644
--- a/dapp/src/hooks/store/useActionFlowActiveStep.ts
+++ b/dapp/src/hooks/store/useActionFlowActiveStep.ts
@@ -1,6 +1,6 @@
import { selectActionFlowActiveStep } from "#/store/action-flow"
-import { useAppSelector } from "./useAppSelector"
+import useAppSelector from "./useAppSelector"
-export function useActionFlowActiveStep() {
+export default function useActionFlowActiveStep() {
return useAppSelector(selectActionFlowActiveStep)
}
diff --git a/dapp/src/hooks/store/useActionFlowPause.ts b/dapp/src/hooks/store/useActionFlowPause.ts
index 7bb907d88..fd88fe5b0 100644
--- a/dapp/src/hooks/store/useActionFlowPause.ts
+++ b/dapp/src/hooks/store/useActionFlowPause.ts
@@ -1,12 +1,12 @@
import { setStatus } from "#/store/action-flow"
import { PROCESS_STATUSES } from "#/types"
-import { useAppDispatch } from "./useAppDispatch"
+import useAppDispatch from "./useAppDispatch"
/**
* Custom hook that provides functions to pause and resume the action flow process.
* @returns An object containing the `handlePause` and `handleResume` functions.
*/
-export function useActionFlowPause() {
+export default function useActionFlowPause() {
const dispatch = useAppDispatch()
/**
diff --git a/dapp/src/hooks/store/useActionFlowStatus.ts b/dapp/src/hooks/store/useActionFlowStatus.ts
index 5fb18915d..2c4030b3c 100644
--- a/dapp/src/hooks/store/useActionFlowStatus.ts
+++ b/dapp/src/hooks/store/useActionFlowStatus.ts
@@ -1,6 +1,6 @@
import { selectActionFlowStatus } from "#/store/action-flow"
-import { useAppSelector } from "./useAppSelector"
+import useAppSelector from "./useAppSelector"
-export function useActionFlowStatus() {
+export default function useActionFlowStatus() {
return useAppSelector(selectActionFlowStatus)
}
diff --git a/dapp/src/hooks/store/useActionFlowTokenAmount.ts b/dapp/src/hooks/store/useActionFlowTokenAmount.ts
index f580df058..02ffe10f1 100644
--- a/dapp/src/hooks/store/useActionFlowTokenAmount.ts
+++ b/dapp/src/hooks/store/useActionFlowTokenAmount.ts
@@ -1,6 +1,6 @@
import { selectActionFlowTokenAmount } from "#/store/action-flow"
-import { useAppSelector } from "./useAppSelector"
+import useAppSelector from "./useAppSelector"
-export function useActionFlowTokenAmount() {
+export default function useActionFlowTokenAmount() {
return useAppSelector(selectActionFlowTokenAmount)
}
diff --git a/dapp/src/hooks/store/useActionFlowTxHash.ts b/dapp/src/hooks/store/useActionFlowTxHash.ts
index 0dce7063e..b061a4628 100644
--- a/dapp/src/hooks/store/useActionFlowTxHash.ts
+++ b/dapp/src/hooks/store/useActionFlowTxHash.ts
@@ -1,6 +1,6 @@
import { selectActionFlowTxHash } from "#/store/action-flow"
-import { useAppSelector } from "./useAppSelector"
+import useAppSelector from "./useAppSelector"
-export function useActionFlowTxHash() {
+export default function useActionFlowTxHash() {
return useAppSelector(selectActionFlowTxHash)
}
diff --git a/dapp/src/hooks/store/useActionFlowType.ts b/dapp/src/hooks/store/useActionFlowType.ts
index c2b0d3c65..1942f1cb7 100644
--- a/dapp/src/hooks/store/useActionFlowType.ts
+++ b/dapp/src/hooks/store/useActionFlowType.ts
@@ -1,6 +1,6 @@
import { selectActionFlowType } from "#/store/action-flow"
-import { useAppSelector } from "./useAppSelector"
+import useAppSelector from "./useAppSelector"
-export function useActionFlowType() {
+export default function useActionFlowType() {
return useAppSelector(selectActionFlowType)
}
diff --git a/dapp/src/hooks/store/useAppDispatch.ts b/dapp/src/hooks/store/useAppDispatch.ts
index ef697bd15..3d47f6334 100644
--- a/dapp/src/hooks/store/useAppDispatch.ts
+++ b/dapp/src/hooks/store/useAppDispatch.ts
@@ -1,4 +1,4 @@
import { useDispatch } from "react-redux"
import { AppDispatch } from "#/store"
-export const useAppDispatch = useDispatch.withTypes()
+export default useDispatch.withTypes()
diff --git a/dapp/src/hooks/store/useAppSelector.ts b/dapp/src/hooks/store/useAppSelector.ts
index 9cbdbbe9f..172d2a36a 100644
--- a/dapp/src/hooks/store/useAppSelector.ts
+++ b/dapp/src/hooks/store/useAppSelector.ts
@@ -1,4 +1,4 @@
import { useSelector } from "react-redux"
import { RootState } from "#/store"
-export const useAppSelector = useSelector.withTypes()
+export default useSelector.withTypes()
diff --git a/dapp/src/hooks/store/useIsSignedMessage.ts b/dapp/src/hooks/store/useIsSignedMessage.ts
index 79a6a6aa1..9c088643f 100644
--- a/dapp/src/hooks/store/useIsSignedMessage.ts
+++ b/dapp/src/hooks/store/useIsSignedMessage.ts
@@ -1,6 +1,6 @@
import { selectIsSignedMessage } from "#/store/wallet"
-import { useAppSelector } from "./useAppSelector"
+import useAppSelector from "./useAppSelector"
-export function useIsSignedMessage() {
+export default function useIsSignedMessage() {
return useAppSelector(selectIsSignedMessage)
}
diff --git a/dapp/src/hooks/store/useMinDepositAmount.ts b/dapp/src/hooks/store/useMinDepositAmount.ts
index 082a0a68a..157d99f15 100644
--- a/dapp/src/hooks/store/useMinDepositAmount.ts
+++ b/dapp/src/hooks/store/useMinDepositAmount.ts
@@ -1,6 +1,6 @@
import { selectMinDepositAmount } from "#/store/btc"
-import { useAppSelector } from "./useAppSelector"
+import useAppSelector from "./useAppSelector"
-export function useMinDepositAmount() {
+export default function useMinDepositAmount() {
return useAppSelector(selectMinDepositAmount)
}
diff --git a/dapp/src/hooks/store/useWalletAddress.ts b/dapp/src/hooks/store/useWalletAddress.ts
index 424d4cd8f..9e6e38792 100644
--- a/dapp/src/hooks/store/useWalletAddress.ts
+++ b/dapp/src/hooks/store/useWalletAddress.ts
@@ -1,5 +1,5 @@
import { selectWalletAddress } from "#/store/wallet"
-import { useAppSelector } from "./useAppSelector"
+import useAppSelector from "./useAppSelector"
export default function useWalletAddress() {
return useAppSelector(selectWalletAddress)
diff --git a/dapp/src/hooks/useAcrePointsData.ts b/dapp/src/hooks/useAcrePointsData.ts
index f46474a27..13ef8abe4 100644
--- a/dapp/src/hooks/useAcrePointsData.ts
+++ b/dapp/src/hooks/useAcrePointsData.ts
@@ -1,4 +1,4 @@
-import { queryKeysFactory, REFETCH_INTERVAL_IN_MILLISECONDS } from "#/constants"
+import { queryKeysFactory, time } from "#/constants"
import { useQuery } from "@tanstack/react-query"
import { acreApi } from "#/utils"
@@ -8,6 +8,6 @@ export default function useAcrePointsData() {
return useQuery({
queryKey: [...acreKeys.pointsData()],
queryFn: async () => acreApi.getPointsData(),
- refetchInterval: REFETCH_INTERVAL_IN_MILLISECONDS,
+ refetchInterval: time.REFETCH_INTERVAL_IN_MILLISECONDS,
})
}
diff --git a/dapp/src/hooks/useActivities.ts b/dapp/src/hooks/useActivities.ts
index adeb004fe..fb5e4d210 100644
--- a/dapp/src/hooks/useActivities.ts
+++ b/dapp/src/hooks/useActivities.ts
@@ -1,10 +1,10 @@
-import { queryKeysFactory, REFETCH_INTERVAL_IN_MILLISECONDS } from "#/constants"
+import { queryKeysFactory, time } from "#/constants"
import { useQuery } from "@tanstack/react-query"
import { Activity } from "#/types"
import { DepositStatus } from "@acre-btc/sdk"
import { useAcreContext } from "#/acre-react/hooks"
-import { sortActivitiesByTimestamp } from "#/utils"
-import { useWallet } from "./useWallet"
+import { activitiesUtils } from "#/utils"
+import useWallet from "./useWallet"
const { userKeys } = queryKeysFactory
@@ -41,8 +41,11 @@ export default function useActivities() {
}
},
)
- return sortActivitiesByTimestamp([...deposits, ...withdrawals])
+ return activitiesUtils.sortActivitiesByTimestamp([
+ ...deposits,
+ ...withdrawals,
+ ])
},
- refetchInterval: REFETCH_INTERVAL_IN_MILLISECONDS,
+ refetchInterval: time.REFETCH_INTERVAL_IN_MILLISECONDS,
})
}
diff --git a/dapp/src/hooks/useAggregatedAcrePointsData.ts b/dapp/src/hooks/useAggregatedAcrePointsData.ts
index 3e7309a31..453a30666 100644
--- a/dapp/src/hooks/useAggregatedAcrePointsData.ts
+++ b/dapp/src/hooks/useAggregatedAcrePointsData.ts
@@ -1,10 +1,10 @@
import { useMutation } from "@tanstack/react-query"
import { acreApi } from "#/utils"
import { MODAL_TYPES } from "#/types"
-import { PostHogEvent } from "#/posthog/events"
-import { useWallet } from "./useWallet"
-import { useModal } from "./useModal"
-import { usePostHogCapture } from "./posthog/usePostHogCapture"
+import PostHogEvent from "#/posthog/events"
+import useWallet from "./useWallet"
+import useModal from "./useModal"
+import usePostHogCapture from "./posthog/usePostHogCapture"
import useUserPointsData from "./useUserPointsData"
import useAcrePointsData from "./useAcrePointsData"
diff --git a/dapp/src/hooks/router/useAppNavigate.ts b/dapp/src/hooks/useAppNavigate.ts
similarity index 100%
rename from dapp/src/hooks/router/useAppNavigate.ts
rename to dapp/src/hooks/useAppNavigate.ts
diff --git a/dapp/src/hooks/useBitcoinBalance.ts b/dapp/src/hooks/useBitcoinBalance.ts
index d3f17aee6..07ae8c522 100644
--- a/dapp/src/hooks/useBitcoinBalance.ts
+++ b/dapp/src/hooks/useBitcoinBalance.ts
@@ -1,7 +1,7 @@
import { useQuery } from "@tanstack/react-query"
-import { REFETCH_INTERVAL_IN_MILLISECONDS, queryKeysFactory } from "#/constants"
+import { time, queryKeysFactory } from "#/constants"
import useWalletAddress from "./store/useWalletAddress"
-import { useBitcoinProvider } from "./orangeKit/useBitcoinProvider"
+import useBitcoinProvider from "./orangeKit/useBitcoinProvider"
const { userKeys } = queryKeysFactory
@@ -18,6 +18,6 @@ export default function useBitcoinBalance() {
const { total } = await provider.getBalance()
return BigInt(total)
},
- refetchInterval: REFETCH_INTERVAL_IN_MILLISECONDS,
+ refetchInterval: time.REFETCH_INTERVAL_IN_MILLISECONDS,
})
}
diff --git a/dapp/src/hooks/useBitcoinPosition.ts b/dapp/src/hooks/useBitcoinPosition.ts
index 8f208b958..f7bc409ab 100644
--- a/dapp/src/hooks/useBitcoinPosition.ts
+++ b/dapp/src/hooks/useBitcoinPosition.ts
@@ -1,7 +1,7 @@
import { useAcreContext } from "#/acre-react/hooks"
import { useQuery } from "@tanstack/react-query"
-import { REFETCH_INTERVAL_IN_MILLISECONDS, queryKeysFactory } from "#/constants"
-import { useWallet } from "./useWallet"
+import { time, queryKeysFactory } from "#/constants"
+import useWallet from "./useWallet"
const { userKeys } = queryKeysFactory
@@ -22,6 +22,6 @@ export default function useBitcoinPosition() {
return { sharesBalance, estimatedBitcoinBalance }
},
- refetchInterval: REFETCH_INTERVAL_IN_MILLISECONDS,
+ refetchInterval: time.REFETCH_INTERVAL_IN_MILLISECONDS,
})
}
diff --git a/dapp/src/hooks/useBitcoinRecoveryAddress.ts b/dapp/src/hooks/useBitcoinRecoveryAddress.ts
index 5eb56deea..cf978310e 100644
--- a/dapp/src/hooks/useBitcoinRecoveryAddress.ts
+++ b/dapp/src/hooks/useBitcoinRecoveryAddress.ts
@@ -1,7 +1,7 @@
-import { BITCOIN_NETWORK, tbtc } from "#/constants"
+import { chains, tbtc } from "#/constants"
import { isPublicKeyHashTypeAddress } from "@acre-btc/sdk"
import { useMemo } from "react"
-import { useWallet } from "./useWallet"
+import useWallet from "./useWallet"
export default function useBitcoinRecoveryAddress() {
const { address } = useWallet()
@@ -14,7 +14,7 @@ export default function useBitcoinRecoveryAddress() {
// but only P2PKH or P2WPKH address can be used as recovery address in tBTC v2.
// So we are going to use default bitcoin address that should be used when user is connected
// to other Bitcoin address type than supported by tBTC v2 network.
- if (!isPublicKeyHashTypeAddress(recoveryAddress, BITCOIN_NETWORK)) {
+ if (!isPublicKeyHashTypeAddress(recoveryAddress, chains.BITCOIN_NETWORK)) {
recoveryAddress = tbtc.DEPOSIT_BITCOIN_RECOVERY_ADDRESS
}
diff --git a/dapp/src/hooks/useCountdown.ts b/dapp/src/hooks/useCountdown.ts
index 69a9c91a2..16bc02e1a 100644
--- a/dapp/src/hooks/useCountdown.ts
+++ b/dapp/src/hooks/useCountdown.ts
@@ -1,11 +1,7 @@
import { useState, useEffect } from "react"
import { TimeUnits } from "#/types"
-import { ONE_SEC_IN_MILLISECONDS } from "#/constants"
-import {
- dateToUnixTimestamp,
- unixTimestampToTimeUnits,
- addLeadingZero,
-} from "#/utils"
+import { time } from "#/constants"
+import { timeUtils, numbersUtils } from "#/utils"
/**
* It was decided to use an already implemented hook used by Threshold Network.
@@ -15,16 +11,18 @@ import {
* Source:
* https://github.com/threshold-network/components/blob/main/src/hooks/useCountdown.ts
*/
-export const useCountdown = (
+const useCountdown = (
targetDateInUnix: number,
addLeadingZeroes?: boolean,
onComplete?: (targetDateInUnix: number) => void,
): TimeUnits => {
- const [diff, setDiff] = useState(targetDateInUnix - dateToUnixTimestamp())
+ const [diff, setDiff] = useState(
+ targetDateInUnix - timeUtils.dateToUnixTimestamp(),
+ )
useEffect(() => {
const countdownInterval = setInterval(() => {
- const newDiff = targetDateInUnix - dateToUnixTimestamp()
+ const newDiff = targetDateInUnix - timeUtils.dateToUnixTimestamp()
if (newDiff === 0) {
if (onComplete) {
onComplete(targetDateInUnix)
@@ -33,18 +31,19 @@ export const useCountdown = (
}
setDiff(newDiff)
- }, ONE_SEC_IN_MILLISECONDS)
+ }, time.ONE_SEC_IN_MILLISECONDS)
return () => clearInterval(countdownInterval)
}, [targetDateInUnix, onComplete])
- let { days, hours, minutes, seconds } = unixTimestampToTimeUnits(diff)
+ let { days, hours, minutes, seconds } =
+ timeUtils.unixTimestampToTimeUnits(diff)
if (addLeadingZeroes) {
- days = addLeadingZero(Number(days))
- hours = addLeadingZero(Number(hours))
- minutes = addLeadingZero(Number(minutes))
- seconds = addLeadingZero(Number(seconds))
+ days = numbersUtils.addLeadingZero(Number(days))
+ hours = numbersUtils.addLeadingZero(Number(hours))
+ minutes = numbersUtils.addLeadingZero(Number(minutes))
+ seconds = numbersUtils.addLeadingZero(Number(seconds))
}
return {
@@ -54,3 +53,5 @@ export const useCountdown = (
seconds,
}
}
+
+export default useCountdown
diff --git a/dapp/src/hooks/useCurrencyConversion.ts b/dapp/src/hooks/useCurrencyConversion.ts
index 5003b0dce..09b509a4f 100644
--- a/dapp/src/hooks/useCurrencyConversion.ts
+++ b/dapp/src/hooks/useCurrencyConversion.ts
@@ -1,6 +1,6 @@
-import { CURRENCIES_BY_TYPE } from "#/constants"
+import { currencies } from "#/constants"
import { selectBtcUsdPrice } from "#/store/btc"
-import { bigIntToUserAmount } from "#/utils"
+import { numbersUtils } from "#/utils"
import { CurrencyType } from "#/types"
import { useMemo } from "react"
import { useAppSelector } from "./store"
@@ -16,7 +16,7 @@ const isBtcUsdConversion = (
to: CurrencyConversionType,
): boolean => from.currency === "bitcoin" && to.currency === "usd"
-export function useCurrencyConversion({
+export default function useCurrencyConversion({
from,
to,
}: {
@@ -31,9 +31,12 @@ export function useCurrencyConversion({
if (from.amount === undefined || !price) return undefined
const { amount, currency } = from
- const { decimals } = CURRENCIES_BY_TYPE[currency]
+ const { decimals } = currencies.CURRENCIES_BY_TYPE[currency]
- return bigIntToUserAmount(BigInt(amount), decimals, decimals - 1) * price
+ return (
+ numbersUtils.bigIntToUserAmount(BigInt(amount), decimals, decimals - 1) *
+ price
+ )
}, [from, price])
return conversionAmount
diff --git a/dapp/src/hooks/useDepositBTCTransaction.ts b/dapp/src/hooks/useDepositBTCTransaction.ts
index e56f20828..8d85394f2 100644
--- a/dapp/src/hooks/useDepositBTCTransaction.ts
+++ b/dapp/src/hooks/useDepositBTCTransaction.ts
@@ -1,6 +1,6 @@
import { useMutation, UseMutationOptions } from "@tanstack/react-query"
import { useConnector } from "./orangeKit"
-import { useWallet } from "./useWallet"
+import useWallet from "./useWallet"
type MutationFnParams = {
recipient: string
diff --git a/dapp/src/hooks/useDetectThemeMode.ts b/dapp/src/hooks/useDetectThemeMode.ts
index 7e11a51c9..2bf80f9cf 100644
--- a/dapp/src/hooks/useDetectThemeMode.ts
+++ b/dapp/src/hooks/useDetectThemeMode.ts
@@ -3,7 +3,7 @@ import { useColorMode } from "@chakra-ui/react"
import { router } from "#/utils"
import { SEARCH_PARAMS_NAMES } from "#/router/path"
-export function useDetectThemeMode(): string | null {
+export default function useDetectThemeMode(): string | null {
const { colorMode, toggleColorMode } = useColorMode()
// The ledger live passes the theme mode via url.
// Let's detect the theme set by the user and toggle the color mode
diff --git a/dapp/src/hooks/useDisconnectWallet.ts b/dapp/src/hooks/useDisconnectWallet.ts
index b90a7b43b..0729a0603 100644
--- a/dapp/src/hooks/useDisconnectWallet.ts
+++ b/dapp/src/hooks/useDisconnectWallet.ts
@@ -1,9 +1,9 @@
import { useEffect } from "react"
-import { useIsSignedMessage } from "./store/useIsSignedMessage"
-import { useWallet } from "./useWallet"
-import { useModal } from "./useModal"
+import useIsSignedMessage from "./store/useIsSignedMessage"
+import useWallet from "./useWallet"
+import useModal from "./useModal"
-export function useDisconnectWallet() {
+export default function useDisconnectWallet() {
const isSignedMessage = useIsSignedMessage()
const { isConnected, onDisconnect } = useWallet()
const { modalType } = useModal()
diff --git a/dapp/src/hooks/useFetchBTCPriceUSD.ts b/dapp/src/hooks/useFetchBTCPriceUSD.ts
index 0bce617ca..71d275d26 100644
--- a/dapp/src/hooks/useFetchBTCPriceUSD.ts
+++ b/dapp/src/hooks/useFetchBTCPriceUSD.ts
@@ -3,7 +3,7 @@ import { fetchBTCPriceUSD } from "#/store/btc"
import { logPromiseFailure } from "#/utils"
import { useAppDispatch } from "./store"
-export function useFetchBTCPriceUSD() {
+export default function useFetchBTCPriceUSD() {
const dispatch = useAppDispatch()
useEffect(() => {
diff --git a/dapp/src/hooks/useInitApp.ts b/dapp/src/hooks/useInitApp.ts
index caf792595..bb0eb61e3 100644
--- a/dapp/src/hooks/useInitApp.ts
+++ b/dapp/src/hooks/useInitApp.ts
@@ -1,13 +1,13 @@
-import { useAccountChangedOKX } from "./orangeKit/useAccountChangedOKX"
-import { useAccountsChangedUnisat } from "./orangeKit/useAccountsChangedUnisat"
-import { useAccountsChangedOKX } from "./orangeKit/useAccountsChangedOKX"
+import useAccountChangedOKX from "./orangeKit/useAccountChangedOKX"
+import useAccountsChangedUnisat from "./orangeKit/useAccountsChangedUnisat"
+import useAccountsChangedOKX from "./orangeKit/useAccountsChangedOKX"
import { useInitDataFromSdk, useInitializeAcreSdk } from "./sdk"
-import { useSentry } from "./sentry"
import useDetectEmbed from "./useDetectEmbed"
-import { useDisconnectWallet } from "./useDisconnectWallet"
-import { useFetchBTCPriceUSD } from "./useFetchBTCPriceUSD"
+import useFetchBTCPriceUSD from "./useFetchBTCPriceUSD"
+import useDisconnectWallet from "./useDisconnectWallet"
+import useSentry from "./useSentry"
-export function useInitApp() {
+export default function useInitApp() {
// TODO: Let's uncomment when dark mode is ready
// useDetectThemeMode()
useSentry()
diff --git a/dapp/src/hooks/useMats.ts b/dapp/src/hooks/useMats.ts
index fe62d63f2..be479bab9 100644
--- a/dapp/src/hooks/useMats.ts
+++ b/dapp/src/hooks/useMats.ts
@@ -1,5 +1,5 @@
import { useQuery } from "@tanstack/react-query"
-import { REFETCH_INTERVAL_IN_MILLISECONDS, queryKeysFactory } from "#/constants"
+import { time, queryKeysFactory } from "#/constants"
import { acreApi } from "#/utils"
const { acreKeys } = queryKeysFactory
@@ -8,6 +8,6 @@ export default function useMats() {
return useQuery({
queryKey: [...acreKeys.mats()],
queryFn: async () => acreApi.getMats(),
- refetchInterval: REFETCH_INTERVAL_IN_MILLISECONDS,
+ refetchInterval: time.REFETCH_INTERVAL_IN_MILLISECONDS,
})
}
diff --git a/dapp/src/hooks/useModal.ts b/dapp/src/hooks/useModal.ts
index 67758bf30..55758dd1e 100644
--- a/dapp/src/hooks/useModal.ts
+++ b/dapp/src/hooks/useModal.ts
@@ -7,10 +7,10 @@ import {
} from "#/store/modal"
import { ModalProps, ModalType } from "#/types"
import { useCallback } from "react"
-import { useAppDispatch } from "./store/useAppDispatch"
-import { useAppSelector } from "./store/useAppSelector"
+import useAppDispatch from "./store/useAppDispatch"
+import useAppSelector from "./store/useAppSelector"
-export function useModal() {
+export default function useModal() {
const modalType = useAppSelector(selectModalType)
const modalProps = useAppSelector(selectModalProps)
const isOpenGlobalErrorModal = useAppSelector(selectIsOpenGlobalErrorModal)
diff --git a/dapp/src/hooks/usePagination.ts b/dapp/src/hooks/usePagination.ts
index 83f646fba..2b944d5c7 100644
--- a/dapp/src/hooks/usePagination.ts
+++ b/dapp/src/hooks/usePagination.ts
@@ -1,10 +1,12 @@
import React from "react"
import { PaginationContext } from "#/contexts"
-export const usePagination = () => {
+const usePagination = () => {
const context = React.useContext(PaginationContext)
if (!context) {
throw new Error("usePagination must be used within a PaginationProvider")
}
return context
}
+
+export default usePagination
diff --git a/dapp/src/hooks/useResetWalletState.ts b/dapp/src/hooks/useResetWalletState.ts
index 28d72030d..912f6d627 100644
--- a/dapp/src/hooks/useResetWalletState.ts
+++ b/dapp/src/hooks/useResetWalletState.ts
@@ -3,7 +3,7 @@ import { useCallback } from "react"
import { resetState } from "#/store/wallet"
import { queryKeysFactory } from "#/constants"
import { logPromiseFailure } from "#/utils"
-import { useAppDispatch } from "./store/useAppDispatch"
+import useAppDispatch from "./store/useAppDispatch"
const { userKeys } = queryKeysFactory
diff --git a/dapp/src/hooks/sentry/useSentry.ts b/dapp/src/hooks/useSentry.ts
similarity index 79%
rename from dapp/src/hooks/sentry/useSentry.ts
rename to dapp/src/hooks/useSentry.ts
index 06facd4c0..240f6d5c8 100644
--- a/dapp/src/hooks/sentry/useSentry.ts
+++ b/dapp/src/hooks/useSentry.ts
@@ -2,10 +2,12 @@ import { env } from "#/constants"
import sentry from "#/sentry"
import { useEffect } from "react"
-export const useSentry = () => {
+const useSentry = () => {
useEffect(() => {
if (env.SENTRY_SUPPORT) {
sentry.initialize(env.SENTRY_DSN)
}
}, [])
}
+
+export default useSentry
diff --git a/dapp/src/hooks/useStakeFlowContext.ts b/dapp/src/hooks/useStakeFlowContext.ts
index 51f3824fc..5e440de7b 100644
--- a/dapp/src/hooks/useStakeFlowContext.ts
+++ b/dapp/src/hooks/useStakeFlowContext.ts
@@ -1,7 +1,7 @@
import { useContext } from "react"
import { StakeFlowContext } from "#/contexts"
-export function useStakeFlowContext() {
+export default function useStakeFlowContext() {
const context = useContext(StakeFlowContext)
if (!context) {
diff --git a/dapp/src/hooks/useStatistics.ts b/dapp/src/hooks/useStatistics.ts
index 22dc77acd..6d9946dd4 100644
--- a/dapp/src/hooks/useStatistics.ts
+++ b/dapp/src/hooks/useStatistics.ts
@@ -1,4 +1,4 @@
-import { queryKeysFactory, REFETCH_INTERVAL_IN_MILLISECONDS } from "#/constants"
+import { queryKeysFactory, time } from "#/constants"
import { acreApi } from "#/utils"
import { useQuery } from "@tanstack/react-query"
@@ -8,7 +8,7 @@ const useStatistics = () => {
const { data } = useQuery({
queryKey: [...acreKeys.statistics()],
queryFn: acreApi.getStatistics,
- refetchInterval: REFETCH_INTERVAL_IN_MILLISECONDS,
+ refetchInterval: time.REFETCH_INTERVAL_IN_MILLISECONDS,
})
const bitcoinTvl = data?.btc ?? 0
diff --git a/dapp/src/hooks/useTimeout.ts b/dapp/src/hooks/useTimeout.ts
index ba037809e..f5c1c0e52 100644
--- a/dapp/src/hooks/useTimeout.ts
+++ b/dapp/src/hooks/useTimeout.ts
@@ -1,7 +1,7 @@
import { useEffect, useLayoutEffect, useRef } from "react"
// Source: https://usehooks-ts.com/react-hook/use-timeout
-export function useTimeout(callback: () => void, delay: number | null) {
+export default function useTimeout(callback: () => void, delay: number | null) {
const savedCallback = useRef(callback)
// Remember the latest callback if it changes.
diff --git a/dapp/src/hooks/useTransactionDetails.ts b/dapp/src/hooks/useTransactionDetails.ts
index 16237f52c..0e4748d38 100644
--- a/dapp/src/hooks/useTransactionDetails.ts
+++ b/dapp/src/hooks/useTransactionDetails.ts
@@ -1,6 +1,6 @@
import { useEffect, useState } from "react"
import { ACTION_FLOW_TYPES, ActionFlowType, Fee } from "#/types"
-import { initialFee, useTransactionFee } from "./useTransactionFee"
+import useTransactionFee, { initialFee } from "./useTransactionFee"
type UseTransactionDetailsResult = {
amount: bigint
@@ -14,7 +14,7 @@ const initialTransactionDetails = {
estimatedAmount: 0n,
}
-export function useTransactionDetails(
+export default function useTransactionDetails(
amount: bigint | undefined,
flow: ActionFlowType = ACTION_FLOW_TYPES.STAKE,
) {
diff --git a/dapp/src/hooks/useTransactionFee.ts b/dapp/src/hooks/useTransactionFee.ts
index bdc2aebf9..1e3ea3b50 100644
--- a/dapp/src/hooks/useTransactionFee.ts
+++ b/dapp/src/hooks/useTransactionFee.ts
@@ -10,7 +10,7 @@ export const initialFee = {
total: 0n,
}
-export function useTransactionFee(
+export default function useTransactionFee(
amount: bigint | undefined,
flow: ActionFlowType,
): Fee {
diff --git a/dapp/src/hooks/useTransactionModal.ts b/dapp/src/hooks/useTransactionModal.ts
index 7e4b9d0be..8b48a0c9e 100644
--- a/dapp/src/hooks/useTransactionModal.ts
+++ b/dapp/src/hooks/useTransactionModal.ts
@@ -1,8 +1,8 @@
import { ActionFlowType, MODAL_TYPES } from "#/types"
import { useCallback } from "react"
-import { useModal } from "./useModal"
+import useModal from "./useModal"
-export function useTransactionModal(type: ActionFlowType) {
+export default function useTransactionModal(type: ActionFlowType) {
const { openModal } = useModal()
return useCallback(() => {
diff --git a/dapp/src/hooks/useTriggerConnectWalletModal.ts b/dapp/src/hooks/useTriggerConnectWalletModal.ts
index 2a869c0cd..c28a90bf9 100644
--- a/dapp/src/hooks/useTriggerConnectWalletModal.ts
+++ b/dapp/src/hooks/useTriggerConnectWalletModal.ts
@@ -1,7 +1,7 @@
import { useEffect, useRef } from "react"
import { MODAL_TYPES } from "#/types"
-import { useIsSignedMessage } from "./store/useIsSignedMessage"
-import { useModal } from "./useModal"
+import useIsSignedMessage from "./store/useIsSignedMessage"
+import useModal from "./useModal"
import useIsEmbed from "./useIsEmbed"
export default function useTriggerConnectWalletModal() {
diff --git a/dapp/src/hooks/useUserPointsData.ts b/dapp/src/hooks/useUserPointsData.ts
index 9e6e2cad2..9ad1166b5 100644
--- a/dapp/src/hooks/useUserPointsData.ts
+++ b/dapp/src/hooks/useUserPointsData.ts
@@ -1,7 +1,7 @@
import { queryKeysFactory } from "#/constants"
import { useQuery } from "@tanstack/react-query"
import { acreApi } from "#/utils"
-import { useWallet } from "./useWallet"
+import useWallet from "./useWallet"
const { userKeys } = queryKeysFactory
diff --git a/dapp/src/hooks/useVerifyDepositAddress.ts b/dapp/src/hooks/useVerifyDepositAddress.ts
index a03b43b8f..11bfdb1dc 100644
--- a/dapp/src/hooks/useVerifyDepositAddress.ts
+++ b/dapp/src/hooks/useVerifyDepositAddress.ts
@@ -1,15 +1,15 @@
import { useCallback } from "react"
import { DepositReceipt } from "@acre-btc/sdk"
import { verifyDepositAddress } from "#/utils"
-import { BITCOIN_NETWORK } from "#/constants"
+import { chains } from "#/constants"
-export function useVerifyDepositAddress() {
+export default function useVerifyDepositAddress() {
return useCallback(
async (deposit: DepositReceipt, depositAddress: string) => {
const { status } = await verifyDepositAddress(
deposit,
depositAddress,
- BITCOIN_NETWORK,
+ chains.BITCOIN_NETWORK,
)
return status
diff --git a/dapp/src/hooks/useWallet.ts b/dapp/src/hooks/useWallet.ts
index 8125fd51a..dcf25536d 100644
--- a/dapp/src/hooks/useWallet.ts
+++ b/dapp/src/hooks/useWallet.ts
@@ -43,7 +43,7 @@ type UseWalletReturn = {
onDisconnect: () => void
}
-export function useWallet(): UseWalletReturn {
+export default function useWallet(): UseWalletReturn {
const queryClient = useQueryClient()
const dispatch = useDispatch()
const btcAddress = useWalletAddress()
diff --git a/dapp/src/pages/DashboardPage/AcrePointsCard.tsx b/dapp/src/pages/DashboardPage/AcrePointsCard.tsx
index 4b4f8be46..9a7ddfe7d 100644
--- a/dapp/src/pages/DashboardPage/AcrePointsCard.tsx
+++ b/dapp/src/pages/DashboardPage/AcrePointsCard.tsx
@@ -11,14 +11,13 @@ import {
VStack,
} from "@chakra-ui/react"
import Countdown from "#/components/shared/Countdown"
-import { logPromiseFailure, numberToLocaleString } from "#/utils"
-import { useAggregatedAcrePointsData, useWallet } from "#/hooks"
+import { logPromiseFailure, numbersUtils } from "#/utils"
+import { useAggregatedAcrePointsData, useDebounce, useWallet } from "#/hooks"
import Spinner from "#/components/shared/Spinner"
import UserDataSkeleton from "#/components/shared/UserDataSkeleton"
import TooltipIcon from "#/components/shared/TooltipIcon"
-import useDebounce from "#/hooks/useDebounce"
-import { ONE_SEC_IN_MILLISECONDS } from "#/constants"
-import acrePointsIllustrationSrc from "#/assets/images/acre-points-illustration.png"
+import { time } from "#/constants"
+import { acrePointsIllustration } from "#/assets/images"
// TODO: Define colors as theme value
const COLOR_TEXT_LIGHT_PRIMARY = "#1C1A16"
@@ -27,6 +26,8 @@ const COLOR_TEXT_LIGHT_TERTIARY = "#7D6A4B"
const COLOR_BUTTON_LABEL = "#FBF7EC"
const COLOR_BUTTON_BACKGROUND = "#33A321"
+const { numberToLocaleString } = numbersUtils
+
export default function AcrePointsCard(props: CardProps) {
const {
claimableBalance,
@@ -40,7 +41,10 @@ export default function AcrePointsCard(props: CardProps) {
} = useAggregatedAcrePointsData()
const { isConnected } = useWallet()
- const debouncedClaimPoints = useDebounce(claimPoints, ONE_SEC_IN_MILLISECONDS)
+ const debouncedClaimPoints = useDebounce(
+ claimPoints,
+ time.ONE_SEC_IN_MILLISECONDS,
+ )
const formattedTotalPointsAmount = numberToLocaleString(totalBalance)
const formattedClaimablePointsAmount = numberToLocaleString(claimableBalance)
@@ -80,7 +84,7 @@ export default function AcrePointsCard(props: CardProps) {
-
+
{isDataReady && (
diff --git a/dapp/src/pages/DashboardPage/AcrePointsTemplateCard.tsx b/dapp/src/pages/DashboardPage/AcrePointsTemplateCard.tsx
index 6a17c8992..29065c8ee 100644
--- a/dapp/src/pages/DashboardPage/AcrePointsTemplateCard.tsx
+++ b/dapp/src/pages/DashboardPage/AcrePointsTemplateCard.tsx
@@ -12,13 +12,13 @@ import {
TagLeftIcon,
VStack,
} from "@chakra-ui/react"
-import acrePointsCardPlaceholderSrc from "#/assets/images/acre-points-card-placeholder.png"
+import { acrePointsCardPlaceholder } from "#/assets/images"
import UserDataSkeleton from "#/components/shared/UserDataSkeleton"
import {
IconArrowUpRight,
IconPlayerTrackNextFilled,
} from "@tabler/icons-react"
-import { EXTERNAL_HREF } from "#/constants"
+import { externalHref } from "#/constants"
export default function AcrePointsTemplateCard(props: CardProps) {
return (
@@ -33,7 +33,7 @@ export default function AcrePointsTemplateCard(props: CardProps) {
diff --git a/dapp/src/pages/DashboardPage/AcreTVLProgress.tsx b/dapp/src/pages/DashboardPage/AcreTVLProgress.tsx
index 51c645153..b9a2614c7 100644
--- a/dapp/src/pages/DashboardPage/AcreTVLProgress.tsx
+++ b/dapp/src/pages/DashboardPage/AcreTVLProgress.tsx
@@ -9,7 +9,7 @@ import {
} from "@chakra-ui/react"
import { useStatistics } from "#/hooks"
import { BitcoinIcon } from "#/assets/icons"
-import { CurrencyBalance } from "#/components/shared/CurrencyBalance"
+import CurrencyBalance from "#/components/shared/CurrencyBalance"
import ProgressBar from "#/components/shared/ProgressBar"
import { TextMd, TextXs } from "#/components/shared/Typography"
@@ -17,7 +17,7 @@ type AcreTVLProgressProps = StackProps
const STEP_COUNT = 5
-export function AcreTVLProgress(props: AcreTVLProgressProps) {
+export default function AcreTVLProgress(props: AcreTVLProgressProps) {
const styles = useMultiStyleConfig("AcreTVLProgress")
const { tvl } = useStatistics()
diff --git a/dapp/src/pages/DashboardPage/BeehiveCard.tsx b/dapp/src/pages/DashboardPage/BeehiveCard.tsx
index d768e94d7..3fe55468e 100644
--- a/dapp/src/pages/DashboardPage/BeehiveCard.tsx
+++ b/dapp/src/pages/DashboardPage/BeehiveCard.tsx
@@ -1,12 +1,12 @@
import React from "react"
import { MezoSignIcon } from "#/assets/icons"
-import beehiveIllustrationSrc from "#/assets/images/beehive-illustration.svg"
+import { beehiveIllustration } from "#/assets/images"
import TooltipIcon from "#/components/shared/TooltipIcon"
import { H6, TextMd, TextSm } from "#/components/shared/Typography"
import UserDataSkeleton from "#/components/shared/UserDataSkeleton"
import { useMats, useModal } from "#/hooks"
import { MODAL_TYPES } from "#/types"
-import { numberToLocaleString } from "#/utils"
+import { numbersUtils } from "#/utils"
import {
Box,
Button,
@@ -39,7 +39,7 @@ export default function BeehiveCard(props: CardProps) {
-
+
@@ -54,7 +54,7 @@ export default function BeehiveCard(props: CardProps) {
{data && (
- {numberToLocaleString(data.totalMats)}
+ {numbersUtils.numberToLocaleString(data.totalMats)}
)}
diff --git a/dapp/src/pages/DashboardPage/PositionDetails.tsx b/dapp/src/pages/DashboardPage/PositionDetails.tsx
index 6b4f4267e..8091581ba 100644
--- a/dapp/src/pages/DashboardPage/PositionDetails.tsx
+++ b/dapp/src/pages/DashboardPage/PositionDetails.tsx
@@ -1,5 +1,5 @@
import React from "react"
-import { CurrencyBalanceWithConversion } from "#/components/shared/CurrencyBalanceWithConversion"
+import CurrencyBalanceWithConversion from "#/components/shared/CurrencyBalanceWithConversion"
import {
useActivitiesCount,
useBitcoinPosition,
@@ -17,7 +17,7 @@ import { featureFlags } from "#/constants"
import { TextMd } from "#/components/shared/Typography"
import { IconClockHour5Filled } from "@tabler/icons-react"
import TooltipIcon from "#/components/shared/TooltipIcon"
-import { hasPendingDeposits } from "#/utils"
+import { activitiesUtils } from "#/utils"
import AcreTVLMessage from "./AcreTVLMessage"
const isWithdrawalFlowEnabled = featureFlags.WITHDRAWALS_ENABLED
@@ -55,7 +55,7 @@ export default function PositionDetails() {
{/* TODO: Component should be moved to `CardHeader` */}
Your Acre balance
- {hasPendingDeposits(activities ?? []) && (
+ {activitiesUtils.hasPendingDeposits(activities ?? []) && (
@@ -28,7 +28,10 @@ export default function EstimatedDuration({
Est. duration
- {getEstimatedDuration(activity.amount, activity.type)}
+ {activitiesUtils.getEstimatedDuration(
+ activity.amount,
+ activity.type,
+ )}
diff --git a/dapp/src/pages/DashboardPage/TransactionHistory/TransactionTable.tsx b/dapp/src/pages/DashboardPage/TransactionHistory/TransactionTable.tsx
index baba6aa83..ce14a3311 100644
--- a/dapp/src/pages/DashboardPage/TransactionHistory/TransactionTable.tsx
+++ b/dapp/src/pages/DashboardPage/TransactionHistory/TransactionTable.tsx
@@ -8,8 +8,8 @@ import {
PaginationStatus,
} from "#/components/shared/Pagination"
import { TextSm } from "#/components/shared/Typography"
-import { CurrencyBalance } from "#/components/shared/CurrencyBalance"
-import { displayBlockTimestamp, getActivityTimestamp } from "#/utils"
+import CurrencyBalance from "#/components/shared/CurrencyBalance"
+import { timeUtils, activitiesUtils } from "#/utils"
import { Activity } from "#/types"
import BlockExplorerLink from "#/components/shared/BlockExplorerLink"
import { IconArrowUpRight } from "@tabler/icons-react"
@@ -52,7 +52,9 @@ export default function TransactionTable() {
- {displayBlockTimestamp(getActivityTimestamp(activity))}
+ {timeUtils.displayBlockTimestamp(
+ activitiesUtils.getActivityTimestamp(activity),
+ )}
{activity.txHash ? (
-
- ,You have no transactions yet!
+ ,
+ You have no transactions yet!
)
diff --git a/dapp/src/pages/DashboardPage/index.tsx b/dapp/src/pages/DashboardPage/index.tsx
index b35928aa6..13482816b 100644
--- a/dapp/src/pages/DashboardPage/index.tsx
+++ b/dapp/src/pages/DashboardPage/index.tsx
@@ -6,7 +6,7 @@ import DashboardCard from "./DashboardCard"
import AcrePointsCard from "./AcrePointsCard"
import AcrePointsTemplateCard from "./AcrePointsTemplateCard"
import BeehiveCard from "./BeehiveCard"
-import { AcreTVLProgress } from "./AcreTVLProgress"
+import AcreTVLProgress from "./AcreTVLProgress"
export default function DashboardPage() {
useTriggerConnectWalletModal()
diff --git a/dapp/src/posthog/events.ts b/dapp/src/posthog/events.ts
index 992b9958e..706a5a5ed 100644
--- a/dapp/src/posthog/events.ts
+++ b/dapp/src/posthog/events.ts
@@ -1,4 +1,4 @@
-export enum PostHogEvent {
+enum PostHogEvent {
PageView = "$pageview",
DepositSuccess = "deposit_success",
DepositFailure = "deposit_failure",
@@ -7,3 +7,5 @@ export enum PostHogEvent {
PointsClaimSuccess = "points_claim_success",
PointsClaimFailure = "points_claim_failure",
}
+
+export default PostHogEvent
diff --git a/dapp/src/router/index.tsx b/dapp/src/router/index.tsx
index 351a8504e..ead4161cb 100644
--- a/dapp/src/router/index.tsx
+++ b/dapp/src/router/index.tsx
@@ -30,7 +30,7 @@ const mainLayoutLoader: LoaderFunction = ({ request }) => {
return routerUtils.redirectWithSearchParams(request.url, "/access")
}
-export const router = createBrowserRouter([
+const router = createBrowserRouter([
{
path: "/",
element: ,
@@ -75,3 +75,5 @@ export const router = createBrowserRouter([
],
},
])
+
+export default router
diff --git a/dapp/src/store/btc/btcThunk.ts b/dapp/src/store/btc/btcThunk.ts
index 87f121201..c5383d6aa 100644
--- a/dapp/src/store/btc/btcThunk.ts
+++ b/dapp/src/store/btc/btcThunk.ts
@@ -1,6 +1,7 @@
import { createAsyncThunk } from "@reduxjs/toolkit"
import { acreApi } from "#/utils"
+// eslint-disable-next-line import/prefer-default-export
export const fetchBTCPriceUSD = createAsyncThunk(
"btc/fetchBTCPriceUSD",
async () => acreApi.getBtcUsdPrice(),
diff --git a/dapp/src/store/devTools.ts b/dapp/src/store/devTools.ts
index 27b9d9ea7..ff5368086 100644
--- a/dapp/src/store/devTools.ts
+++ b/dapp/src/store/devTools.ts
@@ -16,9 +16,11 @@ function devToolsSanitizer(input: unknown): unknown {
}
}
-export const devTools = !env.PROD
+const devTools = !env.PROD
? ({
actionSanitizer: devToolsSanitizer,
stateSanitizer: devToolsSanitizer,
} as DevToolsEnhancerOptions)
: false
+
+export default devTools
diff --git a/dapp/src/store/index.ts b/dapp/src/store/index.ts
index 3353ac94a..0b4ffc1cb 100644
--- a/dapp/src/store/index.ts
+++ b/dapp/src/store/index.ts
@@ -1,9 +1,9 @@
import { configureStore } from "@reduxjs/toolkit"
-import { middleware } from "./middleware"
-import { reducer } from "./reducer"
-import { devTools } from "./devTools"
+import devTools from "./devTools"
+import middleware from "./middleware"
+import reducer from "./reducer"
-export const store = configureStore({
+const store = configureStore({
reducer,
middleware: (getDefaultMiddleware) => getDefaultMiddleware(middleware),
devTools,
@@ -11,3 +11,5 @@ export const store = configureStore({
export type RootState = ReturnType
export type AppDispatch = typeof store.dispatch
+
+export default store
diff --git a/dapp/src/store/middleware.ts b/dapp/src/store/middleware.ts
index 80413c5ce..854f6ce6b 100644
--- a/dapp/src/store/middleware.ts
+++ b/dapp/src/store/middleware.ts
@@ -1,6 +1,6 @@
import { isPlain } from "@reduxjs/toolkit"
-export const middleware = {
+export default {
serializableCheck: {
isSerializable: (value: unknown) =>
isPlain(value) || typeof value === "bigint",
diff --git a/dapp/src/store/reducer.ts b/dapp/src/store/reducer.ts
index 10b092a34..cbc30d054 100644
--- a/dapp/src/store/reducer.ts
+++ b/dapp/src/store/reducer.ts
@@ -4,7 +4,7 @@ import { walletSlice } from "./wallet/walletSlice"
import { actionFlowSlice } from "./action-flow/actionFlowSlice"
import { modalSlice } from "./modal/modalSlice"
-export const reducer = combineReducers({
+export default combineReducers({
btc: btcSlice.reducer,
wallet: walletSlice.reducer,
actionFlow: actionFlowSlice.reducer,
diff --git a/dapp/src/store/wallet/walletSlice.ts b/dapp/src/store/wallet/walletSlice.ts
index a067fbcca..4f00636d1 100644
--- a/dapp/src/store/wallet/walletSlice.ts
+++ b/dapp/src/store/wallet/walletSlice.ts
@@ -41,4 +41,3 @@ export const {
resetState,
setAddress,
} = walletSlice.actions
-export default walletSlice.reducer
diff --git a/dapp/src/theme/acreTVLProgressTheme.ts b/dapp/src/theme/acreTVLProgressTheme.ts
index 16d5524bc..fda13f990 100644
--- a/dapp/src/theme/acreTVLProgressTheme.ts
+++ b/dapp/src/theme/acreTVLProgressTheme.ts
@@ -82,6 +82,6 @@ const baseStyle = multiStyleConfig.definePartsStyle({
progressLabel: progressLabelStyles,
})
-export const acreTVLProgressTheme = multiStyleConfig.defineMultiStyleConfig({
+export default multiStyleConfig.defineMultiStyleConfig({
baseStyle,
})
diff --git a/dapp/src/theme/alertTheme.ts b/dapp/src/theme/alertTheme.ts
index 905c63e97..ad63da841 100644
--- a/dapp/src/theme/alertTheme.ts
+++ b/dapp/src/theme/alertTheme.ts
@@ -63,7 +63,7 @@ const variants = {
elevated: variantElevated,
}
-export const alertTheme = multiStyleConfig.defineMultiStyleConfig({
+export default multiStyleConfig.defineMultiStyleConfig({
baseStyle,
variants,
})
diff --git a/dapp/src/theme/buttonTheme.ts b/dapp/src/theme/buttonTheme.ts
index 62623b3e0..6bd5c08ec 100644
--- a/dapp/src/theme/buttonTheme.ts
+++ b/dapp/src/theme/buttonTheme.ts
@@ -20,7 +20,7 @@ const variantCard = defineStyle({
})
// TODO: Update the button styles correctly when ready
-export const buttonTheme: ComponentSingleStyleConfig = {
+const buttonTheme: ComponentSingleStyleConfig = {
baseStyle: {
// Remove a blue outline when the button is in focus.
boxShadow: "none !important",
@@ -163,3 +163,5 @@ export const buttonTheme: ComponentSingleStyleConfig = {
colorScheme: "brand",
},
}
+
+export default buttonTheme
diff --git a/dapp/src/theme/cardTheme.ts b/dapp/src/theme/cardTheme.ts
index dc2873d4b..f4d0c78e5 100644
--- a/dapp/src/theme/cardTheme.ts
+++ b/dapp/src/theme/cardTheme.ts
@@ -24,6 +24,6 @@ const baseStyle = multiStyleConfig.definePartsStyle({
body: baseStyleBody,
})
-export const cardTheme = multiStyleConfig.defineMultiStyleConfig({
+export default multiStyleConfig.defineMultiStyleConfig({
baseStyle,
})
diff --git a/dapp/src/theme/closeButtonTheme.ts b/dapp/src/theme/closeButtonTheme.ts
index 57543f291..bc3671469 100644
--- a/dapp/src/theme/closeButtonTheme.ts
+++ b/dapp/src/theme/closeButtonTheme.ts
@@ -4,6 +4,6 @@ const baseStyle = defineStyle({
bg: "transparent",
})
-export const closeButtonTheme = defineStyleConfig({
+export default defineStyleConfig({
baseStyle,
})
diff --git a/dapp/src/theme/countdownTheme.ts b/dapp/src/theme/countdownTheme.ts
index bf159456b..1acb0aecb 100644
--- a/dapp/src/theme/countdownTheme.ts
+++ b/dapp/src/theme/countdownTheme.ts
@@ -44,7 +44,7 @@ const sizes = Object.fromEntries(
]),
)
-export const countdownTheme = multiStyleConfig.defineMultiStyleConfig({
+export default multiStyleConfig.defineMultiStyleConfig({
baseStyle,
sizes,
})
diff --git a/dapp/src/theme/currencyBalanceTheme.ts b/dapp/src/theme/currencyBalanceTheme.ts
index 8bf0a37b0..d073c88cb 100644
--- a/dapp/src/theme/currencyBalanceTheme.ts
+++ b/dapp/src/theme/currencyBalanceTheme.ts
@@ -167,7 +167,7 @@ const sizes = {
"6xl": size6Xl,
}
-export const currencyBalanceTheme = multiStyleConfig.defineMultiStyleConfig({
+export default multiStyleConfig.defineMultiStyleConfig({
baseStyle,
variants,
sizes,
diff --git a/dapp/src/theme/footerTheme.ts b/dapp/src/theme/footerTheme.ts
index 3aced57fe..c92aff846 100644
--- a/dapp/src/theme/footerTheme.ts
+++ b/dapp/src/theme/footerTheme.ts
@@ -58,6 +58,6 @@ const baseStyle = multiStyleConfig.definePartsStyle({
link: linkStyles,
})
-export const footerTheme = multiStyleConfig.defineMultiStyleConfig({
+export default multiStyleConfig.defineMultiStyleConfig({
baseStyle,
})
diff --git a/dapp/src/theme/formErrorTheme.ts b/dapp/src/theme/formErrorTheme.ts
index 5cc44f3ad..cac61f15b 100644
--- a/dapp/src/theme/formErrorTheme.ts
+++ b/dapp/src/theme/formErrorTheme.ts
@@ -15,6 +15,6 @@ const baseStyle = multiStyleConfig.definePartsStyle({
text: baseStyleText,
})
-export const formErrorTheme = multiStyleConfig.defineMultiStyleConfig({
+export default multiStyleConfig.defineMultiStyleConfig({
baseStyle,
})
diff --git a/dapp/src/theme/formLabelTheme.ts b/dapp/src/theme/formLabelTheme.ts
index 4eb3044c8..84ea032ff 100644
--- a/dapp/src/theme/formLabelTheme.ts
+++ b/dapp/src/theme/formLabelTheme.ts
@@ -20,4 +20,4 @@ const sizes = {
lg: sizeLg,
}
-export const formLabelTheme = defineStyleConfig({ baseStyle, sizes })
+export default defineStyleConfig({ baseStyle, sizes })
diff --git a/dapp/src/theme/formTheme.ts b/dapp/src/theme/formTheme.ts
index f195c872d..deb7d01c9 100644
--- a/dapp/src/theme/formTheme.ts
+++ b/dapp/src/theme/formTheme.ts
@@ -15,4 +15,4 @@ const baseStyle = multiStyleConfig.definePartsStyle({
helperText: baseStyleHelperText,
})
-export const formTheme = multiStyleConfig.defineMultiStyleConfig({ baseStyle })
+export default multiStyleConfig.defineMultiStyleConfig({ baseStyle })
diff --git a/dapp/src/theme/headingTheme.ts b/dapp/src/theme/headingTheme.ts
index f3f137294..e601d7f47 100644
--- a/dapp/src/theme/headingTheme.ts
+++ b/dapp/src/theme/headingTheme.ts
@@ -1,6 +1,6 @@
import { ComponentSingleStyleConfig } from "@chakra-ui/react"
-export const headingTheme: ComponentSingleStyleConfig = {
+const headingTheme: ComponentSingleStyleConfig = {
sizes: {
"7xl": {
fontSize: "7xl",
@@ -28,3 +28,5 @@ export const headingTheme: ComponentSingleStyleConfig = {
},
},
}
+
+export default headingTheme
diff --git a/dapp/src/theme/index.ts b/dapp/src/theme/index.ts
index eb1c2cd41..5f3c9eaf2 100644
--- a/dapp/src/theme/index.ts
+++ b/dapp/src/theme/index.ts
@@ -1,33 +1,26 @@
import { extendTheme } from "@chakra-ui/react"
-import {
- colors,
- fonts,
- lineHeights,
- semanticTokens,
- styles,
- zIndices,
-} from "./utils"
-import { acreTVLProgressTheme } from "./acreTVLProgressTheme"
-import { alertTheme } from "./alertTheme"
-import { buttonTheme } from "./buttonTheme"
-import { cardTheme } from "./cardTheme"
-import { closeButtonTheme } from "./closeButtonTheme"
-import { countdownTheme } from "./countdownTheme"
-import { currencyBalanceTheme } from "./currencyBalanceTheme"
-import { footerTheme } from "./footerTheme"
-import { formErrorTheme } from "./formErrorTheme"
-import { formLabelTheme } from "./formLabelTheme"
-import { formTheme } from "./formTheme"
-import { headingTheme } from "./headingTheme"
-import { inputTheme } from "./inputTheme"
-import { linkTheme } from "./linkTheme"
-import { modalTheme } from "./modalTheme"
-import { progressTheme } from "./progressTheme"
-import { skeletonTheme } from "./skeletonTheme"
-import { spinnerTheme } from "./spinnerTheme"
-import { tagTheme } from "./tagTheme"
-import { tokenBalanceInputTheme } from "./tokenBalanceInputTheme"
-import { tooltipTheme } from "./tooltipTheme"
+import { colors, typography, semanticTokens, styles, zIndices } from "./utils"
+import acreTVLProgressTheme from "./acreTVLProgressTheme"
+import alertTheme from "./alertTheme"
+import buttonTheme from "./buttonTheme"
+import cardTheme from "./cardTheme"
+import closeButtonTheme from "./closeButtonTheme"
+import countdownTheme from "./countdownTheme"
+import currencyBalanceTheme from "./currencyBalanceTheme"
+import footerTheme from "./footerTheme"
+import formErrorTheme from "./formErrorTheme"
+import formLabelTheme from "./formLabelTheme"
+import formTheme from "./formTheme"
+import headingTheme from "./headingTheme"
+import inputTheme from "./inputTheme"
+import linkTheme from "./linkTheme"
+import modalTheme from "./modalTheme"
+import progressTheme from "./progressTheme"
+import skeletonTheme from "./skeletonTheme"
+import spinnerTheme from "./spinnerTheme"
+import tagTheme from "./tagTheme"
+import tokenBalanceInputTheme from "./tokenBalanceInputTheme"
+import tooltipTheme from "./tooltipTheme"
const defaultTheme = {
// TODO: Remove when dark mode is ready
@@ -35,8 +28,7 @@ const defaultTheme = {
initialColorMode: "light",
useSystemColorMode: false,
colors,
- fonts,
- lineHeights,
+ ...typography,
zIndices,
semanticTokens,
styles,
@@ -70,6 +62,4 @@ const defaultTheme = {
},
}
-const theme = extendTheme(defaultTheme)
-
-export default theme
+export default extendTheme(defaultTheme)
diff --git a/dapp/src/theme/inputTheme.ts b/dapp/src/theme/inputTheme.ts
index bd998fdb3..128d4d418 100644
--- a/dapp/src/theme/inputTheme.ts
+++ b/dapp/src/theme/inputTheme.ts
@@ -48,7 +48,7 @@ const variants = {
outline: variantOutline,
}
-export const inputTheme = multiStyleConfig.defineMultiStyleConfig({
+export default multiStyleConfig.defineMultiStyleConfig({
variants,
defaultProps: {
variant: "outline",
diff --git a/dapp/src/theme/linkTheme.ts b/dapp/src/theme/linkTheme.ts
index f8b064299..bfa57e337 100644
--- a/dapp/src/theme/linkTheme.ts
+++ b/dapp/src/theme/linkTheme.ts
@@ -36,7 +36,7 @@ const sizes = {
md: sizeMd,
}
-export const linkTheme = multiStyleConfig.defineMultiStyleConfig({
+export default multiStyleConfig.defineMultiStyleConfig({
baseStyle: {
container: containerBaseStyle,
size: "sm",
diff --git a/dapp/src/theme/modalTheme.ts b/dapp/src/theme/modalTheme.ts
index d4cb15d5d..2a1ecb89a 100644
--- a/dapp/src/theme/modalTheme.ts
+++ b/dapp/src/theme/modalTheme.ts
@@ -104,7 +104,7 @@ const sizes = {
lg: sizeLg,
}
-export const modalTheme = multiStyleConfig.defineMultiStyleConfig({
+export default multiStyleConfig.defineMultiStyleConfig({
baseStyle,
sizes,
variants,
diff --git a/dapp/src/theme/progressTheme.ts b/dapp/src/theme/progressTheme.ts
index 7dcebf86d..3b332d23d 100644
--- a/dapp/src/theme/progressTheme.ts
+++ b/dapp/src/theme/progressTheme.ts
@@ -102,7 +102,7 @@ const sizes = {
}),
}
-export const progressTheme = multiStyleConfig.defineMultiStyleConfig({
+export default multiStyleConfig.defineMultiStyleConfig({
sizes,
baseStyle,
defaultProps: {
diff --git a/dapp/src/theme/skeletonTheme.ts b/dapp/src/theme/skeletonTheme.ts
index dbf7966fe..1f771222c 100644
--- a/dapp/src/theme/skeletonTheme.ts
+++ b/dapp/src/theme/skeletonTheme.ts
@@ -16,4 +16,4 @@ const baseStyle = defineStyle({
},
})
-export const skeletonTheme = defineStyleConfig({ baseStyle })
+export default defineStyleConfig({ baseStyle })
diff --git a/dapp/src/theme/spinnerTheme.ts b/dapp/src/theme/spinnerTheme.ts
index 7800c896d..320fbd80f 100644
--- a/dapp/src/theme/spinnerTheme.ts
+++ b/dapp/src/theme/spinnerTheme.ts
@@ -32,7 +32,7 @@ const sizes = {
"2xl": size2Xl,
}
-export const spinnerTheme = defineStyleConfig({
+export default defineStyleConfig({
baseStyle,
sizes,
variants,
diff --git a/dapp/src/theme/tagTheme.ts b/dapp/src/theme/tagTheme.ts
index 1c1169fe4..454b449d6 100644
--- a/dapp/src/theme/tagTheme.ts
+++ b/dapp/src/theme/tagTheme.ts
@@ -35,7 +35,7 @@ const variants = {
outline: variantOutline,
}
-export const tagTheme = multiStyleConfig.defineMultiStyleConfig({
+export default multiStyleConfig.defineMultiStyleConfig({
defaultProps: { variant: "outline" },
baseStyle,
variants,
diff --git a/dapp/src/theme/tokenBalanceInputTheme.ts b/dapp/src/theme/tokenBalanceInputTheme.ts
index cea039b38..87141b315 100644
--- a/dapp/src/theme/tokenBalanceInputTheme.ts
+++ b/dapp/src/theme/tokenBalanceInputTheme.ts
@@ -25,6 +25,6 @@ const baseStyle = multiStyleConfig.definePartsStyle({
balance: baseStyleBalance,
})
-export const tokenBalanceInputTheme = multiStyleConfig.defineMultiStyleConfig({
+export default multiStyleConfig.defineMultiStyleConfig({
baseStyle,
})
diff --git a/dapp/src/theme/tooltipTheme.ts b/dapp/src/theme/tooltipTheme.ts
index 922d31fd6..19875d089 100644
--- a/dapp/src/theme/tooltipTheme.ts
+++ b/dapp/src/theme/tooltipTheme.ts
@@ -41,7 +41,7 @@ const sizes = {
sm: sizeSm,
}
-export const tooltipTheme = defineStyleConfig({
+export default defineStyleConfig({
defaultProps: {
size: "sm",
},
diff --git a/dapp/src/theme/utils/colors.ts b/dapp/src/theme/utils/colors.ts
index 47a25f093..9289da785 100644
--- a/dapp/src/theme/utils/colors.ts
+++ b/dapp/src/theme/utils/colors.ts
@@ -1,4 +1,4 @@
-export const colors = {
+export default {
brand: {
100: "#FFEDEB",
200: "#FFC5BF",
diff --git a/dapp/src/theme/utils/index.ts b/dapp/src/theme/utils/index.ts
index d100be7bb..d29f605b1 100644
--- a/dapp/src/theme/utils/index.ts
+++ b/dapp/src/theme/utils/index.ts
@@ -1,5 +1,5 @@
-export * from "./colors"
-export * from "./fonts"
-export * from "./zIndices"
-export * from "./semanticTokens"
-export * from "./styles"
+export { default as colors } from "./colors"
+export { default as typography } from "./typography"
+export { default as zIndices } from "./zIndices"
+export { default as semanticTokens } from "./semanticTokens"
+export { default as styles } from "./styles"
diff --git a/dapp/src/theme/utils/semanticTokens.ts b/dapp/src/theme/utils/semanticTokens.ts
index 8fb5ba562..c6ce5f934 100644
--- a/dapp/src/theme/utils/semanticTokens.ts
+++ b/dapp/src/theme/utils/semanticTokens.ts
@@ -1,4 +1,4 @@
-export const semanticTokens = {
+export default {
space: {
dashboard_card_padding: 5,
},
diff --git a/dapp/src/theme/utils/styles.ts b/dapp/src/theme/utils/styles.ts
index 104130760..e9dea2f14 100644
--- a/dapp/src/theme/utils/styles.ts
+++ b/dapp/src/theme/utils/styles.ts
@@ -11,6 +11,6 @@ const globalStyle = (props: StyleFunctionProps) => ({
body: bodyStyle(props),
})
-export const styles = {
+export default {
global: (props: StyleFunctionProps) => globalStyle(props),
}
diff --git a/dapp/src/theme/utils/fonts.ts b/dapp/src/theme/utils/typography.ts
similarity index 76%
rename from dapp/src/theme/utils/fonts.ts
rename to dapp/src/theme/utils/typography.ts
index d7221da48..ce641de01 100644
--- a/dapp/src/theme/utils/fonts.ts
+++ b/dapp/src/theme/utils/typography.ts
@@ -1,4 +1,4 @@
-export const lineHeights = {
+const lineHeights = {
"7xl": "5.625rem",
"6xl": "4.5rem",
"5xl": "3.75rem",
@@ -12,7 +12,12 @@ export const lineHeights = {
xs: "1.125rem",
}
-export const fonts = {
+const fonts = {
heading: "Segment, sans-serif",
body: "Segment, sans-serif",
}
+
+export default {
+ fonts,
+ lineHeights,
+}
diff --git a/dapp/src/theme/utils/zIndices.ts b/dapp/src/theme/utils/zIndices.ts
index 3ada56278..c47f53442 100644
--- a/dapp/src/theme/utils/zIndices.ts
+++ b/dapp/src/theme/utils/zIndices.ts
@@ -1,4 +1,4 @@
-export const zIndices = {
+export default {
mobileBanner: 1500,
header: 1400,
footer: 1380,
diff --git a/dapp/src/utils/activities.ts b/dapp/src/utils/activitiesUtils.ts
similarity index 77%
rename from dapp/src/utils/activities.ts
rename to dapp/src/utils/activitiesUtils.ts
index 8d599f64b..4a9e944f6 100644
--- a/dapp/src/utils/activities.ts
+++ b/dapp/src/utils/activitiesUtils.ts
@@ -3,29 +3,26 @@ import { Activity, ActivityType } from "#/types"
const MIN_LIMIT_VALUE_DURATION = BigInt(String(1e7)) // 0.1 BTC
const MAX_LIMIT_VALUE_DURATION = BigInt(String(1e8)) // 1 BTC
-export const isActivityCompleted = (activity: Activity): boolean =>
+const isActivityCompleted = (activity: Activity): boolean =>
activity.status === "completed"
-export const getActivityTimestamp = (activity: Activity): number =>
+const getActivityTimestamp = (activity: Activity): number =>
activity?.finalizedAt ?? activity.initializedAt
-export const hasPendingDeposits = (activities: Activity[]): boolean =>
+const hasPendingDeposits = (activities: Activity[]): boolean =>
activities.some(
(activity) => activity.status === "pending" && activity.type === "deposit",
)
-export const sortActivitiesByTimestamp = (activities: Activity[]): Activity[] =>
+const sortActivitiesByTimestamp = (activities: Activity[]): Activity[] =>
[...activities].sort(
(activity1, activity2) =>
getActivityTimestamp(activity2) - getActivityTimestamp(activity1),
)
-export const isWithdrawType = (type: ActivityType) => type === "withdraw"
+const isWithdrawType = (type: ActivityType) => type === "withdraw"
-export function getEstimatedDuration(
- amount: bigint,
- type: ActivityType,
-): string {
+function getEstimatedDuration(amount: bigint, type: ActivityType): string {
// Withdrawal duration is related to the tBTC redemption process, which takes
// approximately 5 - 7 hours. We use the average value of 6 hours.
if (isWithdrawType(type)) return "6 hours"
@@ -54,3 +51,12 @@ export function getEstimatedDuration(
// For >=1 BTC estimated duration is around 2 hours 10 minutes.
return "3 hours"
}
+
+export default {
+ isActivityCompleted,
+ getActivityTimestamp,
+ hasPendingDeposits,
+ sortActivitiesByTimestamp,
+ isWithdrawType,
+ getEstimatedDuration,
+}
diff --git a/dapp/src/utils/address.ts b/dapp/src/utils/address.ts
deleted file mode 100644
index 7ed3caa1a..000000000
--- a/dapp/src/utils/address.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export function truncateAddress(address: string): string {
- return `${address.slice(0, 6)}…${address.slice(-5)}`
-}
diff --git a/dapp/src/utils/addressUtils.ts b/dapp/src/utils/addressUtils.ts
new file mode 100644
index 000000000..6118b34e7
--- /dev/null
+++ b/dapp/src/utils/addressUtils.ts
@@ -0,0 +1,7 @@
+function truncateAddress(address: string): string {
+ return `${address.slice(0, 6)}…${address.slice(-5)}`
+}
+
+export default {
+ truncateAddress,
+}
diff --git a/dapp/src/utils/chain.ts b/dapp/src/utils/chainUtils.ts
similarity index 68%
rename from dapp/src/utils/chain.ts
rename to dapp/src/utils/chainUtils.ts
index 6f030dcba..bf9bb388e 100644
--- a/dapp/src/utils/chain.ts
+++ b/dapp/src/utils/chainUtils.ts
@@ -1,11 +1,11 @@
-import { BLOCK_EXPLORER } from "#/constants"
+import { chains } from "#/constants"
import { Chain, ExplorerDataType } from "#/types"
// At this moment, the function returns
// the correct part of the URL only for the transaction.
// However, it provides us with an easy way
// to handle the next data for block explorer.
-export const createBlockExplorerLink = (
+const createBlockExplorerLink = (
prefix: string,
id: string,
type: ExplorerDataType,
@@ -18,12 +18,17 @@ export const createBlockExplorerLink = (
}
}
-export const createLinkToBlockExplorerForChain = (
+const createLinkToBlockExplorerForChain = (
chain: Chain,
id: string,
type: ExplorerDataType,
) => {
- const { title, url } = BLOCK_EXPLORER[chain]
+ const { title, url } = chains.BLOCK_EXPLORER[chain]
const link = createBlockExplorerLink(url, id, type)
return { title, link }
}
+
+export default {
+ createBlockExplorerLink,
+ createLinkToBlockExplorerForChain,
+}
diff --git a/dapp/src/utils/currency.ts b/dapp/src/utils/currency.ts
deleted file mode 100644
index 4d8b02a78..000000000
--- a/dapp/src/utils/currency.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import { Currency, CurrencyType } from "#/types"
-import { CURRENCIES_BY_TYPE } from "#/constants"
-
-export const getCurrencyByType = (currency: CurrencyType): Currency =>
- CURRENCIES_BY_TYPE[currency]
diff --git a/dapp/src/utils/currencyUtils.ts b/dapp/src/utils/currencyUtils.ts
new file mode 100644
index 000000000..affd658e3
--- /dev/null
+++ b/dapp/src/utils/currencyUtils.ts
@@ -0,0 +1,9 @@
+import { Currency, CurrencyType } from "#/types"
+import { currencies } from "#/constants"
+
+const getCurrencyByType = (currency: CurrencyType): Currency =>
+ currencies.CURRENCIES_BY_TYPE[currency]
+
+export default {
+ getCurrencyByType,
+}
diff --git a/dapp/src/utils/eip1193.ts b/dapp/src/utils/eip1193.ts
index 8a0131b1a..5160a997f 100644
--- a/dapp/src/utils/eip1193.ts
+++ b/dapp/src/utils/eip1193.ts
@@ -3,7 +3,9 @@ import {
EIP1193ErrorCodeNumbers,
EIP1193_ERROR_CODES,
} from "#/types"
-import { isNumber, isObject, isString } from "./type-check"
+import typeCheck from "./type-check"
+
+const { isNumber, isObject, isString } = typeCheck
function isEIP1193ErrorCodeNumber(
code: unknown,
diff --git a/dapp/src/utils/json.ts b/dapp/src/utils/encodeJSON.ts
similarity index 85%
rename from dapp/src/utils/json.ts
rename to dapp/src/utils/encodeJSON.ts
index 4214e25db..8d3dd78fd 100644
--- a/dapp/src/utils/json.ts
+++ b/dapp/src/utils/encodeJSON.ts
@@ -3,7 +3,7 @@
*
* @param input an object, array, or primitive to encode as JSON
*/
-export function encodeJSON(input: unknown) {
+export default function encodeJSON(input: unknown) {
return JSON.stringify(input, (_, value: unknown) => {
if (typeof value === "bigint") {
return { B_I_G_I_N_T: value.toString() }
diff --git a/dapp/src/utils/forms.ts b/dapp/src/utils/forms.ts
index b66523703..438dbe53e 100644
--- a/dapp/src/utils/forms.ts
+++ b/dapp/src/utils/forms.ts
@@ -1,50 +1,47 @@
-import {
- ACTION_FORM_ERRORS,
- PASSWORD_FORM_ERRORS,
- TOKEN_FORM_ERRORS,
-} from "#/constants"
+import { errorMessages } from "#/constants"
import sentry from "#/sentry"
import { ACTION_FLOW_TYPES, ActionFlowType, CurrencyType } from "#/types"
import acreApi from "./acreApi"
-import { getCurrencyByType } from "./currency"
-import { fixedPointNumberToString } from "./numbers"
+import currencyUtils from "./currencyUtils"
+import numbersUtils from "./numbersUtils"
-export function getErrorsObj(errors: { [key in keyof T]: string }) {
+function getErrorsObj(errors: { [key in keyof T]: string }) {
return (Object.keys(errors) as Array).every((name) => !errors[name])
? {}
: errors
}
-export async function validatePassword(
+async function validatePassword(
value: string | undefined,
): Promise {
- if (value === undefined || value === "") return PASSWORD_FORM_ERRORS.REQUIRED
+ if (value === undefined || value === "")
+ return errorMessages.PASSWORD_FORM_ERRORS.REQUIRED
try {
const encodedCode = window.btoa(value)
const isValid = await acreApi.verifyAccessCode(encodedCode)
- if (!isValid) return PASSWORD_FORM_ERRORS.INCORRECT_VALUE
+ if (!isValid) return errorMessages.PASSWORD_FORM_ERRORS.INCORRECT_VALUE
} catch (error) {
sentry.captureException(error)
console.error(error)
- return PASSWORD_FORM_ERRORS.DEFAULT
+ return errorMessages.PASSWORD_FORM_ERRORS.DEFAULT
}
return undefined
}
-export function validateTokenAmount(
+function validateTokenAmount(
actionType: ActionFlowType,
value: bigint | undefined,
maxValue: bigint,
minValue: bigint,
currency: CurrencyType,
): string | undefined {
- const ERRORS_BY_ACTION_TYPE = ACTION_FORM_ERRORS[actionType]
+ const ERRORS_BY_ACTION_TYPE = errorMessages.ACTION_FORM_ERRORS[actionType]
if (value === undefined) return ERRORS_BY_ACTION_TYPE.REQUIRED
- const { decimals } = getCurrencyByType(currency)
+ const { decimals } = currencyUtils.getCurrencyByType(currency)
const isMaximumValueExceeded = value > maxValue
const isMinimumValueFulfilled = value >= minValue
@@ -53,7 +50,7 @@ export function validateTokenAmount(
if (!isMinimumValueFulfilled)
return ERRORS_BY_ACTION_TYPE.INSUFFICIENT_VALUE(
actionType === ACTION_FLOW_TYPES.STAKE ? "deposit" : "withdrawal",
- fixedPointNumberToString(minValue, decimals),
+ numbersUtils.fixedPointNumberToString(minValue, decimals),
)
return undefined
@@ -61,13 +58,13 @@ export function validateTokenAmount(
type ParametrizedError = (value: number) => string
-export const isFormError = (
- type: keyof typeof TOKEN_FORM_ERRORS,
+const isFormError = (
+ type: keyof typeof errorMessages.TOKEN_FORM_ERRORS,
message: string,
) => {
let errorPredicates = [
- ACTION_FORM_ERRORS.STAKE[type],
- ACTION_FORM_ERRORS.UNSTAKE[type],
+ errorMessages.ACTION_FORM_ERRORS.STAKE[type],
+ errorMessages.ACTION_FORM_ERRORS.UNSTAKE[type],
]
const isParametrizedError = errorPredicates.every(
@@ -87,3 +84,10 @@ export const isFormError = (
return errorPredicates.includes(message)
}
+
+export default {
+ getErrorsObj,
+ validatePassword,
+ validateTokenAmount,
+ isFormError,
+}
diff --git a/dapp/src/utils/index.ts b/dapp/src/utils/index.ts
index 64e1ffc9b..eddfe1724 100644
--- a/dapp/src/utils/index.ts
+++ b/dapp/src/utils/index.ts
@@ -1,14 +1,14 @@
-export * from "./numbers"
-export * from "./address"
-export * from "./forms"
-export * from "./currency"
-export * from "./chain"
-export * from "./time"
-export * from "./promise"
-export * from "./verifyDepositAddress"
-export * from "./json"
-export * from "./activities"
-export * from "./type-check"
+export { default as numbersUtils } from "./numbersUtils"
+export { default as addressUtils } from "./addressUtils"
+export { default as forms } from "./forms"
+export { default as currencyUtils } from "./currencyUtils"
+export { default as chainUtils } from "./chainUtils"
+export { default as timeUtils } from "./timeUtils"
+export { default as logPromiseFailure } from "./logPromiseFailure"
+export { default as verifyDepositAddress } from "./verifyDepositAddress"
+export { default as encodeJSON } from "./encodeJSON"
+export { default as activitiesUtils } from "./activitiesUtils"
+export { default as typeCheck } from "./type-check"
export { default as eip1193 } from "./eip1193"
export { default as orangeKit } from "./orangekit"
export { default as userAgent } from "./userAgent"
diff --git a/dapp/src/utils/promise.ts b/dapp/src/utils/logPromiseFailure.ts
similarity index 75%
rename from dapp/src/utils/promise.ts
rename to dapp/src/utils/logPromiseFailure.ts
index 22f13c622..b6166e174 100644
--- a/dapp/src/utils/promise.ts
+++ b/dapp/src/utils/logPromiseFailure.ts
@@ -4,7 +4,7 @@
*
* Does nothing to successful promises.
*/
-export function logPromiseFailure(promise: Promise) {
+export default function logPromiseFailure(promise: Promise) {
promise.catch((error) => {
console.error(error)
throw error
diff --git a/dapp/src/utils/numbers.ts b/dapp/src/utils/numbersUtils.ts
similarity index 90%
rename from dapp/src/utils/numbers.ts
rename to dapp/src/utils/numbersUtils.ts
index 0de6c8d4a..7075241e7 100644
--- a/dapp/src/utils/numbers.ts
+++ b/dapp/src/utils/numbersUtils.ts
@@ -1,8 +1,8 @@
-export function roundUp(amount: number, desiredDecimals = 2): number {
+function roundUp(amount: number, desiredDecimals = 2): number {
return Math.ceil(amount * 10 ** desiredDecimals) / 10 ** desiredDecimals
}
-export const numberToLocaleString = (
+const numberToLocaleString = (
value: string | number,
desiredDecimals = 0,
): string => {
@@ -26,7 +26,7 @@ export const numberToLocaleString = (
* Source:
* https://github.com/tahowallet/extension/blob/main/background/lib/fixed-point.ts#L216-L239
*/
-export function bigIntToUserAmount(
+function bigIntToUserAmount(
fixedPoint: bigint,
fixedPointDecimals: number,
desiredDecimals = 2,
@@ -54,7 +54,7 @@ export function bigIntToUserAmount(
* - Other amounts are formatted according to the use of the `bigIntToUserAmount` function.
*
*/
-export const formatTokenAmount = (
+const formatTokenAmount = (
amount: number | string | bigint,
decimals = 18,
desiredDecimals = 2,
@@ -86,7 +86,7 @@ export const formatTokenAmount = (
return numberToLocaleString(finalFormattedAmount, desiredDecimals)
}
-export const formatSatoshiAmount = (
+const formatSatoshiAmount = (
amount: number | string | bigint,
desiredDecimals = 2,
) => formatTokenAmount(amount, 8, desiredDecimals)
@@ -103,7 +103,7 @@ export const formatSatoshiAmount = (
* Source:
* https://github.com/tahowallet/extension/blob/main/background/lib/fixed-point.ts#L172-L214
*/
-export function fixedPointNumberToString(
+function fixedPointNumberToString(
amount: bigint,
decimals: number,
trimTrailingZeros = true,
@@ -198,10 +198,7 @@ function parseToFixedPointNumber(
* Then convert a fixed point bigint with precision `parsedAmount.decimals` to another
* fixed point bigint with precision `decimals`.
*/
-export function userAmountToBigInt(
- amount: string,
- decimals = 18,
-): bigint | undefined {
+function userAmountToBigInt(amount: string, decimals = 18): bigint | undefined {
const parsedAmount = parseToFixedPointNumber(amount)
if (typeof parsedAmount === "undefined") {
@@ -212,11 +209,24 @@ export function userAmountToBigInt(
}
// Generates a random integer in min-max range (inclusively)
-export const randomInteger = (min: number, max: number) =>
+const randomInteger = (min: number, max: number) =>
Math.floor(Math.random() * (max - min + 1)) + min
-export const addLeadingZero = (num: number): string =>
+const addLeadingZero = (num: number): string =>
num >= 0 && num <= 9 ? `0${num}` : `${num}`
-export const getPercentValue = (value: number, maxValue: number) =>
+const getPercentValue = (value: number, maxValue: number) =>
(value * 100) / maxValue
+
+export default {
+ roundUp,
+ numberToLocaleString,
+ bigIntToUserAmount,
+ formatTokenAmount,
+ formatSatoshiAmount,
+ fixedPointNumberToString,
+ userAmountToBigInt,
+ randomInteger,
+ addLeadingZero,
+ getPercentValue,
+}
diff --git a/dapp/src/utils/orangekit/index.ts b/dapp/src/utils/orangekit/index.ts
index f900de0c9..a839dc239 100644
--- a/dapp/src/utils/orangekit/index.ts
+++ b/dapp/src/utils/orangekit/index.ts
@@ -1,4 +1,4 @@
-import { ACRE_SESSION_EXPIRATION_TIME, wallets } from "#/constants"
+import { time, wallets } from "#/constants"
import { OrangeKitError, OrangeKitConnector } from "#/types"
import {
isUnsupportedBitcoinAddressError,
@@ -7,8 +7,8 @@ import {
import { Connector } from "wagmi"
import { SignInWithWalletMessage } from "@orangekit/sign-in-with-wallet"
import { ConnectionAlert } from "#/components/ConnectWalletModal/ConnectWalletAlert"
-import { getExpirationDate } from "../time"
import { getOrangeKitLedgerLiveConnector } from "./ledger-live"
+import timeUtils from "../timeUtils"
const getWalletInfo = (connector: OrangeKitConnector) => {
switch (connector.id) {
@@ -46,9 +46,9 @@ const createSignInWithWalletMessage = (address: string, nonce: string) => {
issuedAt: new Date().toISOString(),
version: "1",
networkFamily: "bitcoin",
- expirationTime: getExpirationDate(
- ACRE_SESSION_EXPIRATION_TIME,
- ).toISOString(),
+ expirationTime: timeUtils
+ .getExpirationDate(time.ACRE_SESSION_EXPIRATION_TIME)
+ .toISOString(),
nonce,
})
diff --git a/dapp/src/utils/orangekit/ledger-live/index.ts b/dapp/src/utils/orangekit/ledger-live/index.ts
index aa74b353a..5a9c9a669 100644
--- a/dapp/src/utils/orangekit/ledger-live/index.ts
+++ b/dapp/src/utils/orangekit/ledger-live/index.ts
@@ -1 +1,2 @@
+// eslint-disable-next-line import/prefer-default-export
export { default as getOrangeKitLedgerLiveConnector } from "./connector"
diff --git a/dapp/src/utils/time.ts b/dapp/src/utils/time.ts
deleted file mode 100644
index 6ff33dea0..000000000
--- a/dapp/src/utils/time.ts
+++ /dev/null
@@ -1,71 +0,0 @@
-import {
- DATE_FORMAT_LOCALE_TAG,
- ONE_DAY_IN_SECONDS,
- ONE_HOUR_IN_SECONDS,
- ONE_MINUTE_IN_SECONDS,
- ONE_SEC_IN_MILLISECONDS,
-} from "#/constants"
-import { TimeUnits } from "#/types"
-import { DateTime } from "luxon"
-
-export const dateToUnixTimestamp = (date: Date = new Date()) =>
- Math.floor(date.getTime() / ONE_SEC_IN_MILLISECONDS)
-
-export const unixTimestampToTimeUnits = (targetUnix: number): TimeUnits => {
- const days = Math.floor(targetUnix / ONE_DAY_IN_SECONDS)
- const hours = Math.floor(
- (targetUnix % ONE_DAY_IN_SECONDS) / ONE_HOUR_IN_SECONDS,
- )
- const minutes = Math.floor(
- (targetUnix % ONE_HOUR_IN_SECONDS) / ONE_MINUTE_IN_SECONDS,
- )
- const seconds = Math.floor(targetUnix % ONE_MINUTE_IN_SECONDS)
-
- return {
- days: days.toString(),
- hours: hours.toString(),
- minutes: minutes.toString(),
- seconds: seconds.toString(),
- }
-}
-
-export const timestampToRelativeTime = (timestamp: number) =>
- DateTime.fromMillis(timestamp).toRelative()
-
-export const blockTimestampToRelativeTime = (
- unixTimestamp: number,
-): string | null => {
- const time = unixTimestamp * ONE_SEC_IN_MILLISECONDS
- return timestampToRelativeTime(time)
-}
-
-// The function displays the date in the format: 21 Nov 2024, 16:02
-export const formatBlockTimestamp = (blockTimestamp: number) =>
- new Date(blockTimestamp * ONE_SEC_IN_MILLISECONDS).toLocaleString(
- DATE_FORMAT_LOCALE_TAG,
- {
- dateStyle: "medium",
- timeStyle: "short",
- },
- )
-
-export const displayBlockTimestamp = (blockTimestamp: number) => {
- const diff = Math.round(dateToUnixTimestamp() - blockTimestamp)
- const executedMoreThanDayAgo = diff > ONE_DAY_IN_SECONDS
-
- if (executedMoreThanDayAgo) return formatBlockTimestamp(blockTimestamp)
-
- return blockTimestampToRelativeTime(blockTimestamp)
-}
-
-export const getExpirationDate = (duration: number, startDate?: Date) => {
- const date = startDate ?? new Date()
- return new Date(date.getTime() + duration)
-}
-
-/**
- * Returns the expiration timestamp from the start date considering the specified duration.
- * If the startDate is not passed, the function will take the current time as the start date.
- */
-export const getExpirationTimestamp = (duration: number, startDate?: Date) =>
- dateToUnixTimestamp(getExpirationDate(duration, startDate))
diff --git a/dapp/src/utils/timeUtils.ts b/dapp/src/utils/timeUtils.ts
new file mode 100644
index 000000000..aa78dbda1
--- /dev/null
+++ b/dapp/src/utils/timeUtils.ts
@@ -0,0 +1,72 @@
+import { time } from "#/constants"
+import { TimeUnits } from "#/types"
+import { DateTime } from "luxon"
+
+const dateToUnixTimestamp = (date: Date = new Date()) =>
+ Math.floor(date.getTime() / time.ONE_SEC_IN_MILLISECONDS)
+
+const unixTimestampToTimeUnits = (targetUnix: number): TimeUnits => {
+ const days = Math.floor(targetUnix / time.ONE_DAY_IN_SECONDS)
+ const hours = Math.floor(
+ (targetUnix % time.ONE_DAY_IN_SECONDS) / time.ONE_HOUR_IN_SECONDS,
+ )
+ const minutes = Math.floor(
+ (targetUnix % time.ONE_HOUR_IN_SECONDS) / time.ONE_MINUTE_IN_SECONDS,
+ )
+ const seconds = Math.floor(targetUnix % time.ONE_MINUTE_IN_SECONDS)
+
+ return {
+ days: days.toString(),
+ hours: hours.toString(),
+ minutes: minutes.toString(),
+ seconds: seconds.toString(),
+ }
+}
+
+const timestampToRelativeTime = (timestamp: number) =>
+ DateTime.fromMillis(timestamp).toRelative()
+
+const blockTimestampToRelativeTime = (unixTimestamp: number): string | null =>
+ timestampToRelativeTime(unixTimestamp * time.ONE_SEC_IN_MILLISECONDS)
+
+// The function displays the date in the format: 21 Nov 2024, 16:02
+const formatBlockTimestamp = (blockTimestamp: number) =>
+ new Date(blockTimestamp * time.ONE_SEC_IN_MILLISECONDS).toLocaleString(
+ time.DATE_FORMAT_LOCALE_TAG,
+ {
+ dateStyle: "medium",
+ timeStyle: "short",
+ },
+ )
+
+const displayBlockTimestamp = (blockTimestamp: number) => {
+ const diff = Math.round(dateToUnixTimestamp() - blockTimestamp)
+ const executedMoreThanDayAgo = diff > time.ONE_DAY_IN_SECONDS
+
+ if (executedMoreThanDayAgo) return formatBlockTimestamp(blockTimestamp)
+
+ return blockTimestampToRelativeTime(blockTimestamp)
+}
+
+const getExpirationDate = (duration: number, startDate?: Date) => {
+ const date = startDate ?? new Date()
+ return new Date(date.getTime() + duration)
+}
+
+/**
+ * Returns the expiration timestamp from the start date considering the specified duration.
+ * If the startDate is not passed, the function will take the current time as the start date.
+ */
+const getExpirationTimestamp = (duration: number, startDate?: Date) =>
+ dateToUnixTimestamp(getExpirationDate(duration, startDate))
+
+export default {
+ dateToUnixTimestamp,
+ unixTimestampToTimeUnits,
+ timestampToRelativeTime,
+ blockTimestampToRelativeTime,
+ formatBlockTimestamp,
+ displayBlockTimestamp,
+ getExpirationDate,
+ getExpirationTimestamp,
+}
diff --git a/dapp/src/utils/type-check.ts b/dapp/src/utils/type-check.ts
index 2f9ea3491..f8c8e4018 100644
--- a/dapp/src/utils/type-check.ts
+++ b/dapp/src/utils/type-check.ts
@@ -1,13 +1,19 @@
-export function isObject(
+function isObject(
arg: unknown,
): arg is Record {
return typeof arg === "object" && arg !== null && !Array.isArray(arg)
}
-export function isString(arg: unknown): arg is string {
+function isString(arg: unknown): arg is string {
return typeof arg === "string"
}
-export function isNumber(arg: unknown): arg is number {
+function isNumber(arg: unknown): arg is number {
return typeof arg === "number"
}
+
+export default {
+ isObject,
+ isString,
+ isNumber,
+}
diff --git a/dapp/src/utils/verifyDepositAddress.ts b/dapp/src/utils/verifyDepositAddress.ts
index af1bd1222..a7041a007 100644
--- a/dapp/src/utils/verifyDepositAddress.ts
+++ b/dapp/src/utils/verifyDepositAddress.ts
@@ -1,4 +1,4 @@
-import { ONE_SEC_IN_MILLISECONDS } from "#/constants"
+import { time } from "#/constants"
import { BitcoinNetwork, DepositReceipt } from "@acre-btc/sdk"
import axios from "axios"
@@ -22,7 +22,7 @@ function createURL(deposit: DepositReceipt, network: BitcoinNetwork): string {
return extraData ? `${baseUrl}/${extraData.toString()}` : baseUrl
}
-export async function verifyDepositAddress(
+export default async function verifyDepositAddress(
deposit: DepositReceipt,
depositAddress: string,
network: BitcoinNetwork,
@@ -33,7 +33,7 @@ export async function verifyDepositAddress(
try {
const url = createURL(deposit, network)
const response = await axios.get<{ address: string }>(url, {
- timeout: ONE_SEC_IN_MILLISECONDS * 10,
+ timeout: time.ONE_SEC_IN_MILLISECONDS * 10,
})
const match = response.data.address === depositAddress
diff --git a/dapp/test/utils/activities.test.ts b/dapp/test/utils/activitiesUtils.test.ts
similarity index 77%
rename from dapp/test/utils/activities.test.ts
rename to dapp/test/utils/activitiesUtils.test.ts
index c25c4f93a..cc59ec042 100644
--- a/dapp/test/utils/activities.test.ts
+++ b/dapp/test/utils/activitiesUtils.test.ts
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest"
-import { getEstimatedDuration } from "#/utils/activities"
+import { activitiesUtils } from "#/utils"
describe("Utils functions for activities", () => {
describe("getEstimatedDuration", () => {
@@ -15,9 +15,12 @@ describe("Utils functions for activities", () => {
{ value: 10, expectedResult: "6 hours" },
])("when it is $value BTC", ({ value, expectedResult }) => {
it(`should return ${expectedResult}`, () => {
- expect(getEstimatedDuration(BigInt(value * 1e8), "withdraw")).toEqual(
- expectedResult,
- )
+ expect(
+ activitiesUtils.getEstimatedDuration(
+ BigInt(value * 1e8),
+ "withdraw",
+ ),
+ ).toEqual(expectedResult)
})
})
})
@@ -42,9 +45,12 @@ describe("Utils functions for activities", () => {
{ value: 10, expectedResult: "3 hours" },
])("when it is $value BTC", ({ value, expectedResult }) => {
it(`should return ${expectedResult}`, () => {
- expect(getEstimatedDuration(BigInt(value * 1e8), "deposit")).toEqual(
- expectedResult,
- )
+ expect(
+ activitiesUtils.getEstimatedDuration(
+ BigInt(value * 1e8),
+ "deposit",
+ ),
+ ).toEqual(expectedResult)
})
})
})
diff --git a/dapp/test/utils/numbers.test.ts b/dapp/test/utils/numbers.test.ts
index 1699ee0d7..9482666d0 100644
--- a/dapp/test/utils/numbers.test.ts
+++ b/dapp/test/utils/numbers.test.ts
@@ -1,5 +1,5 @@
+import { numbersUtils } from "#/utils"
import { describe, expect, it } from "vitest"
-import { roundUp } from "#/utils/numbers"
describe("Utils functions for numbers", () => {
describe("roundUp", () => {
@@ -10,7 +10,7 @@ describe("Utils functions for numbers", () => {
{ value: 2.1, desiredDecimals: 0, expectedValue: 3 },
])("when it is $value", ({ value, desiredDecimals, expectedValue }) => {
it(`should be rounded up to ${expectedValue}`, () => {
- const result = roundUp(value, desiredDecimals)
+ const result = numbersUtils.roundUp(value, desiredDecimals)
expect(result).toEqual(expectedValue)
})
})
@@ -21,7 +21,7 @@ describe("Utils functions for numbers", () => {
{ value: 2, desiredDecimals: 0 },
])("when it is $value", ({ value, desiredDecimals }) => {
it("should not be rounded up", () => {
- const result = roundUp(value, desiredDecimals)
+ const result = numbersUtils.roundUp(value, desiredDecimals)
expect(result).toEqual(value)
})
})