Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feat/ddw-1025-mato…
Browse files Browse the repository at this point in the history
…mo-poc
  • Loading branch information
Marcin Mazurek committed Aug 8, 2022
2 parents 62a8779 + 6d19133 commit efeff61
Show file tree
Hide file tree
Showing 32 changed files with 495 additions and 246 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,30 @@

### Fixes

- Ensured non-recommended decimal place setting alert is correctly shown ([PR 3007](https://github.com/input-output-hk/daedalus/pull/3007))
- Disabled the possibility to choose a syncing wallet for ITN rewards and delegation ([PR 3015](https://github.com/input-output-hk/daedalus/pull/3015))

### Chores

- Updated cardano-node to 1.35.2 ([PR 3021](https://github.com/input-output-hk/daedalus/pull/3021))
- Fix `darwin-launcher.go` to replace its process image with `cardano-launcher` (binary), and not swallow `stdout` ([PR 3023](https://github.com/input-output-hk/daedalus/pull/3023))
- Updated cardano-node to 1.35.1 ([PR 3012](https://github.com/input-output-hk/daedalus/pull/3012))

### Features

- Updated Terms of Service ([PR 3009](https://github.com/input-output-hk/daedalus/pull/3009))

## 4.12.0

### Fixes

- Fixed downloaded installer being left in Downloads after latest update installs ([PR 2941](https://github.com/input-output-hk/daedalus/pull/2941))
- Fixed incorrect amount of token sent ([PR 2962](https://github.com/input-output-hk/daedalus/pull/2962))

### Chores

- Made Windows installer more resilient w.r.t. auto-updates ([PR 3017](https://github.com/input-output-hk/daedalus/pull/3017))
- Added OS-architecture tuple to installer file names to help with releases ([PR 3016](https://github.com/input-output-hk/daedalus/pull/3016))
- Added Vasil-supported cardano-wallet ([PR 3001](https://github.com/input-output-hk/daedalus/pull/3001))
- Upgraded webpack to version 5 ([PR 2772](https://github.com/input-output-hk/daedalus/pull/2772))

Expand Down
19 changes: 16 additions & 3 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,20 @@ let
cardanoLib = localLib.iohkNix.cardanoLib;
daedalus-bridge = self.bridgeTable.${nodeImplementation};

nodejs = pkgs.nodejs-16_x;
nodejs = let
njPath = pkgs.path + "/pkgs/development/web/nodejs";
buildNodeJs = pkgs.callPackage (import (njPath + "/nodejs.nix")) {
python = pkgs.python3;
icu = pkgs.icu68; # can’t build against ICU 69: <https://chromium-review.googlesource.com/c/v8/v8/+/2477751>
};
in
buildNodeJs {
enableNpm = true;
version = "14.17.0";
sha256 = "1vf989canwcx0wdpngvkbz2x232yccp7fzs1vcbr60rijgzmpq2n";
patches = pkgs.lib.optional pkgs.stdenv.isDarwin (njPath + "/bypass-xcodebuild.diff");
};

nodePackages = pkgs.nodePackages.override { nodejs = self.nodejs; };
yarnInfo = {
version = "1.22.4";
Expand Down Expand Up @@ -302,7 +315,7 @@ let
signed-windows-installer = let
backend_version = self.daedalus-bridge.wallet-version;
frontend_version = (builtins.fromJSON (builtins.readFile ./package.json)).version;
fullName = "daedalus-${frontend_version}-${cluster}${buildNumSuffix}.exe"; # must match to packageFileName in make-installer
fullName = "daedalus-${frontend_version}-${cluster}${buildNumSuffix}-x86_64-windows.exe"; # must match to packageFileName in make-installer
in pkgs.runCommand "signed-windows-installer-${cluster}" {} ''
mkdir $out
cp -v ${self.signFile "${self.unsigned-windows-installer}/${fullName}"} $out/${fullName}
Expand Down Expand Up @@ -419,7 +432,7 @@ let
version = (builtins.fromJSON (builtins.readFile ./package.json)).version;
backend = "cardano-wallet-${nodeImplementation}";
suffix = if buildNum == null then "" else "-${toString buildNum}";
fn = "daedalus-${version}-${self.linuxClusterBinName}${suffix}.bin";
fn = "daedalus-${version}-${self.linuxClusterBinName}${suffix}-x86_64-linux.bin";
in pkgs.runCommand fn {} ''
mkdir -p $out
cp ${self.newBundle} $out/${fn}
Expand Down
10 changes: 9 additions & 1 deletion installers/common/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import Turtle (pwd, cd)
import Turtle.Format (format, fp)
import Data.Aeson (FromJSON(..), withObject, eitherDecode, (.:), genericParseJSON, defaultOptions)
import qualified Data.ByteString.Lazy.Char8 as L8
import qualified System.Info

data OS
= Linux64
Expand Down Expand Up @@ -113,7 +114,7 @@ packageFileName :: OS -> Cluster -> Version -> Backend -> Text -> Maybe BuildJob
packageFileName _os cluster ver backend _backendVer build = fromText name <.> ext
where
name = T.intercalate "-" parts
parts = ["daedalus", fromVer ver, lshowText cluster] ++ build'
parts = ["daedalus", fromVer ver, lshowText cluster] ++ build' ++ [archOS]
_backend' = case backend of
Cardano _ -> "cardano-wallet"
ext = case _os of
Expand All @@ -124,6 +125,13 @@ packageFileName _os cluster ver backend _backendVer build = fromText name <.> ex
Win64 -> "windows"
Macos64 -> "macos"
Linux64 -> "linux"
archOS = case _os of
Win64 -> "x86_64-windows"
Macos64 ->
if System.Info.arch == "aarch64"
then "aarch64-darwin"
else "x86_64-darwin"
Linux64 -> "x86_64-linux"
build' = maybe [] (\b -> [fromBuildJob b]) build

instance FromJSON Version where
Expand Down
30 changes: 26 additions & 4 deletions installers/common/WindowsInstaller.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import Development.NSIS (Attrib (IconFile, IconIndex, RebootOK, Recurs
name, nsis, onPagePre, onError, outFile, page, readRegStr,
requestExecutionLevel, rmdir, section, setOutPath, str,
strLength, uninstall, unsafeInject, unsafeInjectGlobal,
loadLanguage,
loadLanguage, sleep, (@=), detailPrint, (%<), (%&&),
not_, mutableInt_, mutable_, while, false, true, strShow, (&),
writeRegDWORD, writeRegStr, (%/=), fileExists)
import Prelude ((!!))
import qualified System.IO as IO
Expand Down Expand Up @@ -185,9 +186,30 @@ writeInstallerNSIS outName (Version fullVersion') InstallerConfig{installDirecto
createDirectory "$APPDATA\\$InstallDir\\Secrets-1.0"
createDirectory "$APPDATA\\$InstallDir\\Logs"
createDirectory "$APPDATA\\$InstallDir\\Logs\\pub"
onError (delete [] "$APPDATA\\$InstallDir\\daedalus_lockfile") $
--abort "$SpacedName $(AlreadyRunning)"
unsafeInject $ T.unpack $ "Abort \" " <> installDirectory <> "$(AlreadyRunning)\""

-- XXX: sometimes during auto-update, it takes longer for Daedalus to exit,
-- and cardano-launcher.exe’s lockfile to be unlocked (deletable), so
-- let’s loop waiting for this to happen:
let waitSeconds = 30
lockfileCounter <- mutableInt_ 0
lockfileDeleted <- mutable_ false
while ((lockfileCounter %< waitSeconds) %&& (not_ lockfileDeleted)) $ do
detailPrint (
"Checking if Daedalus is not running ("
Development.NSIS.& strShow (lockfileCounter + 1)
Development.NSIS.& "/"
Development.NSIS.& strShow waitSeconds
Development.NSIS.& ")..."
)
lockfileDeleted @= true
onError (delete [] "$APPDATA\\$InstallDir\\daedalus_lockfile") $ do
lockfileDeleted @= false
iff_ (not_ lockfileDeleted) $ do
sleep 1000 -- milliseconds
lockfileCounter @= lockfileCounter + 1
iff_ (not_ (lockfileDeleted)) $ do
unsafeInject $ T.unpack $ "Abort \"" <> installDirectory <> " $(AlreadyRunning)\""

iff_ (fileExists "$APPDATA\\$InstallDir\\Wallet-1.0\\open\\*.*") $
rmdir [] "$APPDATA\\$InstallDir\\Wallet-1.0\\open"
case oBackend of
Expand Down
4 changes: 2 additions & 2 deletions installers/nix/electron.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{ stdenv, lib, makeWrapper, fetchurl, unzip, atomEnv, libuuid, at-spi2-atk, at_spi2_core, libxshmfence,
libxkbcommon }:
libxkbcommon, runCommand, binutils-unwrapped }:

let
version = "13.6.3";
version = (builtins.fromJSON (builtins.readFile ../../package.json)).dependencies.electron;
name = "electron-${version}";

throwSystem = throw "Unsupported system: ${stdenv.hostPlatform.system}";
Expand Down
24 changes: 18 additions & 6 deletions nix/darwin-launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ import (
"os"
"os/exec"
"path/filepath"
"syscall"
)

func main() {
fmt.Fprintf(os.Stderr, "darwin-launcher: PID = %d\n", os.Getpid())

ex, err := os.Executable()
if err != nil {
panic(err)
Expand All @@ -17,14 +20,23 @@ func main() {

os.Setenv("PATH", fmt.Sprintf("%s:%s", installDir, os.Getenv("PATH")))

launcherConfig := filepath.Join(installDir, "../Resources/launcher-config.yaml")
helper := filepath.Join(installDir, "../Resources/helper")

launcherConfigPath := filepath.Join(installDir, "../Resources/launcher-config.yaml")
helperPath := filepath.Join(installDir, "../Resources/helper")

if err = exec.Command(helper).Run(); err != nil {
helperCmd := exec.Command(helperPath)
helperCmd.Stdout = os.Stdout
helperCmd.Stderr = os.Stderr
if err := helperCmd.Run(); err != nil {
panic(err)
}
if err = exec.Command("cardano-launcher", "--config", launcherConfig).Run(); err != nil {
panic(err)

// Replace the current process (otherwise WDIO complains in end-to-end tests):
img := filepath.Join(installDir, "cardano-launcher")
argv := []string{"cardano-launcher", "--config", launcherConfigPath}
env := os.Environ()
if err := syscall.Exec(img, argv, env); err != nil {
fmt.Println(err)
}

fmt.Fprintf(os.Stderr, "this won’t happen\n")
}
16 changes: 8 additions & 8 deletions nix/sources.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"cardano-node": {
"branch": "tags/1.35.0",
"branch": "tags/1.35.2",
"description": null,
"homepage": null,
"owner": "input-output-hk",
"repo": "cardano-node",
"rev": "9f1d7dc163ee66410d912e48509d6a2300cfa68a",
"sha256": "06arx9hv7dn3qxfy83f0b6018rxbsvh841nvfyg5w6qclm1hddj7",
"rev": "7612a245a6e2c51d0f1c3e0d65d7fe9363850043",
"sha256": "01a5qdrmsag18s2mlf8axfbrag59j2fp6xyc89pwmzgs7x77ldsr",
"type": "tarball",
"url": "https://github.com/input-output-hk/cardano-node/archive/9f1d7dc163ee66410d912e48509d6a2300cfa68a.tar.gz",
"url": "https://github.com/input-output-hk/cardano-node/archive/7612a245a6e2c51d0f1c3e0d65d7fe9363850043.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"cardano-shell": {
Expand All @@ -24,15 +24,15 @@
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"cardano-wallet": {
"branch": "v2022-07-01",
"branch": "master",
"description": "Official Wallet Backend & API for Cardano decentralized",
"homepage": null,
"owner": "input-output-hk",
"repo": "cardano-wallet",
"rev": "211c357a91d48b30fdf77a3a169499b38822f9cd",
"sha256": "0ii631ak757kjzs7jm625zfv2g28ffjrfkmgslxbbgvwpqxkdbaj",
"rev": "7ed8f067dd6d5dc78e7353bf65ea5e3423cdfca8",
"sha256": "1f9lwqi4qghaqi3754732h0cz98f7qbjhcx416jliqy6nibly6lp",
"type": "tarball",
"url": "https://github.com/input-output-hk/cardano-wallet/archive/211c357a91d48b30fdf77a3a169499b38822f9cd.tar.gz",
"url": "https://github.com/input-output-hk/cardano-wallet/archive/7ed8f067dd6d5dc78e7353bf65ea5e3423cdfca8.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"flake-compat": {
Expand Down
4 changes: 4 additions & 0 deletions nix/yarn-nix-shell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,9 @@ if [ -z "$command" ] ; then
fi

export NETWORK

# Prevent segfaults on Darwin in `GC_*` code:
export GC_DONT_GC=1

# `return` will make the user stay in `nix-shell` after the initial command finishes:
exec nix-shell --argstr nodeImplementation cardano --argstr cluster "$cluster" --command "$command ; return"
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "daedalus",
"productName": "Daedalus",
"version": "4.11.0",
"version": "4.12.0",
"description": "Cryptocurrency Wallet",
"main": "./dist/main/index.js",
"scripts": {
Expand All @@ -13,7 +13,7 @@
"build:main": "yarn webpack -c source/main/webpack.config.js --progress",
"build:renderer": "yarn webpack -c source/renderer/webpack.config.js --progress",
"build:cleanup": "rimraf ./dist",
"build:electron": "electron-rebuild -w usb --useCache -s --debug",
"build:electron": "electron-rebuild --useCache && electron-rebuild -w usb --useCache -s --debug",
"check:all": "yarn prettier:check && yarn lint && yarn compile && yarn stylelint && yarn lockfile:check && yarn i18n:manage && yarn storybook:build",
"start": "yarn electron ./",
"start:dev": "nodemon --watch 'dist/main' --exec 'NODE_ENV=development yarn start'",
Expand Down
5 changes: 4 additions & 1 deletion release.nix
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,11 @@ in {
in {
daedalus-installer = allArchesNoWindows;
yaml2json = allArchesNoWindows;
nodejs = allArchesNoWindows;
bridgeTable = {
cardano = allArches;
};
cardano-node = allArches;
}))
})) // {
recurseForDerivations = {};
}
5 changes: 5 additions & 0 deletions scripts/postinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@

if [[ "$CI" != "true" ]]; then
yarn lockfile:fix

# Let’s patch electron-rebuild to force correct Node.js headers to
# build native modules against even in `nix-shell`, otherwise, it
# doesn’t work reliably.
eval "$(nix-build -A rawapp.patchElectronRebuild)"
fi
55 changes: 41 additions & 14 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,6 @@ let
ln -svf $(type -P cardano-node)
ln -svf $(type -P cardano-wallet)
ln -svf $(type -P cardano-cli)
mkdir -p ${BUILDTYPE}/
${let
# (TODO: investigate why – @michalrus)
sourceBUILDTYPE = "Release";
in ''
ln -svf $PWD/node_modules/usb/build/${sourceBUILDTYPE}/usb_bindings.node ${BUILDTYPE}/
ln -svf $PWD/node_modules/node-hid/build/${sourceBUILDTYPE}/HID.node ${BUILDTYPE}/
ln -svf $PWD/node_modules/node-hid/build/${sourceBUILDTYPE}/HID_hidraw.node ${BUILDTYPE}/
ln -svf $PWD/node_modules/usb-detection/build/${sourceBUILDTYPE}/detection.node ${BUILDTYPE}/
''}
${pkgs.lib.optionalString (nodeImplementation == "cardano") ''
source <(cardano-node --bash-completion-script `type -p cardano-node`)
Expand All @@ -135,14 +125,51 @@ let
''
}
yarn install --frozen-lockfile
# Rebuild native modules for <https://www.electronjs.org/docs/latest/tutorial/using-native-node-modules>:
find Debug/ Release/ -name '*.node' | xargs rm -v || true
yarn build:electron
${let
# Several native modules have to be linked in ${BUILDTYPE}/ in
# root directory, for `yarn dev` to work correctly. If a Debug
# version of such extension exists, we use it, otherwise, we
# use Release:
tryLink = dependency: fileName: ''
symlinkTarget=$(ls 2>/dev/null -d \
"$PWD/node_modules/${dependency}/build/Debug/${fileName}" \
"$PWD/node_modules/${dependency}/build/Release/${fileName}" \
| head -1
)
if [ -z "$symlinkTarget" ] ; then
echo >&2 "error: symlink target not found: ‘${fileName}’ in ‘${dependency}’"
# ~exit 1~ — do not exit, let the person fix from inside `nix-shell`
fi
${localLib.optionalString pkgs.stdenv.isLinux ''
${pkgs.patchelf}/bin/patchelf --set-rpath ${pkgs.lib.makeLibraryPath [
pkgs.stdenv.cc.cc pkgs.udev
]} "$symlinkTarget"
''}
mkdir -p ${BUILDTYPE}/
ln -svf "$symlinkTarget" ${BUILDTYPE}/
unset symlinkTarget
'';
in ''
${tryLink "usb" "usb_bindings.node"}
${tryLink "usb-detection" "detection.node"}
${tryLink "node-hid" "HID.node"}
${localLib.optionalString pkgs.stdenv.isLinux ''
${tryLink "node-hid" "HID_hidraw.node"}
''}
''}
${localLib.optionalString pkgs.stdenv.isLinux ''
${pkgs.patchelf}/bin/patchelf --set-rpath ${pkgs.lib.makeLibraryPath [ pkgs.stdenv.cc.cc pkgs.udev ]} ${BUILDTYPE}/usb_bindings.node
${pkgs.patchelf}/bin/patchelf --set-rpath ${pkgs.lib.makeLibraryPath [ pkgs.stdenv.cc.cc pkgs.udev ]} ${BUILDTYPE}/HID.node
# TODO: is this needed for `detection.node`?
${pkgs.patchelf}/bin/patchelf --set-rpath ${pkgs.lib.makeLibraryPath [ pkgs.stdenv.cc.cc pkgs.udev ]} ${BUILDTYPE}/detection.node
ln -svf ${daedalusPkgs.electron}/bin/electron ./node_modules/electron/dist/electron
''}
echo 'jq < $LAUNCHER_CONFIG'
echo debug the node by running debug-node
'';
Expand Down
2 changes: 1 addition & 1 deletion source/common/types/logging.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import type {
} from '../../renderer/app/api/wallets/types';
import type { Address } from '../../renderer/app/api/addresses/types';
import type { GetTransactionsRequest } from '../../renderer/app/api/transactions/types';
import type { HardwareWalletLocalData } from '../../renderer/app/api/utils/localStorage';
import type { AdaApiStakePool } from '../../renderer/app/api/staking/types';
import { HardwareWalletLocalData } from '../../renderer/app/types/localDataTypes';

export type LoggingLevel = 'debug' | 'info' | 'error' | 'warn';
export type Logger = {
Expand Down
2 changes: 1 addition & 1 deletion source/main/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const isDevelopment = checkIsDevelopment(NETWORK);
const analyticsFeatureEnabled = isMainnet || isStaging || isTestnet;
const keepLocalClusterRunning = process.env.KEEP_LOCAL_CLUSTER_RUNNING;
const API_VERSION = process.env.API_VERSION || 'dev';
const NODE_VERSION = '1.35.0'; // TODO: pick up this value from process.env
const NODE_VERSION = '1.35.2'; // TODO: pick up this value from process.env

const mainProcessID = get(process, 'ppid', '-');
const rendererProcessID = process.pid;
Expand Down
1 change: 0 additions & 1 deletion source/main/trezor/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export const initTrezorConnect = async () => {
logger.info('[TREZOR-CONNECT] Called TrezorConnect.init()');
} catch (error) {
logger.info('[TREZOR-CONNECT] Failed to call TrezorConnect.init()');
throw error;
}
};

Expand Down
Loading

0 comments on commit efeff61

Please sign in to comment.