Skip to content

Commit

Permalink
Merge pull request #2 from fwd/business_wallet
Browse files Browse the repository at this point in the history
Business wallet
  • Loading branch information
nano2dev committed Mar 7, 2024
2 parents d7aa4a9 + 1a8704b commit 5061316
Show file tree
Hide file tree
Showing 38 changed files with 846 additions and 353 deletions.
21 changes: 13 additions & 8 deletions .github/workflows/electron_hash.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,31 @@ jobs:

release:
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}

# Run different jobs for each OS
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
artifact_name: checksums
asset_name: checksums
app_ext: AppImage
app_os: linux
experimental: false
- os: macos-11
artifact_name: checksums
asset_name: checksums
app_ext: dmg
app_os: mac
experimental: false
- os: windows-2022
artifact_name: checksums
asset_name: checksums
app_ext: exe
app_os: windows
experimental: true

needs: pre_build # job dependency and shared variables
steps:
Expand Down Expand Up @@ -81,17 +86,17 @@ jobs:
- name: Build Electron app
run: |
npm run desktop:local
npm run desktop:local --openssl_fips=''
- name: Create Hashes
if: startsWith(github.ref, 'refs/tags/')
run: |
openssl sha1 desktop-app/build/*.${{ matrix.app_ext }} >> desktop-app/build/${{ matrix.artifact_name }} | bash
openssl md5 desktop-app/build/*.${{ matrix.app_ext }} >> desktop-app/build/${{ matrix.artifact_name }} | bash
openssl sha256 desktop-app/build/*.${{ matrix.app_ext }} >> desktop-app/build/${{ matrix.artifact_name }} | bash
openssl sha512 desktop-app/build/*.${{ matrix.app_ext }} >> desktop-app/build/${{ matrix.artifact_name }} | bash
openssl sha3-512 desktop-app/build/*.${{ matrix.app_ext }} >> desktop-app/build/${{ matrix.artifact_name }} | bash
openssl blake2b512 desktop-app/build/*.${{ matrix.app_ext }} >> desktop-app/build/${{ matrix.artifact_name }} | bash
openssl sha1 desktop-app/build/*.${{ matrix.app_ext }} | tee -a desktop-app/build/${{ matrix.artifact_name }}
openssl md5 desktop-app/build/*.${{ matrix.app_ext }} | tee -a desktop-app/build/${{ matrix.artifact_name }}
openssl sha256 desktop-app/build/*.${{ matrix.app_ext }} | tee -a desktop-app/build/${{ matrix.artifact_name }}
openssl sha512 desktop-app/build/*.${{ matrix.app_ext }} | tee -a desktop-app/build/${{ matrix.artifact_name }}
openssl sha3-512 desktop-app/build/*.${{ matrix.app_ext }} | tee -a desktop-app/build/${{ matrix.artifact_name }}
openssl blake2b512 desktop-app/build/*.${{ matrix.app_ext }} | tee -a desktop-app/build/${{ matrix.artifact_name }}
shell: bash

- name: Rename file paths in .yml (Linux)
Expand Down Expand Up @@ -199,4 +204,4 @@ jobs:
path: |
desktop-app/build/*.AppImage
desktop-app/build/*.dmg
desktop-app/build/*.exe
desktop-app/build/*.exe
12 changes: 4 additions & 8 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,13 @@ npm install
npm run wallet:dev
```

If you want to debug in VS code, first install [debugger for chrome](https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome)
Then you can just go to the debug screen and choose "Launch Chrome http"
You can use JavaScript debugger bundled with VS Code to debug. Refer [here](https://github.com/microsoft/vscode-js-debug) for additional information.

#### Run the wallet in dev mode as https (for example if using the Ledger device)
```bash
npm run wallet:dev-ssl
```

To debug in VS code: Go to debug screen and choose "Launch Chrome https"

## Build Wallet (For Production)
Build a production version of the wallet for web:
```bash
Expand All @@ -52,12 +49,11 @@ Run the desktop wallet in dev mode:
npm run desktop:dev
```

If you want to debug in VS code, first install [debugger for chrome](https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome)
Then you can just go to the debug screen and choose "Electron: Main", "Electron: Renderer", or "Electron: All" for both Main and Renderer threads.
You can use JavaScript debugger bundled with VS Code to debug. Refer [here](https://github.com/microsoft/vscode-js-debug) for additional information.

Build the desktop wallet for your local OS (Will be in `desktop-app\build`):
```bash
npm run desktop:local
npm run desktop:local --openssl_fips=''
```

Can also run a complete build for your local OS. The "wallet:build-desktop" command is run automatically. (Will be in `desktop-app\build`):
Expand Down Expand Up @@ -97,4 +93,4 @@ npm version patch
git push --follow-tags
```

3. The github actions will take care of the rest. Linting, release draft, docker, desktop app building and uploading binaries based on the new version
3. The github actions will take care of the rest. Linting, release draft, docker, desktop app building and uploading binaries based on the new version
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

![line](https://github.com/fwd/n2/raw/master/.github/line.png)

## Changes

- ✅ Redesigned UI/UX
- ✅ Add Nano.to Usernames to send page.
- ✅ Add Nano.to Usernames to transactions.
Expand Down
64 changes: 43 additions & 21 deletions desktop-app/src/lib/ledger.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import TransportNodeHid from '@ledgerhq/hw-transport-node-hid';
import TransportNodeBle from '@ledgerhq/hw-transport-node-ble';
import * as LedgerLogs from '@ledgerhq/logs';
import Transport from '@ledgerhq/hw-transport';
import Nano from 'hw-app-nano';

import * as rx from 'rxjs';
Expand All @@ -20,24 +20,29 @@ const LedgerStatus = {
READY: 'ready',
};

export interface LedgerData {
status: string;
nano: any|null;
transport: Transport|null;
}


/**
* This class is close to a clone of the LedgerService for web, but it
* talks to the USB device directly and relays messages over Electron IPC
*/
export class LedgerService {
walletPrefix = `44'/165'/`;
waitTimeout = 300000;
normalTimeout = 5000;
pollInterval = 45000;
waitTimeout = 30000;
pollInterval = 5000;

pollingLedger = false;
queryingLedger = false;

ledgerStatus$ = new rx.Subject();
ledgerMessage$ = new rx.Subject();

ledger = {
ledger: LedgerData = {
status: LedgerStatus.NOT_CONNECTED,
nano: null,
transport: null,
Expand All @@ -56,15 +61,33 @@ export class LedgerService {
// Open a connection to the usb device and initialize up the Nano Ledger library
async loadTransport(bluetooth: boolean) {
return new Promise((resolve, reject) => {
(bluetooth ? TransportNodeBle : TransportNodeHid).create().then(trans => {

// LedgerLogs.listen((log) => console.log(`Ledger: ${log.type}: ${log.message}`))
this.ledger.transport = trans;
this.ledger.transport.setExchangeTimeout(this.waitTimeout); // 5 minutes
this.ledger.nano = new Nano(this.ledger.transport);

resolve(this.ledger.transport);
}).catch(reject);
const transport = bluetooth ? TransportNodeBle : TransportNodeHid;
let found = false;
const sub = transport.listen({
next: async(e) => {
found = true;
if (sub) sub.unsubscribe();
clearTimeout(timeoutId);
this.ledger.transport = await transport.open(e.descriptor);
this.ledger.nano = new Nano(this.ledger.transport);
resolve(this.ledger.transport);
},
error: (e) => {
clearTimeout(timeoutId);
reject(e);
},
complete: () => {
clearTimeout(timeoutId);
if (!found) {
reject(new Error(transport.ErrorMessage_NoDeviceFound));
}
}
})

const timeoutId = setTimeout(() => {
sub.unsubscribe();
reject(new Error(transport.ErrorMessage_ListenTimeout));
}, this.waitTimeout);
});
}

Expand All @@ -88,10 +111,6 @@ export class LedgerService {
}

let resolved = false;
if (this.ledger.status === LedgerStatus.READY) {
this.ledgerStatus$.next({ status: this.ledger.status, statusText: 'Ledger device already ready' });
return true; // Already ready?
}

setTimeout(() => {
if (resolved || this.ledger.status === LedgerStatus.READY) return;
Expand All @@ -117,6 +136,7 @@ export class LedgerService {
} catch (err) {
console.log(err);
if (err.statusCode === STATUS_CODES.SECURITY_STATUS_NOT_SATISFIED) {
this.setLedgerStatus(LedgerStatus.LOCKED, `Ledger device locked`);
}
}

Expand All @@ -125,8 +145,6 @@ export class LedgerService {

async getLedgerAccount(accountIndex, showOnScreen = false) {
try {
this.ledger.transport.setExchangeTimeout(showOnScreen ? this.waitTimeout : this.normalTimeout);

this.queryingLedger = true;
const account = await this.ledger.nano.getAddress(this.ledgerPath(accountIndex), showOnScreen);
this.queryingLedger = false;
Expand Down Expand Up @@ -208,7 +226,11 @@ export class LedgerService {
await this.getLedgerAccount(0, false);
this.setLedgerStatus(LedgerStatus.READY);
} catch (err) {
this.setLedgerStatus(LedgerStatus.NOT_CONNECTED, `Ledger Disconnected: ${err.message || err }`);
if (err.statusCode === STATUS_CODES.SECURITY_STATUS_NOT_SATISFIED) {
this.setLedgerStatus(LedgerStatus.LOCKED, `Ledger device locked`);
} else {
this.setLedgerStatus(LedgerStatus.NOT_CONNECTED, `Ledger Disconnected: ${err.message || err }`);
}
this.pollingLedger = false;
}
}
Expand Down
4 changes: 4 additions & 0 deletions desktop-app/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"esModuleInterop": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "es2017",
Expand All @@ -20,5 +21,8 @@
},
"include": [
"src/**/*"
],
"exclude": [
"**/node_modules/**"
]
}
4 changes: 2 additions & 2 deletions docs/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"accounts": {
"account-address-confirmed-on-ledger": "Account address confirmed on Ledger",
"account-address-denied-if-it-is-wrong-do-not-use-the-wallet": "Account address denied - if it is wrong do not use the wallet!",
"add-new-account": "Add New Account",
"add-new-account": "Add Account",
"advanced-mode": "Advanced Mode",
"confirm-address-on-ledger": "Confirm Address On Ledger",
"confirming-account-address-on-ledger-device": "Confirming account address on Ledger device...",
Expand Down Expand Up @@ -237,7 +237,7 @@
"this-has-to-be-a-valid-work": {
"1": "This has to be a valid",
"2-link-work": "Nano Work Server",
"3": "endpoint or an API compliant with it. If your server on localhost does not work, try the desktop app instead."
"3": "endpoint or an API compliant with it."
},
"this-representative-will-be-used-for-any-new-account": "This representative will be used for any new account",
"this-server-is-used-for-rpc-communication-with-the-nano-node": "This server is used for RPC communication with the nano node",
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<div style="position: absolute; width: 100%; height: 100%; background-color: #19191B;">
<div style="position: absolute; text-align: center; height: 30px; font-size: 30px; margin: auto; top: 25%; left: 0; right: 0;">
<img src="assets/img/nault-logo-night-mode.svg" width="250px" style="display: block; margin: 0 auto 20px auto;" alt="Logo"/>
<div style="color: #8F8FBB; font-family: 'Open Sans', Arial, Helvetica, sans-serif; font-weight: bold;">Pro</div>
<div style="color: #8F8FBB; font-family: 'Open Sans', Arial, Helvetica, sans-serif; font-weight: bold;">Business</div>
</div>
</div>
</app-root>
Expand Down

0 comments on commit 5061316

Please sign in to comment.