Skip to content

Commit

Permalink
Merge pull request #1354 from crypto-com/dev
Browse files Browse the repository at this point in the history
Internal Release v1.4.1
  • Loading branch information
crypto-matto authored Mar 3, 2023
2 parents 4c49eb5 + eb7efd0 commit 0026676
Show file tree
Hide file tree
Showing 13 changed files with 118 additions and 39 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file.
*Unreleased*

*Released*
## [v1.4.1] - 2023-03-03
### Additions
- Revise on validator uptime calculation & list layout
## [v1.4.0] - 2023-02-14
### Additions
- Testnet Croeseid 5 as default Crypto.org Chain Testnet
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chain-desktop-wallet",
"version": "1.4.0",
"version": "1.4.1",
"description": "Crypto.com DeFi Desktop Wallet App",
"repository": "github:crypto-com/chain-desktop-wallet",
"author": "Crypto.com <[email protected]>",
Expand Down Expand Up @@ -360,7 +360,7 @@
"hosted-git-info": "3.0.8",
"underscore": "1.12.1",
"trim": "0.0.3",
"dns-packet": "5.2.2",
"dns-packet": "5.4.0",
"css-what": "5.0.1",
"trim-newlines": "3.0.1",
"normalize-url": "5.3.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
import React from 'react';
import { Tooltip, Progress } from 'antd';
import { Tooltip, Progress, Typography } from 'antd';
import './ValidatorPowerPercentBar.less';
import { VALIDATOR_VOTING_POWER_THRESHOLD } from '../../config/StaticConfig';

interface ValidatorPowerPercentBarProps {
percentExcludeCurrent: number;
percentIncludeCurrent: number;
}

const { Text } = Typography;
const ValidatorPowerPercentBar: React.FC<ValidatorPowerPercentBarProps> = props => {
const { percentExcludeCurrent, percentIncludeCurrent } = props;
const rounded = new Number(percentIncludeCurrent).toPrecision(4);
const sub = new Number(percentIncludeCurrent - percentExcludeCurrent).toPrecision(4);
const color = new Number(percentIncludeCurrent - percentExcludeCurrent) < Math.round(VALIDATOR_VOTING_POWER_THRESHOLD * 100) ? 'success' : 'danger';

return (
<Tooltip title={`${rounded}%`}>
<div style={{ display: 'flex', minWidth: '150px' }}>
<span style={{ display: 'inline-block', marginRight: '8px' }}>{sub}%</span>
<Text type={color} style={{ display: 'inline-block', marginRight: '8px' }}>{sub}%</Text>
<Progress
percent={percentIncludeCurrent}
success={{ percent: percentExcludeCurrent }}
Expand Down
4 changes: 3 additions & 1 deletion src/config/StaticConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ export const NodePorts = {
export const LedgerWalletMaximum = 2147483647;

export const VALIDATOR_CUMULATIVE_SHARE_PERCENTAGE_THRESHOLD = 33.3;
export const VALIDATOR_UPTIME_THRESHOLD = 0.999;
export const VALIDATOR_LIFE_UPTIME_THRESHOLD = 0.999;
export const VALIDATOR_RECENT_UPTIME_THRESHOLD = 0.98;
export const VALIDATOR_VOTING_POWER_THRESHOLD = 0.07;

// 1 year = 60sec * 60 * 24 * 365 = 31536000 sec
export const SECONDS_OF_YEAR = 31536000;
Expand Down
2 changes: 2 additions & 0 deletions src/language/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,8 @@
"staking.validatorList.table.validatorUptime": "Uptime",
"staking.validatorList.table.validatorApy": "APY",
"staking.validatorList.table.action": "Action",
"staking.validatorList.table.tooltip1": "It's recommended to select a validator that has >{{ uptime }}% uptime for staking rewards performance.",
"staking.validatorList.table.tooltip2": "It's recommended to select a validator that has <{{ voting }}% voting power to keep the staking pool decentralized.",
"staking.formWithdralStakingReward.table.validatorName": "Name",
"staking.formWithdralStakingReward.table.rewardAmount": "Reward Amount",
"staking.formWithdralStakingReward.table.withdraw": "Withdraw",
Expand Down
20 changes: 11 additions & 9 deletions src/language/ko-KR.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@
"general.table.triggerDesc": "내림차순으로 정렬",
"general.table.triggerAsc": "오름차순 정렬",
"general.table.cancelSort": "정렬 취소",
"general.walletconnect.connect.desc1": "다음에 연결하고 싶습니다 :",
"general.walletconnect.connect.desc1": "연결하고 싶습니다 :",
"general.walletconnect.connect.desc2": "권한을 허용함으로써 다음 DAPP가 주소에 액세스 할 수 있도록합니다.",
"general.walletconnect.connect.desc3": "지갑 균형과 활동을보십시오",
"general.walletconnect.connect.desc4": "거래에 대한 승인을 요청합니다",
"general.walletconnect.connect.desc4": "거래에 대한 승인을 요청하십시오",
"general.walletconnect.connect.desc5": "DAPP를 다음으로 허용합니다.",
"general.walletconnect.connected": "연결",
"general.walletconnect.disconnect": "연결을 끊습니다",
Expand Down Expand Up @@ -461,10 +461,10 @@
"dapp.requestConfirmation.requestAccounts.message": "요청 계정",
"dapp.requestConfirmation.tokenApproval.message": "{{name}}이 {{symbol}}에 액세스하도록 허용하겠습니까?",
"dapp.requestConfirmation.error.insufficientBalance": " 잔고가 부족합니다",
"dapp.addressbar.placeholder": "DAPP 또는 유형 URL을 검색하십시오",
"dapp.addressbar.placeholder": "dapps 또는 유형 URL을 검색하십시오",
"dapp.disclaimer.title": "부인 성명",
"dapp.disclaimer.sure": "알았어요",
"dapp.disclaimer.content1": "귀하는 귀하의 DAPP 사용에 대한 책임이 있습니다. DAPP는 해당 프로젝트 제공 업체에 의해서만 제어됩니다. 자산을 양도하기 전에 수신 주소 또는 계약 주소를 확인하십시오.",
"dapp.disclaimer.content1": "귀하는 DAPP 사용에 대한 책임이 있습니다. DAPP는 해당 프로젝트 제공 업체에 의해서만 제어됩니다. 자산을 양도하기 전에 수신 주소 또는 계약 주소를 확인하십시오.",
"dapp.disclaimer.content2": "우리는 그러한 DAPP의 정확성, 완전성 또는 유용성에 대해 책임을지지 않습니다. 따라서, 우리는 그러한 DAPP에 대한 의견, 조언 또는 어떤 의견도지지하거나 추천하거나 제공하지 않습니다. DAPP를 사용하는 동안 발생한 손실에 대해 책임을지지 않거나 책임을지지 않습니다.",
"dapp.disclaimer.checkbox.label": "이 메시지를 다시 표시하지 마십시오.",
"dapp.tab.popular.title": "인기 있는",
Expand All @@ -474,7 +474,7 @@
"dapp.errorModal.title": "거래 실패. 나중에 다시 시도 해주십시오.",
"dapp.cronosDApps.table.title.name": "이름",
"dapp.cronosDApps.table.title.tvl": "TVL (총 잠금 값)",
"dapp.cronosDApps.table.title.1d": "일 -날 변화",
"dapp.cronosDApps.table.title.1d": "1 일 변화",
"dapp.cronosDApps.table.title.7d": "일곱 날 변화",
"dapp.cronosDApps.table.title.category": "범주",
"dapp.cronosDApps.table.title.audit": "심사",
Expand Down Expand Up @@ -503,7 +503,7 @@
"gas-price": "가스 가격",
"custom-gas": "맞춤형 가스",
"custom-options": "사용자 정의 옵션",
"sending-crypto-on-blockchain-requires-confirmation": "블록 체인에서 cryptocurrencies를 보내는 것은 네트워크에서 확인해야합니다. 정상적인 상황에서는 네트워크 비용이 높을수록 단기간에 거래가 확인 될 가능성이 높습니다.",
"sending-crypto-on-blockchain-requires-confirmation": "블록 체인에서 cryptocurrencies를 보내는 것은 네트워크에서 확인해야합니다. 정상적인 상황에서는 네트워크 비용이 높을수록 단기간에 확인 될 가능성이 높아집니다.",
"confirmation-speed": "확인 속도",
"staking.title": "스테이킹",
"staking.withdraw.restake": "모두보상 인출하기/스테이킹",
Expand Down Expand Up @@ -532,6 +532,8 @@
"staking.validatorList.table.validatorUptime": "정상 가동 시간",
"staking.validatorList.table.validatorApy": "APY",
"staking.validatorList.table.action": "활동",
"staking.validatorList.table.tooltip1": "보다 좋은 스테이킹 보상을 위해 >{{ uptime }}% 가동 시간을 가진 검증인을 선택하는 것이 좋습니다",
"staking.validatorList.table.tooltip2": "스테이킹 풀을 보다 분산된 상태로 유지하기위해 투표 권한이 <{{ voting }}%인 검증인을 선택하는 것이 좋습니다.",
"staking.formWithdralStakingReward.table.validatorName": "이름",
"staking.formWithdralStakingReward.table.rewardAmount": "보상 금액",
"staking.formWithdralStakingReward.table.withdraw": "인출하기",
Expand All @@ -549,7 +551,7 @@
"staking.modal1.label2": "검증인에게 위임하기",
"staking.modal1.label3": "금액",
"staking.modal1.label4": "메모",
"staking.model1.warning": "우리 커뮤니티 회원들은 커미션 비율을 지속적으로 변경 함으로써이 유효성 검사기를 나쁜 행위자로 표시했으며, 이로 인해 대표단의 스테이 킹 보상이 심각하게 손실 될 수 있습니다. 위임하기 전에 조심 하고이 검증기를 신뢰하십시오.",
"staking.model1.warning": "우리 커뮤니티 회원들은 커미션 비율을 지속적으로 변경 함으로써이 유효성 검사기를 나쁜 행위자로 표시하여 대표단의 스테이 킹 보상이 심각하게 손실 될 수 있습니다. 위임하기 전에 조심 스럽게이 유효성 검사기를 신뢰하십시오.",
"staking.modal2.title": "트랜잭션 확인",
"staking.modal2.description": "아래 정보를 확인하세요",
"staking.modal2.label1": "송신인 주소",
Expand Down Expand Up @@ -828,7 +830,7 @@
"settings.revoke.risk": "위험 노출",
"settings.revoke": "취소",
"settings.revoke.unlimited": "무제한",
"settings.revoke.success": "완화 성공!",
"settings.revoke.success": "성공을 취소!",
"settings.noApproval": "승인 데이터가 없습니다",
"settings.support.title": "지원",
"settings.support.helpCenter.title": "지원 센터",
Expand All @@ -837,7 +839,7 @@
"settings.support.feedbackForm.description": "크립토닷컴 디파이 데스크탑 지갑과 관련된 피드백, 질문, 불만 사항이 있는 경우 피드백 양식을 작성해 주세요.",
"settings.about.title": "자세한 사항",
"settings.about.termsAndConditions.title": "이용 약관",
"general.customerService.notification.title": "응답을 받았습니다",
"general.customerService.notification.title": "당신은 응답을 받았습니다",
"general.customerService.notification.body": "고객 서비스의 새로운 메시지가 있습니다.",
"general.customerService.liveChat": "라이브 채팅",
"general.notification.viewMessage": "메시지를 봅니다",
Expand Down
4 changes: 3 additions & 1 deletion src/language/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@
"dapp.requestConfirmation.error.insufficientBalance": "余额不足",
"dapp.addressbar.placeholder": "搜索 DApp 或输入链接",
"dapp.disclaimer.title": "免责声明",
"dapp.disclaimer.sure": "知道了",
"dapp.disclaimer.sure": "知道知道",
"dapp.disclaimer.content1": "你对任何使用的 DApp 负责。 DApp 由各自的项目提供者控制。在转移任何资产之前,请检查接受地址或合约地址。",
"dapp.disclaimer.content2": "我们不对 DApp 的准确性,完整性或有用性负责。我们既支持,推荐,也不会给 DApp 提供任何意见。对于你使用 DApp 期间发生的任何损失,不负任何责任。",
"dapp.disclaimer.checkbox.label": "不要再次显示此消息。",
Expand Down Expand Up @@ -535,6 +535,8 @@
"staking.validatorList.table.validatorUptime": "正常上线时间",
"staking.validatorList.table.validatorApy": "年收益率",
"staking.validatorList.table.action": "操作",
"staking.validatorList.table.tooltip1": "建议选择 正常上常时间 >{{ uptime }}% 的验者证 以确保奖励收益表现",
"staking.validatorList.table.tooltip2": "建议选择 投票权 <{{ voting }}% 的验证者 以维持网络的去中心化。",
"staking.formWithdralStakingReward.table.validatorName": "名称",
"staking.formWithdralStakingReward.table.rewardAmount": "奖励数目",
"staking.formWithdralStakingReward.table.withdraw": "提取",
Expand Down
2 changes: 2 additions & 0 deletions src/language/zh-HK.json
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,8 @@
"staking.validatorList.table.validatorUptime": "正常上線時間",
"staking.validatorList.table.validatorApy": "年收益率",
"staking.validatorList.table.action": "操作",
"staking.validatorList.table.tooltip1": "建議選擇 正常上常時間 >{{ uptime }}% 的驗者證 以確保獎勵收益表現",
"staking.validatorList.table.tooltip2": "建議選擇 投票權 <{{ voting }}% 的驗證者 以維持網絡的去中心化。",
"staking.formWithdralStakingReward.table.validatorName": "名稱",
"staking.formWithdralStakingReward.table.rewardAmount": "獎勵數目",
"staking.formWithdralStakingReward.table.withdraw": "提取",
Expand Down
39 changes: 33 additions & 6 deletions src/pages/staking/components/ValidatorListTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ import React, { useEffect, useState } from 'react';
import Big from 'big.js';
import { useTranslation } from 'react-i18next';
import { ExclamationCircleOutlined } from '@ant-design/icons';
import { AutoComplete, FormInstance, Table, Tooltip } from 'antd';
import { AutoComplete, FormInstance, Table, Tooltip, Typography } from 'antd';
import numeral from 'numeral';

import './ValidatorListTable.less';

import {
ThemeColor,
VALIDATOR_CUMULATIVE_SHARE_PERCENTAGE_THRESHOLD,
VALIDATOR_UPTIME_THRESHOLD,
VALIDATOR_RECENT_UPTIME_THRESHOLD,
VALIDATOR_VOTING_POWER_THRESHOLD,
} from '../../../config/StaticConfig';
import { ellipsis, middleEllipsis } from '../../../utils/utils';
import { renderExplorerUrl } from '../../../models/Explorer';
Expand All @@ -20,6 +21,8 @@ import { scaledAmount } from '../../../models/UserAsset';
import { isValidatorAddressSuspicious, ModerationConfig } from '../../../models/ModerationConfig';
import ValidatorPowerPercentBar from '../../../components/ValidatorPowerPercentBar/ValidatorPowerPercentBar';

const { Text } = Typography;

const ValidatorListTable = (props: {
currentSession: Session;
currentValidatorList;
Expand Down Expand Up @@ -99,7 +102,17 @@ const ValidatorListTable = (props: {
},
},
{
title: t('staking.validatorList.table.cumulativeShares'),
title: <>
{t('staking.validatorList.table.cumulativeShares')}
<Tooltip title={t(
'staking.validatorList.table.tooltip2',
{ voting: Math.round(VALIDATOR_VOTING_POWER_THRESHOLD * 100) }
)}>
<span>
<ExclamationCircleOutlined style={{ paddingLeft: '5px', cursor: 'pointer', color: ThemeColor.BLUE }} />
</span>
</Tooltip>
</>,
// dataIndex: 'cumulativeShares',
key: 'cumulativeShares',
// sorter: (a, b) => new Big(a.cumulativeShares).cmp(new Big(b.cumulativeShares)),
Expand Down Expand Up @@ -134,11 +147,25 @@ const ValidatorListTable = (props: {
},
},
{
title: t('staking.validatorList.table.validatorUptime'),
title: <>
{t('staking.validatorList.table.validatorUptime')}
<Tooltip title={t(
'staking.validatorList.table.tooltip1',
{ uptime: Math.round(VALIDATOR_RECENT_UPTIME_THRESHOLD * 100) }
)}>
<span>
<ExclamationCircleOutlined style={{ paddingLeft: '5px', cursor: 'pointer', color: ThemeColor.BLUE }} />
</span>
</Tooltip>
</>,
key: 'uptime',
// sorter: (a, b) => new Big(a.uptime).cmp(new Big(b.uptime)),
render: record => {
return <span>{new Big(record.uptime).times(100).toFixed(2)}%</span>;
const color = record.uptime >= VALIDATOR_RECENT_UPTIME_THRESHOLD ? 'success' : 'danger';

return <Text type={color}>
{new Big(record.uptime).times(100).toFixed(2)}%
</Text>;
},
},
{
Expand Down Expand Up @@ -253,7 +280,7 @@ const ValidatorListTable = (props: {
}}
rowClassName={record => {
const greyBackground =
Big(record.uptime ?? '0').lt(VALIDATOR_UPTIME_THRESHOLD) ||
Big(record.uptime ?? '0').lt(VALIDATOR_RECENT_UPTIME_THRESHOLD) ||
isValidatorAddressSuspicious(record.validatorAddress, moderationConfig);
// new Big(record.cumulativeSharesIncludePercentage!).lte(
// VALIDATOR_CUMULATIVE_SHARE_PERCENTAGE_THRESHOLD,
Expand Down
23 changes: 13 additions & 10 deletions src/service/TransactionHistoryService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { NodeRpcService } from './rpc/NodeRpcService';
import {
NOT_KNOWN_YET_VALUE,
SECONDS_OF_YEAR,
VALIDATOR_UPTIME_THRESHOLD,
VALIDATOR_RECENT_UPTIME_THRESHOLD,
} from '../config/StaticConfig';
import { UserAsset, UserAssetType } from '../models/UserAsset';
import {
Expand Down Expand Up @@ -130,32 +130,35 @@ export class TransactionHistoryService {
return val.operatorAddress === validator.validatorAddress;
});

const totalRecentSignedBlocks = matchValidator?.totalRecentSignedBlocks ?? 0;
const totalRecentActiveBlocks = matchValidator?.totalRecentActiveBlocks ?? 100;

return {
...validator,
apy: matchValidator?.apy,
uptime: matchValidator?.impreciseUpTime,
uptime: totalRecentSignedBlocks / (totalRecentActiveBlocks > 0 ? totalRecentActiveBlocks : 100), // avoid div by zero
};
})
// Group validators by uptime >= 99.9% & uptime < 99.9%
// For Group uptime < 99.9%, sort by Highest uptime %
// Group validators by recent uptime >= 98% & uptime < 98%
// For Group uptime < 98%, sort by Highest uptime %
.sort((v1, v2) => {
const v1Uptime = Big(v1.uptime ?? '0');
const v2Uptime = Big(v2.uptime ?? '0');
if (
v1Uptime.cmp(VALIDATOR_UPTIME_THRESHOLD) >= 0 &&
v2Uptime.cmp(VALIDATOR_UPTIME_THRESHOLD) < 0
v1Uptime.cmp(VALIDATOR_RECENT_UPTIME_THRESHOLD) >= 0 &&
v2Uptime.cmp(VALIDATOR_RECENT_UPTIME_THRESHOLD) < 0
) {
return -1;
}
if (
v1Uptime.cmp(VALIDATOR_UPTIME_THRESHOLD) < 0 &&
v2Uptime.cmp(VALIDATOR_UPTIME_THRESHOLD) >= 0
v1Uptime.cmp(VALIDATOR_RECENT_UPTIME_THRESHOLD) < 0 &&
v2Uptime.cmp(VALIDATOR_RECENT_UPTIME_THRESHOLD) >= 0
) {
return 1;
}
if (
v1Uptime.cmp(VALIDATOR_UPTIME_THRESHOLD) < 0 &&
v2Uptime.cmp(VALIDATOR_UPTIME_THRESHOLD) < 0
v1Uptime.cmp(VALIDATOR_RECENT_UPTIME_THRESHOLD) < 0 &&
v2Uptime.cmp(VALIDATOR_RECENT_UPTIME_THRESHOLD) < 0
) {
return v2Uptime.cmp(v1Uptime);
}
Expand Down
29 changes: 27 additions & 2 deletions src/service/rpc/ChainIndexingAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,10 @@ export class ChainIndexingAPI implements IChainIndexingAPI {
}

public async getValidatorsDetail(validatorAddrList: string[]) {
const recentBlocks = '100';
const limit = '10000';
const validatorList = await this.axiosClient.get<ValidatorListResponse>(
'validators?limit=1000000',
`validators?recentBlocks=${recentBlocks}&limit=${limit}`,
);

if (validatorList.data.pagination.total_page > 1) {
Expand Down Expand Up @@ -525,7 +527,7 @@ export class ChainIndexingAPI implements IChainIndexingAPI {
}

// NOTE: getting validator by address doesn't have `apy` property
public async getValidatorUptimeByAddress(validatorAddr: string) {
public async getValidatorLifeUptimeByAddress(validatorAddr: string) {
const validatorInfo = await this.axiosClient.get<ValidatorResponse>(
`validators/${validatorAddr}`,
);
Expand All @@ -541,6 +543,29 @@ export class ChainIndexingAPI implements IChainIndexingAPI {
return validatorInfo.data.result.impreciseUpTime;
}

public async getValidatorRecentUptimeByAddress(validatorAddr: string, recentBlocks: number) {
if (recentBlocks <= 0) {
return '0';
}

const validatorInfo = await this.axiosClient.get<ValidatorResponse>(
`validators/${validatorAddr}?recentBlocks=${recentBlocks.toString()}`,
);

if (!validatorInfo.data.result) {
throw new Error('Validator details not found.');
}

if (validatorInfo.data.result && !validatorInfo.data.result.totalRecentSignedBlocks && !validatorInfo.data.result.totalRecentActiveBlocks) {
return '0';
}

const totalRecentSignedBlocks = validatorInfo.data.result.totalRecentSignedBlocks;
const totalRecentActiveBlocks = validatorInfo.data.result.totalRecentActiveBlocks > 0 ? validatorInfo.data.result.totalRecentActiveBlocks : recentBlocks; // avoid div by zero

return totalRecentSignedBlocks / totalRecentActiveBlocks;
}

/**
* Get total rewards for an active account on CRO (Cosmos SDK) chain
* @param address
Expand Down
4 changes: 3 additions & 1 deletion src/service/rpc/ChainIndexingModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,10 @@ export interface ValidatorInfo {
commissionMaxRate: string;
commissionMaxChangeRate: string;
minSelfDelegation: string;
totalSignedBlock: number;
totalActiveBlock: number;
totalRecentActiveBlocks: number;
totalSignedBlock: number;
totalRecentSignedBlocks: number;
impreciseUpTime: string;
votedGovProposal: number;
powerPercentage: string;
Expand Down
Loading

0 comments on commit 0026676

Please sign in to comment.