diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 8e2e71b..f306226 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -6,13 +6,10 @@ import "@burnt-labs/ui/dist/index.css"; import { ToastContainer } from "react-toastify"; import "react-toastify/dist/ReactToastify.css"; +import { dashboardUrl, rpcEndpoint } from "@/constants"; import BaseWrapper from "@/features/core/components/base-wrapper"; import { CoreProvider } from "@/features/core/context/provider"; import { StakingProvider } from "@/features/staking/context/provider"; -import { - dashboardUrl, - rpcEndpoint, -} from "@/features/staking/lib/core/constants"; import "./globals.css"; diff --git a/src/features/staking/lib/core/constants.ts b/src/constants.ts similarity index 100% rename from src/features/staking/lib/core/constants.ts rename to src/constants.ts diff --git a/src/features/core/components/base-wrapper.tsx b/src/features/core/components/base-wrapper.tsx index bcdaaa2..05b2b50 100644 --- a/src/features/core/components/base-wrapper.tsx +++ b/src/features/core/components/base-wrapper.tsx @@ -3,7 +3,7 @@ import { Abstraxion, useModal } from "@burnt-labs/abstraxion"; import Link from "next/link"; -import { basePath } from "@/features/staking/lib/core/constants"; +import { basePath } from "@/constants"; import NavAccount from "./nav-account"; diff --git a/src/features/core/components/base.tsx b/src/features/core/components/base.tsx index 769554b..dec7424 100644 --- a/src/features/core/components/base.tsx +++ b/src/features/core/components/base.tsx @@ -5,10 +5,9 @@ import type { FC, PropsWithChildren, ReactNode } from "react"; import { useState } from "react"; import { toast } from "react-toastify"; -import { clipboard, loader, search } from "@/features/staking/lib/core/icons"; - import { useCore } from "../context/hooks"; import { setPopupOpenId } from "../context/reducer"; +import { clipboard, loader, loader2, search } from "../lib/icons"; type TypographyProps = PropsWithChildren & { className?: string; @@ -310,3 +309,17 @@ export const TabButton = ({ active, ...props }: TabButtonProps) => ( ].join(" ")} /> ); + +export const LoadingBanner = () => ( +
+
+ Loading the data...{" "} +
+
+ +
+
+); diff --git a/src/features/core/components/common-modal.tsx b/src/features/core/components/common-modal.tsx index c5abcf6..5ef0d15 100644 --- a/src/features/core/components/common-modal.tsx +++ b/src/features/core/components/common-modal.tsx @@ -2,7 +2,7 @@ import type { PropsWithChildren } from "react"; import { useEffect } from "react"; import Modal from "react-modal"; -import { cross } from "@/features/staking/lib/core/icons"; +import { cross } from "../lib/icons"; type Props = { children: React.ReactNode; diff --git a/src/features/core/components/nav-account.tsx b/src/features/core/components/nav-account.tsx index e0690c5..00187a7 100644 --- a/src/features/core/components/nav-account.tsx +++ b/src/features/core/components/nav-account.tsx @@ -7,9 +7,9 @@ import { } from "@burnt-labs/abstraxion"; import { Button } from "@burnt-labs/ui"; -import { isTestnet } from "@/features/staking/lib/core/constants"; -import { wallet } from "@/features/staking/lib/core/icons"; +import { isTestnet } from "@/constants"; +import { wallet } from "../lib/icons"; import { ButtonPill, FloatingDropdown } from "./base"; const Account = () => ( diff --git a/src/features/core/components/table.tsx b/src/features/core/components/table.tsx index 2a82645..d6c1e85 100644 --- a/src/features/core/components/table.tsx +++ b/src/features/core/components/table.tsx @@ -1,6 +1,6 @@ import type { PropsWithChildren } from "react"; -import { chevron } from "@/features/staking/lib/core/icons"; +import { chevron } from "../lib/icons"; type Props = PropsWithChildren & { onSort?: (method: SortMethod) => void; diff --git a/src/features/staking/lib/core/icons.ts b/src/features/core/lib/icons.ts similarity index 100% rename from src/features/staking/lib/core/icons.ts rename to src/features/core/lib/icons.ts index f44bd4c..c440a16 100644 --- a/src/features/staking/lib/core/icons.ts +++ b/src/features/core/lib/icons.ts @@ -1,9 +1,45 @@ -export const chevron = - ''; +export const loader2 = [ + '', + '', + "", + '', + '', + '', + "", + "", + "", +].join(""); + +export const search = [ + '', + '', + "", +].join(""); + +export const loader = [ + '', + '', + "", + '', + "", + '', + "", + "", + "", +].join(""); export const clipboard = ''; +export const chevron = + ''; + +export const cross = [ + '', + '', + "", +].join(""); + export const wallet = [ '', '', @@ -12,12 +48,6 @@ export const wallet = [ "", ].join(""); -export const cross = [ - '', - '', - "", -].join(""); - export const pointer = [ '', '', @@ -32,33 +62,3 @@ export const menu = [ '', "", ].join(""); - -export const loader = [ - '', - '', - "", - '', - "", - '', - "", - "", - "", -].join(""); - -export const loader2 = [ - '', - '', - "", - '', - '', - '', - "", - "", - "", -].join(""); - -export const search = [ - '', - '', - "", -].join(""); diff --git a/src/features/staking/components/delegation-details.tsx b/src/features/staking/components/delegation-details.tsx index 747d73a..d87c10f 100644 --- a/src/features/staking/components/delegation-details.tsx +++ b/src/features/staking/components/delegation-details.tsx @@ -7,6 +7,7 @@ import { FloatingDropdown, } from "@/features/core/components/base"; import { HeaderTitleBase } from "@/features/core/components/table"; +import { menu, pointer } from "@/features/core/lib/icons"; import { sortUtil } from "@/features/core/utils"; import { getAndSetValidatorAction } from "../context/actions"; @@ -20,7 +21,6 @@ import { import type { StakingContextType, StakingState } from "../context/state"; import { useValidatorLogo } from "../hooks"; import { coinIsPositive } from "../lib/core/coins"; -import { menu, pointer } from "../lib/core/icons"; import { formatCoin, formatCommission, diff --git a/src/features/staking/components/modals/staking.tsx b/src/features/staking/components/modals/staking.tsx index a33fd4b..e304cba 100644 --- a/src/features/staking/components/modals/staking.tsx +++ b/src/features/staking/components/modals/staking.tsx @@ -3,6 +3,7 @@ import type { FormEventHandler } from "react"; import { useEffect, useState } from "react"; import { toast } from "react-toastify"; +import { xionToUSD } from "@/constants"; import { Button, FormError, @@ -21,7 +22,6 @@ import { useStaking } from "../../context/hooks"; import { setModalOpened } from "../../context/reducer"; import { getTokensAvailableBG } from "../../context/selectors"; import { getXionCoin } from "../../lib/core/coins"; -import { xionToUSD } from "../../lib/core/constants"; import type { StakeAddresses } from "../../lib/core/tx"; import { formatToSmallDisplay } from "../../lib/formatters"; diff --git a/src/features/staking/components/modals/unstaking.tsx b/src/features/staking/components/modals/unstaking.tsx index 8e9c090..8877c96 100644 --- a/src/features/staking/components/modals/unstaking.tsx +++ b/src/features/staking/components/modals/unstaking.tsx @@ -3,6 +3,7 @@ import type { FormEventHandler } from "react"; import { useEffect, useState } from "react"; import { toast } from "react-toastify"; +import { unbondingDays, xionToUSD } from "@/constants"; import { Button, FormError, @@ -21,7 +22,6 @@ import { useStaking } from "../../context/hooks"; import { setModalOpened } from "../../context/reducer"; import { getTotalDelegation } from "../../context/selectors"; import { getXionCoin } from "../../lib/core/coins"; -import { unbondingDays, xionToUSD } from "../../lib/core/constants"; import type { StakeAddresses } from "../../lib/core/tx"; import { formatToSmallDisplay, formatXionToUSD } from "../../lib/formatters"; diff --git a/src/features/staking/components/staking-overview.tsx b/src/features/staking/components/staking-overview.tsx index ad5b1d8..1df6f58 100644 --- a/src/features/staking/components/staking-overview.tsx +++ b/src/features/staking/components/staking-overview.tsx @@ -1,6 +1,7 @@ import { useAbstraxionAccount, useModal } from "@burnt-labs/abstraxion"; import { memo } from "react"; +import { basePath } from "@/constants"; import { BodyMedium, Button, @@ -18,7 +19,6 @@ import { getTotalRewards, } from "../context/selectors"; import { getEmptyXionCoin } from "../lib/core/coins"; -import { basePath } from "../lib/core/constants"; import { getIsMinimumClaimable } from "../lib/core/tx"; import { formatAPR, formatCoin, formatXionToUSD } from "../lib/formatters"; import { DivisorVertical } from "./divisor"; diff --git a/src/features/staking/components/validator-page.tsx b/src/features/staking/components/validator-page.tsx index 84103c8..bbb30ae 100644 --- a/src/features/staking/components/validator-page.tsx +++ b/src/features/staking/components/validator-page.tsx @@ -7,10 +7,12 @@ import Link from "next/link"; import { useSearchParams } from "next/navigation"; import { useEffect, useState } from "react"; +import { basePath, defaultAvatar } from "@/constants"; import { ClipboardCopy, Heading2, Heading8, + LoadingBanner, NavLink, } from "@/features/core/components/base"; @@ -24,7 +26,6 @@ import { } from "../context/selectors"; import { useValidatorLogo } from "../hooks"; import { getXionCoin, normaliseCoin } from "../lib/core/coins"; -import { basePath, defaultAvatar } from "../lib/core/constants"; import { formatCommission, formatToSmallDisplay, @@ -60,7 +61,11 @@ export default function ValidatorPage() { }, [address, stakingRef]); if (!validatorDetails) { - return
Loading the data...
; + return ( +
+ +
+ ); } const votingPowerPerc = getVotingPowerPerc( diff --git a/src/features/staking/components/validators-table.tsx b/src/features/staking/components/validators-table.tsx index 7d467d8..6c05f53 100644 --- a/src/features/staking/components/validators-table.tsx +++ b/src/features/staking/components/validators-table.tsx @@ -6,6 +6,7 @@ import { memo, useState } from "react"; import { ButtonPill, + LoadingBanner, NavLink, SearchInput, TabButton, @@ -23,7 +24,6 @@ import { import type { StakingContextType, StakingState } from "../context/state"; import { useValidatorLogo } from "../hooks"; import { getXionCoinFromUXion } from "../lib/core/coins"; -import { loader2 } from "../lib/core/icons"; import { formatCoin, formatCommission, @@ -293,19 +293,7 @@ const ValidatorsTable = () => {
Voting Power
- {isInitialLoading && ( -
-
- Loading the data...{" "} -
-
- -
-
- )} + {isInitialLoading && } {sortedItems.map((validator) => ( { diff --git a/src/features/staking/lib/core/client.ts b/src/features/staking/lib/core/client.ts index 213b0c9..6194788 100644 --- a/src/features/staking/lib/core/client.ts +++ b/src/features/staking/lib/core/client.ts @@ -18,7 +18,7 @@ import { } from "@cosmjs/stargate"; import { Tendermint34Client } from "@cosmjs/tendermint-rpc"; -import { rpcEndpoint } from "./constants"; +import { rpcEndpoint } from "@/constants"; export type AbstraxionSigningClient = NonNullable< ReturnType["client"] diff --git a/src/features/staking/lib/core/tx.ts b/src/features/staking/lib/core/tx.ts index 88c3389..ea971ac 100644 --- a/src/features/staking/lib/core/tx.ts +++ b/src/features/staking/lib/core/tx.ts @@ -13,10 +13,11 @@ import { MsgUndelegate, } from "cosmjs-types/cosmos/staking/v1beta1/tx"; +import { minClaimableXion } from "@/constants"; + import type { Unbonding } from "../../context/state"; import { type AbstraxionSigningClient } from "./client"; import { getUXionCoinFromXion, normaliseCoin } from "./coins"; -import { minClaimableXion } from "./constants"; import { getCosmosFee } from "./fee"; const getTxCoin = (coin: Coin) => ({ diff --git a/src/features/staking/lib/formatters.ts b/src/features/staking/lib/formatters.ts index 8d14d95..74df4de 100644 --- a/src/features/staking/lib/formatters.ts +++ b/src/features/staking/lib/formatters.ts @@ -1,8 +1,9 @@ import type { Coin } from "@cosmjs/stargate"; import BigNumber from "bignumber.js"; +import { xionToUSD } from "@/constants"; + import { getEmptyXionCoin, normaliseCoin } from "./core/coins"; -import { xionToUSD } from "./core/constants"; export const formatCoin = (coin: Coin, compact?: boolean) => { const resolved = normaliseCoin(coin);