Skip to content

Commit

Permalink
[DDW-330] Fix wallet delegation minimum Balance logic (#2111)
Browse files Browse the repository at this point in the history
* [DDW-330] Fix wallet delegation min amount logic

* [DDW-330] CHANGELOG

* Prevent showing having trouble syncing after verification

* fix build order

* [DDW-330] Temporary dummy wallets

* [DDW-330] Remove testing function

* [DDW-330] Remove unused error message

* [DDW-330] Fix withdrawal param for createTransaction and getTransactionFee

* [DDW-330] Remove unecessary comment

* [DDW-330] Disable Yoroi ITN wallet restoration, Fix tx create/fee-estimate Api integration

* [DDW-330] Bump Daedalus version

Co-authored-by: Nikola Glumac <[email protected]>
Co-authored-by: Samuel Leathers <[email protected]>
  • Loading branch information
3 people authored Aug 3, 2020
1 parent 55967d4 commit b919b12
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 69 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
Changelog
=========

## vNext
## 2.0.1

### Features

- Disabled creating Byron wallets ([PR 2126](https://github.com/input-output-hk/daedalus/pull/2126))

### Fixes

- Improved wallet delegation error messages ([PR 2111](https://github.com/input-output-hk/daedalus/pull/2111))
- Fixed Daedalus logo animation on the "Loading" screen ([PR 2124](https://github.com/input-output-hk/daedalus/pull/2124))
- Fixed text copy on the "Delegation center" screen ([PR 2125](https://github.com/input-output-hk/daedalus/pull/2125))

Expand Down
2 changes: 1 addition & 1 deletion installer-clusters.cfg
Original file line number Diff line number Diff line change
@@ -1 +1 @@
shelley_testnet_v6 shelley_qa mainnet_flight testnet mainnet staging
mainnet mainnet_flight testnet shelley_testnet_v6 shelley_qa staging
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "daedalus",
"productName": "Daedalus",
"version": "2.0.0",
"version": "2.0.1",
"description": "Cryptocurrency Wallet",
"main": "./dist/main/index.js",
"scripts": {
Expand Down
4 changes: 3 additions & 1 deletion source/renderer/app/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
WalletTransaction,
TransactionTypes,
TransactionStates,
TransactionWithdrawal,
} from '../domains/WalletTransaction';
import WalletAddress from '../domains/WalletAddress';

Expand Down Expand Up @@ -225,7 +226,6 @@ export default class AdaApi {
this.config
);
logger.debug('AdaApi::getWallets success', { wallets, legacyWallets });

map(legacyWallets, legacyAdaWallet => {
const extraLegacyWalletProps = {
address_pool_gap: 0, // Not needed for legacy wallets
Expand Down Expand Up @@ -633,6 +633,7 @@ export default class AdaApi {
},
],
passphrase,
withdrawal: TransactionWithdrawal,
};

let response: Transaction;
Expand Down Expand Up @@ -694,6 +695,7 @@ export default class AdaApi {
},
},
],
withdrawal: TransactionWithdrawal,
};

let response: TransactionFee;
Expand Down
12 changes: 2 additions & 10 deletions source/renderer/app/api/transactions/requests/createTransaction.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
// @flow
import type { RequestConfig } from '../../common/types';
import type { Transaction, TransactionPaymentData } from '../types';
import type { Transaction, TransactionParams } from '../types';
import { request } from '../../utils/request';

export type TransactionParams = {
walletId: string,
data: {
payments: Array<TransactionPaymentData>,
passphrase: string,
},
};

export const createTransaction = (
config: RequestConfig,
{ walletId, data }: TransactionParams
Expand All @@ -21,6 +13,6 @@ export const createTransaction = (
path: `/v2/wallets/${walletId}/transactions/`,
...config,
},
{ withdrawRewards: 'self' },
{},
data
);
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
// @flow
import type { RequestConfig } from '../../common/types';
import type { TransactionPaymentData, TransactionFee } from '../types';
import type { TransactionFee, GetTransactionFeeParams } from '../types';
import { request } from '../../utils/request';

export type GetTransactionFeeParams = {
walletId: string,
data: {
payments: Array<TransactionPaymentData>,
},
};

export const getTransactionFee = (
config: RequestConfig,
{ walletId, data }: GetTransactionFeeParams
Expand All @@ -20,6 +13,6 @@ export const getTransactionFee = (
path: `/v2/wallets/${walletId}/payment-fees`,
...config,
},
{ withdrawRewards: 'self' },
{},
data
);
18 changes: 18 additions & 0 deletions source/renderer/app/api/transactions/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export type TransactionWithdrawals = {
stake_address: string,
amount: TransactionAmount,
};
export type TransactionWithdrawalType = 'self';

export type TransactionState = 'pending' | 'in_ledger';

Expand Down Expand Up @@ -117,11 +118,28 @@ export type GetTransactionsResponse = {
total: number,
};

export type TransactionParams = {
walletId: string,
data: {
payments: Array<TransactionPaymentData>,
passphrase: string,
withdrawal: TransactionWithdrawalType,
},
};

export type TransactionFeeAmount = {
quantity: number,
unit: WalletUnits.LOVELACE,
};

export type GetTransactionFeeParams = {
walletId: string,
data: {
payments: Array<TransactionPaymentData>,
withdrawal: TransactionWithdrawalType,
},
};

export type TransactionPaymentData = {
address: string,
amount: TransactionFeeAmount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ export default class SyncingConnecting extends Component<Props, State> {
};

componentDidMount() {
this._defensivelyStartTimers(this.props.isConnected);
const { isConnected, isVerifyingBlockchain } = this.props;
this._defensivelyStartTimers(isConnected, isVerifyingBlockchain);
}

componentDidUpdate() {
Expand All @@ -79,9 +80,12 @@ export default class SyncingConnecting extends Component<Props, State> {
isFlight,
isVerifyingBlockchain,
} = this.props;
const canResetConnecting = this._connectingTimerShouldStop(isConnected);
const canResetConnecting = this._connectingTimerShouldStop(
isConnected,
isVerifyingBlockchain
);

this._defensivelyStartTimers(isConnected);
this._defensivelyStartTimers(isConnected, isVerifyingBlockchain);
if (canResetConnecting) {
this._resetConnectingTime();
}
Expand All @@ -108,14 +112,26 @@ export default class SyncingConnecting extends Component<Props, State> {
this._resetConnectingTime();
}

_connectingTimerShouldStart = (isConnected: boolean): boolean =>
!isConnected && connectingInterval === null;
_connectingTimerShouldStart = (
isConnected: boolean,
isVerifyingBlockchain: boolean
): boolean =>
!isConnected && !isVerifyingBlockchain && connectingInterval === null;

_connectingTimerShouldStop = (isConnected: boolean): boolean =>
isConnected && connectingInterval !== null;
_connectingTimerShouldStop = (
isConnected: boolean,
isVerifyingBlockchain: boolean
): boolean =>
(isConnected || isVerifyingBlockchain) && connectingInterval !== null;

_defensivelyStartTimers = (isConnected: boolean) => {
const needConnectingTimer = this._connectingTimerShouldStart(isConnected);
_defensivelyStartTimers = (
isConnected: boolean,
isVerifyingBlockchain: boolean
) => {
const needConnectingTimer = this._connectingTimerShouldStart(
isConnected,
isVerifyingBlockchain
);
if (needConnectingTimer) {
connectingInterval = setInterval(this._incrementConnectingTime, 1000);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,6 @@ const messages = defineMessages({
description:
'errorMinDelegationFunds Error Label on the delegation setup "choose wallet" step dialog.',
},
errorMinDelegationFundsHasRewards: {
id:
'staking.delegationSetup.chooseWallet.step.dialog.errorMinDelegationFundsHasRewards',
defaultMessage:
'!!!This wallet does not contain the minimum amount of {minDelegationFunds} ADA which is required for delegation to be available.',
description:
'errorMinDelegationFundsHasRewards Error Label on the delegation setup "choose wallet" step dialog.',
},
errorMinDelegationFundsRewardsOnly: {
id:
'staking.delegationSetup.chooseWallet.step.dialog.errorMinDelegationFundsRewardsOnly',
Expand Down Expand Up @@ -155,11 +147,6 @@ export default class DelegationStepsChooseWalletDialog extends Component<
// Wallet only has Reward balance
else if (!amount.isZero() && amount.equals(reward))
errorMessage = messages.errorMinDelegationFundsRewardsOnly;
// Wallet balance - rewards < min delegation funds
/*
else if (!reward.isZero())
errorMessage = messages.errorMinDelegationFundsHasRewards;
*/
// Wallet balance < min delegation funds
else errorMessage = messages.errorMinDelegationFunds;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ export default class WalletTypeDialog extends Component<Props, State> {
}
return {
key: kind,
disabled: !isShelleyActivated && kind.includes('Shelley'),
disabled:
(!isShelleyActivated && kind.includes('Shelley')) ||
kind === WALLET_YOROI_KINDS.SHELLEY_15_WORD,
label: <FormattedHTMLMessage {...msg} />,
selected: value === kind,
onChange: () => this.props.onSetWalletKind(kind, kindParam),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ export default class DelegationSetupWizardDialogContainer extends Component<
walletReward?: BigNumber = 0
) =>
walletAmount &&
walletAmount.minus(walletReward).gte(new BigNumber(MIN_DELEGATION_FUNDS));
walletAmount.gte(new BigNumber(MIN_DELEGATION_FUNDS)) &&
!walletAmount.equals(walletReward);

get selectedWalletId() {
return get(
Expand Down
3 changes: 3 additions & 0 deletions source/renderer/app/domains/WalletTransaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
TransactionType,
TransactionDepth,
TransactionState,
TransactionWithdrawalType,
} from '../api/transactions/types';

export const TransactionStates: EnumMap<string, TransactionState> = {
Expand All @@ -21,6 +22,8 @@ export const TransactionTypes: EnumMap<string, TransactionType> = {
EXCHANGE: 'exchange',
};

export const TransactionWithdrawal: TransactionWithdrawalType = 'self';

export class WalletTransaction {
@observable id: string = '';
@observable type: TransactionType;
Expand Down
26 changes: 6 additions & 20 deletions source/renderer/app/i18n/locales/defaultMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -3550,60 +3550,46 @@
"line": 54
}
},
{
"defaultMessage": "!!!This wallet does not contain the minimum amount of {minDelegationFunds} ADA which is required for delegation to be available.",
"description": "errorMinDelegationFundsHasRewards Error Label on the delegation setup \"choose wallet\" step dialog.",
"end": {
"column": 3,
"line": 69
},
"file": "source/renderer/app/components/staking/delegation-setup-wizard/DelegationStepsChooseWalletDialog.js",
"id": "staking.delegationSetup.chooseWallet.step.dialog.errorMinDelegationFundsHasRewards",
"start": {
"column": 37,
"line": 62
}
},
{
"defaultMessage": "!!!This wallet contains only rewards balances so it cannot be delegated.",
"description": "errorMinDelegationFundsRewardsOnly Error Label on the delegation setup \"choose wallet\" step dialog.",
"end": {
"column": 3,
"line": 77
"line": 69
},
"file": "source/renderer/app/components/staking/delegation-setup-wizard/DelegationStepsChooseWalletDialog.js",
"id": "staking.delegationSetup.chooseWallet.step.dialog.errorMinDelegationFundsRewardsOnly",
"start": {
"column": 38,
"line": 70
"line": 62
}
},
{
"defaultMessage": "!!!This wallet can’t be used for delegation while it’s being synced.",
"description": "RestoringWallet Error Label on the delegation setup \"choose wallet\" step dialog.",
"end": {
"column": 3,
"line": 84
"line": 76
},
"file": "source/renderer/app/components/staking/delegation-setup-wizard/DelegationStepsChooseWalletDialog.js",
"id": "staking.delegationSetup.chooseWallet.step.dialog.errorRestoringWallet",
"start": {
"column": 24,
"line": 78
"line": 70
}
},
{
"defaultMessage": "!!!Continue",
"description": "Label for continue button on the delegation setup \"choose wallet\" step dialog.",
"end": {
"column": 3,
"line": 90
"line": 82
},
"file": "source/renderer/app/components/staking/delegation-setup-wizard/DelegationStepsChooseWalletDialog.js",
"id": "staking.delegationSetup.chooseWallet.step.dialog.continueButtonLabel",
"start": {
"column": 23,
"line": 85
"line": 77
}
}
],
Expand Down
1 change: 0 additions & 1 deletion source/renderer/app/i18n/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@
"staking.delegationSetup.chooseWallet.step.dialog.continueButtonLabel": "Continue",
"staking.delegationSetup.chooseWallet.step.dialog.description": "Choose a wallet that holds the funds you want to delegate. The selected wallet must contain a <span>minimum amount of {minDelegationFunds} ADA</span> for delegation to be an option.",
"staking.delegationSetup.chooseWallet.step.dialog.errorMinDelegationFunds": "This wallet does not contain the minimum amount of {minDelegationFunds} ADA which is required for delegation to be available. Please select a wallet with <span>a minimum amount of {minDelegationFunds} ADA</span> and click continue.",
"staking.delegationSetup.chooseWallet.step.dialog.errorMinDelegationFundsHasRewards": "This wallet does not contain the minimum amount of {minDelegationFunds} ADA which is required for delegation to be available. Rewards cannot be used for this purpose. Please select a wallet with <span>a minimum amount of {minDelegationFunds} ADA</span> and click continue.",
"staking.delegationSetup.chooseWallet.step.dialog.errorMinDelegationFundsRewardsOnly": "This wallet contains only rewards balances so it cannot be delegated.",
"staking.delegationSetup.chooseWallet.step.dialog.errorRestoringWallet": "This wallet can’t be used for delegation while it’s being synced.",
"staking.delegationSetup.chooseWallet.step.dialog.selectWalletInputLabel": "Wallet",
Expand Down
1 change: 0 additions & 1 deletion source/renderer/app/i18n/locales/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@
"staking.delegationSetup.chooseWallet.step.dialog.continueButtonLabel": "続ける",
"staking.delegationSetup.chooseWallet.step.dialog.description": "このウォレットには委任を有効にするために必要な最低額{minDelegationFunds}ADAが入っていません。<span>{minDelegationFunds}ADA以上</span>入っているウォレットを選択して、[続ける]をクリックしてください。",
"staking.delegationSetup.chooseWallet.step.dialog.errorMinDelegationFunds": "選択されたウォレットには委任を有効にするために必要な最低額{minDelegationFunds}ADAが入っていません。<span>{minDelegationFunds}ADA以上</span>入っているウォレットを選択して、[続ける]をクリックしてください。",
"staking.delegationSetup.chooseWallet.step.dialog.errorMinDelegationFundsHasRewards": "このウォレットには委任を有効にするために必要な最低額{minDelegationFunds}ADAが入っていません。Rewards cannot be used for this purpose. <span>{minDelegationFunds}ADA以上</span><span>{minDelegationFunds}ADA以上</span>入っているウォレットを選択して、[続ける]をクリックしてください。",
"staking.delegationSetup.chooseWallet.step.dialog.errorMinDelegationFundsRewardsOnly": "このウォレットに含まれているのは報酬残高のみであるため、委任はできません。",
"staking.delegationSetup.chooseWallet.step.dialog.errorRestoringWallet": "このウォレットは現在同期中のため委任に使用することができません。",
"staking.delegationSetup.chooseWallet.step.dialog.selectWalletInputLabel": "ウォレット",
Expand Down

0 comments on commit b919b12

Please sign in to comment.