Skip to content

Commit

Permalink
Merge pull request #1040 from crypto-com/dev
Browse files Browse the repository at this point in the history
Internal Release v0.7.4
  • Loading branch information
crypto-matto authored Mar 25, 2022
2 parents dc272bd + 34801a6 commit 4ca78f6
Show file tree
Hide file tree
Showing 19 changed files with 99 additions and 49 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
*Unreleased*

*Released*
## [v0.7.4] - 2022-03-25
### Additions
- Duration selection for Auto Update disable
### Bug fixes
- Some CRC20 token price don't show properly
- App crash when sending tokens with market price not available
- Unable to withdraw Staking Rewards when validators > 10
- Dead DApp list urls
- Incorrect token settings during first time setup
## [v0.7.3] - 2022-03-22
### Additions
- Tooltip for different Asset Types
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chain-desktop-wallet",
"version": "0.7.3",
"version": "0.7.4",
"description": "Crypto.com Chain Desktop Wallet App",
"repository": "github:crypto-com/chain-desktop-wallet",
"author": "Crypto.org <chain@crypto.org>",
Expand Down Expand Up @@ -354,6 +354,7 @@
"simple-get": "4.0.1",
"minimist": "1.2.6",
"node-forge": "1.3.0",
"plist": "3.0.5",
"ansi-html": "https://registry.yarnpkg.com/ansi-html-community/-/ansi-html-community-0.0.8.tgz"
}
}
2 changes: 2 additions & 0 deletions src/config/StaticConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ export const NFT_WRAPPED_ETH_DENOM_SCHEMA = {
export const MAX_IMAGE_SIZE = 10 * 1024 * 1024;
export const MAX_VIDEO_SIZE = 20 * 1024 * 1024;

export const AUTO_UPDATE_DISABLE_DURATIONS = [14, 30];

const TestNetConfig: WalletConfig = {
enabled: true,
name: 'TESTNET',
Expand Down
1 change: 1 addition & 0 deletions src/language/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,7 @@
"settings.autoUpdate.title": "Auto Update",
"settings.autoUpdate.description": "Once enabled, the program will keep updated to the latest version.",
"settings.autoUpdate.expire": "Expire",
"settings.autoUpdate.duration": "Disable for {{ duration }} Days",
"settings.exportRecoveryPhrase.title": "Export your Recovery Phrase",
"settings.exportRecoveryPhrase.description": "You are required to enter your App Password for this action.",
"settings.exportRecoveryPhrase.button": "Export",
Expand Down
1 change: 1 addition & 0 deletions src/language/ko-KR.json
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,7 @@
"settings.autoUpdate.title": "자동 업데이트",
"settings.autoUpdate.description": "일단 활성화되면, 계속 최신 버젼으로 업데이트됩니다",
"settings.autoUpdate.expire": "만료",
"settings.autoUpdate.duration": "꺼짐 {{ duration }} 일",
"settings.exportRecoveryPhrase.title": "니모닉 문구 내보내기",
"settings.exportRecoveryPhrase.description": "이 작업을 수행하려면 앱 비밀번호를 입력해야 합니다.",
"settings.exportRecoveryPhrase.button": "내보내기",
Expand Down
1 change: 1 addition & 0 deletions src/language/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,7 @@
"settings.autoUpdate.title": "自动更新",
"settings.autoUpdate.description": "开启后程序将会保持更新至最新版本。",
"settings.autoUpdate.expire": "到期",
"settings.autoUpdate.duration": "关闭 {{ duration }} 天",
"settings.exportRecoveryPhrase.title": "导出助记词",
"settings.exportRecoveryPhrase.description": "需要输入你的密码来进行此操作。",
"settings.exportRecoveryPhrase.button": "导出",
Expand Down
1 change: 1 addition & 0 deletions src/language/zh-HK.json
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,7 @@
"settings.autoUpdate.title": "自動更新",
"settings.autoUpdate.description": "開啟後程式將會保持更新至最新版本。",
"settings.autoUpdate.expire": "到期",
"settings.autoUpdate.duration": "關閉 {{ duration }} 日",
"settings.exportRecoveryPhrase.title": "導出助記詞",
"settings.exportRecoveryPhrase.description": "需要輸入你的密碼來進行此操作。",
"settings.exportRecoveryPhrase.button": "導出",
Expand Down
10 changes: 5 additions & 5 deletions src/models/UserAsset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export const getAssetBalancePrice = (asset: UserAsset, marketPrice: AssetMarketP
return '--';
}
const bigAsset = new Big(scaledBalance(asset));
const bigMarketPrice = new Big(marketPrice.price);
const bigMarketPrice = new Big(marketPrice.price ? marketPrice.price : '0');
return bigAsset.times(bigMarketPrice).toFixed(2);
};

Expand All @@ -167,24 +167,24 @@ export const getAssetAmountInFiat = (amount: string, marketPrice: AssetMarketPri
return '';
}
const bigAsset = new Big(amount);
const bigMarketPrice = new Big(marketPrice.price);
const bigMarketPrice = new Big(marketPrice.price ? marketPrice.price : '0');
return bigAsset.times(bigMarketPrice).toFixed(2);
};

export const getAssetStakingBalancePrice = (asset: UserAsset, marketPrice: AssetMarketPrice) => {
const bigAsset = new Big(scaledStakingBalance(asset));
const bigMarketPrice = new Big(marketPrice.price);
const bigMarketPrice = new Big(marketPrice.price ? marketPrice.price : '0');
return bigAsset.times(bigMarketPrice).toFixed(2);
};

export const getAssetUnbondingBalancePrice = (asset: UserAsset, marketPrice: AssetMarketPrice) => {
const bigAsset = new Big(scaledUnbondingBalance(asset));
const bigMarketPrice = new Big(marketPrice.price);
const bigMarketPrice = new Big(marketPrice.price ? marketPrice.price : '0');
return bigAsset.times(bigMarketPrice).toFixed(2);
};

export const getAssetRewardsBalancePrice = (asset: UserAsset, marketPrice: AssetMarketPrice) => {
const bigAsset = new Big(scaledRewardBalance(asset));
const bigMarketPrice = new Big(marketPrice.price);
const bigMarketPrice = new Big(marketPrice.price ? marketPrice.price : '0');
return bigAsset.times(bigMarketPrice).toFixed(2);
};
6 changes: 3 additions & 3 deletions src/pages/assets/components/AssetTypeTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const AssetTypeTooltip: React.FC<AssetTypeTooltipProps> = props => {
<>
{t('assets.assetTypeTooltip.nativeToken', {
chainName: getChainName(currentAsset?.name, currentSession.wallet.config),
nativeToken: currentAsset.symbol,
nativeToken: 'CRO',
assetType: 'Cronos',
})}
<br />
Expand All @@ -45,7 +45,7 @@ const AssetTypeTooltip: React.FC<AssetTypeTooltipProps> = props => {
<>
{t('assets.assetTypeTooltip.crc20', {
chainName: getChainName(currentAsset?.name, currentSession.wallet.config),
nativeToken: currentAsset.symbol,
nativeToken: 'CRO',
assetType: 'CRC20',
})}
<br />
Expand All @@ -64,7 +64,7 @@ const AssetTypeTooltip: React.FC<AssetTypeTooltipProps> = props => {
<>
{t('assets.assetTypeTooltip.crc20', {
chainName: getChainName(currentAsset?.name, currentSession.wallet.config),
nativeToken: currentAsset.symbol,
nativeToken: 'ETH',
assetType: 'ERC20',
})}
<br />
Expand Down
2 changes: 1 addition & 1 deletion src/pages/assets/components/FormSend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ const FormSend: React.FC<FormSendProps> = props => {
<div className="label">{t('send.modal1.label3')}</div>
<div>
{`${formValues?.amount} ${walletAsset?.symbol}`}{' '}
{walletAsset && localFiatSymbol && assetMarketData
{walletAsset && localFiatSymbol && assetMarketData && assetMarketData.price
? `(${localFiatSymbol}${numeral(
getAssetAmountInFiat(formValues?.amount, assetMarketData),
).format('0,0.00')})`
Expand Down
3 changes: 2 additions & 1 deletion src/pages/bridge/components/BridgeTransactionHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ const BridgeTransactionHistory = () => {
const convertBridgeTransfers = (allTransfers: BridgeTransaction[]) => {
const isTestnet = bridgeService.checkIfTestnet(session.wallet.config.network);

return allTransfers.map(transfer => {
return allTransfers.map((transfer, idx) => {
const data: BridgeTransferTabularData = {
key:
idx.toString() +
transfer.sourceTransactionId +
transfer.sourceAddress +
transfer.destinationTransactionId +
Expand Down
2 changes: 1 addition & 1 deletion src/pages/dapp/assets/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ const unListedProjects: CronosProject[] = [
category: ['Yield Aggregator'],
logo: 'single-finance-logo.png',
description: '',
link: 'https://app.singlefinance.io/prelaunch-vault/stake',
link: 'https://app.singlefinance.io/single-click',
twitter: '',
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/pages/dapp/dapp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const DappList: Dapp[] = [
alt: 'tectonic-logo',
description:
'Tectonic is a cross-chain money market for earning passive yield and accessing instant backed loans.',
url: 'https://app.tectonic.finance/',
url: 'https://tectonic.finance/',
},
// {
// name: 'Cronos Chimp Club',
Expand Down
11 changes: 11 additions & 0 deletions src/pages/settings/settings.less
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@
line-height: 22px;
background-color: #e4f4ff;
}
.auto-update-duration {
width: 180px;
height: 30px;
margin-left: 10px;
.ant-select-selector,
.ant-select-selection-search,
.ant-select-selection-item {
height: 30px;
line-height: 30px;
}
}
}
}

Expand Down
45 changes: 34 additions & 11 deletions src/pages/settings/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ import {
SUPPORTED_CURRENCY,
WalletConfig,
SupportedCurrency,
AUTO_UPDATE_DISABLE_DURATIONS,
} from '../../config/StaticConfig';
import { LEDGER_WALLET_TYPE } from '../../service/LedgerService';
import { AnalyticsService } from '../../service/analytics/AnalyticsService';
import { generalConfigService } from '../../storage/GeneralConfigService';
import { UserAsset, UserAssetConfig, UserAssetType } from '../../models/UserAsset';
import { UserAsset, UserAssetConfig } from '../../models/UserAsset';
import AddressBook from './tabs/AddressBook/AddressBook';
import { getChainName } from '../../utils/utils';
import { getChainName, getCronosTendermintAsset } from '../../utils/utils';
import { AssetIcon } from '../../components/AssetIcon';

const { ipcRenderer } = window.require('electron');
Expand Down Expand Up @@ -273,6 +274,7 @@ function MetaInfoComponent() {
const [defaultAutoUpdateExpireTime, setDefaultAutoUpdateExpireTime] = useState<
number | undefined
>();
const [autoUpdateDisableDuration, setAutoUpdateDisableDuration] = useState<number>(14);
const [supportedCurrencies, setSupportedCurrencies] = useState<SupportedCurrency[]>([]);
const [t, i18n] = useTranslation();

Expand Down Expand Up @@ -391,6 +393,10 @@ function MetaInfoComponent() {
setMomentLocale();
};

const onSwitchAutoUpdateDuration = value => {
setAutoUpdateDisableDuration(value);
};

const onSwitchCurrency = async value => {
if (session.currency === value.toString()) {
return;
Expand Down Expand Up @@ -501,7 +507,9 @@ function MetaInfoComponent() {
const newState = !defaultAutoUpdateDisabled;
setDefaultAutoUpdateDisabled(newState);

const expireTime = newState ? new Date().setDate(new Date().getDate() + 30) : 0;
const expireTime = newState
? new Date().setDate(new Date().getDate() + autoUpdateDisableDuration)
: 0;
setDefaultAutoUpdateExpireTime(expireTime);

ipcRenderer.send('set_auto_update_expire_time', expireTime);
Expand Down Expand Up @@ -603,7 +611,24 @@ function MetaInfoComponent() {
onChange={onAllowAutoUpdateChange}
disabled={updateLoading}
/>{' '}
{defaultAutoUpdateDisabled ? t('general.disabled') : t('general.enabled')}
{defaultAutoUpdateDisabled ? t('general.disabled') : t('general.enabled')}{' '}
{!defaultAutoUpdateDisabled || !defaultAutoUpdateExpireTime ? (
<Select
className="auto-update-duration"
onChange={onSwitchAutoUpdateDuration}
value={autoUpdateDisableDuration}
>
{AUTO_UPDATE_DISABLE_DURATIONS.map(duration => {
return (
<Option value={duration} key={duration}>
{t('settings.autoUpdate.duration', { duration })}
</Option>
);
})}
</Select>
) : (
<></>
)}
</div>
{walletType !== LEDGER_WALLET_TYPE ? (
<>
Expand Down Expand Up @@ -740,9 +765,9 @@ const FormSettings = () => {
const [isButtonDisabled, setIsButtonDisabled] = useState(true);
const [isConfirmationModalVisible, setIsConfirmationModalVisible] = useState(false);
const [isConfirmClearVisible, setIsConfirmClearVisible] = useState(false);
const [currentAssetIdentifier, setCurrentAssetIdentifier] = useState<string>();
const [session, setSession] = useRecoilState(sessionState);
const [walletAllAssets, setWalletAllAssets] = useRecoilState(walletAllAssetsState);
const [currentAssetIdentifier, setCurrentAssetIdentifier] = useState<string>();

const defaultSettings: UserAssetConfig =
session.activeAsset?.config || getAssetConfigFromWalletConfig(session.wallet.config);
Expand All @@ -757,12 +782,7 @@ const FormSettings = () => {
let gasLimit = FIXED_DEFAULT_GAS_LIMIT;

useEffect(() => {
const selectedIdentifier = walletAllAssets
.filter(asset => {
return asset.assetType !== UserAssetType.CRC_20_TOKEN;
})
.find(asset => asset.identifier === session.activeAsset?.identifier)?.identifier;
setCurrentAssetIdentifier(selectedIdentifier || walletAllAssets[0].identifier);
const croAsset = getCronosTendermintAsset(walletAllAssets);

if (defaultSettings.fee !== undefined) {
networkFee = defaultSettings.fee.networkFee;
Expand All @@ -778,6 +798,9 @@ const FormSettings = () => {
networkFee,
gasLimit,
});
if (!currentAssetIdentifier && croAsset) {
setCurrentAssetIdentifier(croAsset?.identifier);
}
}, [form, defaultSettings, walletAllAssets, setSession]);

const onFinish = async values => {
Expand Down
29 changes: 13 additions & 16 deletions src/pages/staking/staking.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ const FormDelegationRequest = props => {
<div className="label">{t('staking.modal1.label3')}</div>
<div>
{`${formValues?.amount} ${walletAsset?.symbol}`}{' '}
{walletAsset && assetMarketData
{walletAsset && assetMarketData && assetMarketData.price
? `(${localFiatSymbol}${numeral(
getAssetAmountInFiat(formValues?.amount, assetMarketData),
).format('0,0.00')})`
Expand Down Expand Up @@ -1337,12 +1337,16 @@ const FormWithdrawStakingReward = () => {
},
{
title: t('staking.formWithdralStakingReward.table.withdraw'),
dataIndex: 'withdrawAction',
key: 'withdrawAction',
render: () => (
render: record => (
<>
<a
onClick={() => {
setWithdrawValues({
validatorAddress: record.validatorAddress,
rewardAmount: record.rewardAmount,
rewardMarketPrice: record.rewardMarketPrice,
});
setRewardAction('withdraw');
setTimeout(() => {
showPasswordInput('withdraw');
Expand All @@ -1356,12 +1360,16 @@ const FormWithdrawStakingReward = () => {
},
{
title: t('staking.formWithdralStakingReward.table.restake'),
dataIndex: 'restakeAction',
key: 'restakeAction',
render: () => (
render: record => (
<>
<a
onClick={() => {
setWithdrawValues({
validatorAddress: record.validatorAddress,
rewardAmount: record.rewardAmount,
rewardMarketPrice: record.rewardMarketPrice,
});
setRewardAction('restake');
setTimeout(() => {
showPasswordInput('restake');
Expand Down Expand Up @@ -1389,17 +1397,6 @@ const FormWithdrawStakingReward = () => {
spinning: isRewardsLoading,
}}
dataSource={rewards}
onRow={record => {
return {
onClick: () => {
setWithdrawValues({
validatorAddress: record.validatorAddress,
rewardAmount: record.rewardAmount,
rewardMarketPrice: record.rewardMarketPrice,
});
},
};
}}
/>
);
};
Expand Down
6 changes: 4 additions & 2 deletions src/service/rpc/MarketApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
CryptoComSlugResponse,
CryptoTokenPriceAPIResponse,
} from './models/marketApi.models';
import { CRC20MainnetTokenInfos } from '../../config/CRC20Tokens';

export interface IMarketApi {
getAssetPrice(assetSymbol: string, currency: string): Promise<AssetMarketPrice>;
Expand Down Expand Up @@ -82,6 +83,7 @@ export class CroMarketApi implements IMarketApi {
}

public async getTokenPriceFromCryptoCom(cryptoSymbol: string, fiatCurrency: string) {
const whitelistedCRC20Tokens: string[] = Array.from( CRC20MainnetTokenInfos.keys() );
const allTokensSlugMap: CryptoComSlugResponse[] = await this.loadTokenSlugMap();

const tokenSlugInfo = allTokensSlugMap.filter(tokenSlug => tokenSlug.symbol === cryptoSymbol);
Expand All @@ -102,9 +104,9 @@ export class CroMarketApi implements IMarketApi {
}),
);

// Filter Cronos token price only
// Filter Cronos / whitelisted token price only
const tokenPriceInUSD = tokenPriceResponses.find(token =>
token.data.tags.includes('cronos-ecosystem'),
token.data.tags.includes('cronos-ecosystem') || whitelistedCRC20Tokens.includes(token.data.symbol)
);

if (!tokenPriceInUSD) {
Expand Down
Loading

0 comments on commit 4ca78f6

Please sign in to comment.