Skip to content
This repository was archived by the owner on Dec 1, 2021. It is now read-only.

Maintenance and fixes #427

Merged
merged 4 commits into from
Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [Unreleased]

* [392] Fixed account page not rendering when the account is empty
* [413] Fixed validator page error after logging in with Ledger

## v0.39.x-1

* [#425] Fixed `commission_rates` might not exists in `validator.commission` object
Expand Down
2 changes: 1 addition & 1 deletion both/utils/coins.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const coinList = Meteor.settings.public.coins;
for (let i in coinList) {
const coin = coinList[i];
if (!coin.displayNamePlural) {
coin.displayNamePlural = coin.displayName + 's';
coin.displayNamePlural = coin.displayName;
}
}

Expand Down
1 change: 0 additions & 1 deletion imports/api/accounts/server/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const fetchFromUrl = (url) => {
};
}
catch (e){
console.log(res);
console.log(e);
}
}
Expand Down
27 changes: 16 additions & 11 deletions imports/ui/accounts/Account.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,28 @@ const cloneDeep = require('lodash/cloneDeep');
export default class AccountDetails extends Component{
constructor(props){
super(props);
const defaultCoin = Meteor.settings.public.coins.map(coin => {
return {
denom: coin.denom,
amount: 0
}
})
this.state = {
address: props.match.params.address,
loading: true,
accountExists: false,
available: [],
available: [defaultCoin],
delegated: 0,
unbonding: 0,
rewards: [],
reward: [],
total: [],
rewards: [defaultCoin],
reward: [defaultCoin],
total: [defaultCoin],
price: 0,
user: localStorage.getItem(CURRENTUSERADDR),
commission: [],
commission: [defaultCoin],
denom: '',
rewardsForEachDel: [],
rewardDenomType: [],
rewardsForEachDel: [defaultCoin],
rewardDenomType: [defaultCoin],
}
}

Expand Down Expand Up @@ -66,13 +72,12 @@ export default class AccountDetails extends Component{

if (result){

if (result.available){
if (result.available && (result.available.length > 0)){

this.setState({
available: cloneDeep(result.available),
denom: Coin.StakingCoin.denom,
total: cloneDeep(result.available)

})
}

Expand Down Expand Up @@ -125,7 +130,7 @@ export default class AccountDetails extends Component{
const totalRewards = cloneDeep(result.total_rewards);

totalRewards.forEach((rewardNum, i) => {
if(rewardNum.denom === this.state.total[i].denom)
if(this.state.total[i] && (rewardNum.denom === this.state.total[i].denom))
this.state.total[i].amount = parseFloat(this.state.total[i].amount) + parseFloat(rewardNum.amount);
}, this)

Expand Down Expand Up @@ -162,7 +167,7 @@ export default class AccountDetails extends Component{
if (result.commission){
result.commission.forEach((commissions, i) => {
const commissionAmount = commissions;
if(commissions.denom === this.state.total[i].denom)
if(this.state.total[i] && (commissions.denom === this.state.total[i].denom))
this.state.total[i].amount = parseFloat(this.state.total[i].amount) + parseFloat(commissions.amount);

this.setState({
Expand Down
1 change: 0 additions & 1 deletion imports/ui/accounts/Delegations.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export default class AccountDelegations extends Component{
{this.props.delegations.sort((b, a) => (a.balance - b.balance)).map((d, i) => {
let reward = this.props.rewardsForEachDel[d.validator_address];
rewardDenom =(reward)?reward.find(({denom}) => denom === denomType): null;

return <Row key={i} className="delegation-info">
<Col xs={7} md={4} className="text-nowrap overflow-auto"><AccountTooltip address={d.validator_address} /></Col>
<Col xs={2} md={5} className="overflow-auto">{new Coin(d.balance.amount, denomType).stakeString()}</Col>
Expand Down
4 changes: 2 additions & 2 deletions imports/ui/ledger/LedgerActions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ class LedgerButton extends Component {
{"sort":{"description.moniker":1}}
);
let redelegations = this.state.redelegations || {};
let maxEntries = this.props.stakingParams.max_entries;
let maxEntries = (this.props.stakingParams&&this.props.stakingParams.max_entries)?this.props.stakingParams.max_entries:7;
return <UncontrolledDropdown direction='down' size='sm' className='redelegate-validators'>
<DropdownToggle caret={true}>
{this.state.targetValidator?this.state.targetValidator.moniker:'Select a Validator'}
Expand Down Expand Up @@ -712,7 +712,7 @@ class DelegationButtons extends LedgerButton {
if (!delegation) return null;
let completionTime = delegation.redelegationCompletionTime;
let isCompleted = !completionTime || new Date() >= completionTime;
let maxEntries = this.props.stakingParams.max_entries;
let maxEntries = this.props.stakingParams?this.props.stakingParams.max_entries:7;
let canUnbond = !delegation.unbonding || maxEntries > delegation.unbonding;
return <span>
<div id='redelegate-button' className={`disabled-btn-wrapper${isCompleted?'':' disabled'}`}>
Expand Down
2 changes: 1 addition & 1 deletion imports/ui/validators/Validator.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export default class Validator extends Component{
<CardBody className="voting-power-card">
{this.state.user?<DelegationButtons validator={this.props.validator}
currentDelegation={this.state.currentUserDelegation}
history={this.props.history} stakingParams={this.props.chainStatus.staking.params}/>:''}
history={this.props.history} stakingParams={this.props.chainStatus.staking?this.props.chainStatus.staking.params:null}/>:''}
<Row>
{this.props.validator.voting_power?<Col xs={12}><h1 className="display-4 voting-power"><Badge color="primary" >{numbro(this.props.validator.voting_power).format('0,0')}</Badge></h1><span>(~{numbro(this.props.validator.voting_power/this.props.chainStatus.activeVotingPower).format('0.00%')})</span></Col>:''}
<Col sm={4} className="label"><T>validators.selfDelegationRatio</T></Col>
Expand Down
Loading