From 85f1e75f664262c99e5b728c306ec4c43b75d76b Mon Sep 17 00:00:00 2001
From: Bliss Da Sailor
Date: Fri, 16 Sep 2022 12:42:48 +0100
Subject: [PATCH 01/14] variables update
---
packages/react-app/src/views/StakeDashboard.jsx | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
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}
From 67cafc49bafd147fe6075e2f69f74ea4438f3025 Mon Sep 17 00:00:00 2001
From: Bliss Da Sailor
Date: Fri, 16 Sep 2022 12:43:33 +0100
Subject: [PATCH 02/14] props and un(stake) functions
---
packages/react-app/src/components/Rounds.jsx | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/packages/react-app/src/components/Rounds.jsx b/packages/react-app/src/components/Rounds.jsx
index 9869fcc..e87df10 100644
--- a/packages/react-app/src/components/Rounds.jsx
+++ b/packages/react-app/src/components/Rounds.jsx
@@ -19,12 +19,11 @@ const Rounds = ({
address,
readContracts,
writeContracts,
- unstake,
migrate,
round,
latestRound,
+ roundEnded,
mainnetProvider,
- unstakeUsers,
userSigner,
targetNetwork,
roundData,
@@ -34,7 +33,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 (
<>
@@ -42,6 +47,8 @@ const Rounds = ({
}
title="Self Staking"
+ roundEnded={roundEnded}
+ unstake={unstake}
description="Stake GTC on yourself"
amount={getSelfStakeAmount(roundData)}
buttonText={getSelfStakeAmount(roundData) ? "Modify Stake" : "Stake"}
@@ -53,6 +60,8 @@ const Rounds = ({
}
+ roundEnded={roundEnded}
+ unstakeUsers={unstakeUsers}
title="Community Staking"
description="Stake GTC on other people"
amount={getCommunityStakeAmount(roundData)}
From b005b4b56ece855926697f75cf159c888865932f Mon Sep 17 00:00:00 2001
From: Bliss Da Sailor
Date: Fri, 16 Sep 2022 12:43:57 +0100
Subject: [PATCH 03/14] conditional render for unstake button
---
.../react-app/src/components/StakeItem.jsx | 19 ++++++++-----
.../src/components/StakeItemCommunity.jsx | 27 ++++++++++++++-----
2 files changed, 33 insertions(+), 13 deletions(-)
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..4e13630 100644
--- a/packages/react-app/src/components/StakeItemCommunity.jsx
+++ b/packages/react-app/src/components/StakeItemCommunity.jsx
@@ -3,17 +3,28 @@ 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);
+
+ console.log({ users });
+
+ await unstakeUsers(users);
+ };
+
return (
@@ -30,12 +41,16 @@ const StakeItemCommunity = ({
{amount} GTC
Staked
-
+ {roundEnded ? (
+
+ ) : (
+
+ )}
{/* List all users staked on */}
From eac01dfa4f9b1c00e6bb5615e6e229428623e80b Mon Sep 17 00:00:00 2001
From: Bliss Da Sailor
Date: Fri, 16 Sep 2022 12:44:04 +0100
Subject: [PATCH 04/14] unstake button component
---
.../react-app/src/components/UnstakeButton.jsx | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
create mode 100644 packages/react-app/src/components/UnstakeButton.jsx
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;
From b43f561061d159c694caefec03e6b5cec82533c9 Mon Sep 17 00:00:00 2001
From: Bliss Da Sailor
Date: Fri, 16 Sep 2022 12:44:17 +0100
Subject: [PATCH 05/14] unstake button colors
---
packages/react-app/tailwind.config.js | 2 ++
1 file changed, 2 insertions(+)
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",
From 87b4f22568828e8ded9aeadfef13e70b4d7a1558 Mon Sep 17 00:00:00 2001
From: Bliss Da Sailor
Date: Fri, 16 Sep 2022 16:29:04 +0100
Subject: [PATCH 06/14] new goerli deployment
---
packages/react-app/src/contracts/hardhat_contracts.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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": [
From 9510773f06f122154e1ecc3a3c446e5c90fd023d Mon Sep 17 00:00:00 2001
From: Bliss Da Sailor
Date: Fri, 16 Sep 2022 19:12:55 +0100
Subject: [PATCH 07/14] remove log
---
packages/react-app/src/components/StakeItemCommunity.jsx | 2 --
1 file changed, 2 deletions(-)
diff --git a/packages/react-app/src/components/StakeItemCommunity.jsx b/packages/react-app/src/components/StakeItemCommunity.jsx
index 4e13630..5d12940 100644
--- a/packages/react-app/src/components/StakeItemCommunity.jsx
+++ b/packages/react-app/src/components/StakeItemCommunity.jsx
@@ -20,8 +20,6 @@ const StakeItemCommunity = ({
const unstakeHandler = async () => {
const users = roundData.map(i => i?.to?.address);
- console.log({ users });
-
await unstakeUsers(users);
};
From 01bed2abcbb0aa029330a6e506e40e07cdb6db09 Mon Sep 17 00:00:00 2001
From: Bliss Da Sailor
Date: Fri, 16 Sep 2022 12:42:48 +0100
Subject: [PATCH 08/14] variables update
---
packages/react-app/src/views/StakeDashboard.jsx | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
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}
From d503ba5d7fcc6153393e7d84c3e89df900311d98 Mon Sep 17 00:00:00 2001
From: Bliss Da Sailor
Date: Fri, 16 Sep 2022 12:43:33 +0100
Subject: [PATCH 09/14] props and un(stake) functions
---
packages/react-app/src/components/Rounds.jsx | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
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)}
From ae4c63f54b4d1cab6e249555a81fe56b7dd85807 Mon Sep 17 00:00:00 2001
From: Bliss Da Sailor
Date: Fri, 16 Sep 2022 12:43:57 +0100
Subject: [PATCH 10/14] conditional render for unstake button
---
.../react-app/src/components/StakeItem.jsx | 19 ++++++++-----
.../src/components/StakeItemCommunity.jsx | 27 ++++++++++++++-----
2 files changed, 33 insertions(+), 13 deletions(-)
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..4e13630 100644
--- a/packages/react-app/src/components/StakeItemCommunity.jsx
+++ b/packages/react-app/src/components/StakeItemCommunity.jsx
@@ -3,17 +3,28 @@ 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);
+
+ console.log({ users });
+
+ await unstakeUsers(users);
+ };
+
return (
@@ -30,12 +41,16 @@ const StakeItemCommunity = ({
{amount} GTC
Staked
-
+ {roundEnded ? (
+
+ ) : (
+
+ )}
{/* List all users staked on */}
From e067cf8ad9d51ed17ffa96a43e1136f319f796bd Mon Sep 17 00:00:00 2001
From: Bliss Da Sailor
Date: Fri, 16 Sep 2022 12:44:04 +0100
Subject: [PATCH 11/14] unstake button component
---
.../react-app/src/components/UnstakeButton.jsx | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
create mode 100644 packages/react-app/src/components/UnstakeButton.jsx
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;
From 126808dfd7666333551023329236ccb68b1a6a9c Mon Sep 17 00:00:00 2001
From: Bliss Da Sailor
Date: Fri, 16 Sep 2022 12:44:17 +0100
Subject: [PATCH 12/14] unstake button colors
---
packages/react-app/tailwind.config.js | 2 ++
1 file changed, 2 insertions(+)
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",
From 85988c7e3703cc1010f48adee0023208bd12431e Mon Sep 17 00:00:00 2001
From: Bliss Da Sailor
Date: Fri, 16 Sep 2022 16:29:04 +0100
Subject: [PATCH 13/14] new goerli deployment
---
packages/react-app/src/contracts/hardhat_contracts.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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": [
From 0a9b37a9cf14a53155295d7b6db713169ba1c859 Mon Sep 17 00:00:00 2001
From: Bliss Da Sailor
Date: Fri, 16 Sep 2022 19:12:55 +0100
Subject: [PATCH 14/14] remove log
---
packages/react-app/src/components/StakeItemCommunity.jsx | 2 --
1 file changed, 2 deletions(-)
diff --git a/packages/react-app/src/components/StakeItemCommunity.jsx b/packages/react-app/src/components/StakeItemCommunity.jsx
index 4e13630..5d12940 100644
--- a/packages/react-app/src/components/StakeItemCommunity.jsx
+++ b/packages/react-app/src/components/StakeItemCommunity.jsx
@@ -20,8 +20,6 @@ const StakeItemCommunity = ({
const unstakeHandler = async () => {
const users = roundData.map(i => i?.to?.address);
- console.log({ users });
-
await unstakeUsers(users);
};