Skip to content

Commit

Permalink
Merge pull request #330 from crypto-com/dev
Browse files Browse the repository at this point in the history
V0.1.1 Master Release - Fix lately reported bugs from yesterday release
  • Loading branch information
crypto-eddy authored Mar 25, 2021
2 parents daddff0 + ff820fc commit 6f86dc6
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 16 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ All notable changes to this project will be documented in this file.

*Released*

## [v0.1.1] - 2021-03-25

### Bug Fixes
- Fix blank screens issues on older databases
- Fetch a new validator set to the store on wallet change event


## [v0.1.0] - 2021-03-24

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chain-desktop-wallet",
"version": "0.1.0",
"version": "0.1.1",
"description": "Crypto.com Chain Desktop Wallet App",
"repository": "github:crypto-com/chain-desktop-wallet",
"author": "Crypto.org <chain@crypto.org>",
Expand Down
25 changes: 21 additions & 4 deletions src/layouts/home/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ import Icon, {
SettingOutlined,
DeleteOutlined,
} from '@ant-design/icons';
import { useRecoilState } from 'recoil';
import { useRecoilState, useSetRecoilState } from 'recoil';

import { sessionState, walletAssetState, walletListState } from '../../recoil/atom';
import {
sessionState,
validatorTopListState,
walletAssetState,
walletListState,
} from '../../recoil/atom';
import { trimString } from '../../utils/utils';
import WalletIcon from '../../assets/icon-wallet-grey.svg';
import IconHome from '../../svg/IconHome';
Expand Down Expand Up @@ -47,6 +52,17 @@ function HomeLayout(props: HomeLayoutProps) {
const [isConfirmationModalVisible, setIsConfirmationModalVisible] = useState(false);
const [isButtonLoading, setIsButtonLoading] = useState(false);
const didMountRef = useRef(false);
const setValidatorTopList = useSetRecoilState(validatorTopListState);

async function fetchAndSetNewValidators() {
try {
const currentValidatorList = await walletService.getLatestTopValidators();
setValidatorTopList(currentValidatorList);
} catch (e) {
// eslint-disable-next-line no-console
console.log('Failed loading new wallet validators list', e);
}
}

const onWalletDeleteFinish = async () => {
setIsButtonLoading(true);
Expand All @@ -66,6 +82,7 @@ function HomeLayout(props: HomeLayoutProps) {
setSession(currentSession);
setUserAsset(currentAsset);
await walletService.syncAll(currentSession);
await fetchAndSetNewValidators();

setIsButtonLoading(false);
setIsConfirmationModalVisible(false);
Expand All @@ -91,8 +108,8 @@ function HomeLayout(props: HomeLayoutProps) {
setHasWallet(hasWalletBeenCreated);
setSession(sessionData);
setUserAsset(currentAsset);

setWalletList(allWalletsData);
await fetchAndSetNewValidators();
setLoading(false);
};

Expand Down Expand Up @@ -144,7 +161,7 @@ function HomeLayout(props: HomeLayoutProps) {
setSession(currentSession);
setUserAsset(currentAsset);
await walletService.syncAll(currentSession);

await fetchAndSetNewValidators();
setLoading(false);
};

Expand Down
10 changes: 8 additions & 2 deletions src/pages/send/send.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ const FormSend = () => {
const transferInoputAmount = adjustedTransactionAmount(
form.getFieldValue('amount'),
walletAsset,
currentSession.wallet.config.fee.networkFee,
currentSession.wallet.config.fee !== undefined &&
currentSession.wallet.config.fee.networkFee !== undefined
? currentSession.wallet.config.fee.networkFee
: FIXED_DEFAULT_FEE,
);
setFormValues({
...form.getFieldsValue(),
Expand Down Expand Up @@ -238,7 +241,10 @@ const FormSend = () => {
<div className="item">
<div className="label">Transaction Fee</div>
<div>{`${getNormalScaleAmount(
currentSession.wallet.config.fee.networkFee ?? FIXED_DEFAULT_FEE,
currentSession.wallet.config.fee !== undefined &&
currentSession.wallet.config.fee.networkFee !== undefined
? currentSession.wallet.config.fee.networkFee
: FIXED_DEFAULT_FEE,
walletAsset,
)} ${walletAsset.symbol}`}</div>
</div>
Expand Down
25 changes: 21 additions & 4 deletions src/pages/settings/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { SettingsDataUpdate } from '../../models/Wallet';
import { Session } from '../../models/Session';
import ModalPopup from '../../components/ModalPopup/ModalPopup';

import { FIXED_DEFAULT_FEE, FIXED_DEFAULT_GAS_LIMIT } from '../../config/StaticConfig';

const { Header, Content, Footer } = Layout;
const { TabPane } = Tabs;
const layout = {
Expand Down Expand Up @@ -107,27 +109,42 @@ const FormSettings = () => {
const defaultSettings = session.wallet.config;
const didMountRef = useRef(false);
const history = useHistory();
let networkFee = FIXED_DEFAULT_FEE;
let gasLimit = FIXED_DEFAULT_GAS_LIMIT;

useEffect(() => {
if (!didMountRef.current) {
didMountRef.current = true;

if (defaultSettings.fee !== undefined) {
networkFee = defaultSettings.fee.networkFee;
}
if (defaultSettings.fee !== undefined) {
gasLimit = defaultSettings.fee.gasLimit;
}

form.setFieldsValue({
nodeUrl: defaultSettings.nodeUrl,
chainId: defaultSettings.network.chainId,
indexingUrl: defaultSettings.indexingUrl,
networkFee: defaultSettings.fee.networkFee,
gasLimit: defaultSettings.fee.gasLimit,
networkFee,
gasLimit,
});
}
}, [form, defaultSettings]);

const onFinish = async values => {
const defaultGasLimit =
defaultSettings.fee !== undefined ? defaultSettings.fee.gasLimit : FIXED_DEFAULT_GAS_LIMIT;
const defaultNetworkFee =
defaultSettings.fee !== undefined ? defaultSettings.fee.networkFee : FIXED_DEFAULT_FEE;

if (
defaultSettings.nodeUrl === values.nodeUrl &&
defaultSettings.indexingUrl === values.indexingUrl &&
defaultSettings.network.chainId === values.chainId &&
defaultSettings.fee.gasLimit === values.gasLimit &&
defaultSettings.fee.networkFee === values.networkFee
defaultGasLimit === values.gasLimit &&
defaultNetworkFee === values.networkFee
) {
// No value was updated, we stop here
return;
Expand Down
10 changes: 9 additions & 1 deletion src/pages/staking/staking.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { walletAssetState, sessionState, validatorTopListState } from '../../rec
import { scaledAmount, scaledBalance, UserAsset } from '../../models/UserAsset';
import { BroadCastResult, RewardTransaction } from '../../models/Transaction';
import { TransactionUtils } from '../../utils/TransactionUtils';
import { FIXED_DEFAULT_FEE } from '../../config/StaticConfig';
import {
adjustedTransactionAmount,
fromScientificNotation,
Expand Down Expand Up @@ -82,10 +83,17 @@ const FormDelegationRequest = () => {

const showConfirmationModal = () => {
setInputPasswordVisible(false);

const networkFee =
currentSession.wallet.config.fee !== undefined &&
currentSession.wallet.config.fee.networkFee !== undefined
? currentSession.wallet.config.fee.networkFee
: FIXED_DEFAULT_FEE;

const stakeInputAmount = adjustedTransactionAmount(
form.getFieldValue('amount'),
walletAsset,
currentSession.wallet.config.fee.networkFee,
networkFee,
);

setFormValues({
Expand Down
6 changes: 4 additions & 2 deletions src/service/signers/LedgerTransactionSigner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ export class LedgerTransactionSigner implements ITransactionSigner {
const rawTx = new cro.RawTransaction();
rawTx.setMemo(transaction.memo);

const networkFee = this.config.fee.networkFee ?? FIXED_DEFAULT_FEE;
const gasLimit = this.config.fee.gasLimit ?? FIXED_DEFAULT_GAS_LIMIT;
const networkFee =
this.config.fee !== undefined ? this.config.fee.networkFee : FIXED_DEFAULT_FEE;
const gasLimit =
this.config.fee !== undefined ? this.config.fee.gasLimit : FIXED_DEFAULT_GAS_LIMIT;

const fee = new cro.Coin(networkFee, Units.BASE);

Expand Down
6 changes: 4 additions & 2 deletions src/service/signers/TransactionSigner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ export class TransactionSigner implements ITransactionSigner {
const rawTx = new cro.RawTransaction();
rawTx.setMemo(transaction.memo);

const networkFee = this.config.fee.networkFee ?? FIXED_DEFAULT_FEE;
const gasLimit = this.config.fee.gasLimit ?? FIXED_DEFAULT_GAS_LIMIT;
const networkFee =
this.config.fee !== undefined ? this.config.fee.networkFee : FIXED_DEFAULT_FEE;
const gasLimit =
this.config.fee !== undefined ? this.config.fee.gasLimit : FIXED_DEFAULT_GAS_LIMIT;

const fee = new cro.Coin(networkFee, Units.BASE);

Expand Down
6 changes: 6 additions & 0 deletions src/storage/StorageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ export class StorageService {
previousWallet.config.indexingUrl = dataUpdate.indexingUrl;
}

if (previousWallet.config.fee === undefined)
previousWallet.config.fee = {
gasLimit: '0',
networkFee: '0',
};

if (dataUpdate.networkFee) {
previousWallet.config.fee.networkFee = dataUpdate.networkFee;
}
Expand Down

0 comments on commit 6f86dc6

Please sign in to comment.