Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DDW-149] Undelegating a wallet #2351

Merged
merged 59 commits into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
f7f2fb8
[DDW-149] Implement undelegate wallet dialog on wallet settings screen
topseniors Feb 8, 2021
40d1631
[DDW-149] Update changelog
topseniors Feb 8, 2021
50ffece
Merge branch 'develop' into feature/ddw-149-undelegating-wallet
topseniors Feb 8, 2021
287fcab
[DDW-149] Update fees and deposit of undelegate wallet confirmation d…
topseniors Feb 8, 2021
600a44a
[DDW-149] Show fees as absolute value on delegation/undelegation dialogs
topseniors Feb 8, 2021
d7dbd19
[DDW-149] Hide undelegate wallet panel for byron wallet
topseniors Feb 8, 2021
d4f8f21
[DDW-149] Add disability to undelegate wallet button
topseniors Feb 8, 2021
9ab1089
[DDW-149] Disable undelegate button when wallet is not delegated yet …
topseniors Feb 8, 2021
add662b
[DDW-149] Fix flow test
topseniors Feb 8, 2021
198d034
[DDW-149] Update undelegate wallet panel on wallet settings screen
topseniors Feb 9, 2021
87fd0d8
[DDW-149] Update undelegate wallet title translations
topseniors Feb 9, 2021
d98380d
[DDW-149] Update undelegate wallet translations
topseniors Feb 9, 2021
506c921
Merge branch 'develop' into feature/ddw-149-undelegating-wallet
topseniors Feb 10, 2021
71cc4c0
[DDW-149] Enable hardware wallet undelegation
topseniors Feb 11, 2021
a19ffcc
Merge branch 'develop' into feature/ddw-149-undelegating-wallet
topseniors Feb 11, 2021
a508ee7
[DDW-149] Fix delegation fee calculation handler
topseniors Feb 11, 2021
4511b1c
[DDW-149] Remove unnecessary undelege wallet handlers
topseniors Feb 11, 2021
dfc406e
Merge branch 'develop' into feature/ddw-149-undelegating-wallet
topseniors Feb 11, 2021
0d6f94b
[DDW-149] Add delegate and undelegate config
topseniors Feb 11, 2021
bc537c4
Merge branch 'develop' into feature/ddw-149-undelegating-wallet
topseniors Feb 11, 2021
65f726a
[DDW-149] Update undeleate wallet variable naming
topseniors Feb 11, 2021
d650958
[DDW-149] Remove unnecessary fee absolute value transformation
topseniors Feb 11, 2021
e7a16ca
[DDW-149] Update config variable names
topseniors Feb 11, 2021
bf7226e
[DDW-149] Remove unnecessary variable of stake pool quit request payload
topseniors Feb 12, 2021
ef0440c
[DDW-149] Adjust undelegate wallet box margin
topseniors Feb 12, 2021
d748c98
[DDW-149] Update undelegate wallet success dialog naming
topseniors Feb 12, 2021
b17c9a1
[DDW-149] Update undelegate wallet panel button click handler names
topseniors Feb 12, 2021
cd85fff
[DDW-149] Update undelegate wallet panel styles
topseniors Feb 12, 2021
788c04d
[DDW-149] Update undelegate wallet panel styles
topseniors Feb 12, 2021
6ae3374
[DDW-149] Add undelegate wallet config comment
topseniors Feb 12, 2021
c94d208
[DDW-149] Update props definition of undelegate wallet dialog container
topseniors Feb 12, 2021
549b062
[DDW-149] Fix storybook error
thedanheller Feb 12, 2021
5d52b79
Merge branch 'develop' into feature/ddw-149-undelegating-wallet
thedanheller Feb 12, 2021
109f853
[DDW-149] Add hardware wallet story for undelegating
topseniors Feb 12, 2021
c647bcb
[DDW-149] Change Wallet Settings Delegation to reflect Future Epoch
thedanheller Feb 12, 2021
f881519
[DDW-149] Fix issue with null status
thedanheller Feb 12, 2021
3f7d777
[DDW-149] Add Storybook groupId
thedanheller Feb 12, 2021
ff754d0
Updates CHANGELOG, Disables 'Voting Center' for Flight builds
nikolaglumac Feb 12, 2021
b857b7e
Re-enable Voting registration on Flight
nikolaglumac Feb 15, 2021
80cafa6
[DDW-149] Merges develop
nikolaglumac Feb 15, 2021
1c58db8
Merge branch 'develop' into feature/ddw-149-undelegating-wallet
topseniors Feb 15, 2021
fcdfae8
[DDW-149] Update hardware wallet fee calculation
topseniors Feb 15, 2021
88fddb0
Merge branch 'develop' into feature/ddw-149-undelegating-wallet
topseniors Feb 15, 2021
44286f6
[DDW-149] Update delegation and undelegation fee calculation
topseniors Feb 16, 2021
5cfa9f9
[DDW-149] Update wallet sync status checking on wallet settings screen
topseniors Feb 16, 2021
364b852
Merge branch 'develop' into feature/ddw-149-undelegating-wallet
topseniors Feb 16, 2021
347aaf3
Merge branch 'develop' into feature/ddw-149-undelegating-wallet
topseniors Feb 18, 2021
f730acc
[DDW-149] Show warning on wallet settings screen for non delegated wa…
topseniors Feb 18, 2021
44764c8
[DDW-149] Fix japanese translation
topseniors Feb 18, 2021
7aa9a34
Merge branch 'develop' into feature/ddw-149-undelegating-wallet
topseniors Feb 19, 2021
77d9515
[DDW-149] Bignumber isZero function exception handling
topseniors Feb 19, 2021
75936c4
[DDW-149] Fix CHANGELOG
nikolaglumac Feb 19, 2021
00431a3
[DDW-149] Apply current delegation status also to the wallet delegati…
topseniors Feb 19, 2021
302895f
[DDW-149] Fix variable naming
topseniors Feb 19, 2021
92e183f
[DDW-149] Fix undelegate wallet box style
topseniors Feb 19, 2021
e960ac5
Merge branch 'develop' into feature/ddw-149-undelegating-wallet
nikolaglumac Feb 19, 2021
26d1af4
[DDW-149] Fix delegation check logic
topseniors Feb 19, 2021
de83bd3
[DDW-149] Remove rewarded wallet invisibility on undelegation box
topseniors Feb 19, 2021
40f5779
[DDW-149] Disable wallet undelegation
nikolaglumac Feb 19, 2021
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ Changelog

## vNext

### Features

- Implemented "Undelegate wallet" feature on "Wallet settings" screen ([PR 2351](https://github.com/input-output-hk/daedalus/pull/2351))

### Fixes

- Fixed calendar style issue on Filter dialog on transaction list screen ([PR 2387](https://github.com/input-output-hk/daedalus/pull/2387))
Expand Down
7 changes: 2 additions & 5 deletions source/renderer/app/actions/wallets-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
HardwareWalletExtendedPublicKeyResponse,
} from '../../../common/types/hardware-wallets.types';
import type { CsvFileContent } from '../../../common/types/csv-request.types';
import type { QuitStakePoolRequest } from '../api/staking/types';

export type WalletImportFromFileParams = {
filePath: string,
Expand Down Expand Up @@ -44,11 +45,7 @@ export default class WalletsActions {
restoreWallet: Action<any> = new Action();
importWalletFromFile: Action<WalletImportFromFileParams> = new Action();
deleteWallet: Action<{ walletId: string, isLegacy: boolean }> = new Action();
undelegateWallet: Action<{
walletId: string,
stakePoolId: string,
passphrase: string,
}> = new Action();
undelegateWallet: Action<QuitStakePoolRequest> = new Action();
setUndelegateWalletSubmissionSuccess: Action<{
result: boolean,
}> = new Action();
Expand Down
38 changes: 28 additions & 10 deletions source/renderer/app/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ import {
SMASH_SERVERS_LIST,
MIN_REWARDS_REDEMPTION_RECEIVER_BALANCE,
REWARDS_REDEMPTION_FEE_CALCULATION_AMOUNT,
DELEGATION_DEPOSIT,
DELEGATION_ACTIONS,
} from '../config/stakingConfig';
import {
ADA_CERTIFICATE_MNEMONIC_LENGTH,
Expand Down Expand Up @@ -998,19 +1000,30 @@ export default class AdaApi {
});
}

const deposits = map(response.deposits, (deposit) => deposit.quantity);
const totalDeposits = deposits.length
? BigNumber.sum.apply(null, deposits)
const depositsArray = map(
response.deposits,
(deposit) => deposit.quantity
);
const deposits = depositsArray.length
? BigNumber.sum.apply(null, depositsArray)
: new BigNumber(0);
const feeWithDeposits = totalInputs.minus(totalOutputs);
const fee = feeWithDeposits.minus(totalDeposits);
// @TODO - Use api response when api is ready
const depositsReclaimed =
delegation && delegation.delegationAction === DELEGATION_ACTIONS.QUIT
? new BigNumber(DELEGATION_DEPOSIT).multipliedBy(LOVELACES_PER_ADA)
: new BigNumber(0);
const fee =
delegation && delegation.delegationAction === DELEGATION_ACTIONS.QUIT
? totalInputs.minus(totalOutputs).plus(depositsReclaimed)
: totalInputs.minus(totalOutputs).minus(deposits);

const extendedResponse = {
inputs: inputsData,
outputs: outputsData,
certificates: certificatesData,
feeWithDeposits: feeWithDeposits.dividedBy(LOVELACES_PER_ADA),
fee: fee.dividedBy(LOVELACES_PER_ADA),
deposits: deposits.dividedBy(LOVELACES_PER_ADA),
depositsReclaimed: depositsReclaimed.dividedBy(LOVELACES_PER_ADA),
};
logger.debug('AdaApi::selectCoins success', { extendedResponse });
return extendedResponse;
Expand Down Expand Up @@ -2479,7 +2492,9 @@ const _createWalletFromServerData = action(
const next = get(delegation, 'next', null);
const lastPendingStakePool = next ? last(next) : null;
const lastTarget = get(lastPendingStakePool, 'target', null);
const lastDelegationStakePoolId = isLegacy ? null : lastTarget;
const lastStatus = get(lastPendingStakePool, 'status', null);
const lastDelegatedStakePoolId = isLegacy ? null : lastTarget;
const lastDelegationStakePoolStatus = isLegacy ? null : lastStatus;

return new Wallet({
id,
Expand All @@ -2496,7 +2511,8 @@ const _createWalletFromServerData = action(
isHardwareWallet,
delegatedStakePoolId,
delegationStakePoolStatus,
lastDelegationStakePoolId,
lastDelegatedStakePoolId,
lastDelegationStakePoolStatus,
pendingDelegations: next,
discovery,
});
Expand Down Expand Up @@ -2605,10 +2621,12 @@ const _createDelegationFeeFromServerData = action(
const fee = new BigNumber(
get(data, ['estimated_max', 'quantity'], 0)
).dividedBy(LOVELACES_PER_ADA);
const deposit = new BigNumber(
const deposits = new BigNumber(
get(data, ['deposit', 'quantity'], 0)
).dividedBy(LOVELACES_PER_ADA);
return { fee, deposit };
// @TODO Use api response data when api is ready
const depositsReclaimed = new BigNumber(0);
return { fee, deposits, depositsReclaimed };
}
);

Expand Down
4 changes: 3 additions & 1 deletion source/renderer/app/api/staking/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,14 @@ export type GetDelegationFeeRequest = {

export type DelegationCalculateFeeResponse = {
fee: BigNumber,
deposit: BigNumber,
deposits: BigNumber,
depositsReclaimed: BigNumber,
};

export type QuitStakePoolRequest = {
walletId: string,
passphrase: string,
isHardwareWallet?: boolean,
};

export type GetRedeemItnRewardsFeeRequest = {
Expand Down
3 changes: 2 additions & 1 deletion source/renderer/app/api/transactions/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ export type CoinSelectionsResponse = {
inputs: Array<CoinSelectionInput>,
outputs: Array<CoinSelectionOutput>,
certificates: CoinSelectionCertificates,
feeWithDeposits: BigNumber,
deposits: BigNumber,
depositsReclaimed: BigNumber,
fee: BigNumber,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export default class DelegationStepsChooseStakePoolDialog extends Component<
);
const lastDelegatedStakePoolId = get(
selectedWallet,
'lastDelegationStakePoolId',
'lastDelegatedStakePoolId',
null
);
const delegatedStakePoolId = get(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,26 +305,28 @@ export default class DelegationStepsConfirmationDialog extends Component<Props>
{formattedWalletAmount(transactionFee.fee, false)}
</span>
<span className={styles.feesAmountLabel}>
&nbsp;{intl.formatMessage(globalMessages.unitAda)}
{` `}
{intl.formatMessage(globalMessages.unitAda)}
</span>
</>
)}
</p>
</div>
{transactionFee &&
transactionFee.deposit.isZero &&
!transactionFee.deposit.isZero() && (
transactionFee.deposits.isZero &&
!transactionFee.deposits.isZero() && (
<>
<div className={styles.depositWrapper}>
<p className={styles.depositLabel}>
{intl.formatMessage(messages.depositLabel)}
</p>
<p className={styles.depositAmount}>
<span>
{formattedWalletAmount(transactionFee.deposit, false)}
{formattedWalletAmount(transactionFee.deposits, false)}
</span>
<span className={styles.depositAmountLabel}>
&nbsp;{intl.formatMessage(globalMessages.unitAda)}
{` `}
{intl.formatMessage(globalMessages.unitAda)}
</span>
</p>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// @flow
import React, { Component } from 'react';
import { defineMessages, intlShape } from 'react-intl';
import { Button } from 'react-polymorph/lib/components/Button';
import styles from './DelegateWalletButton.scss';

const messages = defineMessages({
label: {
id: 'wallet.settings.delegateWalletButtonLabel',
defaultMessage: '!!!Delegate',
description: 'Label for the delegate button on wallet settings',
},
});

type Props = {
disabled?: boolean,
onDelegate: Function,
};

export default class DelegateWalletButton extends Component<Props> {
static contextTypes = {
intl: intlShape.isRequired,
};

render() {
const { disabled, onDelegate } = this.props;
const label = this.context.intl.formatMessage(messages.label);
return (
<Button
label={label}
disabled={disabled}
onClick={onDelegate}
themeOverrides={styles}
/>
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.root {
font-weight: 500;
height: 36px;
line-height: 36px;
margin-left: 20px;
min-width: 160px;
width: 160px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// @flow
import React, { Component } from 'react';
import { defineMessages, intlShape } from 'react-intl';
import { Button } from 'react-polymorph/lib/components/Button';
import styles from './UndelegateWalletButton.scss';

const messages = defineMessages({
label: {
id: 'wallet.settings.undelegateWalletButtonLabel',
defaultMessage: '!!!Undelegate',
description: 'Label for the undelegate button on wallet settings',
},
});

type Props = {
disabled?: boolean,
onUndelegate: Function,
};

export default class UndelegateWalletButton extends Component<Props> {
static contextTypes = {
intl: intlShape.isRequired,
};

render() {
const { disabled, onUndelegate } = this.props;
const label = this.context.intl.formatMessage(messages.label);
return (
<Button
className="flat"
label={label}
disabled={disabled}
onClick={onUndelegate}
themeOverrides={styles}
/>
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.root {
font-weight: 500;
height: 36px;
line-height: 36px;
margin-left: 20px;
min-width: 160px;
width: 160px;
}
Loading