From 45c9410f733bb963014accb199330d6f0f24a782 Mon Sep 17 00:00:00 2001
From: snoopy1412
Date: Tue, 8 Oct 2024 13:11:39 +0800
Subject: [PATCH] Add migration helper tool link and adjust UI #100
---
src/components/migration/migration.tsx | 115 ++++++-------------------
src/components/migration/start.tsx | 16 ++--
2 files changed, 33 insertions(+), 98 deletions(-)
diff --git a/src/components/migration/migration.tsx b/src/components/migration/migration.tsx
index 52eac0f..df7949e 100644
--- a/src/components/migration/migration.tsx
+++ b/src/components/migration/migration.tsx
@@ -1,16 +1,14 @@
"use client";
import Image from "next/image";
-import { PropsWithChildren, useCallback, useRef, useState } from "react";
+import { PropsWithChildren, useRef } from "react";
import { createPortal } from "react-dom";
import { CSSTransition } from "react-transition-group";
-import { useStaking, useApp } from "@/hooks";
-import { formatBalanceParts, getChainConfig, notifyTransaction } from "@/utils";
-import { writeContract, waitForTransaction } from "@wagmi/core";
-import { notification } from "../notification";
+import { useStaking } from "@/hooks";
+import { formatBalanceParts } from "@/utils";
import EnsureMatchNetworkButton from "../ensure-match-network-button";
-import CountLoading from "../count-loading";
import Link from "next/link";
+import CountLoading from "../count-loading";
interface Props {
isOpen: boolean;
@@ -20,38 +18,13 @@ interface Props {
}
export function MigrationModal({ isOpen, maskClosable = true, onClose = () => undefined }: PropsWithChildren) {
- const [step1Busy, setStep1Busy] = useState(false);
- const { activeChain } = useApp();
- const { stakedRing, stakedDeposit, stakedDeposits, isLedgersInitialized, isDepositsInitialized } = useStaking();
+ const { stakedRing, stakedDeposit, isLedgersInitialized, isDepositsInitialized } = useStaking();
+
const nodeRef = useRef(null);
const total = stakedRing + stakedDeposit;
const { integer, decimal } = formatBalanceParts(total);
- const currentStep = total > 0n ? 1 : 2;
-
- const handleUnbond = useCallback(async () => {
- const { contract, explorer } = getChainConfig(activeChain);
- setStep1Busy(true);
-
- try {
- const { hash } = await writeContract({
- address: contract.staking.address,
- abi: (await import(`@/config/abi/${contract.staking.abiFile}`)).default,
- functionName: "unstake",
- args: [stakedRing, stakedDeposits],
- });
-
- const receipt = await waitForTransaction({ hash });
- notifyTransaction(receipt, explorer);
- } catch (err) {
- console.error(err);
- notification.error({ description: (err as Error).message });
- } finally {
- setStep1Busy(false);
- }
- }, [activeChain, stakedRing, stakedDeposits]);
-
const isLoading = !isLedgersInitialized || !isDepositsInitialized;
return (
@@ -96,66 +69,30 @@ export function MigrationModal({ isOpen, maskClosable = true, onClose = () => un
-
-
- {total === 0n ? (
-
- No Unstake required
-
-
- ) : (
- "Step1: Unstake"
- )}
-
+
{isLoading && (
diff --git a/src/components/migration/start.tsx b/src/components/migration/start.tsx
index 8aa315d..723b74d 100644
--- a/src/components/migration/start.tsx
+++ b/src/components/migration/start.tsx
@@ -35,15 +35,13 @@ export function MigrationStartModal({
. To migrate, please follow the steps below:
- {[
- "to unstake your staked RING and Deposit.",
- "to migrate your Deposit.",
- "to go to the new staking DApp and create a new stake.",
- ].map((step, index) => (
-
- Step {index + 1}: Click "{["Unstake", "Migrate", "Stake in new pool"][index]}" button {step}
-
- ))}
+
+ Step 1: Click "Unstake and Migrate" button to go to a new page where you can unstake all your assets
+ and migrate all your deposits.
+
+
+ Step 2: Click "Stake in New Pool" button to go to the new staking DApp and create a new stake.
+
);