diff --git a/app/ZetaChainContext.tsx b/app/ZetaChainContext.tsx deleted file mode 100644 index 1332201..0000000 --- a/app/ZetaChainContext.tsx +++ /dev/null @@ -1,41 +0,0 @@ -import React, { ReactNode, createContext, useContext, useState } from "react" -import { ZetaChainClient } from "@zetachain/toolkit/client" - -const ZetaChainContext = createContext(undefined!) - -interface ZetaChainProviderProps { - children: ReactNode -} - -export function ZetaChainProvider({ children }: ZetaChainProviderProps) { - const [client] = useState( - () => - new ZetaChainClient({ - network: "testnet", - chains: { - zeta_testnet: { - api: [ - { - url: `https://zetachain-athens.g.allthatnode.com/archive/evm/${process.env.NEXT_PUBLIC_ATN_KEY}`, - type: "evm", - }, - ], - }, - }, - }) - ) - - return ( - - {children} - - ) -} - -export function useZetaChain(): any { - const context = useContext(ZetaChainContext) - if (context === undefined) { - throw new Error("useZetaChain must be used within a ZetaChainProvider") - } - return context -} diff --git a/app/index.tsx b/app/index.tsx index c7283c9..66533f9 100644 --- a/app/index.tsx +++ b/app/index.tsx @@ -1,431 +1,29 @@ "use client" -import { EvmPriceServiceConnection } from "@pythnetwork/pyth-evm-js" +import { AppProvider } from "@/context/AppContext" -import "@/styles/globals.css" -import { createContext, useCallback, useEffect, useState } from "react" -import { getEndpoints } from "@zetachain/networks/dist/src/getEndpoints" -import EventEmitter from "eventemitter3" -// @ts-ignore -import Cookies from "js-cookie" -import debounce from "lodash/debounce" -import { useAccount } from "wagmi" - -import { hexToBech32Address } from "@/lib/hexToBech32Address" import { Toaster } from "@/components/ui/toaster" -import { useToast } from "@/components/ui/use-toast" import { SiteHeader } from "@/components/site-header" import { ThemeProvider } from "@/components/theme-provider" -import { useZetaChain } from "./ZetaChainContext" import { NFTProvider } from "./nft/useNFT" interface RootLayoutProps { children: React.ReactNode } -export const AppContext = createContext(null) - export default function Index({ children }: RootLayoutProps) { - const { client } = useZetaChain() - - const [balances, setBalances] = useState([]) - const [balancesLoading, setBalancesLoading] = useState(true) - const [balancesRefreshing, setBalancesRefreshing] = useState(false) - const [bitcoinAddress, setBitcoinAddress] = useState("") - const [fees, setFees] = useState([]) - const [pools, setPools] = useState([]) - const [poolsLoading, setPoolsLoading] = useState(false) - const [validators, setValidators] = useState([]) - const [validatorsLoading, setValidatorsLoading] = useState(false) - const [stakingDelegations, setStakingDelegations] = useState([]) - const [stakingRewards, setStakingRewards] = useState([]) - const [unbondingDelegations, setUnbondingDelegations] = useState([]) - const [observers, setObservers] = useState([]) - const [prices, setPrices] = useState([]) - const { address, isConnected } = useAccount() - const { toast } = useToast() - - const fetchObservers = useCallback( - debounce(async () => { - try { - const api = getEndpoints("cosmos-http", "zeta_testnet")[0]?.url - const url = `${api}/zeta-chain/observer/nodeAccount` - const response = await fetch(url) - const data = await response.json() - setObservers(data.NodeAccount) - } catch (e) { - console.error(e) - } - }, 500), - [] - ) - - const fetchUnbondingDelegations = useCallback( - debounce(async () => { - try { - if (!isConnected) { - return setUnbondingDelegations([]) - } - const api = getEndpoints("cosmos-http", "zeta_testnet")[0]?.url - const addr = hexToBech32Address(address as any, "zeta") - const url = `${api}/cosmos/staking/v1beta1/delegators/${addr}/unbonding_delegations` - const response = await fetch(url) - const data = await response.json() - setUnbondingDelegations(data.unbonding_responses) - } catch (e) { - console.error(e) - } - }, 500), - [address, isConnected] - ) - - const connectBitcoin = async () => { - const w = window as any - console.log("connect bitcoin") - if ("xfi" in w && w.xfi?.bitcoin) { - w.xfi.bitcoin.changeNetwork("testnet") - const btc = (await w.xfi.bitcoin.getAccounts())[0] - await setBitcoinAddress(btc) - // fetchBalances(true, btc) - } - } - - const fetchStakingDelegations = useCallback( - debounce(async () => { - try { - if (!isConnected) { - return setStakingDelegations([]) - } - const api = getEndpoints("cosmos-http", "zeta_testnet")[0]?.url - const addr = hexToBech32Address(address as any, "zeta") - const url = `${api}/cosmos/staking/v1beta1/delegations/${addr}` - const response = await fetch(url) - const data = await response.json() - setStakingDelegations(data.delegation_responses) - } catch (e) { - console.error(e) - } - }, 500), - [address, isConnected] - ) - - const fetchStakingRewards = useCallback( - debounce(async () => { - try { - if (!isConnected) { - return setStakingRewards([]) - } - const api = getEndpoints("cosmos-http", "zeta_testnet")[0]?.url - const addr = hexToBech32Address(address as any, "zeta") - const url = `${api}/cosmos/distribution/v1beta1/delegators/${addr}/rewards` - const response = await fetch(url) - const data = await response.json() - setStakingRewards(data.rewards) - } catch (e) { - console.error(e) - } - }, 500), - [address, isConnected] - ) - - const fetchValidators = useCallback( - debounce(async () => { - setValidatorsLoading(true) - let allValidators: any[] = [] - let nextKey: any = null - - try { - if (!isConnected) { - setValidatorsLoading(false) - setValidators([]) - } - const api = getEndpoints("cosmos-http", "zeta_testnet")[0]?.url - - const fetchBonded = async () => { - const response = await fetch(`${api}/cosmos/staking/v1beta1/pool`) - const data = await response.json() - return data - } - - const fetchPage = async (key: string) => { - const endpoint = "/cosmos/staking/v1beta1/validators" - const query = `pagination.key=${encodeURIComponent(key)}` - const url = `${api}${endpoint}?${key && query}` - - const response = await fetch(url) - const data = await response.json() - - allValidators = allValidators.concat(data.validators) - - if (data.pagination && data.pagination.next_key) { - await fetchPage(data.pagination.next_key) - } - } - const pool = (await fetchBonded())?.pool - const tokens = parseInt(pool.bonded_tokens) - await fetchPage(nextKey) - allValidators = allValidators.map((v) => { - return { - ...v, - voting_power: tokens ? (parseInt(v.tokens) / tokens) * 100 : 0, - } - }) - } catch (e) { - console.error(e) - } finally { - setValidators(allValidators) - setValidatorsLoading(false) - } - }, 500), - [address, isConnected] - ) - - const fetchBalances = useCallback( - debounce(async (refresh: Boolean = false, btc: any = null) => { - if (refresh) setBalancesRefreshing(true) - if (balances.length === 0) setBalancesLoading(true) - try { - if (!isConnected) { - return setBalances([]) - } - const b = await client.getBalances({ - evmAddress: address, - btcAddress: btc, - }) - setBalances(b) - } catch (e) { - console.log(e) - } finally { - setBalancesRefreshing(false) - setBalancesLoading(false) - } - }, 500), - [isConnected, address] - ) - - const fetchFeesList = useCallback( - debounce(async () => { - try { - if (!isConnected) { - return setFees([]) - } - setFees(await client.getFees(500000)) - } catch (e) { - console.log(e) - } - }, 500), - [] - ) - - const fetchPools = useCallback( - debounce(async () => { - setPoolsLoading(true) - try { - setPools(await client.getPools()) - } catch (e) { - console.log(e) - } finally { - setPoolsLoading(false) - } - }, 500), - [] - ) - - useEffect(() => { - fetchBalances(true) - fetchFeesList() - fetchStakingDelegations() - fetchPrices() - }, [isConnected, address]) - - const fetchPrices = useCallback( - debounce(async () => { - let priceIds: any = [] - const api = getEndpoints("cosmos-http", "zeta_testnet")[0]?.url - - const zetaChainUrl = `${api}/zeta-chain/fungible/foreign_coins` - const pythNetworkUrl = "https://benchmarks.pyth.network/v1/price_feeds/" - - try { - const zetaResponse = await fetch(zetaChainUrl) - const zetaData = await zetaResponse.json() - const foreignCoins = zetaData.foreignCoins - const symbolsFromZeta = foreignCoins.map((coin: any) => - coin.symbol.replace(/^[tg]/, "") - ) - - const pythResponse = await fetch(pythNetworkUrl) - const pythData = await pythResponse.json() - const priceFeeds = pythData - - priceIds = priceFeeds - .filter((feed: any) => { - const base = symbolsFromZeta.includes(feed.attributes.base) - const quote = feed.attributes.quote_currency === "USD" - return base && quote - }) - .map((feed: any) => ({ - symbol: feed.attributes.base, - id: feed.id, - })) - } catch (error) { - console.error("Error fetching or processing data:", error) - return [] - } - const connection = new EvmPriceServiceConnection( - "https://hermes.pyth.network" - ) - - const priceFeeds = await connection.getLatestPriceFeeds( - priceIds.map((p: any) => p.id) - ) - - setPrices( - priceFeeds?.map((p: any) => { - const pr = p.getPriceNoOlderThan(60) - return { - id: p.id, - symbol: priceIds.find((i: any) => i.id === p.id)?.symbol, - price: parseInt(pr.price) * 10 ** pr.expo, - } - }) - ) - }, 500), - [] - ) - - const [inbounds, setInbounds] = useState([]) - const [cctxs, setCCTXs] = useState([]) - - const updateCCTX = (updatedItem: any) => { - setCCTXs((prevItems: any) => { - const index = prevItems.findIndex( - (item: any) => item.inboundHash === updatedItem.inboundHash - ) - - if (index === -1) return prevItems - - const newItems = [...prevItems] - newItems[index] = { - ...newItems[index], - ...updatedItem, - } - - return newItems - }) - } - - useEffect(() => { - const cctxList = cctxs.map((c: any) => c.inboundHash) - for (let i of inbounds) { - if (!cctxList.includes(i.inboundHash)) { - const emitter = new EventEmitter() - emitter - .on("search-add", ({ text }) => { - updateCCTX({ - inboundHash: i.inboundHash, - progress: text, - status: "searching", - }) - }) - .on("add", ({ text }) => { - updateCCTX({ - inboundHash: i.inboundHash, - progress: text, - status: "searching", - }) - }) - .on("succeed", ({ text }) => { - updateCCTX({ - inboundHash: i.inboundHash, - progress: text, - status: "succeed", - }) - }) - .on("fail", ({ text }) => { - updateCCTX({ - inboundHash: i.inboundHash, - progress: text, - status: "failed", - }) - }) - .on("mined-success", (value) => { - updateCCTX({ - inboundHash: i.inboundHash, - status: "mined-success", - ...value, - }) - }) - .on("mined-fail", (value) => { - updateCCTX({ - inboundHash: i.inboundHash, - status: "mined-fail", - ...value, - }) - }) - - client.trackCCTX(i.inboundHash, false, emitter) - setCCTXs([...cctxs, { inboundHash: i.inboundHash, desc: i.desc }]) - } - } - }, [inbounds]) - - useEffect(() => { - if (!Cookies.get("firstTimeVisit")) { - toast({ - title: "Welcome to ZetaChain Example App", - description: "This is a testnet. Please do not use real funds.", - duration: 60000, - }) - Cookies.set("firstTimeVisit", "true", { expires: 7 }) - } - }, []) - return ( - <> - - - -
- -
{children}
-
- -
-
-
- + + + +
+ +
{children}
+
+ +
+
+
) } diff --git a/app/layout.tsx b/app/layout.tsx index 16a292c..a70a960 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,6 +1,7 @@ "use client" import "@/styles/globals.css" +import { Inter as FontSans } from "next/font/google" import { injectedWallet, metaMaskWallet, @@ -8,23 +9,16 @@ import { xdefiWallet, } from "@rainbow-me/rainbowkit/wallets" -import { fontSans } from "@/lib/fonts" -import { cn } from "@/lib/utils" +import { ZetaChainProvider } from "@/hooks/useZetaChainClient" import Index from "@/app/index" -import { ZetaChainProvider } from "./ZetaChainContext" import "@rainbow-me/rainbowkit/styles.css" import { RainbowKitProvider, connectorsForWallets, } from "@rainbow-me/rainbowkit" import { WagmiConfig, configureChains, createConfig } from "wagmi" -import { - bscTestnet, - polygonMumbai, - sepolia, - zetachainAthensTestnet, -} from "wagmi/chains" +import { bscTestnet, sepolia, zetachainAthensTestnet } from "wagmi/chains" import { publicProvider } from "wagmi/providers/public" interface RootLayoutProps { @@ -34,7 +28,6 @@ interface RootLayoutProps { const { chains, publicClient, webSocketPublicClient } = configureChains( [ sepolia, - polygonMumbai, bscTestnet, { ...zetachainAthensTestnet, @@ -63,26 +56,26 @@ const wagmiConfig = createConfig({ webSocketPublicClient, }) +const fontSans = FontSans({ + subsets: ["latin"], + variable: "--font-sans", +}) + export default function RootLayout({ children }: RootLayoutProps) { return ( - <> - - - - - - - {children} - - - - - - + + + + + + + {children} + + + + + ) } diff --git a/app/messaging/page.tsx b/app/messaging/page.tsx index 76f6865..91daf2d 100644 --- a/app/messaging/page.tsx +++ b/app/messaging/page.tsx @@ -2,6 +2,7 @@ import { useCallback, useContext, useEffect, useState } from "react" import Link from "next/link" +import { useAppContext } from "@/context/AppContext" import UniswapV2Factory from "@uniswap/v2-periphery/build/IUniswapV2Router02.json" import Quoter from "@uniswap/v3-periphery/artifacts/contracts/lens/Quoter.sol/Quoter.json" import { getExplorers } from "@zetachain/networks" @@ -20,8 +21,7 @@ import { useWaitForTransaction, } from "wagmi" -import { useEthersSigner } from "@/lib/ethers" -import { cn } from "@/lib/utils" +import { useEthersSigner } from "@/hooks/useEthersSigner" import { Alert, AlertDescription } from "@/components/ui/alert" import { Button } from "@/components/ui/button" import { Card } from "@/components/ui/card" @@ -36,7 +36,6 @@ import { SelectTrigger, SelectValue, } from "@/components/ui/select" -import { AppContext } from "@/app/index" const contracts: any = { goerli_testnet: "0x122F9Cca5121F23b74333D5FBd0c5D9B413bc002", @@ -73,7 +72,7 @@ const MessagingPage = () => { (networks as any)[destinationNetwork]?.chain_id ?? null ) }, [destinationNetwork]) - const { inbounds, setInbounds, fees } = useContext(AppContext) + const { inbounds, setInbounds, fees } = useAppContext() const { config, @@ -347,7 +346,7 @@ const MessagingPage = () => { disabled checked={!!destinationNetwork} /> - + First, select the destination network @@ -361,13 +360,13 @@ const MessagingPage = () => { )}
  • - + Next, write a message in the input field
  • - + Finally, click Send message and confirm in your wallet
  • diff --git a/app/nft/burn.ts b/app/nft/burn.ts index fbd2e0c..0d8c3e8 100644 --- a/app/nft/burn.ts +++ b/app/nft/burn.ts @@ -1,10 +1,10 @@ import { useContext } from "react" +import { useAppContext } from "@/context/AppContext" import { abi } from "@zetachain/example-contracts/abi/omnichain/NFT.sol/NFT.json" import { ethers } from "ethers" import { useAccount } from "wagmi" -import { useEthersSigner } from "@/lib/ethers" -import { AppContext } from "@/app/index" +import { useEthersSigner } from "@/hooks/useEthersSigner" import { useFetchNFTs } from "./fetchNFTs" import { useNFT } from "./useNFT" @@ -16,7 +16,7 @@ export const useBurn = () => { setAssetsBurned, omnichainContract, } = useNFT() - const { setInbounds, inbounds } = useContext(AppContext) + const { setInbounds, inbounds } = useAppContext() const { address } = useAccount() const signer = useEthersSigner() const { fetchNFTs } = useFetchNFTs() diff --git a/app/nft/fetchNFTs.ts b/app/nft/fetchNFTs.ts index 1ceb9f2..ca21610 100644 --- a/app/nft/fetchNFTs.ts +++ b/app/nft/fetchNFTs.ts @@ -59,7 +59,6 @@ export const useFetchNFTs = () => { const { address } = useAccount() const fetchNFTs = async () => { - console.log("Fetching NFTs...") setAssetsReloading(true) try { let ownedNFTs: any = [] @@ -96,7 +95,7 @@ export const useFetchNFTs = () => { assets.sort((a: any, b: any) => parseInt(b.id) - parseInt(a.id)) setAssets(assets) } catch (e) { - console.log(e) + console.error(e) } finally { setAssetsReloading(false) } diff --git a/app/nft/mint.ts b/app/nft/mint.ts index c3035e8..10346f2 100644 --- a/app/nft/mint.ts +++ b/app/nft/mint.ts @@ -1,12 +1,12 @@ import { useContext } from "react" +import { useAppContext } from "@/context/AppContext" import { networks } from "@zetachain/networks" import { getAddress } from "@zetachain/protocol-contracts" import { prepareData } from "@zetachain/toolkit/client" import { parseEther } from "viem" import { useAccount } from "wagmi" -import { useEthersSigner } from "@/lib/ethers" -import { AppContext } from "@/app/index" +import { useEthersSigner } from "@/hooks/useEthersSigner" import { useNFT } from "./useNFT" @@ -14,7 +14,7 @@ export const useMint = () => { const { amount, setAmount, setMintingInProgress, omnichainContract } = useNFT() const { bitcoinAddress, setInbounds, inbounds, connectBitcoin } = - useContext(AppContext) + useAppContext() const { address } = useAccount() const signer = useEthersSigner() diff --git a/app/nft/page.tsx b/app/nft/page.tsx index 0fbca11..ce64953 100644 --- a/app/nft/page.tsx +++ b/app/nft/page.tsx @@ -1,6 +1,7 @@ "use client" import { useContext, useEffect } from "react" +import { useAppContext } from "@/context/AppContext" import { AnimatePresence, motion } from "framer-motion" import { debounce } from "lodash" import { Flame, Loader, RefreshCw, Send, Sparkles } from "lucide-react" @@ -21,7 +22,6 @@ import { SelectTrigger, SelectValue, } from "@/components/ui/select" -import { AppContext } from "@/app/index" import { useBurn } from "./burn" import { useFetchNFTs } from "./fetchNFTs" @@ -44,7 +44,7 @@ const NFTPage = () => { setRecipient, foreignCoins, } = useNFT() - const { cctxs } = useContext(AppContext) + const { cctxs } = useAppContext() const { switchNetwork } = useSwitchNetwork() const { chain } = useNetwork() const { transfer } = useTransfer() diff --git a/app/nft/transfer.ts b/app/nft/transfer.ts index 91972b2..c2f1a9f 100644 --- a/app/nft/transfer.ts +++ b/app/nft/transfer.ts @@ -2,7 +2,7 @@ import { abi } from "@zetachain/example-contracts/abi/omnichain/NFT.sol/NFT.json import { ethers } from "ethers" import { useAccount } from "wagmi" -import { useEthersSigner } from "@/lib/ethers" +import { useEthersSigner } from "@/hooks/useEthersSigner" import { useFetchNFTs } from "./fetchNFTs" import { useNFT } from "./useNFT" diff --git a/app/page.tsx b/app/page.tsx index 79bd04d..6a0c108 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,30 +1,15 @@ "use client" -import { useContext, useEffect, useState } from "react" -import Link from "next/link" -import { - ArrowBigUp, - ChevronDown, - ChevronUp, - MessageCircle, - RefreshCw, -} from "lucide-react" -import { formatUnits } from "viem" +import { useEffect, useState } from "react" +import { useAppContext } from "@/context/AppContext" +import { RefreshCw } from "lucide-react" import { useAccount } from "wagmi" import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert" import { Button } from "@/components/ui/button" import { Skeleton } from "@/components/ui/skeleton" -import { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, -} from "@/components/ui/table" -import Transfer from "@/components/transfer" -import { AppContext } from "@/app/index" +import BalancesTable from "@/components/BalancesTable" +import Swap from "@/components/swap" const LoadingSkeleton = () => { return ( @@ -38,83 +23,6 @@ const LoadingSkeleton = () => { ) } -const BalancesTable = ({ - balances, - showAll, - toggleShowAll, - stakingAmountTotal, -}: any) => { - return ( -
    - - - - Asset - Type - Price - Balance - - - - {balances - .slice(0, showAll ? balances.length : 5) - .map((b: any, index: any) => ( - - -
    {b.ticker}
    -
    {b.chain_name}
    -
    - {b.coin_type} - - {b.price?.toFixed(2)} - - - {parseFloat(b.balance).toFixed(2) || "N/A"} - {b.ticker === "ZETA" && b.coin_type === "Gas" && ( -
    - -
    - )} -
    -
    - ))} -
    -
    - {balances?.length > 5 && ( -
    - -
    - )} -
    - ) -} - const ConnectWallet = () => { return ( @@ -134,7 +42,7 @@ export default function IndexPage() { fetchBalances, prices, stakingDelegations, - } = useContext(AppContext) + } = useAppContext() const [sortedBalances, setSortedBalances] = useState([]) const [showAll, setShowAll] = useState(false) @@ -150,12 +58,10 @@ export default function IndexPage() { const balancesPrices = sortedBalances.map((balance: any) => { const normalizeSymbol = (symbol: string) => symbol.replace(/^[tg]/, "") - const normalizedSymbol = normalizeSymbol(balance.symbol) const priceObj = prices.find( (price: any) => normalizeSymbol(price.symbol) === normalizedSymbol ) - return { ...balance, price: priceObj ? priceObj.price : null, @@ -173,20 +79,18 @@ export default function IndexPage() { // Prioritize ZETA if (a.ticker === "ZETA" && a.coin_type === "Gas") return -1 if (b.ticker === "ZETA" && b.coin_type === "Gas") return 1 - if (a.coin_type === "Gas" && b.coin_type !== "Gas") return -1 if (a.coin_type !== "Gas" && b.coin_type === "Gas") return 1 return a.chain_name < b.chain_name ? -1 : 1 }) - .filter((b: any) => { - return b.balance > 0 - }) + .filter((b: any) => b.balance > 0) setSortedBalances(balance) }, [balances]) - const balancesTotal = balancesPrices.reduce((a: any, c: any) => { - return a + parseFloat(c.balance) - }, 0) + const balancesTotal = balancesPrices.reduce( + (a: any, c: any) => a + parseFloat(c.balance), + 0 + ) const formatBalanceTotal = (b: string) => { if (parseFloat(b) > 1000) { @@ -199,7 +103,7 @@ export default function IndexPage() { return (
    -
    +
    Total balance
    @@ -227,17 +131,9 @@ export default function IndexPage() { ) : ( )} -
    - - - -
    - +
    diff --git a/app/pools/page.tsx b/app/pools/page.tsx index 9613562..c3e9d6a 100644 --- a/app/pools/page.tsx +++ b/app/pools/page.tsx @@ -1,16 +1,16 @@ "use client" import { useContext, useEffect, useState } from "react" +import { useAppContext } from "@/context/AppContext" import { formatUnits } from "viem" import { useAccount } from "wagmi" import { Card } from "@/components/ui/card" import { Skeleton } from "@/components/ui/skeleton" -import { AppContext } from "@/app/index" const PoolsPage = () => { const { pools, balances, balancesLoading, poolsLoading, fetchPools } = - useContext(AppContext) + useAppContext() const [poolsSorted, setPoolsSorted] = useState([]) const { address, isConnected } = useAccount() diff --git a/app/staking/page.tsx b/app/staking/page.tsx index 99add30..043f32b 100644 --- a/app/staking/page.tsx +++ b/app/staking/page.tsx @@ -2,6 +2,7 @@ import { useCallback, useContext, useEffect, useState } from "react" import Link from "next/link" +import { useAppContext } from "@/context/AppContext" import { generatePostBodyBroadcast } from "@evmos/provider" import { createTxMsgBeginRedelegate, @@ -67,7 +68,6 @@ import { TableRow, } from "@/components/ui/table" import { useToast } from "@/components/ui/use-toast" -import { AppContext } from "@/app/index" const StakingPage = () => { const { @@ -84,7 +84,7 @@ const StakingPage = () => { fetchBalances, observers, fetchObservers, - } = useContext(AppContext) + } = useAppContext() const [selectedValidator, setSelectedValidator] = useState(null) const [isSending, setIsSending] = useState(false) const [isZetaChain, setIsZetaChain] = useState(false) diff --git a/components/BalancesTable.tsx b/components/BalancesTable.tsx new file mode 100644 index 0000000..9cd7dbf --- /dev/null +++ b/components/BalancesTable.tsx @@ -0,0 +1,92 @@ +import Link from "next/link" +import { ArrowBigUp, ChevronDown, ChevronUp } from "lucide-react" +import { formatUnits } from "viem" + +import { Button } from "@/components/ui/button" +import { + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow, +} from "@/components/ui/table" + +const BalancesTable = ({ + balances, + showAll, + toggleShowAll, + stakingAmountTotal, +}: any) => { + return ( +
    + + + + Asset + Type + Price + Balance + + + + {balances + .slice(0, showAll ? balances.length : 5) + .map((b: any, index: any) => ( + + +
    {b.ticker}
    +
    {b.chain_name}
    +
    + {b.coin_type} + + {b.price?.toFixed(2)} + + + {parseFloat(b.balance).toFixed(2) || "N/A"} + {b.ticker === "ZETA" && b.coin_type === "Gas" && ( +
    + +
    + )} +
    +
    + ))} +
    +
    + {balances?.length > 5 && ( +
    + +
    + )} +
    + ) +} + +export default BalancesTable diff --git a/components/SwapToAnyToken.json b/components/SwapToAnyToken.json new file mode 100644 index 0000000..879a8f3 --- /dev/null +++ b/components/SwapToAnyToken.json @@ -0,0 +1,143 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "SwapToAnyToken", + "sourceName": "contracts/SwapToAnyToken.sol", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "systemContractAddress", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "CantBeIdenticalAddresses", + "type": "error" + }, + { + "inputs": [], + "name": "CantBeZeroAddress", + "type": "error" + }, + { + "inputs": [], + "name": "OffsetOutOfBounds", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "name": "OnlySystemContract", + "type": "error" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes", + "name": "origin", + "type": "bytes" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "chainID", + "type": "uint256" + } + ], + "internalType": "struct zContext", + "name": "context", + "type": "tuple" + }, + { + "internalType": "address", + "name": "zrc20", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "message", + "type": "bytes" + } + ], + "name": "onCrossChainCall", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "inputToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "targetToken", + "type": "address" + }, + { + "internalType": "bytes", + "name": "recipient", + "type": "bytes" + }, + { + "internalType": "bool", + "name": "withdraw", + "type": "bool" + } + ], + "name": "swap", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "systemContract", + "outputs": [ + { + "internalType": "contract SystemContract", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "bytecode": "0x60806040523480156200001157600080fd5b506040516200262a3803806200262a833981810160405281019062000037919062000095565b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550506200011a565b6000815190506200008f8162000100565b92915050565b600060208284031215620000ae57620000ad620000fb565b5b6000620000be848285016200007e565b91505092915050565b6000620000d482620000db565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600080fd5b6200010b81620000c7565b81146200011757600080fd5b50565b612500806200012a6000396000f3fe6080604052600436106100385760003560e01c806374718c5814610044578063bb88b7691461006d578063de43156e146100985761003f565b3661003f57005b600080fd5b34801561005057600080fd5b5061006b600480360381019061006691906119f9565b6100c1565b005b34801561007957600080fd5b50610082610165565b60405161008f9190611e8d565b60405180910390f35b3480156100a457600080fd5b506100bf60048036038101906100ba9190611b06565b610189565b005b8473ffffffffffffffffffffffffffffffffffffffff166323b872dd3330876040518463ffffffff1660e01b81526004016100fe93929190611dfd565b602060405180830381600087803b15801561011857600080fd5b505af115801561012c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101509190611ad9565b5061015e85858585856103a1565b5050505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff168073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610218576040517f14c6658d00000000000000000000000000000000000000000000000000000000815260040161020f90611ea8565b60405180910390fd5b60006040518060600160405280600073ffffffffffffffffffffffffffffffffffffffff16815260200160405180602001604052806000815250815260200160011515815250905061479c876040013514156103105761027a8484600061081e565b816000019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506102bd8484601461081e565b6040516020016102cd9190611d59565b60405160208183030381529060405281602001819052506029848490501061030b576102fb84846028610893565b8160400190151590811515815250505b61037f565b60008060008686810190610324919061194a565b92509250925082846000019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050818460200181905250808460400190151590811515815250505050505b61039886868360000151846020015185604001516103a1565b50505050505050565b6000806000808415610462578673ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b8152600401604080518083038186803b1580156103f257600080fd5b505afa158015610406573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061042a91906119b9565b809250819350505061045f60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff168a83858c610901565b92505b6104a760008054906101000a900473ffffffffffffffffffffffffffffffffffffffff168a87610492578a61049f565b858b61049e91906120d1565b5b8a6000610e9a565b935084156105d0578173ffffffffffffffffffffffffffffffffffffffff1663095ea7b388836040518363ffffffff1660e01b81526004016104ea929190611e34565b602060405180830381600087803b15801561050457600080fd5b505af1158015610518573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061053c9190611ad9565b508673ffffffffffffffffffffffffffffffffffffffff1663c701262687866040518363ffffffff1660e01b8152600401610578929190611e5d565b602060405180830381600087803b15801561059257600080fd5b505af11580156105a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105ca9190611ad9565b50610813565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663569541b96040518163ffffffff1660e01b815260040160206040518083038186803b15801561063957600080fd5b505afa15801561064d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610671919061191d565b90508073ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff161415610770578073ffffffffffffffffffffffffffffffffffffffff16632e1a7d4d866040518263ffffffff1660e01b81526004016106e09190611ec8565b600060405180830381600087803b1580156106fa57600080fd5b505af115801561070e573d6000803e3d6000fd5b5050505060008761071e90612195565b60601c90508073ffffffffffffffffffffffffffffffffffffffff166108fc879081150290604051600060405180830381858888f19350505050158015610769573d6000803e3d6000fd5b5050610811565b60008761077c90612195565b60601c90508873ffffffffffffffffffffffffffffffffffffffff1663a9059cbb82886040518363ffffffff1660e01b81526004016107bc929190611e34565b602060405180830381600087803b1580156107d657600080fd5b505af11580156107ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061080e9190611ad9565b50505b505b505050505050505050565b60008084848490601486610832919061207b565b9261083f93929190612040565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050905060148101519150509392505050565b60008383905082106108d1576040517f9605a01000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008484848181106108e6576108e5612302565b5b9050013560f81c60f81b60f81c60ff16141590509392505050565b60008061098c8773ffffffffffffffffffffffffffffffffffffffff1663d936a0126040518163ffffffff1660e01b815260040160206040518083038186803b15801561094d57600080fd5b505afa158015610961573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610985919061191d565b878661143f565b905060608115610a8557600267ffffffffffffffff8111156109b1576109b0612331565b5b6040519080825280602002602001820160405280156109df5781602001602082028036833780820191505090505b50905086816000815181106109f7576109f6612302565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508481600181518110610a4657610a45612302565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050610c3c565b600367ffffffffffffffff811115610aa057610a9f612331565b5b604051908082528060200260200182016040528015610ace5781602001602082028036833780820191505090505b5090508681600081518110610ae657610ae5612302565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508773ffffffffffffffffffffffffffffffffffffffff1663569541b96040518163ffffffff1660e01b815260040160206040518083038186803b158015610b6657600080fd5b505afa158015610b7a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b9e919061191d565b81600181518110610bb257610bb1612302565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508481600281518110610c0157610c00612302565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250505b8673ffffffffffffffffffffffffffffffffffffffff1663095ea7b38973ffffffffffffffffffffffffffffffffffffffff1663842da36d6040518163ffffffff1660e01b815260040160206040518083038186803b158015610c9e57600080fd5b505afa158015610cb2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cd6919061191d565b866040518363ffffffff1660e01b8152600401610cf4929190611e34565b602060405180830381600087803b158015610d0e57600080fd5b505af1158015610d22573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d469190611ad9565b5060008873ffffffffffffffffffffffffffffffffffffffff1663842da36d6040518163ffffffff1660e01b815260040160206040518083038186803b158015610d8f57600080fd5b505afa158015610da3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dc7919061191d565b73ffffffffffffffffffffffffffffffffffffffff16638803dbee8887853060c861ffff1642610df7919061207b565b6040518663ffffffff1660e01b8152600401610e17959493929190611ee3565b600060405180830381600087803b158015610e3157600080fd5b505af1158015610e45573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190610e6e9190611a90565b905080600081518110610e8457610e83612302565b5b6020026020010151935050505095945050505050565b600080610f258773ffffffffffffffffffffffffffffffffffffffff1663d936a0126040518163ffffffff1660e01b815260040160206040518083038186803b158015610ee657600080fd5b505afa158015610efa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f1e919061191d565b878661143f565b90506060811561101e57600267ffffffffffffffff811115610f4a57610f49612331565b5b604051908082528060200260200182016040528015610f785781602001602082028036833780820191505090505b5090508681600081518110610f9057610f8f612302565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508481600181518110610fdf57610fde612302565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506111d5565b600367ffffffffffffffff81111561103957611038612331565b5b6040519080825280602002602001820160405280156110675781602001602082028036833780820191505090505b509050868160008151811061107f5761107e612302565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508773ffffffffffffffffffffffffffffffffffffffff1663569541b96040518163ffffffff1660e01b815260040160206040518083038186803b1580156110ff57600080fd5b505afa158015611113573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611137919061191d565b8160018151811061114b5761114a612302565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050848160028151811061119a57611199612302565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250505b8673ffffffffffffffffffffffffffffffffffffffff1663095ea7b38973ffffffffffffffffffffffffffffffffffffffff1663842da36d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561123757600080fd5b505afa15801561124b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061126f919061191d565b886040518363ffffffff1660e01b815260040161128d929190611e34565b602060405180830381600087803b1580156112a757600080fd5b505af11580156112bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112df9190611ad9565b5060008873ffffffffffffffffffffffffffffffffffffffff1663842da36d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561132857600080fd5b505afa15801561133c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611360919061191d565b73ffffffffffffffffffffffffffffffffffffffff166338ed17398887853060c861ffff1642611390919061207b565b6040518663ffffffff1660e01b81526004016113b0959493929190611ee3565b600060405180830381600087803b1580156113ca57600080fd5b505af11580156113de573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906114079190611a90565b9050806001835161141891906120d1565b8151811061142957611428612302565b5b6020026020010151935050505095945050505050565b60008061144d858585611579565b905060008473ffffffffffffffffffffffffffffffffffffffff166370a08231836040518263ffffffff1660e01b815260040161148a9190611de2565b60206040518083038186803b1580156114a257600080fd5b505afa1580156114b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114da9190611baa565b11801561156f575060008373ffffffffffffffffffffffffffffffffffffffff166370a08231836040518263ffffffff1660e01b815260040161151d9190611de2565b60206040518083038186803b15801561153557600080fd5b505afa158015611549573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061156d9190611baa565b115b9150509392505050565b600080600061158885856115eb565b915091508582826040516020016115a0929190611d74565b604051602081830303815290604052805190602001206040516020016115c7929190611da0565b6040516020818303038152906040528051906020012060001c925050509392505050565b6000808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415611654576040517fcb1e7cfe00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161061168e578284611691565b83835b8092508193505050600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611700576040517f78b507da00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b9250929050565b600061171a61171584611f62565b611f3d565b9050808382526020820190508285602086028201111561173d5761173c61238e565b5b60005b8581101561176d57816117538882611908565b845260208401935060208301925050600181019050611740565b5050509392505050565b600061178a61178584611f8e565b611f3d565b9050828152602081018484840111156117a6576117a5612393565b5b6117b1848285612232565b509392505050565b6000813590506117c88161246e565b92915050565b6000815190506117dd8161246e565b92915050565b6000813590506117f281612485565b92915050565b600082601f83011261180d5761180c61237a565b5b815161181d848260208601611707565b91505092915050565b6000813590506118358161249c565b92915050565b60008151905061184a8161249c565b92915050565b60008083601f8401126118665761186561237a565b5b8235905067ffffffffffffffff81111561188357611882612375565b5b60208301915083600182028301111561189f5761189e61238e565b5b9250929050565b600082601f8301126118bb576118ba61237a565b5b81356118cb848260208601611777565b91505092915050565b6000606082840312156118ea576118e961237f565b5b81905092915050565b600081359050611902816124b3565b92915050565b600081519050611917816124b3565b92915050565b6000602082840312156119335761193261239d565b5b6000611941848285016117ce565b91505092915050565b6000806000606084860312156119635761196261239d565b5b6000611971868287016117e3565b935050602084013567ffffffffffffffff81111561199257611991612398565b5b61199e868287016118a6565b92505060406119af86828701611826565b9150509250925092565b600080604083850312156119d0576119cf61239d565b5b60006119de858286016117ce565b92505060206119ef85828601611908565b9150509250929050565b600080600080600060a08688031215611a1557611a1461239d565b5b6000611a23888289016117b9565b9550506020611a34888289016118f3565b9450506040611a45888289016117b9565b935050606086013567ffffffffffffffff811115611a6657611a65612398565b5b611a72888289016118a6565b9250506080611a8388828901611826565b9150509295509295909350565b600060208284031215611aa657611aa561239d565b5b600082015167ffffffffffffffff811115611ac457611ac3612398565b5b611ad0848285016117f8565b91505092915050565b600060208284031215611aef57611aee61239d565b5b6000611afd8482850161183b565b91505092915050565b600080600080600060808688031215611b2257611b2161239d565b5b600086013567ffffffffffffffff811115611b4057611b3f612398565b5b611b4c888289016118d4565b9550506020611b5d888289016117b9565b9450506040611b6e888289016118f3565b935050606086013567ffffffffffffffff811115611b8f57611b8e612398565b5b611b9b88828901611850565b92509250509295509295909350565b600060208284031215611bc057611bbf61239d565b5b6000611bce84828501611908565b91505092915050565b6000611be38383611bef565b60208301905092915050565b611bf881612105565b82525050565b611c0781612105565b82525050565b611c1e611c1982612105565b6122a5565b82525050565b6000611c2f82611fdf565b611c398185612002565b9350611c4483611fbf565b8060005b83811015611c75578151611c5c8882611bd7565b9750611c6783611ff5565b925050600181019050611c48565b5085935050505092915050565b611c93611c8e82612161565b6122b7565b82525050565b6000611ca482611fea565b611cae8185612013565b9350611cbe818560208601612241565b611cc7816123a2565b840191505092915050565b611cdb816121fc565b82525050565b6000611cee602b83612024565b9150611cf9826123cd565b604082019050919050565b6000611d11602083612035565b9150611d1c8261241c565b602082019050919050565b6000611d34600183612035565b9150611d3f82612445565b600182019050919050565b611d538161218b565b82525050565b6000611d658284611c0d565b60148201915081905092915050565b6000611d808285611c0d565b601482019150611d908284611c0d565b6014820191508190509392505050565b6000611dab82611d27565b9150611db78285611c0d565b601482019150611dc78284611c82565b602082019150611dd682611d04565b91508190509392505050565b6000602082019050611df76000830184611bfe565b92915050565b6000606082019050611e126000830186611bfe565b611e1f6020830185611bfe565b611e2c6040830184611d4a565b949350505050565b6000604082019050611e496000830185611bfe565b611e566020830184611d4a565b9392505050565b60006040820190508181036000830152611e778185611c99565b9050611e866020830184611d4a565b9392505050565b6000602082019050611ea26000830184611cd2565b92915050565b60006020820190508181036000830152611ec181611ce1565b9050919050565b6000602082019050611edd6000830184611d4a565b92915050565b600060a082019050611ef86000830188611d4a565b611f056020830187611d4a565b8181036040830152611f178186611c24565b9050611f266060830185611bfe565b611f336080830184611d4a565b9695505050505050565b6000611f47611f58565b9050611f538282612274565b919050565b6000604051905090565b600067ffffffffffffffff821115611f7d57611f7c612331565b5b602082029050602081019050919050565b600067ffffffffffffffff821115611fa957611fa8612331565b5b611fb2826123a2565b9050602081019050919050565b6000819050602082019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b6000808585111561205457612053612389565b5b8386111561206557612064612384565b5b6001850283019150848603905094509492505050565b60006120868261218b565b91506120918361218b565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156120c6576120c56122d3565b5b828201905092915050565b60006120dc8261218b565b91506120e78361218b565b9250828210156120fa576120f96122d3565b5b828203905092915050565b60006121108261216b565b9050919050565b60006121228261216b565b9050919050565b60008115159050919050565b60007fffffffffffffffffffffffffffffffffffffffff00000000000000000000000082169050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006121a082611fea565b826121aa84611fcf565b90506121b581612360565b925060148210156121f5576121f07fffffffffffffffffffffffffffffffffffffffff000000000000000000000000836014036008026123c0565b831692505b5050919050565b60006122078261220e565b9050919050565b600061221982612220565b9050919050565b600061222b8261216b565b9050919050565b82818337600083830152505050565b60005b8381101561225f578082015181840152602081019050612244565b8381111561226e576000848401525b50505050565b61227d826123a2565b810181811067ffffffffffffffff8211171561229c5761229b612331565b5b80604052505050565b60006122b0826122c1565b9050919050565b6000819050919050565b60006122cc826123b3565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600061236c8251612135565b80915050919050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b60008160601b9050919050565b600082821b905092915050565b7f4f6e6c792073797374656d20636f6e74726163742063616e2063616c6c20746860008201527f69732066756e6374696f6e000000000000000000000000000000000000000000602082015250565b7f96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f600082015250565b7fff00000000000000000000000000000000000000000000000000000000000000600082015250565b61247781612105565b811461248257600080fd5b50565b61248e81612117565b811461249957600080fd5b50565b6124a581612129565b81146124b057600080fd5b50565b6124bc8161218b565b81146124c757600080fd5b5056fea26469706673582212203c781539b7c12f169a29a309c8e44f90edfd9e9695cd21c3762d33e0b266d21c64736f6c63430008070033", + "deployedBytecode": "0x6080604052600436106100385760003560e01c806374718c5814610044578063bb88b7691461006d578063de43156e146100985761003f565b3661003f57005b600080fd5b34801561005057600080fd5b5061006b600480360381019061006691906119f9565b6100c1565b005b34801561007957600080fd5b50610082610165565b60405161008f9190611e8d565b60405180910390f35b3480156100a457600080fd5b506100bf60048036038101906100ba9190611b06565b610189565b005b8473ffffffffffffffffffffffffffffffffffffffff166323b872dd3330876040518463ffffffff1660e01b81526004016100fe93929190611dfd565b602060405180830381600087803b15801561011857600080fd5b505af115801561012c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101509190611ad9565b5061015e85858585856103a1565b5050505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff168073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610218576040517f14c6658d00000000000000000000000000000000000000000000000000000000815260040161020f90611ea8565b60405180910390fd5b60006040518060600160405280600073ffffffffffffffffffffffffffffffffffffffff16815260200160405180602001604052806000815250815260200160011515815250905061479c876040013514156103105761027a8484600061081e565b816000019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506102bd8484601461081e565b6040516020016102cd9190611d59565b60405160208183030381529060405281602001819052506029848490501061030b576102fb84846028610893565b8160400190151590811515815250505b61037f565b60008060008686810190610324919061194a565b92509250925082846000019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050818460200181905250808460400190151590811515815250505050505b61039886868360000151846020015185604001516103a1565b50505050505050565b6000806000808415610462578673ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b8152600401604080518083038186803b1580156103f257600080fd5b505afa158015610406573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061042a91906119b9565b809250819350505061045f60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff168a83858c610901565b92505b6104a760008054906101000a900473ffffffffffffffffffffffffffffffffffffffff168a87610492578a61049f565b858b61049e91906120d1565b5b8a6000610e9a565b935084156105d0578173ffffffffffffffffffffffffffffffffffffffff1663095ea7b388836040518363ffffffff1660e01b81526004016104ea929190611e34565b602060405180830381600087803b15801561050457600080fd5b505af1158015610518573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061053c9190611ad9565b508673ffffffffffffffffffffffffffffffffffffffff1663c701262687866040518363ffffffff1660e01b8152600401610578929190611e5d565b602060405180830381600087803b15801561059257600080fd5b505af11580156105a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105ca9190611ad9565b50610813565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663569541b96040518163ffffffff1660e01b815260040160206040518083038186803b15801561063957600080fd5b505afa15801561064d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610671919061191d565b90508073ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff161415610770578073ffffffffffffffffffffffffffffffffffffffff16632e1a7d4d866040518263ffffffff1660e01b81526004016106e09190611ec8565b600060405180830381600087803b1580156106fa57600080fd5b505af115801561070e573d6000803e3d6000fd5b5050505060008761071e90612195565b60601c90508073ffffffffffffffffffffffffffffffffffffffff166108fc879081150290604051600060405180830381858888f19350505050158015610769573d6000803e3d6000fd5b5050610811565b60008761077c90612195565b60601c90508873ffffffffffffffffffffffffffffffffffffffff1663a9059cbb82886040518363ffffffff1660e01b81526004016107bc929190611e34565b602060405180830381600087803b1580156107d657600080fd5b505af11580156107ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061080e9190611ad9565b50505b505b505050505050505050565b60008084848490601486610832919061207b565b9261083f93929190612040565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050905060148101519150509392505050565b60008383905082106108d1576040517f9605a01000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008484848181106108e6576108e5612302565b5b9050013560f81c60f81b60f81c60ff16141590509392505050565b60008061098c8773ffffffffffffffffffffffffffffffffffffffff1663d936a0126040518163ffffffff1660e01b815260040160206040518083038186803b15801561094d57600080fd5b505afa158015610961573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610985919061191d565b878661143f565b905060608115610a8557600267ffffffffffffffff8111156109b1576109b0612331565b5b6040519080825280602002602001820160405280156109df5781602001602082028036833780820191505090505b50905086816000815181106109f7576109f6612302565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508481600181518110610a4657610a45612302565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050610c3c565b600367ffffffffffffffff811115610aa057610a9f612331565b5b604051908082528060200260200182016040528015610ace5781602001602082028036833780820191505090505b5090508681600081518110610ae657610ae5612302565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508773ffffffffffffffffffffffffffffffffffffffff1663569541b96040518163ffffffff1660e01b815260040160206040518083038186803b158015610b6657600080fd5b505afa158015610b7a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b9e919061191d565b81600181518110610bb257610bb1612302565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508481600281518110610c0157610c00612302565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250505b8673ffffffffffffffffffffffffffffffffffffffff1663095ea7b38973ffffffffffffffffffffffffffffffffffffffff1663842da36d6040518163ffffffff1660e01b815260040160206040518083038186803b158015610c9e57600080fd5b505afa158015610cb2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cd6919061191d565b866040518363ffffffff1660e01b8152600401610cf4929190611e34565b602060405180830381600087803b158015610d0e57600080fd5b505af1158015610d22573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d469190611ad9565b5060008873ffffffffffffffffffffffffffffffffffffffff1663842da36d6040518163ffffffff1660e01b815260040160206040518083038186803b158015610d8f57600080fd5b505afa158015610da3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dc7919061191d565b73ffffffffffffffffffffffffffffffffffffffff16638803dbee8887853060c861ffff1642610df7919061207b565b6040518663ffffffff1660e01b8152600401610e17959493929190611ee3565b600060405180830381600087803b158015610e3157600080fd5b505af1158015610e45573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190610e6e9190611a90565b905080600081518110610e8457610e83612302565b5b6020026020010151935050505095945050505050565b600080610f258773ffffffffffffffffffffffffffffffffffffffff1663d936a0126040518163ffffffff1660e01b815260040160206040518083038186803b158015610ee657600080fd5b505afa158015610efa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f1e919061191d565b878661143f565b90506060811561101e57600267ffffffffffffffff811115610f4a57610f49612331565b5b604051908082528060200260200182016040528015610f785781602001602082028036833780820191505090505b5090508681600081518110610f9057610f8f612302565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508481600181518110610fdf57610fde612302565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506111d5565b600367ffffffffffffffff81111561103957611038612331565b5b6040519080825280602002602001820160405280156110675781602001602082028036833780820191505090505b509050868160008151811061107f5761107e612302565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508773ffffffffffffffffffffffffffffffffffffffff1663569541b96040518163ffffffff1660e01b815260040160206040518083038186803b1580156110ff57600080fd5b505afa158015611113573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611137919061191d565b8160018151811061114b5761114a612302565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050848160028151811061119a57611199612302565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250505b8673ffffffffffffffffffffffffffffffffffffffff1663095ea7b38973ffffffffffffffffffffffffffffffffffffffff1663842da36d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561123757600080fd5b505afa15801561124b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061126f919061191d565b886040518363ffffffff1660e01b815260040161128d929190611e34565b602060405180830381600087803b1580156112a757600080fd5b505af11580156112bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112df9190611ad9565b5060008873ffffffffffffffffffffffffffffffffffffffff1663842da36d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561132857600080fd5b505afa15801561133c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611360919061191d565b73ffffffffffffffffffffffffffffffffffffffff166338ed17398887853060c861ffff1642611390919061207b565b6040518663ffffffff1660e01b81526004016113b0959493929190611ee3565b600060405180830381600087803b1580156113ca57600080fd5b505af11580156113de573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906114079190611a90565b9050806001835161141891906120d1565b8151811061142957611428612302565b5b6020026020010151935050505095945050505050565b60008061144d858585611579565b905060008473ffffffffffffffffffffffffffffffffffffffff166370a08231836040518263ffffffff1660e01b815260040161148a9190611de2565b60206040518083038186803b1580156114a257600080fd5b505afa1580156114b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114da9190611baa565b11801561156f575060008373ffffffffffffffffffffffffffffffffffffffff166370a08231836040518263ffffffff1660e01b815260040161151d9190611de2565b60206040518083038186803b15801561153557600080fd5b505afa158015611549573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061156d9190611baa565b115b9150509392505050565b600080600061158885856115eb565b915091508582826040516020016115a0929190611d74565b604051602081830303815290604052805190602001206040516020016115c7929190611da0565b6040516020818303038152906040528051906020012060001c925050509392505050565b6000808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415611654576040517fcb1e7cfe00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161061168e578284611691565b83835b8092508193505050600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611700576040517f78b507da00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b9250929050565b600061171a61171584611f62565b611f3d565b9050808382526020820190508285602086028201111561173d5761173c61238e565b5b60005b8581101561176d57816117538882611908565b845260208401935060208301925050600181019050611740565b5050509392505050565b600061178a61178584611f8e565b611f3d565b9050828152602081018484840111156117a6576117a5612393565b5b6117b1848285612232565b509392505050565b6000813590506117c88161246e565b92915050565b6000815190506117dd8161246e565b92915050565b6000813590506117f281612485565b92915050565b600082601f83011261180d5761180c61237a565b5b815161181d848260208601611707565b91505092915050565b6000813590506118358161249c565b92915050565b60008151905061184a8161249c565b92915050565b60008083601f8401126118665761186561237a565b5b8235905067ffffffffffffffff81111561188357611882612375565b5b60208301915083600182028301111561189f5761189e61238e565b5b9250929050565b600082601f8301126118bb576118ba61237a565b5b81356118cb848260208601611777565b91505092915050565b6000606082840312156118ea576118e961237f565b5b81905092915050565b600081359050611902816124b3565b92915050565b600081519050611917816124b3565b92915050565b6000602082840312156119335761193261239d565b5b6000611941848285016117ce565b91505092915050565b6000806000606084860312156119635761196261239d565b5b6000611971868287016117e3565b935050602084013567ffffffffffffffff81111561199257611991612398565b5b61199e868287016118a6565b92505060406119af86828701611826565b9150509250925092565b600080604083850312156119d0576119cf61239d565b5b60006119de858286016117ce565b92505060206119ef85828601611908565b9150509250929050565b600080600080600060a08688031215611a1557611a1461239d565b5b6000611a23888289016117b9565b9550506020611a34888289016118f3565b9450506040611a45888289016117b9565b935050606086013567ffffffffffffffff811115611a6657611a65612398565b5b611a72888289016118a6565b9250506080611a8388828901611826565b9150509295509295909350565b600060208284031215611aa657611aa561239d565b5b600082015167ffffffffffffffff811115611ac457611ac3612398565b5b611ad0848285016117f8565b91505092915050565b600060208284031215611aef57611aee61239d565b5b6000611afd8482850161183b565b91505092915050565b600080600080600060808688031215611b2257611b2161239d565b5b600086013567ffffffffffffffff811115611b4057611b3f612398565b5b611b4c888289016118d4565b9550506020611b5d888289016117b9565b9450506040611b6e888289016118f3565b935050606086013567ffffffffffffffff811115611b8f57611b8e612398565b5b611b9b88828901611850565b92509250509295509295909350565b600060208284031215611bc057611bbf61239d565b5b6000611bce84828501611908565b91505092915050565b6000611be38383611bef565b60208301905092915050565b611bf881612105565b82525050565b611c0781612105565b82525050565b611c1e611c1982612105565b6122a5565b82525050565b6000611c2f82611fdf565b611c398185612002565b9350611c4483611fbf565b8060005b83811015611c75578151611c5c8882611bd7565b9750611c6783611ff5565b925050600181019050611c48565b5085935050505092915050565b611c93611c8e82612161565b6122b7565b82525050565b6000611ca482611fea565b611cae8185612013565b9350611cbe818560208601612241565b611cc7816123a2565b840191505092915050565b611cdb816121fc565b82525050565b6000611cee602b83612024565b9150611cf9826123cd565b604082019050919050565b6000611d11602083612035565b9150611d1c8261241c565b602082019050919050565b6000611d34600183612035565b9150611d3f82612445565b600182019050919050565b611d538161218b565b82525050565b6000611d658284611c0d565b60148201915081905092915050565b6000611d808285611c0d565b601482019150611d908284611c0d565b6014820191508190509392505050565b6000611dab82611d27565b9150611db78285611c0d565b601482019150611dc78284611c82565b602082019150611dd682611d04565b91508190509392505050565b6000602082019050611df76000830184611bfe565b92915050565b6000606082019050611e126000830186611bfe565b611e1f6020830185611bfe565b611e2c6040830184611d4a565b949350505050565b6000604082019050611e496000830185611bfe565b611e566020830184611d4a565b9392505050565b60006040820190508181036000830152611e778185611c99565b9050611e866020830184611d4a565b9392505050565b6000602082019050611ea26000830184611cd2565b92915050565b60006020820190508181036000830152611ec181611ce1565b9050919050565b6000602082019050611edd6000830184611d4a565b92915050565b600060a082019050611ef86000830188611d4a565b611f056020830187611d4a565b8181036040830152611f178186611c24565b9050611f266060830185611bfe565b611f336080830184611d4a565b9695505050505050565b6000611f47611f58565b9050611f538282612274565b919050565b6000604051905090565b600067ffffffffffffffff821115611f7d57611f7c612331565b5b602082029050602081019050919050565b600067ffffffffffffffff821115611fa957611fa8612331565b5b611fb2826123a2565b9050602081019050919050565b6000819050602082019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b6000808585111561205457612053612389565b5b8386111561206557612064612384565b5b6001850283019150848603905094509492505050565b60006120868261218b565b91506120918361218b565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156120c6576120c56122d3565b5b828201905092915050565b60006120dc8261218b565b91506120e78361218b565b9250828210156120fa576120f96122d3565b5b828203905092915050565b60006121108261216b565b9050919050565b60006121228261216b565b9050919050565b60008115159050919050565b60007fffffffffffffffffffffffffffffffffffffffff00000000000000000000000082169050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006121a082611fea565b826121aa84611fcf565b90506121b581612360565b925060148210156121f5576121f07fffffffffffffffffffffffffffffffffffffffff000000000000000000000000836014036008026123c0565b831692505b5050919050565b60006122078261220e565b9050919050565b600061221982612220565b9050919050565b600061222b8261216b565b9050919050565b82818337600083830152505050565b60005b8381101561225f578082015181840152602081019050612244565b8381111561226e576000848401525b50505050565b61227d826123a2565b810181811067ffffffffffffffff8211171561229c5761229b612331565b5b80604052505050565b60006122b0826122c1565b9050919050565b6000819050919050565b60006122cc826123b3565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600061236c8251612135565b80915050919050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b60008160601b9050919050565b600082821b905092915050565b7f4f6e6c792073797374656d20636f6e74726163742063616e2063616c6c20746860008201527f69732066756e6374696f6e000000000000000000000000000000000000000000602082015250565b7f96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f600082015250565b7fff00000000000000000000000000000000000000000000000000000000000000600082015250565b61247781612105565b811461248257600080fd5b50565b61248e81612117565b811461249957600080fd5b50565b6124a581612129565b81146124b057600080fd5b50565b6124bc8161218b565b81146124c757600080fd5b5056fea26469706673582212203c781539b7c12f169a29a309c8e44f90edfd9e9695cd21c3762d33e0b266d21c64736f6c63430008070033", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/components/main-nav.tsx b/components/main-nav.tsx index a13916b..f55ccc1 100644 --- a/components/main-nav.tsx +++ b/components/main-nav.tsx @@ -3,10 +3,9 @@ import { useContext } from "react" import Link from "next/link" import { usePathname } from "next/navigation" +import { useAppContext } from "@/context/AppContext" import { Home, Settings } from "lucide-react" -import { NavItem } from "@/types/nav" -import { cn } from "@/lib/utils" import { Button } from "@/components/ui/button" import { NavigationMenu, @@ -24,11 +23,10 @@ import { SheetTrigger, } from "@/components/ui/sheet" import Transactions from "@/components/transactions" -import { AppContext } from "@/app/index" export function MainNav() { const pathname = usePathname() - const { cctxs } = useContext(AppContext) + const { cctxs } = useAppContext() const inProgress = cctxs.filter( @@ -43,10 +41,9 @@ export function MainNav() { Home @@ -58,7 +55,7 @@ export function MainNav() { diff --git a/components/site-header.tsx b/components/site-header.tsx index fe8938f..a2786dd 100644 --- a/components/site-header.tsx +++ b/components/site-header.tsx @@ -1,8 +1,8 @@ import { useContext } from "react" +import { AppProvider } from "@/context/AppContext" import { ConnectButton } from "@rainbow-me/rainbowkit" import { Bitcoin } from "lucide-react" -import { cn } from "@/lib/utils" import { Button } from "@/components/ui/button" import { Tooltip, @@ -11,10 +11,9 @@ import { TooltipTrigger, } from "@/components/ui/tooltip" import { MainNav } from "@/components/main-nav" -import { AppContext } from "@/app/index" export function SiteHeader() { - const { bitcoinAddress, connectBitcoin } = useContext(AppContext) + // const { bitcoinAddress, connectBitcoin } = useContext(AppContext) return (
    @@ -22,21 +21,16 @@ export function SiteHeader() {