From ae5189a22d65fa600b2dcb2f7e477a8005a2a323 Mon Sep 17 00:00:00 2001
From: Kamlesh P <18464450+kombos@users.noreply.github.com>
Date: Wed, 20 Jul 2022 16:34:50 +0530
Subject: [PATCH] added redirect to home for staking page with login (#24)
updated REST and RPC urls for tendermint in cloudflare worker config
---
.github/workflows/release.yml | 4 ++--
.github/workflows/staging.yml | 4 ++--
src/constants/localStorage.js | 1 +
src/views/DashboardWallet/index.js | 4 ++--
src/views/Staking/index.js | 32 +++++++++++++++++++++++++++---
5 files changed, 36 insertions(+), 9 deletions(-)
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 14324626..88ee7327 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -23,8 +23,8 @@ jobs:
- run: npm run build --if-present
env:
CI: false
- REACT_APP_API_KEY: 'https://rest-lb.assetmantle.one'
- REACT_APP_TENDERMINT_RPC_ENDPOINT: 'https://rpc-lb.assetmantle.one'
+ REACT_APP_API_KEY: 'https://rest.assetmantle.one'
+ REACT_APP_TENDERMINT_RPC_ENDPOINT: 'https://rpc.assetmantle.one'
REACT_APP_WEBSITE_URL: 'https://wallet.assetmantle.one'
REACT_APP_EXPLORER_API: 'https://explorer.assetmantle.one'
REACT_APP_MAIL_CHIMP_URL: ''
diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml
index cd5bf002..808f937b 100644
--- a/.github/workflows/staging.yml
+++ b/.github/workflows/staging.yml
@@ -27,8 +27,8 @@ jobs:
- run: npm run build --if-present
env:
CI: false
- REACT_APP_API_KEY: 'https://rest-lb.assetmantle.one'
- REACT_APP_TENDERMINT_RPC_ENDPOINT: 'https://rpc-lb.assetmantle.one'
+ REACT_APP_API_KEY: 'https://rest.assetmantle.one'
+ REACT_APP_TENDERMINT_RPC_ENDPOINT: 'https://rpc.assetmantle.one'
REACT_APP_WEBSITE_URL: 'https://wallet.persistence.one'
REACT_APP_EXPLORER_API: 'https://explorer.assetmantle.one'
REACT_APP_MAIL_CHIMP_URL: ''
diff --git a/src/constants/localStorage.js b/src/constants/localStorage.js
index 0c4a9de9..7a1deff8 100644
--- a/src/constants/localStorage.js
+++ b/src/constants/localStorage.js
@@ -15,3 +15,4 @@ export const THEME = "theme";
export const ACCOUNT_NUMBER = "accountNumber";
export const LEDGER = "ledger";
export const ADDRESS_INDEX = "addressIndex";
+export const LOGIN_MODES_ARRAY = ["keplr", "ledger", "keystore", "address"];
diff --git a/src/views/DashboardWallet/index.js b/src/views/DashboardWallet/index.js
index 835412b8..139895f0 100644
--- a/src/views/DashboardWallet/index.js
+++ b/src/views/DashboardWallet/index.js
@@ -5,7 +5,7 @@ import GenerateKeyStore from "../../containers/GenerateKeyStore";
import ChangeKeyStorePassword from "../../containers/ChangeKeyStorePassword";
import {useDispatch} from "react-redux";
import { useHistory, useParams } from "react-router-dom";
-import { LOGIN_INFO} from "../../constants/localStorage";
+import { LOGIN_INFO, LOGIN_MODES_ARRAY} from "../../constants/localStorage";
import {addressDetails, setAddress} from "../../store/actions/signIn/address";
import {fetchDelegationsCount} from "../../store/actions/delegations";
import {fetchBalance, fetchTransferableVestingAmount} from "../../store/actions/balance";
@@ -31,7 +31,7 @@ const DashboardWallet = () => {
const {selectedLoginMode} = useParams();
- const loginModesArray = ["keplr", "ledger", "keystore", "address"];
+ const loginModesArray = LOGIN_MODES_ARRAY;
const fetchApi = async (address, loginMode) => {
diff --git a/src/views/Staking/index.js b/src/views/Staking/index.js
index a8184586..c6b8fbd6 100644
--- a/src/views/Staking/index.js
+++ b/src/views/Staking/index.js
@@ -1,11 +1,37 @@
-import React from "react";
-import Staking from "../../containers/Staking";
+import React, { useEffect, useState } from "react";
+import { useHistory, useParams } from "react-router-dom";
+import LoadingComponent from "../../components/LoadingComponent";
+import { LOGIN_INFO } from "../../constants/localStorage";
+import ChangeKeyStorePassword from "../../containers/ChangeKeyStorePassword";
import DashboardHeader from "../../containers/Common/DashboardHeader";
import GenerateKeyStore from "../../containers/GenerateKeyStore";
-import ChangeKeyStorePassword from "../../containers/ChangeKeyStorePassword";
+import Staking from "../../containers/Staking";
const DashboardStaking = () => {
+ const {selectedLoginMode} = useParams();
+ const [loading, setLoading] = useState(true);
+ const history = useHistory();
+
+
+
+
+
+ useEffect(() => {
+ console.log("inside useEffect of DashboardWallet");
+ const loginInfo = JSON.parse(localStorage.getItem(LOGIN_INFO)) || {};
+
+ if((selectedLoginMode == null || selectedLoginMode == undefined) && (loginInfo.address == null || loginInfo.address == undefined)) {
+ setLoading(false);
+ history.push('/');
+ return;
+ }
+ }, [selectedLoginMode]);
+
+ if(loading) {
+ return