Compare commits

..

No commits in common. "4b84a6246764293cf1d0919c1d9c3d16943b0bf2" and "d3d1144985523a8adafc20e6947dabd560fd3564" have entirely different histories.

15 changed files with 52 additions and 77 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "ghost-dao-interface", "name": "ghost-dao-interface",
"private": true, "private": true,
"version": "0.7.48", "version": "0.7.44",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",

View File

@ -17,6 +17,7 @@ import {
import { styled } from "@mui/material/styles"; import { styled } from "@mui/material/styles";
import { NavLink } from "react-router-dom"; import { NavLink } from "react-router-dom";
import { useSwitchChain } from "wagmi"; import { useSwitchChain } from "wagmi";
import ReactGA from "react-ga4";
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import GitHubIcon from '@mui/icons-material/GitHub'; import GitHubIcon from '@mui/icons-material/GitHub';
@ -86,6 +87,10 @@ const NavContent = ({ chainId, addressChainId }) => {
return `(${number}, ${number})`; return `(${number}, ${number})`;
}, [chainId]); }, [chainId]);
useEffect(() => {
ReactGA.send({ hitType: "pageview", page: "/sidebar" });
}, []);
return ( return (
<Paper className="dapp-sidebar"> <Paper className="dapp-sidebar">
<Box className="dapp-sidebar-inner" display="flex" justifyContent="space-between" flexDirection="column"> <Box className="dapp-sidebar-inner" display="flex" justifyContent="space-between" flexDirection="column">

View File

@ -1,4 +1,3 @@
import { useMemo } from "react";
import { import {
Box, Box,
Button, Button,
@ -13,9 +12,8 @@ import {
import { styled } from '@mui/material/styles'; import { styled } from '@mui/material/styles';
import CloseIcon from '@mui/icons-material/Close'; import CloseIcon from '@mui/icons-material/Close';
import LoopIcon from '@mui/icons-material/Loop'; import LoopIcon from '@mui/icons-material/Loop';
import ReactGA from "react-ga4";
import { ReactElement, useState, useEffect } from "react"; import { ReactElement, useState, useEffect } from "react";
import { useNavigate, useLocation, createSearchParams } from "react-router-dom"; import { useNavigate, createSearchParams } from "react-router-dom";
import GhostStyledIcon from "../../Icon/GhostIcon"; import GhostStyledIcon from "../../Icon/GhostIcon";
import { Tokens, useWallet } from "./Token"; import { Tokens, useWallet } from "./Token";
@ -110,14 +108,9 @@ const WalletTotalValue = ({ address, tokens }) => {
function InitialWalletView({ isWalletOpen, address, chainId, onClose }) { function InitialWalletView({ isWalletOpen, address, chainId, onClose }) {
const theme = useTheme(); const theme = useTheme();
const navigate = useNavigate(); const navigate = useNavigate();
const location = useLocation();
const tokens = useWallet(chainId, address); const tokens = useWallet(chainId, address);
const { chains } = useSwitchChain(); const { chains } = useSwitchChain();
const chainName = useMemo(() => {
return chains.find(chain => chain.id === chainId).name.toLowerCase();
}, [chains, chainId])
const onBtnClick = (dexName, from, to) => { const onBtnClick = (dexName, from, to) => {
navigate({ navigate({
pathname: `${chains.find(chain => chain.id === chainId).name.toLowerCase()}/dex/` + dexName, pathname: `${chains.find(chain => chain.id === chainId).name.toLowerCase()}/dex/` + dexName,
@ -130,20 +123,12 @@ function InitialWalletView({ isWalletOpen, address, chainId, onClose }) {
onClose(); onClose();
} }
useEffect(() => {
if (isWalletOpen) {
console.log(`/${chainName.toLowerCase()}/sidebar`)
ReactGA.send({ hitType: "pageview", page: `/${chainName.toLowerCase()}/sidebar` });
}
}, [isWalletOpen, chainName])
useEffect(() => { useEffect(() => {
if (isWalletOpen) { if (isWalletOpen) {
Object.values(tokens ?? {}).forEach(token => token.refetch()); Object.values(tokens ?? {}).forEach(token => token.refetch());
} }
}, [isWalletOpen, tokens]) }, [isWalletOpen, tokens])
return ( return (
<Paper> <Paper>
<Box sx={{ padding: theme.spacing(0, 3), display: "flex", flexDirection: "column", minHeight: "100vh" }}> <Box sx={{ padding: theme.spacing(0, 3), display: "flex", flexDirection: "column", minHeight: "100vh" }}>

View File

@ -49,7 +49,7 @@ export const BondModal = ({ bond, chainId, address, config, connect }) => {
useEffect(() => { useEffect(() => {
ReactGA.send({ hitType: "pageview", page: pathname }); ReactGA.send({ hitType: "pageview", page: pathname });
}, [pathname]) }, [])
const setRecipientAddress = useCallback((value) => { const setRecipientAddress = useCallback((value) => {
setRecipientAddressInner(value); setRecipientAddressInner(value);

View File

@ -1,6 +1,6 @@
import { Box, Tab, Tabs, Typography, Container, useMediaQuery } from "@mui/material"; import { Box, Tab, Tabs, Typography, Container, useMediaQuery } from "@mui/material";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { useParams, useLocation } from "react-router-dom"; import { useParams } from "react-router-dom";
import ReactGA from "react-ga4"; import ReactGA from "react-ga4";
import Paper from "../../components/Paper/Paper"; import Paper from "../../components/Paper/Paper";
@ -20,9 +20,7 @@ import { useFtsoPrice } from "../../hooks/prices";
import { useTokenSymbol } from "../../hooks/tokens"; import { useTokenSymbol } from "../../hooks/tokens";
const Bonds = ({ chainId, address, connect }) => { const Bonds = ({ chainId, address, connect }) => {
const location = useLocation();
const { network } = useParams(); const { network } = useParams();
const [isZoomed] = useState(false); const [isZoomed] = useState(false);
const [secondsTo, setSecondsTo] = useState(0); const [secondsTo, setSecondsTo] = useState(0);
@ -30,8 +28,8 @@ const Bonds = ({ chainId, address, connect }) => {
const isVerySmallScreen = useMediaQuery("(max-width: 379px)"); const isVerySmallScreen = useMediaQuery("(max-width: 379px)");
useEffect(() => { useEffect(() => {
ReactGA.send({ hitType: "pageview", page: location.pathname }); ReactGA.send({ hitType: "pageview", page: "/bonds" });
}, [location]); }, []);
const { liveBonds } = useLiveBonds(chainId, network); const { liveBonds } = useLiveBonds(chainId, network);
const totalReserves = useTotalReserves(chainId); const totalReserves = useTotalReserves(chainId);

View File

@ -248,7 +248,6 @@ const WelcomeView = ({
defaultFunction, defaultFunction,
closeModal closeModal
}) => { }) => {
const [refreshNeeded, setRefreshNeeded] = useState(false);
const [isPending, setIsPending] = useState(false); const [isPending, setIsPending] = useState(false);
const { epoch } = useEpoch(chainId); const { epoch } = useEpoch(chainId);
@ -257,10 +256,9 @@ const WelcomeView = ({
const { isExtensionMissing } = useUnstableProvider(); const { isExtensionMissing } = useUnstableProvider();
const refreshPage = () => window.location.reload();
const getConnect = () => { const getConnect = () => {
setRefreshNeeded(true)
window.open(GHOST_CONNECT, '_blank', 'noopener,noreferrer'); window.open(GHOST_CONNECT, '_blank', 'noopener,noreferrer');
closeModal();
} }
const callDefaultFunction = useCallback(async () => { const callDefaultFunction = useCallback(async () => {
@ -273,7 +271,7 @@ const WelcomeView = ({
return ( return (
<> <>
<Typography>{warmupPeriod <= 0 <Typography>{warmupPeriod <= 0
? `You have succesfully warmed-up your ${isStakingOpened ? " " : "bonded "}${ftsoSymbol} ${isStakingOpened ? "(3, 3)" : "(1, 1)"} Staked at:` ? `You've succesfully warmed-up your ${isStakingOpened ? " " : "bonded "}${ftsoSymbol} ${isStakingOpened ? "(3, 3)" : "(1, 1)"} Staked at:`
: `${isStakingOpened ? "Stake" : "Bond"} is in warm-up${isStakingOpened ? "" : ", which extends with each purchase"}. Your ${ftsoSymbol} ${isStakingOpened ? "(3, 3)" : "(1, 1)"} is Staked at:` : `${isStakingOpened ? "Stake" : "Bond"} is in warm-up${isStakingOpened ? "" : ", which extends with each purchase"}. Your ${ftsoSymbol} ${isStakingOpened ? "(3, 3)" : "(1, 1)"} is Staked at:`
}</Typography> }</Typography>
@ -310,15 +308,10 @@ const WelcomeView = ({
<PrimaryButton <PrimaryButton
disabled={isPending || gatekeeperAddress === EMPTY_ADDRESS} disabled={isPending || gatekeeperAddress === EMPTY_ADDRESS}
onClick={isExtensionMissing onClick={isExtensionMissing ? getConnect : goNext}
? (refreshNeeded ? refreshPage : getConnect)
: goNext
}
fullWidth fullWidth
> >
{isExtensionMissing {isExtensionMissing ? "Get GHOST Connect" : `Start ${bridgeNumbers} ${"Stake\u00B2"}`}
? (refreshNeeded ? "Refresh Page" : "Get GHOST Connect")
: `Start ${bridgeNumbers} ${"Stake\u00B2"}`}
</PrimaryButton> </PrimaryButton>
</> </>
) )
@ -378,7 +371,7 @@ const ConfirmStep = ({
amount: estimatedAmount._value.toString(), amount: estimatedAmount._value.toString(),
sessionIndex: expectedSessionIndex, sessionIndex: expectedSessionIndex,
transactionHash: txHash, transactionHash: txHash,
blockNumber: Number(blockNumber), blockNumber: blockNumber,
chainId: chainId, chainId: chainId,
bridgeStability: 69, // TODO: avoid stability bridgeStability: 69, // TODO: avoid stability
timestamp: Date.now() timestamp: Date.now()

View File

@ -1,5 +1,4 @@
import { useEffect, useState, useMemo, useCallback } from "react"; import { useEffect, useState, useMemo, useCallback } from "react";
import { useLocation } from "react-router-dom";
import ReactGA from "react-ga4"; import ReactGA from "react-ga4";
import { import {
@ -57,8 +56,6 @@ import { BridgeHeader } from "./BridgeHeader";
import { BridgeCardAction, BridgeCardHistory } from "./BridgeCard"; import { BridgeCardAction, BridgeCardHistory } from "./BridgeCard";
const Bridge = ({ chainId, address, config, connect }) => { const Bridge = ({ chainId, address, config, connect }) => {
const location = useLocation();
const isBigScreen = useMediaQuery("(max-width: 980px)") const isBigScreen = useMediaQuery("(max-width: 980px)")
const isSmallScreen = useMediaQuery("(max-width: 650px)"); const isSmallScreen = useMediaQuery("(max-width: 650px)");
const isSemiSmallScreen = useMediaQuery("(max-width: 540px)"); const isSemiSmallScreen = useMediaQuery("(max-width: 540px)");
@ -161,8 +158,8 @@ const Bridge = ({ chainId, address, config, connect }) => {
const { symbol: ghstSymbol } = useTokenSymbol(chainId, "GHST"); const { symbol: ghstSymbol } = useTokenSymbol(chainId, "GHST");
useEffect(() => { useEffect(() => {
ReactGA.send({ hitType: "pageview", page: location.pathname }); ReactGA.send({ hitType: "pageview", page: "/bridge" });
}, [location]); }, []);
const chainExplorerUrl = useMemo(() => { const chainExplorerUrl = useMemo(() => {
const client = config?.getClient(); const client = config?.getClient();

View File

@ -2,7 +2,6 @@ import { useState, useEffect, useMemo } from "react";
import { Box, Container, Typography, useMediaQuery } from "@mui/material"; import { Box, Container, Typography, useMediaQuery } from "@mui/material";
import { useConfig, useBalance } from "wagmi"; import { useConfig, useBalance } from "wagmi";
import { Helmet } from "react-helmet"; import { Helmet } from "react-helmet";
import { useLocation } from "react-router-dom";
import ReactGA from "react-ga4"; import ReactGA from "react-ga4";
import PageTitle from "../../components/PageTitle/PageTitle"; import PageTitle from "../../components/PageTitle/PageTitle";
@ -27,8 +26,6 @@ import {
} from "../../hooks/tokens"; } from "../../hooks/tokens";
const Faucet = ({ chainId, address, config, connect }) => { const Faucet = ({ chainId, address, config, connect }) => {
const location = useLocation();
const isSmallScreen = useMediaQuery("(max-width: 650px)"); const isSmallScreen = useMediaQuery("(max-width: 650px)");
const isSemiSmallScreen = useMediaQuery("(max-width: 480px)"); const isSemiSmallScreen = useMediaQuery("(max-width: 480px)");
const isVerySmallScreen = useMediaQuery("(max-width: 379px)"); const isVerySmallScreen = useMediaQuery("(max-width: 379px)");
@ -57,8 +54,8 @@ const Faucet = ({ chainId, address, config, connect }) => {
const { symbol: reserveSymbol } = useTokenSymbol(chainId, "RESERVE"); const { symbol: reserveSymbol } = useTokenSymbol(chainId, "RESERVE");
useEffect(() => { useEffect(() => {
ReactGA.send({ hitType: "pageview", page: location.pathname }); ReactGA.send({ hitType: "pageview", page: "/faucet" });
}, [location]) }, [])
useEffect(() => { useEffect(() => {
const value = nativeBalance ? nativeBalance.value : 0n; const value = nativeBalance ? nativeBalance.value : 0n;

View File

@ -1,6 +1,6 @@
import { useEffect } from "react"; import { useEffect } from "react";
import ReactGA from "react-ga4"; import ReactGA from "react-ga4";
import { useNavigate, useParams, useLocation } from "react-router-dom"; import { useNavigate, useParams } from "react-router-dom";
import { Box, Container, Grid, Divider, Typography, useMediaQuery } from "@mui/material"; import { Box, Container, Grid, Divider, Typography, useMediaQuery } from "@mui/material";
@ -15,19 +15,17 @@ import { ProposalsCount, MinQuorumPercentage, ProposalThreshold } from "./compon
import { useTokenSymbol } from "../../hooks/tokens"; import { useTokenSymbol } from "../../hooks/tokens";
const Governance = ({ connect, config, address, chainId }) => { const Governance = ({ connect, config, address, chainId }) => {
const location = useLocation();
const navigate = useNavigate();
const { network } = useParams();
const isSemiSmallScreen = useMediaQuery("(max-width: 745px)"); const isSemiSmallScreen = useMediaQuery("(max-width: 745px)");
const isSmallScreen = useMediaQuery("(max-width: 650px)"); const isSmallScreen = useMediaQuery("(max-width: 650px)");
const isVerySmallScreen = useMediaQuery("(max-width: 379px)"); const isVerySmallScreen = useMediaQuery("(max-width: 379px)");
const navigate = useNavigate();
const { network } = useParams();
const { symbol: ghstSymbol } = useTokenSymbol(chainId, "GHST"); const { symbol: ghstSymbol } = useTokenSymbol(chainId, "GHST");
useEffect(() => { useEffect(() => {
ReactGA.send({ hitType: "pageview", page: location.pathname }); ReactGA.send({ hitType: "pageview", page: "/governance" });
}, [location]); }, []);
return ( return (
<Box> <Box>

View File

@ -1,5 +1,4 @@
import { useState, useMemo, useCallback, useEffect } from "react"; import { useState, useMemo, useCallback, useEffect } from "react";
import { useLocation } from 'react-router-dom';
import ReactGA from "react-ga4"; import ReactGA from "react-ga4";
import { import {
@ -39,8 +38,6 @@ import { parseFunctionCalldata } from "./components/functions/index";
import { MY_PROPOSALS_PREFIX } from "./helpers"; import { MY_PROPOSALS_PREFIX } from "./helpers";
const NewProposal = ({ config, address, connect, chainId }) => { const NewProposal = ({ config, address, connect, chainId }) => {
const location = useLocation();
const isSemiSmallScreen = useMediaQuery("(max-width: 745px)"); const isSemiSmallScreen = useMediaQuery("(max-width: 745px)");
const isSmallScreen = useMediaQuery("(max-width: 650px)"); const isSmallScreen = useMediaQuery("(max-width: 650px)");
const isVerySmallScreen = useMediaQuery("(max-width: 379px)"); const isVerySmallScreen = useMediaQuery("(max-width: 379px)");
@ -70,8 +67,8 @@ const NewProposal = ({ config, address, connect, chainId }) => {
}, [chainId, address]); }, [chainId, address]);
useEffect(() => { useEffect(() => {
ReactGA.send({ hitType: "pageview", page: location.pathname }); ReactGA.send({ hitType: "pageview", page: "/governance/create" });
}, [location]); }, []);
const addCalldata = (calldata) => setProposalFunctions(prev => [...prev, calldata]); const addCalldata = (calldata) => setProposalFunctions(prev => [...prev, calldata]);
const removeCalldata = (index) => setProposalFunctions(prev => prev.filter((_, i) => i !== index)); const removeCalldata = (index) => setProposalFunctions(prev => prev.filter((_, i) => i !== index));

View File

@ -1,6 +1,6 @@
import { useEffect, useState, useMemo, useCallback } from "react"; import { useEffect, useState, useMemo, useCallback } from "react";
import ReactGA from "react-ga4"; import ReactGA from "react-ga4";
import { useParams, useLocation } from 'react-router-dom'; import { useParams } from 'react-router-dom';
import { useQueryClient } from '@tanstack/react-query'; import { useQueryClient } from '@tanstack/react-query';
import { useBlock, useBlockNumber } from "wagmi"; import { useBlock, useBlockNumber } from "wagmi";
@ -77,7 +77,6 @@ import RepeatIcon from '@mui/icons-material/Repeat';
const HUNDRED = new DecimalBigNumber(100n, 0); const HUNDRED = new DecimalBigNumber(100n, 0);
const ProposalDetails = ({ chainId, address, connect, config }) => { const ProposalDetails = ({ chainId, address, connect, config }) => {
const location = useLocation();
const { id } = useParams(); const { id } = useParams();
const proposalId = BigInt(id); const proposalId = BigInt(id);
@ -110,10 +109,8 @@ const ProposalDetails = ({ chainId, address, connect, config }) => {
const { pastTotalSupply: totalSupply } = usePastTotalSupply(chainId, "GHST", proposalSnapshot); const { pastTotalSupply: totalSupply } = usePastTotalSupply(chainId, "GHST", proposalSnapshot);
const { pastVotes } = usePastVotes(chainId, "GHST", proposalSnapshot, address); const { pastVotes } = usePastVotes(chainId, "GHST", proposalSnapshot, address);
console.log(location.pathname)
useEffect(() => { useEffect(() => {
ReactGA.send({ hitType: "pageview", page: `${chainId}/governance/${id}` }); ReactGA.send({ hitType: "pageview", page: `/governance/${id}` });
}, []); }, []);
const quorumPercentage = useMemo(() => { const quorumPercentage = useMemo(() => {

View File

@ -1,6 +1,5 @@
import { Dispatch, SetStateAction, useState, useEffect } from "react"; import { Dispatch, SetStateAction, useState, useEffect } from "react";
import { Box, Container, Grid, Divider, Typography, useMediaQuery, useTheme } from "@mui/material"; import { Box, Container, Grid, Divider, Typography, useMediaQuery, useTheme } from "@mui/material";
import { useLocation } from "react-router-dom";
import ReactGA from "react-ga4"; import ReactGA from "react-ga4";
import Paper from "../../components/Paper/Paper"; import Paper from "../../components/Paper/Paper";
@ -20,7 +19,6 @@ import { useEpoch } from "../../hooks/staking";
import { useTokenSymbol } from "../../hooks/tokens"; import { useTokenSymbol } from "../../hooks/tokens";
export const StakeContainer = ({ chainId, address, connect }) => { export const StakeContainer = ({ chainId, address, connect }) => {
const location = useLocation();
const [isModalOpened, handleModal] = useState(false); const [isModalOpened, handleModal] = useState(false);
const isSemiSmallScreen = useMediaQuery("(max-width: 745px)"); const isSemiSmallScreen = useMediaQuery("(max-width: 745px)");
@ -33,8 +31,8 @@ export const StakeContainer = ({ chainId, address, connect }) => {
const { epoch, refetch: refetchEpoch } = useEpoch(chainId); const { epoch, refetch: refetchEpoch } = useEpoch(chainId);
useEffect(() => { useEffect(() => {
ReactGA.send({ hitType: "pageview", page: location.pathname }); ReactGA.send({ hitType: "pageview", page: "/stake" });
}, [location]) }, [])
if (isModalOpened) { if (isModalOpened) {
return ( return (

View File

@ -1,6 +1,6 @@
import { Box, Container, Grid, useMediaQuery, useTheme } from "@mui/material"; import { Box, Container, Grid, useMediaQuery, useTheme } from "@mui/material";
import { memo, useEffect, useMemo, useState } from "react"; import { memo, useEffect, useMemo, useState } from "react";
import { Outlet, Route, Routes, useSearchParams, useLocation } from "react-router-dom"; import { Outlet, Route, Routes, useSearchParams } from "react-router-dom";
import ReactGA from "react-ga4"; import ReactGA from "react-ga4";
import { import {
@ -74,11 +74,9 @@ const TreasuryDashboard = ({ chainId }) => {
const isSmallScreen = useMediaQuery("(max-width: 650px)"); const isSmallScreen = useMediaQuery("(max-width: 650px)");
const isVerySmallScreen = useMediaQuery("(max-width: 379px)"); const isVerySmallScreen = useMediaQuery("(max-width: 379px)");
const location = useLocation();
useEffect(() => { useEffect(() => {
ReactGA.send({ hitType: "pageview", page: location.pathname }); ReactGA.send({ hitType: "pageview", page: "/dashboard" });
}, [location]); }, []);
return ( return (
<> <>

View File

@ -2,7 +2,6 @@ import { useState, useEffect, useMemo } from "react";
import { Box, Container, Typography, useMediaQuery } from "@mui/material"; import { Box, Container, Typography, useMediaQuery } from "@mui/material";
import { useConfig, useBalance } from "wagmi"; import { useConfig, useBalance } from "wagmi";
import { Helmet } from "react-helmet"; import { Helmet } from "react-helmet";
import { useLocation } from "react-router-dom";
import ReactGA from "react-ga4"; import ReactGA from "react-ga4";
import PageTitle from "../../components/PageTitle/PageTitle"; import PageTitle from "../../components/PageTitle/PageTitle";
@ -31,8 +30,6 @@ const WethWrapper = ({ chainId, address, config, connect }) => {
const isSemiSmallScreen = useMediaQuery("(max-width: 480px)"); const isSemiSmallScreen = useMediaQuery("(max-width: 480px)");
const isVerySmallScreen = useMediaQuery("(max-width: 379px)"); const isVerySmallScreen = useMediaQuery("(max-width: 379px)");
const location = useLocation();
const [chainName, setChainName] = useState(""); const [chainName, setChainName] = useState("");
const [isMint, setIsMint] = useState(true); const [isMint, setIsMint] = useState(true);
const [isPending, setIsPending] = useState(false); const [isPending, setIsPending] = useState(false);
@ -53,8 +50,8 @@ const WethWrapper = ({ chainId, address, config, connect }) => {
const { symbol: reserveSymbol } = useTokenSymbol(chainId, "RESERVE"); const { symbol: reserveSymbol } = useTokenSymbol(chainId, "RESERVE");
useEffect(() => { useEffect(() => {
ReactGA.send({ hitType: "pageview", page: location.pathname }); ReactGA.send({ hitType: "pageview", page: "/wrapper" });
}, [location]) }, [])
useEffect(() => { useEffect(() => {
const value = nativeBalance ? nativeBalance.value : 0n; const value = nativeBalance ? nativeBalance.value : 0n;

View File

@ -9,6 +9,7 @@ import {
FTSO_DAI_LP_ADDRESSES, FTSO_DAI_LP_ADDRESSES,
WETH_ADDRESSES, WETH_ADDRESSES,
} from "../constants/addresses"; } from "../constants/addresses";
import { isNetworkLegacyType } from "../constants";
import { config } from "../config"; import { config } from "../config";
import { tokenNameConverter } from "../helpers/tokenConverter"; import { tokenNameConverter } from "../helpers/tokenConverter";
@ -206,6 +207,17 @@ export const getTokenPurchaseLink = (chainId, tokenAddress, chainName) => {
return purchaseUrl; return purchaseUrl;
} }
const sanitizeTransactionRequest = (request, isLegacy) => {
const finalRequest = { ...request };
if (isLegacy) {
delete finalRequest.maxFeePerGas;
delete finalRequest.maxPriorityFeePerGas;
} else {
delete finalRequest.gasPrice;
}
return finalRequest;
}
export const executeOnChainTransaction = async ({ export const executeOnChainTransaction = async ({
chainId, chainId,
abi, abi,
@ -217,6 +229,7 @@ export const executeOnChainTransaction = async ({
value value
}) => { }) => {
try { try {
const isLegacy = isNetworkLegacyType(chainId);
const { request } = await simulateContract(config, { const { request } = await simulateContract(config, {
abi, abi,
address, address,
@ -225,9 +238,11 @@ export const executeOnChainTransaction = async ({
account, account,
chainId, chainId,
value, value,
type: isLegacy ? 'legacy' : 'eip1559',
}); });
const txHash = await writeContract(config, request); const finalRequest = sanitizeTransactionRequest(request, isLegacy);
const txHash = await writeContract(config, { ...finalRequest });
await waitForTransactionReceipt(config, { await waitForTransactionReceipt(config, {
hash: txHash, hash: txHash,
onReplaced: () => toast(messages.replacedMsg), onReplaced: () => toast(messages.replacedMsg),