Skip to content

Commit

Permalink
Merge 502bed9 into 269aed8
Browse files Browse the repository at this point in the history
  • Loading branch information
pbca26 authored Nov 24, 2021
2 parents 269aed8 + 502bed9 commit dcacac9
Show file tree
Hide file tree
Showing 124 changed files with 5,387 additions and 924 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
name: gui
- uses: actions/setup-node@v1
with:
node-version: '12'
node-version: '16'
check-latest: true

- name: Unpack GUI
Expand Down Expand Up @@ -99,7 +99,7 @@ jobs:
name: gui
- uses: actions/setup-node@v1
with:
node-version: '12'
node-version: '16'
check-latest: true

- name: Unpack GUI
Expand All @@ -119,6 +119,8 @@ jobs:
- name: Build Electron App
run: |
sudo apt-get install libusb-1.0-0-dev
sudo apt install libudev-dev
cd electron
npm install
npm run dist
Expand Down Expand Up @@ -157,7 +159,7 @@ jobs:
name: gui
- uses: actions/setup-node@v1
with:
node-version: '12'
node-version: '16'
check-latest: true

- name: Unpack GUI
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: HWKMDTestsCI

on:
push:
branches:
- master
- dev
- ui-refactor

jobs:
linux-run-tests:
name: Unit tests
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: '12'
check-latest: true

- name: Install deps
run: npm install

- name: Run tests
run: env TZ='Europe/Moscow' npm run test
4 changes: 4 additions & 0 deletions config-overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ module.exports = {
path.resolve(paths.appNodeModules, 'lru-cache'),
path.resolve(paths.appNodeModules, 'yallist'),
path.resolve(paths.appNodeModules, 'u2f-api'),
path.resolve(paths.appNodeModules, 'asn1.js'),
path.resolve(paths.appNodeModules, 'bech32'),
path.resolve(paths.appNodeModules, 'webrtc-adapter'),
path.resolve(paths.appNodeModules, '@trezor/utxo-lib'),
path.resolve(paths.appNodeModules, '@ledgerhq/hw-app-btc'),
path.resolve(paths.appNodeModules, '@ledgerhq/hw-transport/lib-es'),
path.resolve(paths.appNodeModules, '@ledgerhq/hw-transport-webusb/lib-es'),
Expand Down
17 changes: 9 additions & 8 deletions electron/ipc-ledger.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
require('babel-polyfill');
const TransportNodeHid = require('@ledgerhq/hw-transport-node-hid').default;
const TransportNodeHid = require('@ledgerhq/hw-transport-node-hid-noevents').default;
const AppBtc = require('@ledgerhq/hw-app-btc').default;
const {ipcMain} = require('electron');
const isDev = process.argv.indexOf('devmode') > -1;

let mainWindow;

Expand All @@ -22,7 +23,7 @@ function getAddress(derivationPath, verify) {
);
})
.catch(e => {
console.warn(e);
if (isDev) console.warn(e);
return -777;
});
}
Expand Down Expand Up @@ -64,7 +65,7 @@ function createPaymentTransactionNew(txData) {
);
})
.catch(e => {
console.warn(e);
if (isDev) console.warn(e);
return -777;
});
}
Expand All @@ -89,18 +90,18 @@ function splitTransaction(txData) {
hasExtraData,
additionals,
);
console.log(txSplit);
if (isDev) console.log(txSplit);
transport.close();
return txSplit;
})
.catch(e => {
console.warn(e);
if (isDev) console.warn(e);
return -777;
});
}

ipcMain.on('getAddress', (e, {derivationPath, ruid}) => {
console.log(derivationPath);
if (isDev) console.log(derivationPath);

if (mainWindow) {
getAddress(derivationPath, false).then(result => {
Expand All @@ -110,7 +111,7 @@ ipcMain.on('getAddress', (e, {derivationPath, ruid}) => {
});

ipcMain.on('createPaymentTransactionNew', (e, {txData, ruid}) => {
console.log(txData);
if (isDev) console.log(txData);

if (mainWindow) {
createPaymentTransactionNew(txData).then(result => {
Expand All @@ -120,7 +121,7 @@ ipcMain.on('createPaymentTransactionNew', (e, {txData, ruid}) => {
});

ipcMain.on('splitTransaction', (e, {txData, ruid}) => {
console.log(txData);
if (isDev) console.log(txData);

if (mainWindow) {
splitTransaction(txData).then(result => {
Expand Down
87 changes: 53 additions & 34 deletions electron/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Modules to control application life and create native browser window
require('babel-polyfill');
require('@electron/remote/main').initialize();
const TransportNodeHid = require('@ledgerhq/hw-transport-node-hid-noevents').default;
const AppBtc = require('@ledgerhq/hw-app-btc').default;

const {
app,
BrowserWindow,
Expand All @@ -10,6 +16,8 @@ const url = require('url');
const ipcLedger = require('./ipc-ledger');
const ipcSPV = require('./spv');
const ipcNSPV = require('./nspv');
const isDev = process.argv.indexOf('devmode') > -1;
const {createAdapter} = require('iocane');

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
Expand All @@ -23,9 +31,13 @@ function createWindow() {
webPreferences: {
nativeWindowOpen: true, // <-- important for trezor
nodeIntegration: true,
contextIsolation: false,
enableRemoteModule: true,
},
});

require("@electron/remote/main").enable(mainWindow.webContents);

require(path.join(__dirname, 'menu'));

const staticMenu = Menu.buildFromTemplate([ // if static
Expand All @@ -45,15 +57,52 @@ function createWindow() {
{ role: 'selectall' },
]);

const decodeStoredData = (str, pw) => {
return new Promise((resolve, reject) => {
if (str.length) {
createAdapter()
.decrypt(str, pw)
.catch((err) => {
console.log('decodeStoredData error', err);
resolve(false);
})
.then(decryptedString => {
//console.log('decryptedString', decryptedString);
resolve(decryptedString);
});
} else {
resolve(false);
}
});
};

const encodeStoredData = (str, pw) => {
return new Promise((resolve, reject) => {
createAdapter()
.encrypt(str, pw)
.catch((err) => {
console.log('encodeStoredData error', err);
resolve(false);
})
.then(encryptedString => {
resolve(encryptedString);
});
});
};

global.app = {
isDev: process.argv.indexOf('devmode') > -1,
isDev,
noFWCheck: true,
blockchainAPI: process.argv.indexOf('api=spv') > -1 || process.argv.indexOf('api=nspv') > -1 ? 'spv' : 'insight',
isNspv: process.argv.indexOf('api=nspv') > -1,
helpers: {
decodeStoredData,
encodeStoredData,
},
};

// and load the index.html of the app.
if (process.argv.indexOf('devmode') > -1) {
if (isDev) {
mainWindow.maximize();
mainWindow.loadURL('http://localhost:3000/');
} else {
Expand Down Expand Up @@ -85,36 +134,6 @@ function createWindow() {
ipcLedger.setMainWindow(mainWindow);
ipcSPV.setMainWindow(mainWindow);
ipcNSPV.setMainWindow(mainWindow);

ipcMain.on('getAddress', (e, {ruid, derivationPath}) => {
console.log(derivationPath);

if (mainWindow) {
getAddress(derivationPath, false).then(result => {
mainWindow.webContents.send('getAddress', {ruid, result});
});
}
});

ipcMain.on('createPaymentTransactionNew', (e, {ruid, txData}) => {
console.log(txData);

if (mainWindow) {
createPaymentTransactionNew(txData).then(result => {
mainWindow.webContents.send('createPaymentTransactionNew', {ruid, result});
});
}
});

ipcMain.on('splitTransaction', (e, {ruid, txData}) => {
console.log(txData);

if (mainWindow) {
splitTransaction(txData).then(result => {
mainWindow.webContents.send('splitTransaction', {ruid, result});
});
}
});
}

// This method will be called when Electron has finished
Expand All @@ -126,7 +145,7 @@ app.on('ready', createWindow);
app.on('window-all-closed', function() {
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin' || process.argv.indexOf('devmode') > -1) {
if (process.platform !== 'darwin' || isDev) {
app.quit();
}
});
Expand All @@ -142,7 +161,7 @@ app.on('activate', function() {
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.
app.on('browser-window-focus', (event, win) => {
if (!win.isDevToolsOpened() && process.argv.indexOf('devmode') > -1) {
if (!win.isDevToolsOpened() && isDev) {
win.openDevTools();
}
});
18 changes: 12 additions & 6 deletions electron/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "hw-kmd-wallet-electron",
"version": "0.2.6",
"version": "0.2.9",
"description": "Komodo Hardware Wallet Electron App",
"main": "main.js",
"scripts": {
Expand All @@ -23,18 +23,24 @@
"author": "Komodo Platform",
"license": "MIT",
"devDependencies": {
"electron": "^5.0.13",
"electron-builder": "22.6.1",
"electron-rebuild": "^1.8.4",
"electron-devtools-installer": "^2.2.4"
"electron": "^15.2.0",
"electron-builder": "22.13.1",
"electron-devtools-installer": "^3.2.0",
"electron-rebuild": "^3.2.3"
},
"dependencies": {
"@electron/remote": "^2.0.1",
"@ledgerhq/hw-app-btc": "^5.16.0",
"@ledgerhq/hw-transport-node-hid": "^4.38.6",
"@ledgerhq/hw-transport-node-hid-noevents": "^5.51.1",
"async": "^2.6.2",
"babel-polyfill": "^6.26.0",
"bitgo-utxo-lib": "git+https://github.com/pbca26/bitgo-utxo-lib",
"create-hash": "git://github.com/pbca26/createHash#electron-v4",
"fix-path": "^2.1.0",
"fs-extra": "^7.0.0",
"iocane": "^5.1.1",
"node-abi": "^3.2.0",
"request": "^2.88.0",
"tx-decoder": "git+https://github.com/pbca26/tx-decoder"
}
}
2 changes: 1 addition & 1 deletion electron/spv.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ const broadcastTx = async(coin, rawtx) => {
});
};

pcMain.on('spvGetAddress', (e, {ruid, coin, address}) => {
ipcMain.on('spvGetAddress', (e, {ruid, coin, address}) => {
if (mainWindow) {
console.warn(`${coin} spvGetAddress called`);
getAddress(coin, address).then(result => {
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hw-kmd-wallet",
"version": "0.2.5",
"version": "0.2.9",
"author": "Luke Childs <[email protected]> (http://lukechilds.co.uk), Komodo Platform (https://komodoplatform.com)",
"repository": "pbca26/hw-kmd-wallet",
"homepage": "https://pbca26.github.io/hw-kmd-wallet",
Expand Down Expand Up @@ -35,6 +35,7 @@
"@ledgerhq/hw-transport-webhid": "^5.34.0",
"@ledgerhq/hw-transport-webusb": "^5.34.1",
"@ledgerhq/hw-transport-web-ble": "^4.78.0",
"@trezor/utxo-lib": "^0.1.2",
"babel-polyfill": "^6.26.0",
"bip32-path": "^0.4.2",
"bitcoinjs-lib": "^4.0.2",
Expand All @@ -44,10 +45,13 @@
"compare-versions": "^3.6.0",
"date-fns": "^1.30.1",
"lodash": "^4.17.19",
"iocane": "^5.1.1",
"react": "^16.6.3",
"react-app-rewire-scss": "^1.0.2",
"react-device-detect": "^1.11.14",
"react-dom": "^16.6.3",
"react-qr-reader": "^2.1.0",
"qrcode.react": "^0.7.1",
"satoshi-bitcoin": "^1.0.4",
"scientific-to-decimal": "^1.1.1",
"trezor-connect": "^8.1.7",
Expand Down
Binary file added public/coins/AXO.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/coins/BET.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/coins/BOTS.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/coins/BTCH.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/coins/CCL.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/coins/CLC.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/coins/COQUICASH.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/coins/CRYPTO.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/coins/DEX.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/coins/DP.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/coins/GLEEC.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/coins/HODL.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/coins/ILN.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/coins/JUMBLR.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/coins/KMD.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/coins/KOIN.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/coins/LABS.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/coins/MCL.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/coins/MESH.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/coins/MGW.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/coins/MORTY.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/coins/MSHARK.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/coins/NINJA.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/coins/PANGEA.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/coins/PGT.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/coins/REVS.png
Binary file added public/coins/RICK.png
Binary file added public/coins/SOULJA.png
Binary file added public/coins/SPACE.png
Binary file added public/coins/SUPERNET.png
Binary file added public/coins/THC.png
Binary file added public/coins/TKLTEST.png
Binary file added public/coins/TOKEL.png
Binary file added public/coins/VOTE2021.png
Binary file added public/coins/VRSC.png
Binary file added public/coins/WLC21.png
Binary file added public/coins/WSB.png
6 changes: 5 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
<meta property="og:url" content="https://pbca26.github.io/hw-kmd-wallet/">
<meta property="og:description" content="Manage your coins from a hardware wallet device.">
<meta property="og:image" content="%PUBLIC_URL%/card-image.png">


<link rel="manifest" href="%PUBLIC_URL%/manifest.webmanifest">
<meta name="mobile-wep-app-capable" content="yes">
<meta name="apple-mobile-wep-app-capable" content="yes">

<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Rubik:300,|Rubik:500,700,regular">

<title>Komodo Hardware Wallet</title>
Expand Down
21 changes: 21 additions & 0 deletions public/manifest.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "KMD HW Wallet",
"short_name": "KMDHW",
"description": "Komodo Hardware Wallet Tool",
"icons": [
{
"src": "favicon.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "favicon.png",
"sizes": "512x512",
"type": "image/png"
}
],
"start_url": "index.html",
"display": "standalone",
"background_color": "#000000",
"theme_color": "#1A2939"
}
Loading

0 comments on commit dcacac9

Please sign in to comment.