Skip to content

Commit

Permalink
Merge branch 'develop' into feature/ddw-269-handle-app-automatic-update
Browse files Browse the repository at this point in the history
  • Loading branch information
thedanheller committed Aug 10, 2020
2 parents 132044c + 8172b22 commit 01e7e33
Show file tree
Hide file tree
Showing 51 changed files with 740 additions and 492 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
@@ -1,21 +1,35 @@
Changelog
=========

## 2.1.0

### Features

- ITN rewards redemption ([PR 2133](https://github.com/input-output-hk/daedalus/pull/2133))

### Chores

- Updated `cardano-wallet` to revision `4a4d0a65`
- Updated `cardano-wallet` to revision `d5b43356`

## 2.0.1

### Features

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

### 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))
- Stake pools search performance ([PR 2131](https://github.com/input-output-hk/daedalus/pull/2131))

### Chores

- Updated `cardano-wallet` to revision `03b7568b` ([PR 2119](https://github.com/input-output-hk/daedalus/pull/2119))
- Updated `cardano-wallet` to revision `e1890dbd` ([PR 2133](https://github.com/input-output-hk/daedalus/pull/2133))

## 2.0.0

Expand Down
6 changes: 3 additions & 3 deletions nix/sources.json
Expand Up @@ -29,10 +29,10 @@
"homepage": null,
"owner": "input-output-hk",
"repo": "cardano-wallet",
"rev": "03b7568bebe587d1e45d402536953c6ea1dc2d99",
"sha256": "0drmqrw9h4as57lix51ddafw25wcvj3bs1wvxrn8gbff1ilghnjh",
"rev": "d5b43356e4dbe9267ede9c8e912da6c893bdda85",
"sha256": "0r6c46dx7yryb54cj6sbw90i19xy4x10lprq7qda1wjd6rkxyqhf",
"type": "tarball",
"url": "https://github.com/input-output-hk/cardano-wallet/archive/03b7568bebe587d1e45d402536953c6ea1dc2d99.tar.gz",
"url": "https://github.com/input-output-hk/cardano-wallet/archive/d5b43356e4dbe9267ede9c8e912da6c893bdda85.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz",
"version": "v2020-04-28"
},
Expand Down
5 changes: 3 additions & 2 deletions package.json
@@ -1,7 +1,7 @@
{
"name": "daedalus",
"productName": "Daedalus",
"version": "2.0.1",
"version": "2.1.0",
"description": "Cryptocurrency Wallet",
"main": "./dist/main/index.js",
"scripts": {
Expand Down Expand Up @@ -200,6 +200,7 @@
"mobx-react-router": "4.1.0",
"moment": "2.24.0",
"node-downloader-helper": "1.0.13",
"omit-deep-lodash": "1.1.4",
"pbkdf2": "3.0.17",
"pdfkit": "0.8.3",
"prop-types": "15.7.2",
Expand All @@ -213,7 +214,6 @@
"react-custom-scrollbars": "4.2.1",
"react-datetime": "2.16.3",
"react-dom": "16.13.1",
"react-flip-move": "3.0.4",
"react-intl": "2.7.2",
"react-lottie": "1.2.3",
"react-markdown": "4.3.1",
Expand All @@ -223,6 +223,7 @@
"react-svg-inline": "2.1.1",
"react-virtualized": "9.21.2",
"recharts": "1.8.5",
"rimraf": "3.0.2",
"rotating-file-stream": "1.4.6",
"route-parser": "0.0.5",
"rust-cardano-crypto": "0.2.0",
Expand Down
5 changes: 3 additions & 2 deletions release-build.nix
Expand Up @@ -4,9 +4,10 @@

let
mkWindows = cluster: (import ./. { inherit cluster buildNum; target = "x86_64-windows"; HSMServer = "HSM"; }).windows-installer;
mkLinux = cluster: (import ./release.nix { inherit buildNum;}).${cluster}.installer.x86_64-linux;
mkLinux = cluster: (import ./. { inherit cluster buildNum;}).wrappedBundle;
pkgs = (import ./. {}).pkgs;
in pkgs.runCommand "signed-release" {} ''
mkdir $out
cp -v ${mkWindows "shelley_testnet_v6"}/*exe $out/
cp -v ${mkLinux "mainnet"}/*bin $out/
cp -v ${mkWindows "mainnet"}/*exe $out/
''
9 changes: 2 additions & 7 deletions source/common/utils/logging.js
@@ -1,5 +1,5 @@
// @flow
import { pickBy } from 'lodash';
import omitDeep from 'omit-deep-lodash';
import type {
FormatMessageContextParams,
ConstructMessageBodyParams,
Expand Down Expand Up @@ -30,12 +30,7 @@ export const filterLogData = (data: Object): Object => {
'passphrase',
'password',
];
return pickBy(data, (value, key) => {
if (sensitiveData.includes(key)) {
return false;
}
return true;
});
return omitDeep(data, ...sensitiveData);
};

export const stringifyData = (data: any) => JSON.stringify(data, null, 2);
Expand Down
2 changes: 2 additions & 0 deletions source/main/utils/setupLogging.js
Expand Up @@ -2,6 +2,7 @@
import fs from 'fs';
import path from 'path';
import log from 'electron-log-daedalus';
import rimraf from 'rimraf';
import ensureDirectoryExists from './ensureDirectoryExists';
import { pubLogsFolderPath, appLogsFolderPath } from '../config';
import {
Expand All @@ -24,6 +25,7 @@ const isDev = process.env.NODE_ENV === 'development';
export const setupLogging = () => {
const logFilePath = path.join(pubLogsFolderPath, 'Daedalus.json');
ensureDirectoryExists(pubLogsFolderPath);
rimraf.sync(path.join(pubLogsFolderPath, './Daedalus.*'));
log.transports.console.level = isTest ? 'error' : 'info';
log.transports.rendererConsole.level = isDev ? 'info' : 'error';
log.transports.file.level = 'debug';
Expand Down
114 changes: 84 additions & 30 deletions source/renderer/app/api/api.js
Expand Up @@ -73,7 +73,6 @@ import { getStakePools } from './staking/requests/getStakePools';
import { getDelegationFee } from './staking/requests/getDelegationFee';
import { joinStakePool } from './staking/requests/joinStakePool';
import { quitStakePool } from './staking/requests/quitStakePool';
import { submitRedeemItnRewards } from './staking/requests/submitRedeemItnRewards';

// Utility functions
import { cardanoFaultInjectionChannel } from '../ipc/cardano.ipc';
Expand All @@ -90,6 +89,7 @@ import { filterLogData } from '../../../common/utils/logging';

// Config constants
import { LOVELACES_PER_ADA } from '../config/numbersConfig';
import { REDEEM_ITN_REWARDS_AMOUNT } from '../config/stakingConfig';
import {
ADA_CERTIFICATE_MNEMONIC_LENGTH,
WALLET_RECOVERY_PHRASE_WORD_COUNT,
Expand Down Expand Up @@ -168,9 +168,10 @@ import type {
AdaApiStakePools,
AdaApiStakePool,
QuitStakePoolRequest,
SubmitRedeemItnRewardsRequest,
SubmitRedeemItnRewardsResponse,
SubmitRedeemItnRewardsApiResponse,
GetRedeemItnRewardsFeeRequest,
GetRedeemItnRewardsFeeResponse,
RequestRedeemItnRewardsRequest,
RequestRedeemItnRewardsResponse,
} from './staking/types';
import type { StakePoolProps } from '../domains/StakePool';
import type { FaultInjectionIpcRequest } from '../../../common/types/cardano-node.types';
Expand Down Expand Up @@ -606,7 +607,14 @@ export default class AdaApi {
logger.debug('AdaApi::createTransaction called', {
parameters: filterLogData(request),
});
const { walletId, address, amount, passphrase, isLegacy } = request;
const {
walletId,
address,
amount,
passphrase,
isLegacy,
withdrawal = TransactionWithdrawal,
} = request;

try {
const data = {
Expand All @@ -620,7 +628,7 @@ export default class AdaApi {
},
],
passphrase,
withdrawal: TransactionWithdrawal,
withdrawal,
};

let response: Transaction;
Expand Down Expand Up @@ -669,6 +677,7 @@ export default class AdaApi {
walletBalance,
availableBalance,
isLegacy,
withdrawal = TransactionWithdrawal,
} = request;

try {
Expand All @@ -682,9 +691,8 @@ export default class AdaApi {
},
},
],
withdrawal: TransactionWithdrawal,
withdrawal,
};

let response: TransactionFee;
if (isLegacy) {
response = await getByronWalletTransactionFee(this.config, {
Expand Down Expand Up @@ -1345,21 +1353,70 @@ export default class AdaApi {
}
};

submitRedeemItnRewards = async (
request: SubmitRedeemItnRewardsRequest
): Promise<SubmitRedeemItnRewardsApiResponse> => {
const { walletId, recoveryPhrase } = request;
getRedeemItnRewardsFee = async (
request: GetRedeemItnRewardsFeeRequest
): Promise<GetRedeemItnRewardsFeeResponse> => {
const { address, wallet, recoveryPhrase: withdrawal } = request;
const amount = REDEEM_ITN_REWARDS_AMOUNT;
const {
id: walletId,
amount: walletBalance,
availableAmount: availableBalance,
} = wallet;
const payload = {
address,
walletId,
walletBalance,
availableBalance,
amount,
withdrawal,
isLegacy: false,
};
try {
const response: SubmitRedeemItnRewardsResponse = await submitRedeemItnRewards(
{
walletId,
recoveryPhrase,
}
);
logger.debug('AdaApi::submitRedeemItnRewards success', { response });
return _createRedeemItnRewardsFromServerData(response);
const fee = await this.calculateTransactionFee(payload);
logger.debug('AdaApi::getRedeemItnRewardsFee success', { fee });
return fee;
} catch (error) {
logger.error('AdaApi::getRedeemItnRewardsFee error', { error });
throw new ApiError(error);
}
};

requestRedeemItnRewards = async (
request: RequestRedeemItnRewardsRequest
): Promise<RequestRedeemItnRewardsResponse> => {
const {
address,
walletId,
spendingPassword: passphrase,
recoveryPhrase: withdrawal,
} = request;
const amount = REDEEM_ITN_REWARDS_AMOUNT;
try {
const data = {
payments: [
{
address,
amount: {
quantity: amount,
unit: WalletUnits.LOVELACE,
},
},
],
passphrase,
withdrawal,
};
const transaction = await createTransaction(this.config, {
walletId,
data,
});
const response = _createRedeemItnRewardsFromServerData(transaction);
logger.debug('AdaApi::requestRedeemItnRewards success', {
response,
});
return response;
} catch (error) {
logger.error('AdaApi::submitRedeemItnRewards error', { error });
logger.error('AdaApi::requestRedeemItnRewards error', { error });
throw new ApiError(error);
}
};
Expand Down Expand Up @@ -1946,13 +2003,10 @@ const _createStakePoolFromServerData = action(

const _createRedeemItnRewardsFromServerData = action(
'AdaApi::_createRedeemItnRewardsFromServerData',
({
rewardsTotal,
transactionFees,
finalTotal,
}: SubmitRedeemItnRewardsResponse) => ({
rewardsTotal: new BigNumber(rewardsTotal),
transactionFees: new BigNumber(transactionFees),
finalTotal: new BigNumber(finalTotal),
})
(transaction: Transaction) => {
const { quantity, unit } = get(transaction, 'withdrawals[0].amount');
return unit === WalletUnits.LOVELACE
? new BigNumber(quantity).dividedBy(LOVELACES_PER_ADA)
: new BigNumber(quantity);
}
);
22 changes: 0 additions & 22 deletions source/renderer/app/api/staking/requests/submitRedeemItnRewards.js

This file was deleted.

23 changes: 12 additions & 11 deletions source/renderer/app/api/staking/types.js
@@ -1,6 +1,7 @@
// @flow
import BigNumber from 'bignumber.js';
import StakePool from '../../domains/StakePool';
import Wallet from '../../domains/Wallet';

export type DelegationAction =
| 'changeDelegation'
Expand Down Expand Up @@ -93,19 +94,19 @@ export type QuitStakePoolRequest = {
passphrase: string,
};

export type SubmitRedeemItnRewardsRequest = {
walletId: string,
export type GetRedeemItnRewardsFeeRequest = {
address: string,
wallet: Wallet,
recoveryPhrase: Array<string>,
};

export type SubmitRedeemItnRewardsResponse = {
rewardsTotal: number,
transactionFees: number,
finalTotal: number,
};
export type GetRedeemItnRewardsFeeResponse = BigNumber;

export type SubmitRedeemItnRewardsApiResponse = {
rewardsTotal: BigNumber,
transactionFees: BigNumber,
finalTotal: BigNumber,
export type RequestRedeemItnRewardsRequest = {
address: string,
walletId: string,
spendingPassword: string,
recoveryPhrase: Array<string>,
};

export type RequestRedeemItnRewardsResponse = BigNumber;

0 comments on commit 01e7e33

Please sign in to comment.