Skip to content

Commit dbef511

Browse files
committed
angular8 version update
1 parent cc52d70 commit dbef511

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+9649
-10693
lines changed

Gulpfile.js

Lines changed: 26 additions & 428 deletions
Large diffs are not rendered by default.

angular.json

Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"newProjectRoot": "projects",
5+
"projects": {
6+
"helperbit": {
7+
"projectType": "application",
8+
"schematics": {
9+
"@schematics/angular:component": {
10+
"style": "scss"
11+
}
12+
},
13+
"root": "app",
14+
"sourceRoot": "app",
15+
"prefix": "app",
16+
"architect": {
17+
"build": {
18+
"builder": "@angular-devkit/build-angular:browser",
19+
"options": {
20+
"budgets": [
21+
{
22+
"type": "initial",
23+
"maximumWarning": "5mb",
24+
"maximumError": "10mb"
25+
},
26+
{
27+
"type": "anyComponentStyle",
28+
"maximumWarning": "6kb",
29+
"maximumError": "10kb"
30+
}
31+
],
32+
"baseHref": "/",
33+
"deployUrl": "/",
34+
"outputPath": "dist/",
35+
"index": "app/index.html",
36+
"main": "app/main.ts",
37+
"polyfills": "app/polyfills.ts",
38+
"tsConfig": "app/tsconfig.app.json",
39+
"aot": false,
40+
"assets": [
41+
"app/favicon.ico",
42+
{
43+
"glob": "**/*",
44+
"input": "app/assets/",
45+
"output": "/"
46+
},
47+
{
48+
"glob": "**/*",
49+
"input": "app/widgets/",
50+
"output": "/widgets",
51+
"ignore": [
52+
"node_modules",
53+
"**/node_modules",
54+
"app/widgets/node_modules"
55+
]
56+
}
57+
],
58+
"styles": [
59+
"node_modules/bootstrap/dist/css/bootstrap.min.css",
60+
"node_modules/leaflet/dist/leaflet.css",
61+
"node_modules/intl-tel-input/build/css/intlTelInput.css",
62+
"node_modules/bootstrap-slider/dist/css/bootstrap-slider.min.css",
63+
"node_modules/bootstrap-social/bootstrap-social.css",
64+
"node_modules/cryptocoins-icons/webfont/cryptocoins.css",
65+
"node_modules/font-awesome/css/font-awesome.min.css",
66+
"app/assets/fonts/fonts.css",
67+
"node_modules/ng-bootstrap-to-bootstrap-3/dist/ng-bootstrap-to-bootstrap-3.min.css",
68+
"node_modules/angular-archwizard/archwizard.css",
69+
"app/styles.scss"
70+
],
71+
"scripts": [
72+
"node_modules/intl-tel-input/build/js/utils.js",
73+
"node_modules/intl-tel-input/build/js/intlTelInput.min.js"
74+
]
75+
},
76+
"configurations": {
77+
"mainnet": {
78+
"fileReplacements": [
79+
{
80+
"replace": "app/config.js",
81+
"with": "app/config/mainnet.js"
82+
}
83+
],
84+
"optimization": true,
85+
"outputHashing": "all",
86+
"sourceMap": false,
87+
"extractCss": false,
88+
"namedChunks": true,
89+
"aot": false,
90+
"extractLicenses": true,
91+
"vendorChunk": true,
92+
"buildOptimizer": false
93+
},
94+
"testnet": {
95+
"fileReplacements": [
96+
{
97+
"replace": "app/config.js",
98+
"with": "app/config/testnet.js"
99+
}
100+
],
101+
"optimization": true,
102+
"outputHashing": "all",
103+
"sourceMap": false,
104+
"extractCss": false,
105+
"namedChunks": true,
106+
"vendorSourceMap": false,
107+
"aot": false,
108+
"extractLicenses": true,
109+
"vendorChunk": true,
110+
"buildOptimizer": false
111+
},
112+
"mainnet-staging": {
113+
"fileReplacements": [
114+
{
115+
"replace": "app/config.js",
116+
"with": "app/config/mainnet-staging.js"
117+
}
118+
],
119+
"optimization": true,
120+
"outputHashing": "all",
121+
"sourceMap": false,
122+
"extractCss": false,
123+
"namedChunks": true,
124+
"aot": false,
125+
"extractLicenses": true,
126+
"vendorChunk": true,
127+
"buildOptimizer": false
128+
},
129+
"dev": {
130+
"fileReplacements": [
131+
{
132+
"replace": "app/config.js",
133+
"with": "app/config/dev.js"
134+
}
135+
],
136+
"optimization": false,
137+
"outputHashing": "all",
138+
"sourceMap": false,
139+
"extractCss": false,
140+
"vendorSourceMap": false,
141+
"namedChunks": true,
142+
"aot": false,
143+
"extractLicenses": false,
144+
"vendorChunk": true,
145+
"buildOptimizer": false
146+
}
147+
}
148+
},
149+
"serve": {
150+
"builder": "@angular-devkit/build-angular:dev-server",
151+
"options": {
152+
"browserTarget": "helperbit:build"
153+
},
154+
"configurations": {
155+
"dev": {
156+
"browserTarget": "helperbit:build:dev"
157+
}
158+
}
159+
},
160+
"extract-i18n": {
161+
"builder": "@angular-devkit/build-angular:extract-i18n",
162+
"options": {
163+
"browserTarget": "helperbit:build"
164+
}
165+
},
166+
"test": {
167+
"builder": "@angular-devkit/build-angular:karma",
168+
"options": {
169+
"codeCoverage": true,
170+
"main": "app/test.ts",
171+
"polyfills": "app/polyfills.ts",
172+
"tsConfig": "tsconfig.spec.json",
173+
"karmaConfig": "karma.conf.js",
174+
"assets": [
175+
"app/favicon.ico",
176+
"app/assets"
177+
],
178+
"styles": [
179+
"app/styles.scss"
180+
],
181+
"scripts": []
182+
}
183+
},
184+
"lint": {
185+
"builder": "@angular-devkit/build-angular:tslint",
186+
"options": {
187+
"tsConfig": [
188+
"app/tsconfig.app.json",
189+
"tsconfig.spec.json",
190+
"e2e/tsconfig.json"
191+
],
192+
"exclude": [
193+
"**/node_modules/**"
194+
]
195+
}
196+
},
197+
"e2e": {
198+
"builder": "@angular-devkit/build-angular:protractor",
199+
"options": {
200+
"protractorConfig": "e2e/protractor.conf.js",
201+
"devServerTarget": "helperbit:serve"
202+
},
203+
"configurations": {
204+
"production": {
205+
"devServerTarget": "helperbit:serve:production"
206+
}
207+
}
208+
},
209+
"server": {
210+
"builder": "@angular-devkit/build-angular:server",
211+
"options": {
212+
"outputPath": "dist/server",
213+
"main": "app/main.server.ts",
214+
"tsConfig": "tsconfig.server.json"
215+
},
216+
"configurations": {
217+
"dev": {
218+
"sourceMap": false,
219+
"optimization": {
220+
"scripts": false,
221+
"styles": true
222+
}
223+
}
224+
}
225+
}
226+
}
227+
}
228+
},
229+
"defaultProject": "helperbit"
230+
}
File renamed without changes.

app/services/bitcoin/ledger.ts renamed to app/components/dashboard/bitcoin.service/ledger.ts

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,29 @@ import TransportU2F from "@ledgerhq/hw-transport-u2f";
33
import Btc from "@ledgerhq/hw-app-btc";
44
import {
55
BitcoinSignService, BitcoinSignOptions, compressPublicKey,
6-
prepareScripts, toByteArray, scriptTypeOfBitcoinScriptType
6+
prepareScripts, toByteArray
77
} from './bitcoin-service';
8-
import { ConfigService } from '../../app.config';
9-
import { deserializeCall } from '../../models/common';
10-
11-
require("babel-polyfill");
8+
import { unwrap } from '../../../models/common';
9+
import AppSettings from '../../../app.settings';
10+
import { Injectable } from '@angular/core';
11+
import { HttpClient } from '@angular/common/http';
12+
import { Observable } from 'rxjs/internal/Observable';
1213

1314

15+
@Injectable()
1416
export default class BitcoinLedgerService implements BitcoinSignService {
15-
config: ConfigService;
16-
$http: any;
17-
1817
defaultAccount: string;
1918
defaultPath: string;
2019

21-
constructor(config: ConfigService, $http) {
22-
this.config = config;
23-
this.$http = $http;
2420

21+
constructor(private http: HttpClient) {
2522
this.defaultAccount = '7276'; // HB
26-
this.defaultPath = "44'/" + (config.networkName == 'testnet' ? '1' : '0') + "'/" + this.defaultAccount + "'/0/0";
23+
this.defaultPath = "44'/" + (AppSettings.networkName == 'testnet' ? '1' : '0') + "'/" + this.defaultAccount + "'/0/0";
2724
}
2825

29-
private rawTransactions(hashes: string[]): Promise<{ [txid: string]: string }> {
30-
return deserializeCall<{ [txid: string]: string }>(
31-
this.$http.post(this.config.apiUrl + '/blockchain/rawtransactions', { hashes: hashes }),
32-
'transactions'
33-
);
26+
private rawTransactions(hashes: string[]): Observable<{ [txid: string]: string }> {
27+
return this.http.post<{ [txid: string]: string }>(AppSettings.apiUrl + '/blockchain/rawtransactions', { hashes: hashes })
28+
.pipe(unwrap('transactions'));
3429
}
3530

3631
private getPublicKeyFromPath(path: string, ledgerWaitCallback) {
@@ -81,7 +76,7 @@ export default class BitcoinLedgerService implements BitcoinSignService {
8176
if (options.scripttype != 'p2sh')
8277
segwit = true;
8378

84-
const walletScripts = prepareScripts(options.scripttype, options.n, options.pubkeys, this.config.network);
79+
const walletScripts = prepareScripts(options.scripttype, options.n, options.pubkeys, AppSettings.network);
8580

8681
return new Promise((resolve, reject) => {
8782
ledgerWaitCallback(1, 'wait');
@@ -92,7 +87,7 @@ export default class BitcoinLedgerService implements BitcoinSignService {
9287
const btc = new Btc(transport);
9388

9489
/* Download utxo transaction raw */
95-
this.rawTransactions(options.utxos.map(utxo => utxo.tx)).then(transactions => {
90+
this.rawTransactions(options.utxos.map(utxo => utxo.tx)).subscribe(transactions => {
9691
/* Create inputs and serialized outputs */
9792
const inputs = options.utxos.map(utxo => [
9893
btc.splitTransaction(transactions[utxo.tx], bitcoinjs.Transaction.fromHex(transactions[utxo.tx]).hasWitnesses()),
@@ -101,14 +96,14 @@ export default class BitcoinLedgerService implements BitcoinSignService {
10196
// bitcoinjs.Transaction.fromHex(transactions[utxo.tx]).outs[utxo.n].sequence
10297
]);
10398
const paths = inputs.map(i => this.defaultPath);
104-
const txb = bitcoinjs.Psbt.fromHex(txhex, { network: this.config.network });
99+
const txb = bitcoinjs.Psbt.fromHex(txhex, { network: AppSettings.network });
105100
const outshex = btc.serializeTransactionOutputs(btc.splitTransaction((txb as any).__CACHE.__TX.toHex(), true)).toString('hex');
106101

107102
btc.signP2SHTransaction(inputs, paths, outshex, 0/*tx.locktime*/, 1 /*SIGHASH_ALL*/, segwit, 2).then(signatures => {
108103
/* Inject signatures */
109104
for (let j = 0; j < txb.inputCount; j++) {
110105
txb.signInput(j, {
111-
network: this.config.network,
106+
network: AppSettings.network,
112107
publicKey: toByteArray(publickey),
113108
sign: (hash) => bitcoinjs.script.signature.decode(toByteArray(signatures[j])).signature
114109
} as bitcoinjs.ECPairInterface);
@@ -122,7 +117,7 @@ export default class BitcoinLedgerService implements BitcoinSignService {
122117
ledgerWaitCallback(2, 'error');
123118
return reject(err);
124119
});
125-
}).catch(err => {
120+
}, err => {
126121
// eslint-disable-next-line no-console
127122
console.log('Failed acquiring txhashes:', err);
128123
ledgerWaitCallback(2, 'error');
@@ -138,6 +133,4 @@ export default class BitcoinLedgerService implements BitcoinSignService {
138133
});
139134
});
140135
}
141-
142-
static get $inject() { return ['config', '$http'] };
143136
}

0 commit comments

Comments
 (0)