Skip to content

Commit eac2bb4

Browse files
nikolaglumacdisassemblerDeeJayEllythedanhellertopseniors
authored
[DDW-106] Wallet import feature (#1956)
* [DDW-106] Adds CHANGELOG * [DDW-106] Enable wallet import for mainnet, flight and testnet * bump SL: new export-wallets * [DDW-106] Genesis file update * [DDW-106] Fix scenario name * [DDW-106] - Wallet import feature * [DDW-106] - Wallet import feature * [DDW-106] - Wallet import feature * [DDW-106] - Wallet import feature * [DDW-106] - Wallet import feature * [DDW-106] - Wallet import feature * [DDW-106] - Wallet import feature * [DDW-106] - Wallet import feature * [DDW-106] - Wallet import feature * [DDW-106] - Wallet import feature * [DDW-106] - Wallet import feature * [DDW-106] - Wallet import feature * [DDW-106] - Wallet import feature * [DDW-106] - Wallet import feature * [DDW-106] - Wallet import feature * [DDW-106] Fix env flags * [DDW-106] - Wallet import feature * [DDW-106] - Wallet import feature * [DDW-106] Export types fix * [DDW-106] Improve logging * [DDW-106] - Wallet import feature * [DDW-106] - Wallet import feature * [DDW-106] - Wallet import feature * [DDW-106] Wallet migration logic WIP * [DDW-106] Reorder methods * [DDW-106] Introduce skipped wallet migration state * [DDW-106] Record skipped wallet migration * [DDW-106] - Wallet import feature - fixing lint errors * [DDW-106] Update migration store * [DDW-106] Update export tool * [DDW-106] Introduce pending import wallets * [DDW-106] Connect UI with store logicu * [DDW-106] Add name/selection handlers * [DDW-106] Fix lint errors * [DDW-106] Button spinner * [DDW-106] Fix default mainnet legacy state dir path * [DDW-106] Enable export source path selection * [DDW-106] Improve button state handling * [DDW-106] Wallet Rename - WIP * [DDW-106] Fix opacity * [DDW-106] Wallet Rename - WIP * [DDW-106] Wallet Rename - WIP * [DDW-106] Restores * [DDW-106] Prevent text selection * [DDW-106] Separate nameless wallets * [DDW-106] Input adjustment * [DDW-106] Remove Fragment * [DDW-106] - Wallet import feature * [DDW-106] Buttons adjustments - WIP * [DDW-106] - Wallet import feature * [DDW-106] Enable pending wallet selection * [DDW-106] - Wallet import feature * [DDW-106] Buttons actions * [DDW-106] Translation manager * [DDW-106] Prevent closing wallet import dialog after first wallet is loaded/imported * [DDW-106] - Wallet import feature * [DDW-106] Finish wallet name field implementation * [DDW-106] Improve import wallet selection * [DDW-106] - Wallet import feature * [DDW-106] Improve inline editing input * [DDW-105] Fix set password overlay scrollbar * [DDW-106] Improve wallet name handling * [DDW-106] Separate existing/completed status * [DDW-106] - Wallet import feature * [DDW-106] - Wallet import feature * [DDW-106] Small styling adjustment * [DDW-106] Storybook story * [DDW-106] Storybook story * [DDW-106] Unamed wallets header * [DDW-106] Close window link * [DDW-106] - Wallet import feature * [DDW-106] - Wallet import feature * [DDW-106]: Fix button styles of wallet import dialog * [DDW-106]: Fix inline edit input style * [DDW-106] 'Enter a wallet name' tooltip * [DDW-106] Hide Wallet import learn more link * [DDW-106] - Wallet import feature * [DDW-106] Remove learn more link * [DDW-106] - Wallet import feature * [DDW-106] Improve styling * [DDW-106] - Wallet import feature * [DDW-106]: Fix disabled inline edit input style * [DDW-106] Split import description to 2 lines * [DDW-106] Styling improvements * [DDW-106] Conditional walletsWithoutNames header * [DDW-106] Change inline editing input border opacity * [DDW-106] Fix tests * [DDW-106] Fix failing tests * [DDW-106]: Fix checkbox style on wallet import modal * [DDW-106]: Fix checkbox style on wallet import modal * [DDW-106] Update e2e address classes * [DDW-106] Update e2e ITN address classes * [DDW-106] Storybook improvements * [DDW-106]: Fix form field error style on wallet import modal * [DDW-106] - Wallet import feature * [DDW-106]: Fix form field error style on wallet import modal * [DDW-106] Scroller fix * [DDW-106] Bump Daedalus version * [DDW-106] Small fix Co-authored-by: Samuel Leathers <samuel.leathers@iohk.io> Co-authored-by: Aleksandar Djordjevic <aca_eliminator@hotmail.com> Co-authored-by: Danilo Prates <daniloprates@gmail.com> Co-authored-by: Yakov Karavelov <yakov.karavelov@iohk.io> Co-authored-by: Tomislav Horaček <tomislav.horacek@thespian.hr>
1 parent 8111e7b commit eac2bb4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2841
-455
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
Changelog
22
=========
33

4-
## vNext
4+
## 1.0.0-FC3
55

66
### Features
77

8+
- Implemented "Wallet Import" feature ([PR 1956](https://github.com/input-output-hk/daedalus/pull/1956))
89
- Force setting spending password on passwordless wallets ([PR 1957](https://github.com/input-output-hk/daedalus/pull/1957))
910

1011
### Chores

nix/launcher-config.nix

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -191,22 +191,18 @@ let
191191
''}
192192
'';
193193

194+
legacyStateDir = if network == "mainnet_flight" then mainnetDataDir else dataDir;
195+
194196
legacyWalletDB = let
195-
prefix = if network == "mainnet_flight"
196-
then "${mainnetDataDir}${dirSep}"
197-
else "${dataDir}${dirSep}";
198-
path.linux = "${prefix}Wallet";
199-
path.macos64 = "${prefix}Wallet-1.0";
200-
path.windows = "${prefix}Wallet-1.0";
197+
path.linux = "Wallet";
198+
path.macos64 = "Wallet-1.0";
199+
path.windows = "Wallet-1.0";
201200
in path.${os};
202201

203202
legacySecretKey = let
204-
prefix = if network == "mainnet_flight"
205-
then "${mainnetDataDir}${dirSep}"
206-
else "${dataDir}${dirSep}";
207-
path.linux = "${prefix}Secrets${dirSep}secret.key";
208-
path.macos64 = "${prefix}Secrets-1.0${dirSep}secret.key";
209-
path.windows = "${prefix}Secrets-1.0${dirSep}secret.key";
203+
path.linux = "Secrets${dirSep}secret.key";
204+
path.macos64 = "Secrets-1.0${dirSep}secret.key";
205+
path.windows = "Secrets-1.0${dirSep}secret.key";
210206
in path.${os};
211207

212208
launcherConfig = defaultLauncherConfig // {
@@ -216,6 +212,7 @@ let
216212
walletBin
217213
exportWalletsBin
218214
dbConverterBin
215+
legacyStateDir
219216
legacyWalletDB
220217
legacySecretKey;
221218
syncTolerance = "300s";

nix/sources.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
"homepage": "",
3030
"owner": "input-output-hk",
3131
"repo": "cardano-sl",
32-
"rev": "1702a9eb12953e76a5a8b070e5c6a2bfb02ff160",
33-
"sha256": "0x6xlby8wzmvyd24qxpamrhq7gi1nw9xs78rk3c1y3ypq050pmqy",
32+
"rev": "c1815b7dce5fb71d997bd3a94c4c5ccf2c9a9a94",
33+
"sha256": "1dzfhv7qhv1498sd8jrac39qd8vgpdahv7dskg1hnfs5rw2gipar",
3434
"type": "tarball",
35-
"url": "https://github.com/input-output-hk/cardano-sl/archive/1702a9eb12953e76a5a8b070e5c6a2bfb02ff160.tar.gz",
35+
"url": "https://github.com/input-output-hk/cardano-sl/archive/c1815b7dce5fb71d997bd3a94c4c5ccf2c9a9a94.tar.gz",
3636
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
3737
},
3838
"cardano-wallet": {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "daedalus",
33
"productName": "Daedalus",
4-
"version": "1.0.0-FC2",
4+
"version": "1.0.0-FC3",
55
"description": "Cryptocurrency Wallet",
66
"main": "./dist/main/index.js",
77
"scripts": {

source/common/ipc/api.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ export type DetectSystemLocaleMainResponse = string;
224224
* Channel where renderer can ask main process to export wallets
225225
*/
226226
export const EXPORT_WALLETS_CHANNEL = 'EXPORT_WALLETS_CHANNEL';
227-
export type ExportWalletsRendererRequest = void;
227+
export type ExportWalletsRendererRequest = {
228+
exportSourcePath: string,
229+
};
228230
export type ExportWalletsMainResponse = {
229231
wallets: Array<ExportedByronWallet>,
230232
errors: string,

source/common/types/logging.types.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import type { CardanoNodeState } from './cardano-node.types';
33
import type { SystemInfo } from '../../renderer/app/types/systemInfoTypes';
44
import type { CoreSystemInfo } from '../../renderer/app/types/coreSystemInfoTypes';
5+
import type { WalletImportStatus } from '../../renderer/app/types/walletExportTypes';
56
import type { WalletMigrationStatus } from '../../renderer/app/stores/WalletMigrationStore';
67
import LocalizableError from '../../renderer/app/i18n/LocalizableError';
78

@@ -81,19 +82,31 @@ export type StateSnapshotLogParams = {
8182
networkTip: ?Object,
8283
};
8384

85+
export type ExportedWalletData = {
86+
id: string,
87+
name: ?string,
88+
hasPassword: boolean,
89+
import?: {
90+
status: WalletImportStatus,
91+
error: ?LocalizableError,
92+
},
93+
};
94+
95+
export type RestoredWalletData = {
96+
id: string,
97+
name: string,
98+
hasPassword: boolean,
99+
};
100+
84101
export type WalletMigrationReportData = {
85-
exportedWalletsData: Array<{ name: string }>,
102+
exportedWalletsData: Array<ExportedWalletData>,
86103
exportedWalletsCount: number,
87104
exportErrors: string,
88-
restoredWalletsData: Array<{
89-
id: string,
90-
name: string,
91-
hasPassword: boolean,
92-
}>,
105+
restoredWalletsData: Array<RestoredWalletData>,
93106
restoredWalletsCount: number,
94107
restorationErrors: Array<{
95108
error: LocalizableError,
96-
wallet: { name: string },
109+
wallet: ExportedWalletData,
97110
}>,
98111
finalMigrationStatus: WalletMigrationStatus,
99112
};

source/main/cardano/setup.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import type {
1818
CardanoStatus,
1919
TlsConfig,
2020
} from '../../common/types/cardano-node.types';
21+
import type { ExportWalletsRendererRequest } from '../../common/ipc/api';
2122
import {
2223
cardanoAwaitUpdateChannel,
2324
cardanoFaultInjectionChannel,
@@ -184,10 +185,16 @@ export const setupCardanoNode = (
184185
return cardanoNode.setFault(fault);
185186
});
186187

187-
exportWalletsChannel.onRequest(() => {
188-
logger.info('ipcMain: Received request from renderer to export wallets');
189-
return Promise.resolve(exportWallets(launcherConfig, mainWindow, locale));
190-
});
188+
exportWalletsChannel.onRequest(
189+
({ exportSourcePath }: ExportWalletsRendererRequest) => {
190+
logger.info('ipcMain: Received request from renderer to export wallets', {
191+
exportSourcePath,
192+
});
193+
return Promise.resolve(
194+
exportWallets(exportSourcePath, launcherConfig, mainWindow, locale)
195+
);
196+
}
197+
);
191198

192199
return cardanoNode;
193200
};

source/main/cardano/utils.js

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ export const createSelfnodeConfig = async (
169169
};
170170

171171
export const exportWallets = async (
172+
exportSourcePath: string,
172173
launcherConfig: LauncherConfig,
173174
mainWindow: BrowserWindow,
174175
locale: string
@@ -182,7 +183,8 @@ export const exportWallets = async (
182183
isFlight,
183184
} = launcherConfig;
184185

185-
logger.info('ipcMain: Exporting wallets...', {
186+
logger.info('ipcMain: Starting wallets export...', {
187+
exportSourcePath,
186188
exportWalletsBin,
187189
legacySecretKey,
188190
legacyWalletDB,
@@ -191,19 +193,19 @@ export const exportWallets = async (
191193
isFlight,
192194
});
193195

194-
let legacySecretKeyPath = legacySecretKey;
195-
let legacyWalletDBPath = legacyWalletDB;
196+
let legacySecretKeyPath = path.join(exportSourcePath, legacySecretKey);
197+
let legacyWalletDBPath = path.join(exportSourcePath, legacyWalletDB);
196198

197199
// In case of Daedalus Flight build we need to copy over
198-
// legacySecretKey and legacyWalletDB from Mainnet state dir
200+
// legacySecretKey and legacyWalletDB from mainnet state dir
199201
// into Daedalus Flight state dir before extracting the wallets
200202
if (isFlight) {
201203
try {
202204
const response = await prepareMigrationData(
203205
mainWindow,
204206
stateDir,
205-
legacySecretKey,
206-
legacyWalletDB,
207+
legacySecretKeyPath,
208+
legacyWalletDBPath,
207209
locale
208210
);
209211
legacySecretKeyPath = response.legacySecretKeyPath;
@@ -219,26 +221,42 @@ export const exportWallets = async (
219221
}
220222
}
221223

222-
const clusterFlags = [];
224+
// Export tool flags
225+
const exportWalletsBinFlags = [];
226+
227+
// Cluster flags
223228
if (cluster === 'testnet') {
224-
clusterFlags.push('--testnet', TESTNET_MAGIC);
229+
exportWalletsBinFlags.push('--testnet', TESTNET_MAGIC);
225230
} else {
226-
clusterFlags.push('--mainnet');
231+
exportWalletsBinFlags.push('--mainnet');
227232
}
228233

229-
const { stdout, stderr } = spawnSync(exportWalletsBin, [
230-
...clusterFlags,
231-
'--keyfile',
232-
legacySecretKeyPath,
233-
'--wallet-db-path',
234-
legacyWalletDBPath,
235-
]);
234+
// Secret key flags
235+
exportWalletsBinFlags.push('--keyfile', legacySecretKeyPath);
236+
237+
// Wallet DB flags
238+
const legacyWalletDBPathExists = await fs.pathExists(
239+
`${legacyWalletDBPath}-acid`
240+
);
241+
if (legacyWalletDBPathExists) {
242+
exportWalletsBinFlags.push('--wallet-db-path', legacyWalletDBPath);
243+
}
244+
245+
logger.info('ipcMain: Exporting wallets...', {
246+
exportWalletsBin,
247+
exportWalletsBinFlags,
248+
});
236249

250+
const { stdout, stderr } = spawnSync(exportWalletsBin, exportWalletsBinFlags);
237251
const wallets = JSON.parse(stdout.toString() || '[]');
238252
const errors = stderr.toString();
239253

240254
logger.info(`ipcMain: Exported ${wallets.length} wallets`, {
241-
walletsData: wallets.map(w => ({ name: w.name })),
255+
walletsData: wallets.map(w => ({
256+
name: w.name,
257+
id: w.id,
258+
hasPassword: w.is_passphrase_empty,
259+
})),
242260
errors,
243261
});
244262

source/main/config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export type LauncherConfig = {
7070
syncTolerance: string,
7171
cliBin: string,
7272
exportWalletsBin: string,
73+
legacyStateDir: string,
7374
legacySecretKey: string,
7475
legacyWalletDB: string,
7576
isFlight: boolean,
@@ -114,6 +115,7 @@ export const {
114115
cluster,
115116
nodeImplementation,
116117
stateDir,
118+
legacyStateDir,
117119
logsPrefix,
118120
isFlight,
119121
} = launcherConfig;
@@ -169,4 +171,4 @@ export const STAKE_POOL_REGISTRY_URL = {
169171
};
170172

171173
// Cardano Byron Testnet network magic
172-
export const TESTNET_MAGIC = 1097911063;
174+
export const TESTNET_MAGIC = '1097911063';

source/main/preload.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ import { ipcRenderer as _ipcRenderer, remote as _remote } from 'electron';
66
import _electronLog from 'electron-log-daedalus';
77
import ElectronStore from 'electron-store';
88
import { environment } from './environment';
9-
import { buildLabel, nodeImplementation, isFlight } from './config';
9+
import {
10+
buildLabel,
11+
legacyStateDir,
12+
nodeImplementation,
13+
isFlight,
14+
} from './config';
1015

1116
const _process = process;
1217
const _isIncentivizedTestnet = nodeImplementation === 'jormungandr';
@@ -52,6 +57,7 @@ process.once('loaded', () => {
5257
},
5358
isIncentivizedTestnet: _isIncentivizedTestnet,
5459
isFlight,
60+
legacyStateDir,
5561
});
5662
// Expose require for Spectron!
5763
if (_process.env.NODE_ENV === 'test') {

0 commit comments

Comments
 (0)