Skip to content

Commit

Permalink
Merge 027cbf5 into 269aed8
Browse files Browse the repository at this point in the history
  • Loading branch information
pbca26 authored Aug 19, 2021
2 parents 269aed8 + 027cbf5 commit 556a886
Show file tree
Hide file tree
Showing 31 changed files with 700 additions and 90 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions config-overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ 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, '@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
2 changes: 1 addition & 1 deletion electron/ipc-ledger.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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');

Expand Down
35 changes: 5 additions & 30 deletions electron/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// Modules to control application life and create native browser window
require('babel-polyfill');
const TransportNodeHid = require('@ledgerhq/hw-transport-node-hid-noevents').default;
const AppBtc = require('@ledgerhq/hw-app-btc').default;

const {
app,
BrowserWindow,
Expand Down Expand Up @@ -85,36 +90,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 Down
7 changes: 5 additions & 2 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.7",
"description": "Komodo Hardware Wallet Electron App",
"main": "main.js",
"scripts": {
Expand Down Expand Up @@ -30,11 +30,14 @@
},
"dependencies": {
"@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",
"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
5 changes: 4 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.7",
"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 @@ -48,6 +49,8 @@
"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
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"
}
61 changes: 41 additions & 20 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import WarnBrowser from './WarnBrowser';
import ConnectionError from './ConnectionError';
import Footer from './Footer';
import FirmwareCheckModal from './FirmwareCheckModal';
import SettingsModal from './SettingsModal';
import {
repository,
version,
Expand All @@ -29,19 +30,17 @@ import {
TX_FEE,
VENDOR,
} from './constants';
import {
setExplorerUrl,
getInfo,
} from './lib/blockchain';
import accountDiscovery from './lib/account-discovery';
import blockchain, {setBlockchainAPI, blockchainAPI} from './lib/blockchain';
import apiEndpoints from './lib/coins';
import getKomodoRewards from './lib/get-komodo-rewards';
import {osName} from 'react-device-detect';
//import {osName} from 'react-device-detect';
import {
isElectron,
appData,
ipcRenderer,
} from './Electron';
import initSettings from './lib/init-settings';

// TODO: receive modal, tos modal, move api end point conn test to blockchain module
const MAX_TIP_TIME_DIFF = 3600 * 24;
Expand All @@ -57,7 +56,7 @@ class App extends React.Component {
vendor: null,
isFirstRun: true,
ledgerDeviceType: null,
ledgerFWVersion: 'default',
ledgerFWVersion: 'webusb',
coin: 'KMD',
theme: getLocalStorageVar('settings') && getLocalStorageVar('settings').theme ? getLocalStorageVar('settings').theme : 'tdark',
};
Expand All @@ -79,6 +78,7 @@ class App extends React.Component {
ipcRenderer.send('nspvRunRecheck', {coin: 'rick'});
}, 2000);*/

initSettings();
hw.trezor.init();

if (!getLocalStorageVar('settings')) {
Expand All @@ -88,16 +88,13 @@ class App extends React.Component {
document.getElementById('body').className = getLocalStorageVar('settings').theme;
}

if (isElectron && appData.blockchainAPI === 'spv') {
blockchain[blockchainAPI].setCoin(this.state.coin);
}

if (!isElectron || (isElectron && appData.blockchainAPI === 'insight')) this.checkExplorerEndpoints();

if (isElectron && appData.blockchainAPI === 'spv'/*&& isElectron.blockchainAPI*/) {
blockchain[blockchainAPI].setCoin(this.state.coin);
setBlockchainAPI('spv');
}

if (!isElectron || (isElectron && appData.blockchainAPI === 'insight')) this.checkExplorerEndpoints();

if (isElectron && appData.isNspv) {
ipcRenderer.on('nspvRecheck', (event, arg) => {
console.warn('nspvRecheck arg', arg);
Expand Down Expand Up @@ -171,7 +168,7 @@ class App extends React.Component {
}

checkExplorerEndpoints = async () => {
const getInfoRes = await Promise.all(apiEndpoints[this.state.coin].map((value, index) => {
const getInfoRes = await Promise.all(apiEndpoints[this.state.coin].api.map((value, index) => {
return blockchain[blockchainAPI].getInfo(value);
}));
let isExplorerEndpointSet = false;
Expand Down Expand Up @@ -279,6 +276,13 @@ class App extends React.Component {
</div>
<h1 className="navbar-item">
<strong>HW KMD {this.state.coin === voteCoin ? 'Notary Elections' : ' wallet'}</strong>
<SettingsModal
updateExplorerEndpoint={this.updateExplorerEndpoint}
coin={this.state.coin}
explorerEndpoint={this.state.explorerEndpoint} />
{/*<button
className="button is-primary add-pwa-button"
style={{'display': 'none'}}>Add to home screen</button>*/}
</h1>
</div>
</Header>
Expand Down Expand Up @@ -315,6 +319,18 @@ class App extends React.Component {
}

<Footer>
{!isElectron &&
<div className="download-desktop-block">
<a
href="https://github.com/pbca26/hw-kmd-wallet/releases"
target="_blank">
<button
className="button is-light">
<i className="fa fa-download"></i>Download for desktop
</button>
</a>
</div>
}
<p>
<strong>{this.state.coin === voteCoin ? 'Hardware wallet KMD Notary Elections' : 'KMD hardware wallet'}</strong> by <a target="_blank" rel="noopener noreferrer" href="https://github.com/atomiclabs">Atomic Labs</a> and <a target="_blank" rel="noopener noreferrer" href="https://github.com/komodoplatform">Komodo Platform</a>.
</p>
Expand All @@ -323,15 +339,15 @@ class App extends React.Component {
<br />
View the <a target="_blank" rel="noopener noreferrer" href={`https://github.com/${repository}#usage`}>README</a> for usage instructions.
</p>
<div className="theme-selector">
{/*<div className="theme-selector">
Theme
<div
onClick={() => this.setTheme('tdark')}
className={'item black' + (this.state.theme === 'tdark' ? ' active' : '')}></div>
<div
onClick={() => this.setTheme('tlight') }
className={'item light' + (this.state.theme === 'tlight' ? ' active' : '')}></div>
</div>
</div>*/}
</Footer>
</div>
);
Expand All @@ -358,7 +374,11 @@ class App extends React.Component {
{this.state.vendor &&
<strong>{VENDOR[this.state.vendor]} KMD HW {this.state.coin === voteCoin ? 'Notary Elections' : ' wallet'}</strong>
}
{apiEndpoints[this.state.coin].api.length > 1 &&
<SettingsModal
updateExplorerEndpoint={this.updateExplorerEndpoint}
coin={this.state.coin}
explorerEndpoint={this.state.explorerEndpoint} />
{/*apiEndpoints[this.state.coin].api.length > 1 &&
<span className="explorer-selector-block">
<i className="fa fa-cog"></i>
<select
Expand All @@ -380,7 +400,7 @@ class App extends React.Component {
))}
</select>
</span>
}
*/}
</h1>
</div>
<div className="navbar-menu">
Expand Down Expand Up @@ -446,7 +466,8 @@ class App extends React.Component {
<ConnectionError />
}

{(!isElectron || (isElectron && !appData.noFWCheck)) &&
{getLocalStorageVar('settings') && getLocalStorageVar('settings').fwCheck &&
(!isElectron || (isElectron && !appData.noFWCheck)) &&
<FirmwareCheckModal
vendor={this.state.vendor}
updateLedgerDeviceType={this.updateLedgerDeviceType}
Expand Down Expand Up @@ -526,15 +547,15 @@ class App extends React.Component {
<br />
View the <a target="_blank" rel="noopener noreferrer" href={`https://github.com/${repository}#usage`}>README</a> for usage instructions.
</p>
<div className="theme-selector">
{/*<div className="theme-selector">
Theme
<div
onClick={() => this.setTheme('tdark')}
className={'item black' + (this.state.theme === 'tdark' ? ' active' : '')}></div>
<div
onClick={() => this.setTheme('tlight') }
className={'item light' + (this.state.theme === 'tlight' ? ' active' : '')}></div>
</div>
</div>*/}
</Footer>
</div>
);
Expand Down
26 changes: 26 additions & 0 deletions src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,32 @@
flex-direction: column;
min-width: 600px;

.download-desktop-block {
text-align: center;
padding-bottom: 20px;

a:hover {
text-decoration: none;
}
button {
padding: 15px;
height: 2.5rem;

i {
padding-right: 7px;
position: relative;
top: -2px;
}
}
}

.add-pwa-button {
position: absolute;
top: 8px;
left: calc(100% - 180px);
z-index: 1000;
}

.col-warning {
color: #ffc107;
}
Expand Down
Loading

0 comments on commit 556a886

Please sign in to comment.