Skip to content

Commit

Permalink
Packaging wallet app (#96)
Browse files Browse the repository at this point in the history
* packaging wallet

* Git ignore update

* Git ignore update

* linting changes

* linting changes

* Package script for mac/windows/common linux distributes

* Package script for mac/windows/common linux distributes

* Package script for mac/windows/common linux distributes

* Package script for mac/windows/common linux distributes

* Package script for mac/windows/common linux distributes

* Package script for mac/windows/common linux distributes

* Package script for mac/windows/common linux distributes
  • Loading branch information
yhaspel authored and Ilya Vilensky committed May 29, 2019
1 parent 76f2b2a commit 49b69f1
Show file tree
Hide file tree
Showing 32 changed files with 1,658 additions and 5,585 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Expand Up @@ -46,6 +46,8 @@ dist
dll
main.js
main.js.map
/release-builds/*
/release-installers/*

.idea
npm-debug.log.*
Expand Down
5 changes: 2 additions & 3 deletions .eslintrc
@@ -1,11 +1,10 @@
{
"parser": "babel-eslint",
"extends": ["airbnb", "prettier", "prettier/flowtype", "prettier/react"],
"plugins": ["react", "import", "prettier", "flowtype", "jest"],
"plugins": ["react", "import", "prettier", "flowtype"],
"env": {
"browser": true,
"node": true,
"jest": true
"node": true
},
"rules": {
"class-methods-use-this": 0,
Expand Down
6 changes: 5 additions & 1 deletion .flowconfig
Expand Up @@ -7,6 +7,7 @@
<PROJECT_ROOT>/release/.*
<PROJECT_ROOT>/dll/.*
<PROJECT_ROOT>/git/.*
<PROJECT_ROOT>/node_modules/

[include]

Expand All @@ -18,5 +19,8 @@ flow-typed
module.name_mapper='^/\(.*\)' -> '<PROJECT_ROOT>/app/\1'
suppress_comment= \\(.\\|\n\\)*\\$FlowStyledIssue

[lints]
deprecated-utility=off

[version]
^0.93.0
^0.98.1
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -30,3 +30,7 @@ flow-typed/
ct-libc/
/dll/
/node_modules/
/release-builds
/release-installers
/desktop/dist/
/desktop/main.prod.js
6 changes: 3 additions & 3 deletions .travis.yml
Expand Up @@ -10,15 +10,15 @@ matrix:
- ELECTRON_BUILDER_CACHE=$HOME/.cache/electron-builder

- os: linux
env:
- ELECTRON_CACHE=$HOME/.cache/electron
- ELECTRON_BUILDER_CACHE=$HOME/.cache/electron-builder

before_cache:
- rm -rf $HOME/.cache/electron-builder/wine

cache:
directories:
- node_modules
- $(npm config get prefix)/lib/node_modules
- flow-typed
- $HOME/.cache/electron
- $HOME/.cache/electron-builder

Expand Down
Binary file added app/assets/icons/1024_app_icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/icons/app_icon.icns
Binary file not shown.
Binary file added app/assets/icons/app_icon.ico
Binary file not shown.
21 changes: 2 additions & 19 deletions app/infra/cryptoService/cryptoService.js
Expand Up @@ -7,22 +7,6 @@ const fromHexString = (hexString: string): Uint8Array => new Uint8Array(hexStrin
const toHexString = (bytes: Uint8Array): string => bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, '0'), '');

class CryptoService {
constructor() {
this.loadWASM();
}

loadWASM = async () => {
await this.loadWASMInternal();
};

loadWASMInternal = async () => {
const response = await fetch('../app/infra/cryptoService/ed25519.wasm');
const bytes = await response.arrayBuffer();
const go = new Go(); // eslint-disable-line no-undef
const { instance } = await WebAssembly.instantiate(bytes, go.importObject);
await go.run(instance);
};

stopAndCleanUp = () => __stopAndCleanUp(); // eslint-disable-line no-undef

generateMnemonic = () => bip39.generateMnemonic();
Expand All @@ -38,8 +22,7 @@ class CryptoService {
sleep();
}
// Generate 64 seed bytes (512 bits) from phrase - this is a wallet's master seed
const seed = bip39.mnemonicToSeedHex(mnemonic);
const seedAsUint8Array = Buffer.from(seed, 'hex');
const seed = bip39.mnemonicToSeedSync(mnemonic);
let publicKey = new Uint8Array(32);
let secretKey = new Uint8Array(64);
const saveKeys = (pk, sk) => {
Expand All @@ -50,7 +33,7 @@ class CryptoService {
publicKey = pk;
secretKey = sk;
};
__generateKeyPair(seedAsUint8Array, saveKeys); // eslint-disable-line no-undef
__generateKeyPair(seed, saveKeys); // eslint-disable-line no-undef
return { publicKey: toHexString(publicKey), secretKey: toHexString(secretKey) };
};

Expand Down
3 changes: 2 additions & 1 deletion configs/webpack.config.main.prod.babel.js
Expand Up @@ -54,7 +54,8 @@ export default merge.smart(baseConfig, {
*/
new webpack.EnvironmentPlugin({
NODE_ENV: 'production',
DEBUG_PROD: false
DEBUG_PROD: false,
START_MINIMIZED: false
})
],

Expand Down
10 changes: 10 additions & 0 deletions debian.json
@@ -0,0 +1,10 @@
{
"dest": "release-installers/linux/",
"icon": "app/assets/icons/1024_app_icon.png",
"categories": [
"Utility"
],
"lintianOverrides": [
"changelog-file-missing-in-native-package"
]
}
11 changes: 10 additions & 1 deletion desktop/app.html
Expand Up @@ -2,11 +2,20 @@
<html>
<head>
<meta charset="utf-8">
<title>SmApp Wallet</title>
<title>Spacemesh Wallet</title>
</head>
<body>
<div id="root" style="height: 100%; width: 100%;"></div>
<script src="wasm_exec.js"></script>
<script>
(async function() {
const response = await fetch('./ed25519.wasm');
const bytes = await response.arrayBuffer();
const go = new Go(); // eslint-disable-line no-undef
const { instance } = await WebAssembly.instantiate(bytes, go.importObject);
await go.run(instance);
})();
</script>
<script>
{
const scripts = [];
Expand Down
14 changes: 6 additions & 8 deletions desktop/diskStorageManager.js
@@ -1,9 +1,10 @@
// @flow
import os from 'os';
import disk from 'diskusage';
import drivelist from 'drivelist';
import { ipcConsts } from '../app/vars';

const checkDiskSpace = require('check-disk-space');

const getMountPoint = (drive: any): string => {
if (drive.mountpoints && drive.mountpoints.length) {
return `${drive.mountpoints[0].path}${os.type() === 'win32' ? '\\' : ''}`;
Expand Down Expand Up @@ -36,13 +37,10 @@ class DiskStorageManager {
});
};

static getAvailableSpace = async ({ event, path }: { event: any, path: string }) => {
try {
const { available } = await disk.check(path);
event.sender.send(ipcConsts.GET_AVAILABLE_DISK_SPACE_SUCCESS, available);
} catch (error) {
event.sender.send(ipcConsts.GET_AVAILABLE_DISK_SPACE_FAILURE, error.message);
}
static getAvailableSpace = ({ event, path }: { event: any, path: string }) => {
checkDiskSpace(path).then((diskSpace) => {
event.sender.send(ipcConsts.GET_AVAILABLE_DISK_SPACE_SUCCESS, diskSpace.free);
});
};
}

Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions desktop/fileManager.js
Expand Up @@ -38,12 +38,12 @@ class FileManager {
const filesWithPath = filteredFiles.map((file) => path.join(appFilesDirPath, file));
if (filesWithPath && filesWithPath[0]) {
shell.showItemInFolder(filesWithPath[0]);
event.sender.send(ipcConsts.OPEN_DIRECTORY_SUCCESS);
} else {
throw new Error('Wallet backup file not found');
shell.openItem(appFilesDirPath);
}
event.sender.send(ipcConsts.OPEN_WALLET_BACKUP_DIRECTORY_SUCCESS);
} catch (error) {
event.sender.send(ipcConsts.OPEN_DIRECTORY_FAILURE, error.message);
event.sender.send(ipcConsts.OPEN_WALLET_BACKUP_DIRECTORY_FAILURE, error.message);
}
};

Expand Down

0 comments on commit 49b69f1

Please sign in to comment.