From bb3969ce2e0de9a0ca85d8ec97123a985b5b307a Mon Sep 17 00:00:00 2001
From: poocart <7067483+poocart@users.noreply.github.com>
Date: Thu, 28 Sep 2023 22:20:21 +0300
Subject: [PATCH] return buidler component toggle logic
---
app/components/views/Stake/index.tsx | 236 ++++++++++++++++++++++-----
app/components/views/Stake/styles.ts | 4 +
2 files changed, 202 insertions(+), 38 deletions(-)
diff --git a/app/components/views/Stake/index.tsx b/app/components/views/Stake/index.tsx
index 4f425048d3..40eb99a443 100644
--- a/app/components/views/Stake/index.tsx
+++ b/app/components/views/Stake/index.tsx
@@ -1,4 +1,3 @@
-/* eslint-disable @typescript-eslint/no-unused-vars */
import FiberNewRoundedIcon from "@mui/icons-material/FiberNewRounded";
import InfoOutlined from "@mui/icons-material/InfoOutlined";
import LibraryAddOutlined from "@mui/icons-material/LibraryAddOutlined";
@@ -41,7 +40,7 @@ import { ImageCard } from "components/ImageCard";
import { RebaseCard } from "components/RebaseCard";
import { TransactionModal } from "components/TransactionModal";
-import { addresses, urls } from "@klimadao/lib/constants";
+import { addresses } from "@klimadao/lib/constants";
import { tokenInfo } from "lib/getTokenInfo";
import * as styles from "./styles";
@@ -164,17 +163,13 @@ export const Stake = (props: Props) => {
const [view, setView] = useState<"stake" | "unstake">("stake");
const [quantity, setQuantity] = useState("");
const [showTransactionModal, setShowTransactionModal] = useState(false);
+ const [showEtherspotBuidler, setShowEtherspotBuidler] = useState(false);
const { disconnect, setIgnoreChainId } = useWeb3();
useEffect(() => {
- if (!setIgnoreChainId) return;
- setIgnoreChainId(true);
- return () => {
- if (!setIgnoreChainId) return;
- setIgnoreChainId(false);
- };
- }, []);
+ if (setIgnoreChainId) setIgnoreChainId(showEtherspotBuidler);
+ }, [showEtherspotBuidler]);
const fullStatus: AppNotificationStatus | null = useSelector(
selectNotificationStatus
@@ -419,42 +414,207 @@ export const Stake = (props: Props) => {
Cross-chain staking is now available through{" "}
- LI.FI and Etherspot , with
+ {
+ e.stopPropagation();
+ setShowEtherspotBuidler(true);
+ }}
+ >
+ LI.FI and Etherspot
+ , with
support for multiple chains and tokens.
- {!props.provider && (
-
-
+
+ {showEtherspotBuidler && (
+ <>
+ {!props.provider && (
+
+
+
+ )}
+ {!!props.provider && typeof window !== undefined && (
+
+ {showEtherspotBuidler && (
+ setShowEtherspotBuidler(false)}
+ className={styles.toggle_form_type}
+ >
+ ← Show Regular Staking
+
+ )}
+ {
+ try {
+ if (props.isConnected && disconnect) disconnect();
+ } catch (e) {
+ //
+ }
+ }}
+ defaultTransactionBlocks={[{ type: "KLIMA_STAKE", closeable: false }]}
+ hideTransactionBlockTitle
+ hideAddTransactionButton
+ hideAddButton
+ hideSettingsButton
+ hideWalletBlock
+ walletBlockActionsReplaceBehaviour
+ />
+
+ )}
+ >
+ )}
+
+ {!showEtherspotBuidler && (
+
+
+
+ {
+ setQuantity("");
+ setStatus(null);
+ setView("stake");
+ }}
+ data-active={view === "stake"}
+ >
+ Stake
+
+ {
+ setQuantity("");
+ setStatus(null);
+ setView("unstake");
+ }}
+ data-active={view === "unstake"}
+ >
+ Unstake
+
+
+
+ (
+ {
+ setQuantity(e.target.value);
+ setStatus(null);
+ }}
+ type="number"
+ placeholder={translation as string}
+ min="0"
+ />
+ )}
+ />
+
+ Max
+
+
+ {props.address && (
+
+ {concatAddress(props.address)}
+
+ )}
+
- )}
- {!!props.provider && typeof window !== undefined && (
-
-
{
- try {
- if (props.isConnected && disconnect) disconnect();
- } catch (e) {
- //
+
+
+
+ 5 Day Rewards
+
+ Approximate rewards, including compounding, should you
+ remain staked for 5 days.
+
}
- }}
- defaultTransactionBlocks={[{ type: "KLIMA_STAKE", closeable: false }]}
- hideTransactionBlockTitle
- hideAddTransactionButton
- hideAddButton
- hideSettingsButton
- hideWalletBlock
- walletBlockActionsReplaceBehaviour
- />
+ >
+
+
+
+
+ AKR
+
+ Annualized KLIMA Rewards, including compounding, should the
+ current reward rate remain unchanged for 12 months (reward
+ rate may be subject to change).
+
+ }
+ >
+
+
+
+
+ Index
+
+ Amount of KLIMA you would have today if you staked 1 KLIMA
+ on launch day. Useful for accounting purposes.
+
+ }
+ >
+
+
+
+
+ {fiveDayRatePercent ? (
+ trimWithPlaceholder(fiveDayRatePercent, 2, locale) + "%"
+ ) : (
+ Loading...
+ )}
+
+
+ {stakingAKR ? (
+ trimWithPlaceholder(stakingAKR, 0, locale) + "%"
+ ) : (
+ Loading...
+ )}
+
+
+ {currentIndex ? (
+ trimWithPlaceholder(currentIndex, 2, locale) + " sKLIMA"
+ ) : (
+ Loading...
+ )}
+
+
+
+
+ {showSpinner ? (
+
+
+
+ ) : (
+
+ )}
- )}
+
+ )}
{showTransactionModal && (
diff --git a/app/components/views/Stake/styles.ts b/app/components/views/Stake/styles.ts
index a7baed183c..46ce81f5e2 100644
--- a/app/components/views/Stake/styles.ts
+++ b/app/components/views/Stake/styles.ts
@@ -251,6 +251,10 @@ export const connect_button = css`
export const toggle_form_type = css`
cursor: pointer;
+ margin-left: 25px;
+ margin-bottom: 10px;
+ text-transform: inherit;
+ font-weight: inherit;
&:hover {
opacity: 0.5;