From b284c0be149b277e5a9977de4c232603690fa850 Mon Sep 17 00:00:00 2001 From: Tom Beynon Date: Tue, 31 Oct 2023 18:48:42 +0000 Subject: [PATCH 1/5] Highlight featured networks with an ownerAddress --- src/components/Networks.js | 13 ++++++++++--- src/utils/Network.mjs | 5 +++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/components/Networks.js b/src/components/Networks.js index 9feaf5fd..698206cb 100644 --- a/src/components/Networks.js +++ b/src/components/Networks.js @@ -22,7 +22,7 @@ function Networks(props) { let filtered = filteredNetworks(networks, filter) let group = filter.group while(filtered.length < 1 && group !== 'all'){ - group = 'all' + group = group == 'featured' ? 'all' : 'featured' filtered = filteredNetworks(networks, {...filter, group}) if(filtered.length > 0 || group === 'all'){ return setFilter({ ...filter, group }) @@ -43,6 +43,9 @@ function Networks(props) { case 'favourites': searchResults = searchResults.filter((network) => favourites.includes(network.path)) break; + case 'featured': + searchResults = searchResults.filter((network) => network.ownerAddress) + break; } if (!keywords || keywords === '') return searchResults @@ -56,7 +59,7 @@ function Networks(props) { } async function changeNetwork(network){ - if(!network.online) return + if(!network.online) return await network.load() await network.connect() @@ -125,6 +128,9 @@ function Networks(props) { Favourites + + Featured + All Networks @@ -133,6 +139,7 @@ function Networks(props) {
@@ -144,4 +151,4 @@ function Networks(props) { ); } -export default Networks; \ No newline at end of file +export default Networks; diff --git a/src/utils/Network.mjs b/src/utils/Network.mjs index f9f2c73d..859dc684 100644 --- a/src/utils/Network.mjs +++ b/src/utils/Network.mjs @@ -14,6 +14,7 @@ class Network { this.data = data this.enabled = data.enabled this.experimental = data.experimental + this.ownerAddress = data.ownerAddress this.operatorAddresses = operatorAddresses || {} this.operatorCount = data.operators?.length || this.estimateOperatorCount() this.name = data.path || data.name @@ -157,8 +158,8 @@ class Network { sortOperators() { const random = _.shuffle(this.operators) - if (this.data.ownerAddress) { - return _.sortBy(random, ({ address }) => address === this.data.ownerAddress ? 0 : 1) + if (this.ownerAddress) { + return _.sortBy(random, ({ address }) => address === this.ownerAddress ? 0 : 1) } return random } From a7a8592261f45db379bc2f5139e7d75f8cd9f048 Mon Sep 17 00:00:00 2001 From: Tom Beynon Date: Tue, 31 Oct 2023 18:49:08 +0000 Subject: [PATCH 2/5] Show message asking for delegations when owner is inactive --- src/components/Validators.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/Validators.js b/src/components/Validators.js index 1f697421..04563093 100644 --- a/src/components/Validators.js +++ b/src/components/Validators.js @@ -21,6 +21,7 @@ import { XCircle } from "react-bootstrap-icons"; import ValidatorName from "./ValidatorName"; import ValidatorServices from './ValidatorServices'; import REStakeStatus from './REStakeStatus'; +import AlertMessage from './AlertMessage'; function Validators(props) { const { address, wallet, network, validators, operators, delegations, operatorGrants } = props @@ -58,7 +59,7 @@ function Validators(props) { return 0 - (delegation?.balance?.amount || 0) }); return _.sortBy(validators, ({ operator_address: address, public_nodes, path }) => { - if(network.data.ownerAddress === address) return -6 + if(network.ownerAddress === address) return -6 if(path === 'ecostake') return -5 const delegation = delegations && delegations[address] @@ -128,6 +129,10 @@ function Validators(props) { return operators.find((el) => el.address === validatorAddress); } + function ownerValidator(){ + return Object.values(validators).find(validator => validator.address === network.ownerAddress) + } + function renderValidator(validator) { const validatorAddress = validator.operator_address const delegation = delegations && delegations[validatorAddress]; @@ -289,6 +294,13 @@ function Validators(props) { return ( <> + {ownerValidator() && !ownerValidator().active && ( + +
props.showValidator(ownerValidator(), { activeTab: 'profile' })}> + {ownerValidator().moniker} is currently inactive on {network.prettyName}. Help support our projects by staking with us. +
+
+ )}
From 16bdd12d18a81ab365f5824b9ca3890a5dff34b3 Mon Sep 17 00:00:00 2001 From: Tom Beynon Date: Tue, 31 Oct 2023 18:49:26 +0000 Subject: [PATCH 3/5] Warn no staking rewards when delegating to inactive validator --- src/components/DelegateForm.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/DelegateForm.js b/src/components/DelegateForm.js index db56af9d..5ee58a3a 100644 --- a/src/components/DelegateForm.js +++ b/src/components/DelegateForm.js @@ -4,11 +4,11 @@ import { MsgDelegate, MsgUndelegate, MsgBeginRedelegate } from "cosmjs-types/cos import { Button, Form, - Alert } from 'react-bootstrap' import { pow, multiply, divide, subtract, bignumber } from 'mathjs' +import AlertMessage from './AlertMessage' import Coins from './Coins' import { buildExecMessage, coin } from '../utils/Helpers.mjs' @@ -144,10 +144,15 @@ function DelegateForm(props) { return ( <> + {!state.error && !validator.active && + + {validator.moniker} is inactive - you will not receive any staking rewards until they are in the active set. + + } {state.error && - + {state.error} - + }
From 8895aa78d1ae9d927b9d3acc8b095847a7fbe21d Mon Sep 17 00:00:00 2001 From: Tom Beynon Date: Tue, 31 Oct 2023 18:49:47 +0000 Subject: [PATCH 4/5] Remove send form error when submitting --- src/components/SendModal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/SendModal.js b/src/components/SendModal.js index 4db6923d..726b536d 100644 --- a/src/components/SendModal.js +++ b/src/components/SendModal.js @@ -48,7 +48,7 @@ function SendModal(props) { if(!valid()) return showLoading(true) - + setError(null) const coinValue = coinAmount() From 1f898ae81dea5d138c7eec6fb4ee95eb43177152 Mon Sep 17 00:00:00 2001 From: Tom Beynon Date: Tue, 31 Oct 2023 22:05:06 +0000 Subject: [PATCH 5/5] Fix redelegation warning --- src/components/DelegateForm.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/DelegateForm.js b/src/components/DelegateForm.js index 5ee58a3a..bc7b8986 100644 --- a/src/components/DelegateForm.js +++ b/src/components/DelegateForm.js @@ -144,9 +144,9 @@ function DelegateForm(props) { return ( <> - {!state.error && !validator.active && + {!state.error && (selectedValidator?.active ?? validator?.active) === false && - {validator.moniker} is inactive - you will not receive any staking rewards until they are in the active set. + {(selectedValidator || validator).moniker} is inactive - you will not receive any staking rewards until they are in the active set. } {state.error &&