Skip to content
This repository has been archived by the owner on Nov 4, 2020. It is now read-only.

WIP: Tokensation Feature #44

Open
wants to merge 386 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
386 commits
Select commit Hold shift + click to select a range
7573ba5
Changed platform version in mac and win scripts
Sumit570 Jul 6, 2020
af7e69f
Added publish workflow steps for windows
Sumit570 Jul 6, 2020
a04ee92
Updated job name for github release workflow
Sumit570 Jul 6, 2020
1371cc8
Used curl instead of wget in window script
Sumit570 Jul 6, 2020
a6171a7
Used powershell instead of normal cmd
Sumit570 Jul 6, 2020
aaa508a
Added specific branches for workflow process
Sumit570 Jul 7, 2020
fcb11e8
Added 'rpcallowip' param for defid config
Sumit570 Jul 7, 2020
d43c8cb
Comment out mac publish steps
Sumit570 Jul 7, 2020
544b0b3
Reset version to 1.0.0
Sumit570 Jul 7, 2020
1f456dc
Uncommented mac publish steps
Sumit570 Jul 7, 2020
50de8d2
Commented out auto updater check
Sumit570 Jul 7, 2020
4887354
Updated window release instructions
Sumit570 Jul 7, 2020
377c6f4
Updated window publish script
Sumit570 Jul 7, 2020
285e463
Uncommented publish steps for linux and mac
Sumit570 Jul 7, 2020
84de376
Added BINARY_FILE_NAME check for window platform
Sumit570 Jul 7, 2020
5ef0aa8
Updated package lock files
Sumit570 Jul 8, 2020
692f40a
Added clear nm cache for release workflow
Sumit570 Jul 8, 2020
8616395
Uncommented auto updating code for testing
Sumit570 Jul 9, 2020
a5cf151
Added mac certificate creds using env
Sumit570 Jul 9, 2020
be72ed6
Updated version to 1.0.1 for auto update testing
Sumit570 Jul 9, 2020
3a4f1a9
Commented code for auto updater
Sumit570 Jul 9, 2020
ce3ea7d
Reset version to 1.0.0
Sumit570 Jul 9, 2020
26132ec
Uncommented auto updater code for testing
Sumit570 Jul 10, 2020
bb40800
Updated publish repo name
Sumit570 Jul 10, 2020
c66e028
Updated Github token
Sumit570 Jul 10, 2020
2c2b3d2
Updated version to 1.0.1 for auto update testing
Sumit570 Jul 10, 2020
2712c20
Handled auto updater errors
Sumit570 Jul 13, 2020
9785e99
Reset version to 1.0.0
Sumit570 Jul 13, 2020
21c3e7a
Updated version to 1.0.1 for testing windows release
Sumit570 Jul 14, 2020
3681d71
Added closed event of electron library
Sumit570 Jul 14, 2020
1f5f5e6
Updated github publish info
Sumit570 Jul 15, 2020
ac4cfba
Added disclaimer dialog
Sumit570 Jul 15, 2020
9e2f57b
Updated version to "1.0.0-alpha1"
Sumit570 Jul 15, 2020
1fe57af
Changed release type to "prerelease"
Sumit570 Jul 16, 2020
4ccd0a4
Minor changed in disclaimer dialog
Sumit570 Jul 16, 2020
651732d
Added confirmation step in disclaimer dialog for close action
Sumit570 Jul 17, 2020
e099d0c
Fixed restore wallet issue for linux and windows
Sumit570 Jul 16, 2020
a22d49b
Added visual behaviour in sidebar
Sumit570 Jul 16, 2020
d7afba2
Updated BTC with DFI for fee label inside setting
Sumit570 Jul 16, 2020
5022db8
Commented out theme option in setting
Sumit570 Jul 16, 2020
4cbbf5f
Added space between amount and unit
Sumit570 Jul 16, 2020
02a1ef6
Fixed raw data issue in payment request header
Sumit570 Jul 16, 2020
f9f4409
Add refresh animation and network name in bottom of app
Jul 16, 2020
53659f8
first letter capitalize
Jul 16, 2020
fec8f9c
update sync status component to show network all the time
Jul 17, 2020
058396d
Updated polling time for wallet and pending balance
Sumit570 Jul 17, 2020
035ca55
Added strategy to kill queue before closing app
Sumit570 Jul 17, 2020
8bd9b48
Removed closed event of electron
Sumit570 Jul 17, 2020
1393458
Updated version to 1.0.0-alpha2
Sumit570 Jul 17, 2020
3ecf9ef
Added isElectron check for kill-queue event
Sumit570 Jul 17, 2020
84fde17
Updated start blockchain check
Sumit570 Jul 17, 2020
95e6517
Resolved issue in send transaction for mainnet dfi transfer
Jul 20, 2020
c9217a1
Add updated snapshot of components
Jul 17, 2020
bf8a3e8
FIx test case and queue kill function
Jul 17, 2020
33c3b8e
Fix linting and test data
Jul 17, 2020
cb60cbd
fix masternode testcase and walletpage services testcase
Jul 17, 2020
8d68a06
Fix: German translation for Wallet on wallet page
saurabh391 Jul 20, 2020
c4b1348
Fix: Redirection issue from help section
saurabh391 Jul 20, 2020
3f6d055
Made CSS changes on Masternodes page
saurabh391 Jul 20, 2020
3f625f0
Added block height inside txn list object
Sumit570 Jul 21, 2020
9845fdb
Add optional tag on amount, label and message in receive page
Jul 21, 2020
b985c7f
Added Link to Block in transaction List
saurabh391 Jul 21, 2020
7cbc86c
Updated 'Block' to 'Height' as label for transaction list
Sumit570 Jul 21, 2020
6d293a3
Updated binary defid link to 1.0.0
Sumit570 Jul 21, 2020
dc925e0
Updated version to '1.0.0-alpha3'
Sumit570 Jul 21, 2020
3cde86d
Add horizontal on wallet page transaction table to view full data
Jul 22, 2020
10dd504
Fix and update snapshots
Jul 22, 2020
8f8876f
Fix graying of send button
Jul 22, 2020
a8fb10a
Called exit app after installing the app update
Sumit570 Jul 27, 2020
57bcbe8
Added branch "bug-fixes/electron-app-update-windows" in push event of…
Sumit570 Jul 27, 2020
2183fc0
Updated version to test "app update on windows"
Sumit570 Jul 27, 2020
57f943b
Updated logic for auto update electron app
Sumit570 Jul 27, 2020
75ba1ff
Updated branch names for push and pull_request events
Sumit570 Jul 27, 2020
0afcf9b
Removed commented code
Sumit570 Jul 27, 2020
72158c9
Reset version to "1.0.0-alpha3"
Sumit570 Jul 27, 2020
73a9245
Removed develop branch tag for push event
Sumit570 Jul 27, 2020
f8c15fa
Updated version to "1.0.0-alpha4"
Sumit570 Jul 27, 2020
f78ec57
Added bug-fixes branch to push event for testing
Sumit570 Jul 28, 2020
92d99ae
Updated publish info for testing
Sumit570 Jul 28, 2020
79aa2a8
Changed hide to minimize for main window
Sumit570 Jul 28, 2020
289492f
Removed "bug-fixes/payment-request-disapper-windows" branch from push…
Sumit570 Jul 28, 2020
a2004f2
Reset publish github info
Sumit570 Jul 28, 2020
23fbb18
Add a feature to restart a node with new masternode config when someo…
Jul 22, 2020
c0c635c
Add feature to restart node with kill queue
Jul 23, 2020
b7b9c7f
Add success label in I18n
Jul 24, 2020
7b69c82
Add checks for electron app restart and queue kill
Jul 27, 2020
dda8d9d
Remove yaml file to fetch and save configuration, only use defi.conf …
Jul 27, 2020
e8334cd
Updated logic to add new masternode operator
Jul 27, 2020
1e94834
WIP: show resign node to wallet which has owner address
Jul 29, 2020
c5449bf
Add a feature to check if masternode owner is associated with your wa…
Jul 29, 2020
1ac71ca
Add updated snapshot
Jul 30, 2020
b9cb7ea
Add masternode setMasternode action reducer test
Jul 30, 2020
69a2136
Add saga test case for fetchMasterNodes, createMasterNode, resignMast…
Jul 30, 2020
605b884
Fix TestData and testcases
Jul 30, 2020
2fcf4be
WIP: update the saga.test file with test case of restart node
Aug 4, 2020
c11a093
Fix saga check for createmasternode and add new transalation for elec…
Aug 4, 2020
eb87816
WIP: Splash loader is added
Aug 4, 2020
903f7cd
Add react md spinner in splash loader screen
Aug 5, 2020
aef810e
Fix styles of color
Aug 5, 2020
9ef20c2
Replace all loader with new loader design
Aug 5, 2020
c5f6205
WIP paginate masternode list
Aug 7, 2020
b649fb4
Add pagination on masternode list
Aug 10, 2020
d69162b
Add pagination token for receive transaction
Aug 10, 2020
ce05ddc
Add a logic to disable pagination while loading new data
Aug 10, 2020
3e3866d
update a condition to look for new transaction data onMount
Aug 10, 2020
6782a18
Remove import address statement
Aug 7, 2020
023ee6e
Update testcase for new logic for create and restart masternode
Aug 10, 2020
9d843ad
WIP: Pagination wallet txn
Aug 11, 2020
3fae88d
change name of showNexOnly and showNextOnly
Aug 11, 2020
5b812a6
Fix listtransaction validation schema
Aug 11, 2020
6715eac
Add a paymentrequests page
Aug 10, 2020
e87d77f
Add a balck color style on dropdown and paymentRequest
Aug 10, 2020
5593a9c
component rename
Aug 10, 2020
1993c90
fix qr code uid issue
Aug 11, 2020
6b4cf4f
create receive new address page
Aug 11, 2020
b18065e
Remove old receive request page
Aug 11, 2020
09b67a8
return a plain blank object in mapstatetoprops and add ui in QR popover
Aug 11, 2020
30241e8
Remove payment request component from wallet
Aug 11, 2020
fa87a3e
recolor purple things to pink
aentan Aug 12, 2020
7eb36b0
Better grid layout for settings
aentan Aug 13, 2020
fd97a91
Fix redirect logic to go to home screen after restart complete
Aug 13, 2020
69bb2fc
Remove disclaimer dialog box
Aug 14, 2020
88aac84
Remove commented code
Aug 17, 2020
887335b
pink animated progress bar
aentan Aug 17, 2020
4f6948b
update test case and snapshot
Aug 17, 2020
b8634e3
Update snapshot and testcases
Aug 17, 2020
aea36b8
add new pink icons
Aug 17, 2020
ded1c6f
Updated defi binary version to 1.0.1
Aug 17, 2020
7e1784d
Update pre-build-win.sh
fullstackninja864 Aug 18, 2020
5b05ecf
Fix: stop showing loader in case of success and error
Aug 17, 2020
220faff
update retry attempts for block chain started and sync info
Aug 18, 2020
b92ea30
Fix: remove label as required in create new receive page
Aug 18, 2020
6fe459c
WIP
Aug 13, 2020
3e57e3c
Fix errorModal message, sync status, balance and pending balance
Aug 14, 2020
8ebe388
Add a logic to store new receive request address
Aug 14, 2020
c88ddf5
Update settings test case
Aug 14, 2020
fcc3f65
remove small loader present in dialog to show progress of restart pro…
Aug 14, 2020
8ea22b4
Fix snapshots of receive page and settings display tab
Aug 17, 2020
555fc0a
Update Test case of change network
Aug 17, 2020
af1f6d7
Update local storage name issue
Aug 17, 2020
ec8ca80
Fix test cases and snapshots
Aug 18, 2020
43a5288
Fixed snapshot and updated test case and moved network switch to gene…
Aug 18, 2020
f184fe4
Hide import wallet functionality
Aug 18, 2020
e3b488f
Update network in german
Aug 18, 2020
a484337
Updated version for defi-app
Aug 18, 2020
4c54063
Updated snapshot test for version upgrate
Aug 18, 2020
3b542a8
Filtered resigned state masternodes
saurabh391 Aug 19, 2020
193c01f
Add Import wallet feature
Aug 25, 2020
6edd25d
Add new save dialog to provide name by the user
Aug 25, 2020
8cfa049
remove unsued import
Aug 25, 2020
1b17f21
add missing packages + audit fix
aentan Aug 24, 2020
ef3835b
UI improvements
aentan Aug 24, 2020
1571c48
Added french translation for users
Aug 7, 2020
b094e89
Fix testcases and snapshot of settings page
Aug 7, 2020
f8f3c2b
update missing words in french
Aug 26, 2020
a84cc56
Remove empty blocks from json
Aug 26, 2020
2208de0
update a missing restartNodeConfirmationText
Aug 26, 2020
bc95e97
Add a utility method to display clear error message
Aug 24, 2020
b8e4e97
Fix testcase
Aug 31, 2020
80349c0
synchronize blocks using windows
Aug 13, 2020
e11ce76
Add new logic to stop binary and close defi-app
Aug 27, 2020
fcc1c66
cleanup of code
Aug 28, 2020
8a1d3c2
Rename stop and kill binary event
Aug 28, 2020
25e906f
refactor code
Aug 28, 2020
c011fb5
Fix testcases
Aug 31, 2020
aa41741
replace setInterval with synchronous setInterval to remove unncessary…
Sep 3, 2020
cc13e6c
Fix masternode list, balance update on restart, createmasternode and …
Aug 31, 2020
2e07d13
Create masternode page ui changes
Sep 2, 2020
ea0daf7
Add Masternode list with tab display
Sep 2, 2020
0b9cafa
Move tab to header
Sep 2, 2020
daa1847
Add validator for address
Sep 2, 2020
79915a0
Fix Masternode
Sep 2, 2020
3f33741
Set height of wallet page blocks to same height
Sep 3, 2020
c79fa73
Add a logic to hide tabs when there is no mine data present
Sep 3, 2020
e751600
Rmove create page and update masternode page
Sep 3, 2020
77389f5
Fix transaltion on german and french
Sep 3, 2020
bb72f1b
Replace magic number with constants
Sep 3, 2020
b5638fe
Update translation
Sep 3, 2020
d4a3826
Fix package.json
Sep 3, 2020
d16e880
update package-lock.json
Sep 3, 2020
477f0ce
replace other to network and reduce cron time for fetching balance
Sep 4, 2020
efdd6e0
Fix window update issue
Sep 4, 2020
5297484
improve form validation styling
aentan Sep 8, 2020
a37136b
Added DAT and DCT components
saurabh391 Aug 26, 2020
fbfac9b
Added required modules
saurabh391 Aug 31, 2020
383f8bf
Made changes in tsconfig file
saurabh391 Aug 31, 2020
1f3de3e
Added constants
saurabh391 Aug 31, 2020
88c86ae
Added Tokens Tab in the sidebar
saurabh391 Aug 31, 2020
5b5a059
Added component for CSV read and upload
saurabh391 Aug 31, 2020
2c4186c
Added Translations english and german
saurabh391 Aug 31, 2020
e815eda
Added Token interfaces
saurabh391 Aug 31, 2020
3c1d250
Added TokensList Component
saurabh391 Sep 1, 2020
d29f95b
Added dummy assets
saurabh391 Sep 1, 2020
88491f0
Added service for tokenisation rpc calls
saurabh391 Sep 1, 2020
656d007
Added reducer and saga for tokenisation
saurabh391 Sep 1, 2020
7db522e
Added token reducer and token saga in the root
saurabh391 Sep 1, 2020
a1e76d3
Improvements and changes in masternodes
saurabh391 Sep 1, 2020
b4d4478
Added config constants
saurabh391 Sep 2, 2020
8a7bc1a
Added saga dummy rpc calls for token transfers and create token
saurabh391 Sep 2, 2020
bfbc79c
Added Transfer object Interface
saurabh391 Sep 2, 2020
ec36c96
Added Tokens Listing page
saurabh391 Sep 2, 2020
8409aef
Added Transfers List component
saurabh391 Sep 2, 2020
1e450f0
Added component for Address List
saurabh391 Sep 2, 2020
455ab40
Added components for Create DCT and DCT distribution
saurabh391 Sep 2, 2020
7939d8e
Added token info page
saurabh391 Sep 2, 2020
38c8b7b
Added Create token page
saurabh391 Sep 2, 2020
534f9b7
Added routes for pages
saurabh391 Sep 2, 2020
c81c835
Updated package-lock.json
saurabh391 Sep 3, 2020
81c42c6
Added constants
saurabh391 Sep 8, 2020
c888bba
Updated CSV Reader
saurabh391 Sep 8, 2020
f081041
Added RPC calls for tokenization
saurabh391 Sep 8, 2020
654ff25
Design changes and made rppc calls in services
saurabh391 Sep 8, 2020
be940e7
Made modification in existing flow
saurabh391 Sep 8, 2020
756b973
Modification in Token Info according to response
saurabh391 Sep 9, 2020
3ad729e
Added Check for Min DFI required
saurabh391 Sep 9, 2020
62ab671
Added confirmation modal Create Token
saurabh391 Sep 9, 2020
05def3b
Added Menu on Token Info page for Token deletion
saurabh391 Sep 9, 2020
26a02cd
Created service and rpc call for destroy token
saurabh391 Sep 9, 2020
3d6109d
Implemented destroy token confirmation modal
saurabh391 Sep 10, 2020
6df4bdf
Added Edit token feature in the UI
saurabh391 Sep 10, 2020
79296da
Implemented saga and rpc call for update token
saurabh391 Sep 10, 2020
350afe9
Integrated rpc call to update token in the UI
saurabh391 Sep 10, 2020
6de75dd
Design fixes and minor bugs
saurabh391 Sep 11, 2020
b2f00a2
Made changes in existing code
saurabh391 Sep 15, 2020
43da6ea
Added test data and test cases for components
saurabh391 Sep 15, 2020
3b06295
Added testcases for reducer and saga
saurabh391 Sep 15, 2020
cdb537e
Added a check for destructionTx in token listing
saurabh391 Sep 16, 2020
c0e4683
Added extra line
saurabh391 Sep 16, 2020
189d086
Removed inline styles and removed type any
saurabh391 Sep 16, 2020
f843784
Removed inline styles and added classes
saurabh391 Sep 16, 2020
a8716f1
Created common props interface for TokenCard
saurabh391 Sep 16, 2020
7ab8d05
Created different component for create DCT footer
saurabh391 Sep 17, 2020
fca4c8c
Improvements in codebase
saurabh391 Sep 17, 2020
20d1734
Replaced any with corresponding types
saurabh391 Sep 17, 2020
7452567
Added contants for Token balance pages
saurabh391 Sep 29, 2020
5744ed3
Added listing token call in reducer and saga
saurabh391 Sep 29, 2020
7483727
Added Token cards for wallet
saurabh391 Sep 29, 2020
30aaa98
Added Wallet token list and Add token list components
saurabh391 Sep 29, 2020
9563c01
Fix: Changed RPC arguments
saurabh391 Sep 29, 2020
3178ade
Fix: Show proper error message createtoken
saurabh391 Sep 29, 2020
b53db56
Update: gettoken and destroytoken tokenIds
saurabh391 Sep 30, 2020
2b46fab
Added rpc call getaccount
saurabh391 Oct 1, 2020
c98c138
Added reducer and service
saurabh391 Oct 1, 2020
e11b9ae
Made changes for Token Balance and Transactions
saurabh391 Oct 1, 2020
d9b0c51
Fix: Removed destroy token functionality
saurabh391 Oct 5, 2020
80cc64f
Merge branch 'feature/implement-token-listing-ui' of github.com:DeFiC…
saurabh391 Oct 7, 2020
ae4ad46
Merge branch 'develop' into feature/implement-token-listing-ui
saurabh391 Oct 7, 2020
892726b
Added listacconts in RPC call
saurabh391 Oct 9, 2020
adfb537
Made changes in the reducer and service
saurabh391 Oct 9, 2020
b160509
Added condition for different tokens
saurabh391 Oct 9, 2020
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
6 changes: 3 additions & 3 deletions .github/workflows/release-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ jobs:
rm -r -fo win -ErrorAction Ignore
mkdir win
cd win
curl https://github.com/DeFiCh/ain/releases/download/v1.0.2/defichain-1.0.2-x86_64-w64-mingw32.zip -O defichain-1.0.2-x86_64-w64-mingw32.zip
Expand-Archive -LiteralPath .\defichain-1.0.2-x86_64-w64-mingw32.zip -DestinationPath .
Copy-Item .\defichain-1.0.2\bin\defid.exe .
curl https://github.com/DeFiCh/ain/releases/download/v1.2.0/defichain-1.2.0-x86_64-w64-mingw32.zip -O defichain-1.2.0-x86_64-w64-mingw32.zip
Expand-Archive -LiteralPath .\defichain-1.2.0-x86_64-w64-mingw32.zip -DestinationPath .
Copy-Item .\defichain-1.2.0\bin\defid.exe .
cd ..\..
Copy-Item temp\win\defid.exe binary\win\defid.exe
icacls binary\win\defid.exe /grant everyone:F
Expand Down
13 changes: 8 additions & 5 deletions electron-app/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import log from 'loglevel';
import * as path from 'path';
import * as url from 'url';
import { app, BrowserWindow, Menu, protocol, dialog } from 'electron';
import { app, BrowserWindow, Menu, protocol } from 'electron';
import { autoUpdater } from 'electron-updater';

import DefiProcessManager from './services/defiprocessmanager';
Expand All @@ -21,6 +21,8 @@ import {
STOP_BINARY_AND_QUEUE,
} from './constants';
import initiateElectronUpdateManager from './ipc-events/electronupdatemanager';
import ElectronLogger from './services/electronLogger';
import initiateBackupImportWalletManager from './ipc-events/backupAndImportWallet';

declare var process: {
argv: any;
Expand All @@ -44,8 +46,8 @@ export default class App {
if (process.mas) app.setName(process.env.npm_package_name);
this.allowQuit = false;
autoUpdater.autoDownload = false;
autoUpdater.logger = ElectronLogger;
/* For future purpose */
initiateElectronUpdateManager(autoUpdater);
}

run() {
Expand All @@ -61,12 +63,14 @@ export default class App {
this.createWindow();
this.createMenu();
// initiate ipcMain events
initiateIpcEvents();
initiateIpcEvents(autoUpdater);

/* For future purpose */
autoUpdater.checkForUpdatesAndNotify().catch((e) => {
log.error(e);
});
initiateElectronUpdateManager(autoUpdater, this.mainWindow);
initiateBackupImportWalletManager(this.mainWindow);
};

initiateInterceptFileProtocol() {
Expand Down Expand Up @@ -162,8 +166,7 @@ export default class App {

this.mainWindow.hide();
event.preventDefault();
const defiProcessManager = new DefiProcessManager();
await defiProcessManager.stop();
await DefiProcessManager.stop();
this.allowQuit = true;
return app.quit();
};
Expand Down
3 changes: 3 additions & 0 deletions electron-app/src/constants/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export const SECOND_INSTANCE = 'second-instance';
export const RESTART_APP = 'restart-app';

export const DARWIN = 'darwin';
export const MAC = 'mac';
export const WIN = 'win';
export const WIN_32 = 'win32';
export const LINUX = 'linux';
export const AIX = 'aix';
Expand All @@ -29,3 +31,4 @@ export const DEFAULT_ELECTRON_FORMAT =
'[{y}-{m}-{d} {h}:{i}:{s}.{ms}] [IPC-MAIN-{level}] {text}';
export const DISCLAIMER_DIALOG_TIMER = 10000;
export const STOP_BINARY_INTERVAL = 500;
export const REINDEX_ERROR_STRING = 'restart with -reindex';
39 changes: 38 additions & 1 deletion electron-app/src/constants/dirpath.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import path from 'path';
import { app } from 'electron';
import { rootPath } from 'electron-root-path';
import { getPlatform } from '../utils';
import {
getPlatform,
isDataDirDefined,
getCustomDebugLogFilePath,
getDefaultDebugLogFilePath,
} from '../utils';

export const APP_NAME = app.name;
export const IS_DEV = process.env.NODE_ENV === 'development';
Expand All @@ -14,9 +19,41 @@ export const CONFIG_FILE_NAME = path.join(APP_DIR, '/defi.conf');
export const UI_CONFIG_FILE_NAME = path.join(APP_DIR, '/defi.ui.yaml');
export const PID_FILE_NAME = path.join(APP_DIR, '/defi.pid');

export const BINARY_LOG_FILE_NAME = 'debug.log';

export const BINARY_FILE_NAME = getPlatform() === 'win' ? 'defid.exe' : 'defid';
export const BINARY_FILE_PATH = IS_DEV
? path.join(rootPath, './binary', getPlatform())
: IS_PACKAGED
? path.join(__dirname, '../../../../..', 'binary', getPlatform())
: path.join(rootPath, '../', 'binary', getPlatform());

export const CONFIG_FILE_PATH = path.join(HOME_PATH, '/.defi', 'defi.conf');

export const BASE_FILE_PATH = isDataDirDefined(CONFIG_FILE_PATH)
? path.join(getCustomDebugLogFilePath(CONFIG_FILE_PATH))
: getDefaultDebugLogFilePath(HOME_PATH);

export const DEBUG_LOG_FILE_PATH = path.join(
BASE_FILE_PATH,
BINARY_LOG_FILE_NAME
);

export const WALLET_DAT = 'wallet.dat';

export const TESTNET_BASE_FOLDER = path.join(
BASE_FILE_PATH,
'testnet3',
'wallets'
);

export const REGTEST_BASE_FOLDER = path.join(
BASE_FILE_PATH,
'regtest',
'wallets'
);

export const MAINNET_BASE_FOLDER =
getPlatform() === 'linux'
? BASE_FILE_PATH
: path.join(BASE_FILE_PATH, 'wallets');
22 changes: 22 additions & 0 deletions electron-app/src/constants/ipcevents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,25 @@ export const MENU_BACKUP_WALLET = 'menu-backup-wallet';
export const MENU_IMPORT_WALLET = 'menu-import-wallet';

export const STOP_BINARY_AND_QUEUE = 'stop-binary-and-queue';

export const UPDATE_PROGRESS_VALUE = 'download-progress';

export const UPDATE_PROGRESS_COMPLETED = 'update-downloaded';

export const UPDATE_PROGRESS_FAILURE = 'update-downloaded-error';

export const POST_UPDATE_ACTION = 'post-update-action';

export const START_DOWNLOAD_UPDATE = 'start-download-update';

export const SHOW_UPDATE_AVAILABLE = 'show-update-available';

export const CLOSE_APP = 'close-app';

export const FORCE_KILL_QUEUE_AND_SHUTDOWN = 'force-kill-queue-and-shutdown';

export const WALLET_BACKUP = 'wallet-backup';

export const BACKUP_WALLET_DAT = 'backup-wallet-dat';

export const START_BACKUP_WALLET = 'start-backup-wallet';
29 changes: 29 additions & 0 deletions electron-app/src/controllers/logs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import * as log from '../services/electronLogger';
import DialogManager from '../services/dialogmanager';
import { getFileData, writeFile } from '../utils';

export default class Logs {
async download(data: string, extension: string) {
try {
const dialogManager = new DialogManager();
const paths = await dialogManager.saveFilePath();
if (!paths.length) {
throw new Error('No valid path available');
}
paths.slice(-5).includes(extension)
? writeFile(paths, data)
: writeFile(paths + extension, data);
} catch (err) {
log.error(err);
}
}

async read(filePath: string) {
try {
const data = getFileData(filePath);
return data;
} catch (err) {
log.error(err);
}
}
}
56 changes: 49 additions & 7 deletions electron-app/src/controllers/wallets.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
import path from 'path';
import * as log from '../services/electronLogger';
import DialogManager from '../services/dialogmanager';
import { MENU_BACKUP_WALLET, MENU_IMPORT_WALLET } from '../constants';
import {
MENU_BACKUP_WALLET,
MENU_IMPORT_WALLET,
START_BACKUP_WALLET,
WALLET_DAT,
} from '../constants';
import { copyFile, getBaseFolder, responseMessage } from '../utils';

const saveFileDailog = async (
extensions: { name: string; extensions: string[] }[]
) => {
const dialogManager = new DialogManager();
const paths = await dialogManager.saveFilePath(extensions);
if (!paths.length) {
throw new Error('No valid path available');
}
return paths;
};

const appendExtension = (paths: string, extension: string) => {
const isDatFile = paths.lastIndexOf('.');
return isDatFile === -1 ? `${paths}.${extension}` : paths;
};

export default class Wallet {
async load(bw: Electron.BrowserWindow) {
Expand All @@ -15,14 +38,33 @@ export default class Wallet {

async backup(bw: Electron.BrowserWindow) {
try {
const dialogManager = new DialogManager();
const paths = await dialogManager.saveFilePath();
if (!paths.length) {
throw new Error('No valid path available');
}
bw.webContents.send(MENU_BACKUP_WALLET, { paths });
const paths = await saveFileDailog([
{ name: 'Text file', extensions: ['txt'] },
]);

bw.webContents.send(MENU_BACKUP_WALLET, {
paths: appendExtension(paths, 'txt'),
});
return responseMessage(true, {});
} catch (err) {
log.error(err);
return responseMessage(false, {
message: err.message,
});
}
}

async backupWalletDat() {
const paths = await saveFileDailog([
{ name: 'Wallet', extensions: ['dat'] },
]);
const dest = appendExtension(paths, 'dat');
const baseFolder = getBaseFolder();
const src = path.join(baseFolder, WALLET_DAT);
return copyFile(src, dest);
}

async startBackupWallet(bw: Electron.BrowserWindow) {
bw.webContents.send(START_BACKUP_WALLET);
}
}
15 changes: 15 additions & 0 deletions electron-app/src/ipc-events/appUpdateManager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { CancellationToken } from 'electron-updater';
import { app, ipcMain } from 'electron';
import { POST_UPDATE_ACTION, START_DOWNLOAD_UPDATE } from '../constants';

export default function initiateAppUpdateManager(autoUpdater: any) {
ipcMain.on(POST_UPDATE_ACTION, () => {
autoUpdater.quitAndInstall();
app.exit();
});

ipcMain.on(START_DOWNLOAD_UPDATE, () => {
const cancellationToken = new CancellationToken();
autoUpdater.downloadUpdate(cancellationToken);
});
}
25 changes: 25 additions & 0 deletions electron-app/src/ipc-events/backupAndImportWallet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ipcMain } from 'electron';
import { WALLET_BACKUP, BACKUP_WALLET_DAT } from '../constants';
import Wallet from '../controllers/wallets';
import { responseMessage } from '../utils';

const initiateBackupImportWalletManager = (bw: Electron.BrowserWindow) => {
ipcMain.on(WALLET_BACKUP, async (event: Electron.IpcMainEvent) => {
const wallet = new Wallet();
event.returnValue = await wallet.backup(bw);
});

ipcMain.on(BACKUP_WALLET_DAT, async (event: Electron.IpcMainEvent) => {
try {
const wallet = new Wallet();
await wallet.backupWalletDat();
event.returnValue = responseMessage(true, {});
} catch (err) {
event.returnValue = responseMessage(false, {
message: err.message,
});
}
});
};

export default initiateBackupImportWalletManager;
25 changes: 18 additions & 7 deletions electron-app/src/ipc-events/defiprocessmanager.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
import { ipcMain } from 'electron';
import DefiProcessManager from '../services/defiprocessmanager';
import { START_DEFI_CHAIN, STOP_DEFI_CHAIN, RESTART_APP } from '../constants';
import {
START_DEFI_CHAIN,
STOP_DEFI_CHAIN,
RESTART_APP,
CLOSE_APP,
FORCE_KILL_QUEUE_AND_SHUTDOWN,
} from '../constants';

export default function initiateDefiProcessManager() {
ipcMain.on(START_DEFI_CHAIN, async (event, arg) => {
const defiProcessManager = new DefiProcessManager();
await defiProcessManager.start(arg, event);
await DefiProcessManager.start(arg, event);
});

ipcMain.on(STOP_DEFI_CHAIN, async (event) => {
const defiProcessManager = new DefiProcessManager();
event.returnValue = await defiProcessManager.stop();
event.returnValue = await DefiProcessManager.stop();
});

ipcMain.on(RESTART_APP, async (event, args) => {
const defiProcessManager = new DefiProcessManager();
event.returnValue = await defiProcessManager.restart(args, event);
event.returnValue = await DefiProcessManager.restart(args, event);
});

ipcMain.on(CLOSE_APP, async () => {
await DefiProcessManager.closeApp();
});

ipcMain.on(FORCE_KILL_QUEUE_AND_SHUTDOWN, async () => {
await DefiProcessManager.forceClose();
});
}
Loading