Skip to content

Commit

Permalink
[DDW-465] Merge latest develop and fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolaglumac committed Jan 31, 2019
2 parents 5179ce4 + 1d885c5 commit f31b106
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 19 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.md
Expand Up @@ -5,10 +5,10 @@ Changelog

### Features

<<<<<<< HEAD
- Implemented Multi-language installers for Windows and macOS ([PR 1287](https://github.com/input-output-hk/daedalus/pull/1287))
- Implemented a "System-info.json" file, containing the system specification of the machine user is running Daedalus ([PR 1292](https://github.com/input-output-hk/daedalus/pull/1292))
- Implemented a block-consolidation status screen ([PR 1275](https://github.com/input-output-hk/daedalus/pull/1275), [PR 1294](https://github.com/input-output-hk/daedalus/pull/1294))
- Implemented Multi-language installers for Windows and OS ([PR 1287](https://github.com/input-output-hk/daedalus/pull/1287))
- Implemented translations for the application menu ([PR 1262](https://github.com/input-output-hk/daedalus/pull/1262))
- Implemented translations for the application menu ([PR 1262](https://github.com/input-output-hk/daedalus/pull/1262), [PR 1296](https://github.com/input-output-hk/daedalus/pull/1296))
- Implemented a success message for logs download ([PR 1228](https://github.com/input-output-hk/daedalus/pull/1228))
- Implemented a better handling for "No disk space" error ([PR 1157](https://github.com/input-output-hk/daedalus/pull/1157))
- Improved the NTP check logic ([PR 1258](https://github.com/input-output-hk/daedalus/pull/1258))
Expand Down Expand Up @@ -37,6 +37,7 @@ Changelog

### Chores

- Added support for newly introduced `UtxoNotEnoughFragmented` API error message ([PR 1297](https://github.com/input-output-hk/daedalus/pull/1297))
- Changed the behavior of "Network status" from screen to dialog ([PR 1286](https://github.com/input-output-hk/daedalus/pull/1286))
- Updated the list of contributors on the "About" screen ([PR 1282](https://github.com/input-output-hk/daedalus/pull/1282))
- Added more logging for API errors ([PR 1278](https://github.com/input-output-hk/daedalus/pull/1278)
Expand Down
2 changes: 1 addition & 1 deletion default.nix
Expand Up @@ -162,7 +162,7 @@ let
newBundle = let
daedalus' = self.daedalus.override { sandboxed = true; };
in (import ./installers/nix/nix-installer.nix {
inherit (self) postInstall preInstall cluster;
inherit (self) postInstall preInstall cluster rawapp;
inherit pkgs;
installationSlug = installPath;
installedPackages = [ daedalus' self.postInstall self.namespaceHelper daedalus'.cfg self.daedalus-bridge daedalus'.daedalus-frontend self.xdg-open ];
Expand Down
9 changes: 9 additions & 0 deletions installers/nix/nix-installer.nix
@@ -1,6 +1,7 @@
{ installationSlug ? "nix-install", installedPackages
, postInstall ? null, nix-bundle, preInstall ? null
, cluster
, rawapp
, pkgs }:
let
installerBundle = nix-bundle.nix-bootstrap {
Expand Down Expand Up @@ -68,6 +69,12 @@ let
exec .${nix-bundle.nix-user-chroot}/bin/nix-user-chroot -n ./nix -c -m /home:/home -m /etc:/host-etc -m etc:/etc -p DISPLAY -p HOME -p XAUTHORITY -p TERM -- /nix/var/nix/profiles/profile/bin/enter-phase2
'';
fontconf = pkgs.writeText "fonts.conf" ''
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<dir>${rawapp}</dir>
</fontconfig>
'';
enter2 = pkgs.writeScriptBin "enter-phase2" ''
#!${pkgs.stdenv.shell}
Expand All @@ -79,6 +86,8 @@ let
export PATH=/bin
ln -svf ${pkgs.iana-etc}/etc/protocols /etc/protocols
ln -svf ${pkgs.iana-etc}/etc/services /etc/services
mkdir -pv /etc/fonts
ln -svf ${fontconf} /etc/fonts/fonts.conf
mkdir -pv /etc/ssl/certs
ln -svf ${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt /etc/ssl/certs/ca-certificates.crt
ln -svf ${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt /etc/ssl/certs/ca-bundle.crt
Expand Down
2 changes: 1 addition & 1 deletion source/main/config.js
Expand Up @@ -57,7 +57,7 @@ export const appLogsFolderPath = launcherConfig.logsPrefix;
export const pubLogsFolderPath = path.join(appLogsFolderPath, 'pub');
export const appFolderPath = launcherConfig.workingDir;
export const nodeDbPath = launcherConfig.nodeDbPath;
export const ALLOWED_LOGS = ['Daedalus.log'];
export const ALLOWED_LOGS = ['Daedalus.log', 'System-info.json'];
export const ALLOWED_NODE_LOGS = new RegExp(/(node.json-)(\d{14}$)/);
export const ALLOWED_LAUNCHER_LOGS = new RegExp(/(launcher-)(\d{14}$)/);
export const MAX_NODE_LOGS_ALLOWED = 3;
Expand Down
43 changes: 32 additions & 11 deletions source/main/index.js
Expand Up @@ -3,8 +3,9 @@ import os from 'os';
import { app, BrowserWindow, shell } from 'electron';
import { client } from 'electron-connect';
import { includes } from 'lodash';
import moment from 'moment';
import { Logger } from './utils/logging';
import { setupLogging } from './utils/setupLogging';
import { setupLogging, updateUserSystemInfoLog } from './utils/setupLogging';
import { getNumberOfEpochsConsolidated } from './utils/getNumberOfEpochsConsolidated';
import { handleDiskSpace } from './utils/handleDiskSpace';
import { createMainWindow } from './windows/main';
Expand All @@ -27,7 +28,10 @@ import type { CheckDiskSpaceResponse } from '../common/types/no-disk-space.types
let mainWindow: BrowserWindow;
let cardanoNode: ?CardanoNode;

const { isDev, isWatchMode, buildLabel, network } = environment;
const {
isDev, isWatchMode, buildLabel, network, current,
version: daedalusVersion, buildNumber: cardanoVersion,
} = environment;

const safeExit = async () => {
if (!cardanoNode || cardanoNode.state === CardanoNodeStates.STOPPED) {
Expand All @@ -49,19 +53,36 @@ const safeExit = async () => {
const onAppReady = async () => {
setupLogging();

Logger.info(`========== Daedalus is starting at ${new Date().toString()} ==========`);
const cpu = os.cpus();
const isInSafeMode = includes(process.argv.slice(1), '--safe-mode');
const platform = os.platform();
const platformVersion = os.release();
const ram = JSON.stringify(os.totalmem(), null, 2);
const startTimeStr = new Date().toString();
const startTime = `${moment(startTimeStr).format('YYYY-MM-DDTHHmmss.0SSS')}Z`;
const systemStart = parseInt(launcherConfig.configuration.systemStart, 10);

Logger.debug(`!!! ${buildLabel} is running on ${os.platform()} version ${os.release()}
with CPU: ${JSON.stringify(os.cpus(), null, 2)} with
${JSON.stringify(os.totalmem(), null, 2)} total RAM !!!`);
updateUserSystemInfoLog({
cardanoVersion,
cpu,
current,
daedalusVersion,
isInSafeMode,
network,
platform,
platformVersion,
ram,
startTime,
});

ensureXDGDataIsSet();
await installChromeExtensions(isDev);
Logger.info(`========== Daedalus is starting at ${startTimeStr} ==========`);

// Detect safe mode
const isInSafeMode = includes(process.argv.slice(1), '--safe-mode');
Logger.debug(`!!! ${buildLabel} is running on ${platform} version ${platformVersion}
with CPU: ${JSON.stringify(cpu, null, 2)} with
${ram} total RAM !!!`);

const systemStart = parseInt(launcherConfig.configuration.systemStart, 10);
ensureXDGDataIsSet();
await installChromeExtensions(isDev);

mainWindow = createMainWindow(isInSafeMode);

Expand Down
39 changes: 39 additions & 0 deletions source/main/utils/setupLogging.js
Expand Up @@ -41,3 +41,42 @@ export const setupLogging = () => {
});
});
};

type Props = {
cardanoVersion: string,
cpu: Array<Object>,
current: string,
daedalusVersion: string,
isInSafeMode: string,
network: string,
platform: string,
platformVersion: string,
ram: string,
startTime: string,
};

export const updateUserSystemInfoLog = (props: Props) => {
const { current, ...data } = props;
const { network, platform, platformVersion, daedalusVersion, startTime: at } = data;
const env = `${network}:${platform}:${platformVersion}:${daedalusVersion}`;
const output = {
at,
env,
ns: [
'daedalus',
`*${current}*`,
],
data,
app: [
'daedalus'
],
msg: '',
sev: '',
thread: '',
};

fs.writeFileSync(
path.join(pubLogsFolderPath, 'System-info.json'),
JSON.stringify(output)
);
};
10 changes: 8 additions & 2 deletions source/renderer/app/api/api.js
Expand Up @@ -311,7 +311,10 @@ export default class AdaApi {
if (error.message === 'OutputIsRedeem') {
throw new NotAllowedToSendMoneyToRedeemAddressError();
}
if (error.message === 'NotEnoughMoney') {
if (
error.message === 'NotEnoughMoney' ||
error.message === 'UtxoNotEnoughFragmented'
) {
throw new NotEnoughMoneyToSendError();
}
if (error.message === 'CannotCreateAddress') {
Expand Down Expand Up @@ -349,7 +352,10 @@ export default class AdaApi {
return _createTransactionFeeFromServerData(response);
} catch (error) {
Logger.debug(`AdaApi::calculateTransactionFee error: ${stringifyData(error)}`);
if (error.message === 'NotEnoughMoney') {
if (
error.message === 'NotEnoughMoney' ||
error.message === 'UtxoNotEnoughFragmented'
) {
const errorMessage = get(error, 'diagnostic.details.msg', '');
if (errorMessage.includes('Not enough coins to cover fee')) {
// Amount + fees exceeds walletBalance:
Expand Down
4 changes: 3 additions & 1 deletion yarn2nix.nix
Expand Up @@ -51,8 +51,10 @@ yarn2nix.mkYarnPackage {
for x in $out/share/daedalus/renderer/index.js $out/share/daedalus/main/preload.js $out/share/daedalus/main/index.js $out/share/daedalus/main/0.js; do
${nukeReferences}/bin/nuke-refs $x
done
mkdir -p $out/share/fonts
ln -sv $out/share/daedalus/renderer/assets $out/share/fonts/daedalus
'';
allowedReferences = [];
allowedReferences = [ "out" ];
yarnPreBuild = ''
set -x
mkdir -p $HOME/.node-gyp/${nodejs.version}
Expand Down

0 comments on commit f31b106

Please sign in to comment.