From 3b2dd422fa413e6c21169ed479c267e995453705 Mon Sep 17 00:00:00 2001 From: Uncle Fatso Date: Sun, 15 Nov 2026 15:26:32 +0300 Subject: [PATCH] fix record in history for unstake and add liquidity Signed-off-by: Uncle Fatso --- package.json | 2 +- src/containers/Bond/components/ClaimBonds.jsx | 1 + src/containers/History/BondModal.jsx | 1 - src/containers/History/DexViewModal.jsx | 199 +++++++++++++++++- src/containers/History/History.jsx | 2 +- src/containers/History/StakingViewModal.jsx | 33 +-- src/hooks/helpers.js | 11 +- 7 files changed, 208 insertions(+), 41 deletions(-) diff --git a/package.json b/package.json index eb096b5..4af859e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ghost-dao-interface", "private": true, - "version": "0.8.18", + "version": "0.8.19", "type": "module", "scripts": { "dev": "vite", diff --git a/src/containers/Bond/components/ClaimBonds.jsx b/src/containers/Bond/components/ClaimBonds.jsx index dbebc7e..5f862bb 100644 --- a/src/containers/Bond/components/ClaimBonds.jsx +++ b/src/containers/Bond/components/ClaimBonds.jsx @@ -89,6 +89,7 @@ export const ClaimBonds = ({ chainId, address, secondsTo }) => { breakoutFromBonding({ defaultFunction, toExecute, amount, warmupLeft }) } + await notesRefetch(); setPendingIndexes([]); setIsPending(false); } diff --git a/src/containers/History/BondModal.jsx b/src/containers/History/BondModal.jsx index a6877cb..6e25935 100644 --- a/src/containers/History/BondModal.jsx +++ b/src/containers/History/BondModal.jsx @@ -123,7 +123,6 @@ const BondModalClaim = ({ chainId, isOpen, close, config, historyRecord }) => { /> - Receiver diff --git a/src/containers/History/DexViewModal.jsx b/src/containers/History/DexViewModal.jsx index aa33ab6..3d1c4fc 100644 --- a/src/containers/History/DexViewModal.jsx +++ b/src/containers/History/DexViewModal.jsx @@ -10,14 +10,16 @@ import GhostStyledIcon from "../../components/Icon/GhostIcon"; import { PrimaryButton } from "../../components/Button"; import { abi as UniswapV2PairAbi } from "../../abi/UniswapV2Pair.json"; -import { formatNumber, shorten } from "../../helpers"; +import { formatNumber, formatCurrency, shorten } from "../../helpers"; +import { DecimalBigNumber } from "../../helpers/DecimalBigNumber"; +import { useLocalStorage } from "../../hooks/localstorage"; import TokenBox from "./TokenBox"; -const DexViewModal = ({ chainId, isOpen, close, config, historyRecord }) => { +const DexSwapViewModal = ({ chainId, isOpen, close, config, historyRecord }) => { if (historyRecord === null) return null; - const { data: receipt, isLoading, error } = useTransactionReceipt({ + const { data: receipt } = useTransactionReceipt({ hash: historyRecord?.txHash, query: { enabled: !!historyRecord?.txHash && isOpen, @@ -163,4 +165,195 @@ const DexViewModal = ({ chainId, isOpen, close, config, historyRecord }) => { ) } +const DexAddViewModal = ({ chainId, isOpen, close, config, historyRecord }) => { + if (historyRecord === null) return null; + + const { data: receipt } = useTransactionReceipt({ + hash: historyRecord?.txHash, + query: { + enabled: !!historyRecord?.txHash && isOpen, + } + }); + + const allDecodedLogs = useMemo(() => { + if (!receipt?.logs) return []; + + return receipt.logs.map((log) => { + try { + const decoded = decodeEventLog({ + abi: UniswapV2PairAbi, + data: log.data, + topics: log.topics, + }); + + return { + eventName: decoded.eventName, + args: decoded.args, + address: log.address + }; + } catch (e) { + return null; + } + }).filter(Boolean); + }, [receipt]); + + const mintInfo = useMemo(() => { + const mintEvent = allDecodedLogs.find(l => l.eventName === 'Mint'); + if (!mintEvent) return null; + + const tokenTransfers = allDecodedLogs.filter( + l => l.eventName === 'Transfer' && l.address.toLowerCase() !== mintEvent.address.toLowerCase() + ); + + const lpMintTransfer = allDecodedLogs.find( + l => + l.eventName === 'Transfer' && + l.address.toLowerCase() === mintEvent.address.toLowerCase() && + l.args.from === "0x0000000000000000000000000000000000000000" + ); + + const token0Log = tokenTransfers.find(t => t.args.value === mintEvent.args.amount0); + const token1Log = tokenTransfers.find( + t => t.args.value === mintEvent.args.amount1 && t !== token0Log + ); + + return { + pairAddress: mintEvent.address, + sender: mintEvent.args.sender, + recipient: lpMintTransfer?.args?.to || receipt?.from, + token0Address: token0Log?.address, + token1Address: token1Log?.address, + amount0: mintEvent.args.amount0, + amount1: mintEvent.args.amount1, + lpAmount: lpMintTransfer?.args?.value ?? 0n, + }; + }, [allDecodedLogs, receipt]); + + const { data: token0 } = useToken({ + address: mintInfo?.token0Address, + scopeKey: `token-${mintInfo ? mintInfo.token0Address : ""}-${chainId}`, + chainId + }); + + const { data: token1 } = useToken({ + address: mintInfo?.token1Address, + scopeKey: `token-${mintInfo ? mintInfo.token1Address : ""}-${chainId}`, + chainId + }); + + const chainInfo = useMemo(() => { + const client = config?.getClient(); + + return { + url: client?.chain?.blockExplorers?.default?.url, + symbol: client?.chain?.nativeCurrency?.symbol, + }; + }, [config]); + + return ( + + {mintInfo && "DEX Add Liquidity"} + {!mintInfo && "Parsing Transaction Hash"} + + } + onClose={() => close()} + > + {mintInfo && ( + + + + Recipient + + {shorten(mintInfo.recipient, 12, -10)} + + + + + Liquidity Pool + + {shorten(mintInfo.pairAddress, 12, -10)} + + + + + Liquidity Amount + {formatCurrency(new DecimalBigNumber(mintInfo.lpAmount, 18), 10, "LP")} + + + + + + + + + + + + + + View Transaction Details + + + )} + + ) +} + +const DexViewModal = ({ chainId, isOpen, close, config, historyRecord }) => { + const { CONSTANTS } = useLocalStorage(); + + switch (historyRecord.name) { + case CONSTANTS.dex.swap: + return ( + + ); + case CONSTANTS.dex.add: + return ( + + ); + default: + return null; + } +} + export default DexViewModal; diff --git a/src/containers/History/History.jsx b/src/containers/History/History.jsx index 77165df..43c0951 100644 --- a/src/containers/History/History.jsx +++ b/src/containers/History/History.jsx @@ -241,7 +241,7 @@ const HistoryList = ({ chainId, storedTransactions, historyType, config, eraseRe ) } - }, [isSmallScreen, storedTransactions, config]); + }, [isSmallScreen, currentTime, storedTransactions, config]); return ( <> diff --git a/src/containers/History/StakingViewModal.jsx b/src/containers/History/StakingViewModal.jsx index 87d1974..72af894 100644 --- a/src/containers/History/StakingViewModal.jsx +++ b/src/containers/History/StakingViewModal.jsx @@ -16,34 +16,7 @@ import { formatNumber, shorten } from "../../helpers"; import { useTokenSymbol } from "../../hooks/tokens"; import { getTokenDecimals } from "../../hooks/helpers"; - -const TokenBox = ({ tokenAmount, tokenSymbol, decimals, chainTokenSymbol }) => { - return ( - - - - - {tokenSymbol} - - {formatNumber( - new DecimalBigNumber(tokenAmount ? tokenAmount : 0n, decimals), - 5 - )} - - - ) -} +import TokenBox from "./TokenBox"; const StakingViewModal = ({ chainId, isOpen, close, config, historyRecord }) => { if (historyRecord === null) return null; @@ -78,7 +51,7 @@ const StakingViewModal = ({ chainId, isOpen, close, config, historyRecord }) => }, [receipt]); const stakeInfo = useMemo(() => { - return allDecodedLogs.find(l => l.eventName === 'Staked'); + return allDecodedLogs.find(l => l.eventName === 'Staked' || l.eventName === 'Unstaked'); }, [allDecodedLogs]); const { symbol: ftsoSymbol } = useTokenSymbol(chainId, "FTSO"); @@ -100,7 +73,7 @@ const StakingViewModal = ({ chainId, isOpen, close, config, historyRecord }) => open={isOpen} headerText={ <> - {stakeInfo && "Staked"} + {stakeInfo && historyRecord.name} {!stakeInfo && "Parsing Transaction Hash"} } diff --git a/src/hooks/helpers.js b/src/hooks/helpers.js index 861647b..66ca1c2 100644 --- a/src/hooks/helpers.js +++ b/src/hooks/helpers.js @@ -210,13 +210,14 @@ export const getTokenPurchaseLink = (chainId, tokenAddress, chainName) => { let purchaseUrl = `https://app.dao.ghostchain.io/#/${chainName}/dex/uniswap`; switch (tokenAddress) { case RESERVE_ADDRESSES[chainId]: - purchaseUrl = `https://app.dao.ghostchain.io/#/${chainName}/faucet`; - if (chainId == 63) { - purchaseUrl = `https://app.dao.ghostchain.io/#/${chainName}/wrapper`; - } + purchaseUrl = `https://ghostchain.io/faucet/`; break; case FTSO_RESERVE_LP_ADDRESSES[chainId]: - purchaseUrl += `?pool=true&from=${RESERVE_ADDRESSES[chainId]}&to=${FTSO_ADDRESSES[chainId]}`; + const reserve = RESERVE_ADDRESSES[chainId] === WETH_ADDRESSES[chainId] + ? "0x0000000000000000000000000000000000000000" + : RESERVE_ADDRESSES[chainId]; + + purchaseUrl += `?pool=true&from=${reserve}&to=${FTSO_ADDRESSES[chainId]}`; break; } return purchaseUrl;