diff --git a/packages/react-app/src/components/Rounds.jsx b/packages/react-app/src/components/Rounds.jsx
index 717b079..046e1ec 100644
--- a/packages/react-app/src/components/Rounds.jsx
+++ b/packages/react-app/src/components/Rounds.jsx
@@ -18,12 +18,11 @@ const Rounds = ({
address,
readContracts,
writeContracts,
- unstake,
migrate,
round,
latestRound,
+ roundEnded,
mainnetProvider,
- unstakeUsers,
userSigner,
targetNetwork,
roundData,
@@ -32,7 +31,13 @@ const Rounds = ({
const [isModalVisible, setIsModalVisible] = useState(false);
const [stakingType, setStakingType] = useState("self");
- // console.log("view new data ", data, error);
+ const unstake = async amount => {
+ tx(writeContracts.IDStaking.unstake(round + "", ethers.utils.parseUnits(amount)));
+ };
+
+ const unstakeUsers = async users => {
+ tx(writeContracts.IDStaking.unstakeUsers(round + "", users));
+ };
return (
<>
@@ -40,6 +45,8 @@ const Rounds = ({
}
title="Self Staking"
+ roundEnded={roundEnded}
+ unstake={unstake}
description="Stake GTC on yourself"
amount={getSelfStakeAmount(roundData)}
buttonText={getSelfStakeAmount(roundData) ? "Modify Stake" : "Stake"}
@@ -51,6 +58,8 @@ const Rounds = ({
}
+ roundEnded={roundEnded}
+ unstakeUsers={unstakeUsers}
title="Community Staking"
description="Stake GTC on other people"
amount={getCommunityStakeAmount(roundData)}
diff --git a/packages/react-app/src/components/StakeItem.jsx b/packages/react-app/src/components/StakeItem.jsx
index c45fe2f..1a53973 100644
--- a/packages/react-app/src/components/StakeItem.jsx
+++ b/packages/react-app/src/components/StakeItem.jsx
@@ -1,6 +1,7 @@
import React from "react";
+import UnstakeButton from "./UnstakeButton";
-const StakeItem = ({ icon, title, description, amount, buttonText, buttonHandler }) => {
+const StakeItem = ({ icon, roundEnded, unstake, title, description, amount, buttonText, buttonHandler }) => {
return (
@@ -16,12 +17,16 @@ const StakeItem = ({ icon, title, description, amount, buttonText, buttonHandler
{amount} GTC
Staked
-
+ {roundEnded ? (
+
unstake(amount)} />
+ ) : (
+
+ )}
);
};
diff --git a/packages/react-app/src/components/StakeItemCommunity.jsx b/packages/react-app/src/components/StakeItemCommunity.jsx
index 6129c76..5d12940 100644
--- a/packages/react-app/src/components/StakeItemCommunity.jsx
+++ b/packages/react-app/src/components/StakeItemCommunity.jsx
@@ -3,17 +3,26 @@ import React from "react";
// Format User Address
import DisplayAddressEns from "./DisplayAddressEns";
import { formatAmountUnits } from "./StakingModal/utils";
+import UnstakeButton from "./UnstakeButton";
const StakeItemCommunity = ({
icon,
title,
+ roundEnded,
description,
amount,
+ unstakeUsers,
buttonText,
buttonHandler,
roundData,
mainnetProvider,
}) => {
+ const unstakeHandler = async () => {
+ const users = roundData.map(i => i?.to?.address);
+
+ await unstakeUsers(users);
+ };
+
return (
@@ -30,12 +39,16 @@ const StakeItemCommunity = ({
{amount} GTC
Staked
-
+ {roundEnded ? (
+
+ ) : (
+
+ )}
{/* List all users staked on */}
diff --git a/packages/react-app/src/components/UnstakeButton.jsx b/packages/react-app/src/components/UnstakeButton.jsx
new file mode 100644
index 0000000..3f722ca
--- /dev/null
+++ b/packages/react-app/src/components/UnstakeButton.jsx
@@ -0,0 +1,18 @@
+import React from "react";
+
+const UnstakeButton = ({ amount = 0, handler }) => {
+ const noBalance = amount === 0;
+
+ return (
+
+ );
+};
+
+export default UnstakeButton;
diff --git a/packages/react-app/src/contracts/hardhat_contracts.json b/packages/react-app/src/contracts/hardhat_contracts.json
index 8777a4f..3ecbc44 100644
--- a/packages/react-app/src/contracts/hardhat_contracts.json
+++ b/packages/react-app/src/contracts/hardhat_contracts.json
@@ -569,7 +569,7 @@
"chainId": "5",
"contracts": {
"IDStaking": {
- "address": "0xA9757F8bA79341553D6728080A352EB8281d47eF",
+ "address": "0xe3d7684C87c6dD50602B34D3CDAc99752950c1a1",
"abi": [
{
"inputs": [
diff --git a/packages/react-app/src/views/StakeDashboard.jsx b/packages/react-app/src/views/StakeDashboard.jsx
index 9b7b443..1c02f00 100644
--- a/packages/react-app/src/views/StakeDashboard.jsx
+++ b/packages/react-app/src/views/StakeDashboard.jsx
@@ -87,14 +87,6 @@ function StakeDashboard({
tx(writeContracts.Token.mintAmount(ethers.utils.parseUnits("1000")));
};
- const unstake = async (id, amount) => {
- tx(writeContracts.IDStaking.unstake(id + "", ethers.utils.parseUnits(amount)));
- };
-
- const unstakeUsers = async (id, users) => {
- tx(writeContracts.IDStaking.unstakeUsers(id + "", users));
- };
-
const migrate = async id => {
tx(writeContracts.IDStaking.migrateStake(id + ""));
};
@@ -131,6 +123,9 @@ function StakeDashboard({
},
});
+ const roundEndTimestamp = moment.unix((start || zero).add(duration || zero).toString());
+ const roundEnded = moment.unix(moment().toString()).unix() >= roundEndTimestamp.unix();
+
return (
<>
{moment.unix((start || zero).toString()).format("MMMM Do YYYY (h:mm:ss a)")} {" - "}
- {moment.unix((start || zero).add(duration || zero).toString()).format("MMMM Do YYYY (h:mm:ss a)")}
+ {roundEndTimestamp.format("MMMM Do YYYY (h:mm:ss a)")}
) : (
<>>
@@ -181,12 +176,11 @@ function StakeDashboard({
tx={tx}
key={roundInView}
round={roundInView}
- unstake={unstake}
address={address}
migrate={migrate}
+ roundEnded={roundEnded}
latestRound={latestRound}
tokenSymbol={tokenSymbol}
- unstakeUsers={unstakeUsers}
readContracts={readContracts}
writeContracts={writeContracts}
mainnetProvider={mainnetProvider}
diff --git a/packages/react-app/tailwind.config.js b/packages/react-app/tailwind.config.js
index b436bbb..2d65873 100644
--- a/packages/react-app/tailwind.config.js
+++ b/packages/react-app/tailwind.config.js
@@ -19,6 +19,8 @@ module.exports = {
asideBG: "#F6F0FF",
orange: colors.orange,
signout: "#FF4D4F",
+ grayBtn: "#BFBFBF",
+ dustRed: "#F5222D",
purple: {
darkpurple: "#0E0333",
connectPurple: "#6F3FF5",