Skip to content

Commit 0ccf8b0

Browse files
committed
workaround to keep the tsc version on copay
1 parent 187bab8 commit 0ccf8b0

File tree

9 files changed

+49
-62
lines changed

9 files changed

+49
-62
lines changed

packages/bitcore-wallet-client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"docs": "./node_modules/.bin/jsdox lib/* lib/common lib/errors -o docs && cat README.header.md docs/*.md LICENSE > README.md",
6767
"coveralls": "./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
6868
"compile": "npm run tsc",
69-
"tsc": "npm run clean && ./node_modules/.bin/tsc",
69+
"tsc": "npm run clean && tsc",
7070
"build": "tsc && npm run lint",
7171
"clean": "rimraf ./ts_build",
7272
"lint": "tslint -c tslint.json 'src/**/*.ts'",

packages/bitcore-wallet-client/src/lib/api.ts

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { EventEmitter } from 'events';
44
import _ from 'lodash';
55
import sjcl from 'sjcl';
6-
import { Common } from './common';
6+
import { Constants, Utils } from './common';
77
import { Credentials } from './credentials';
88
import { Key } from './key';
99
import { PayPro } from './paypro';
@@ -23,10 +23,6 @@ var Mnemonic = require('bitcore-mnemonic');
2323
var url = require('url');
2424
var querystring = require('querystring');
2525

26-
var Constants = Common.Constants;
27-
var Defaults = Common.Defaults;
28-
var Utils = Common.Utils;
29-
3026
var log = require('./log');
3127
const Errors = require('./errors');
3228

@@ -99,7 +95,7 @@ export class API extends EventEmitter {
9995
}
10096

10197
_fetchLatestNotifications(interval, cb) {
102-
cb = cb || function() {};
98+
cb = cb || function () { };
10399

104100
var opts: any = {
105101
lastNotificationId: this.lastNotificationId,
@@ -290,7 +286,7 @@ export class API extends EventEmitter {
290286
var words;
291287
try {
292288
words = c.getMnemonic();
293-
} catch (ex) {}
289+
} catch (ex) { }
294290

295291
var xpriv;
296292
if (words && (!c.mnemonicHasPassphrase || opts.passphrase)) {
@@ -627,7 +623,7 @@ export class API extends EventEmitter {
627623
};
628624
t.inputs[i].addSignature(t, s);
629625
i++;
630-
} catch (e) {}
626+
} catch (e) { }
631627
});
632628
if (i != txp.inputs.length) throw new Error('Wrong signatures');
633629
}
@@ -737,9 +733,9 @@ export class API extends EventEmitter {
737733

738734
this.request.get(
739735
'/v2/feelevels/?coin=' +
740-
(coin || 'btc') +
741-
'&network=' +
742-
(network || 'livenet'),
736+
(coin || 'btc') +
737+
'&network=' +
738+
(network || 'livenet'),
743739
(err, result) => {
744740
if (err) return cb(err);
745741
return cb(err, result);
@@ -1458,9 +1454,9 @@ export class API extends EventEmitter {
14581454
encryptedPkr: opts.doNotEncryptPkr
14591455
? null
14601456
: Utils.encryptMessage(
1461-
JSON.stringify(this.credentials.publicKeyRing),
1462-
this.credentials.personalEncryptingKey
1463-
),
1457+
JSON.stringify(this.credentials.publicKeyRing),
1458+
this.credentials.personalEncryptingKey
1459+
),
14641460
unencryptedPkr: opts.doNotEncryptPkr
14651461
? JSON.stringify(this.credentials.publicKeyRing)
14661462
: null,
@@ -2118,11 +2114,11 @@ export class API extends EventEmitter {
21182114
var ret;
21192115
try {
21202116
ret = JSON.parse(decrypted);
2121-
} catch (e) {}
2117+
} catch (e) { }
21222118
return ret;
21232119
}
21242120

2125-
getWalletIdsFromOldCopay(username, password, blob) {
2121+
getWalletIdsFromOldCopay(username, password, blob): any[] {
21262122
var p = this._oldCopayDecrypt(username, password, blob);
21272123
if (!p) return null;
21282124
var ids = p.walletIds.concat(_.keys(p.focusedTimestamps));
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { Constants } from './constants';
2-
import { Defaults } from './defaults';
3-
import { Utils } from './utils';
4-
export const Common = { Constants, Defaults, Utils };
1+
export { Constants } from './constants';
2+
export { Defaults } from './defaults';
3+
export { Utils } from './utils';

packages/bitcore-wallet-client/src/lib/credentials.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
'use strict';
22

3-
import { Common } from './common';
3+
import { Constants, Utils } from './common';
44
const $ = require('preconditions').singleton();
55
const _ = require('lodash');
66

77
const Bitcore = require('bitcore-lib');
88
const Mnemonic = require('bitcore-mnemonic');
99
const sjcl = require('sjcl');
1010

11-
const Constants = Common.Constants;
12-
const Utils = Common.Utils;
1311
export class Credentials {
1412
static FIELDS = [
1513
'coin',
@@ -183,7 +181,7 @@ export class Credentials {
183181
throw new Error('Bad credentials version');
184182
}
185183

186-
_.each(Credentials.FIELDS, function(k) {
184+
_.each(Credentials.FIELDS, function (k) {
187185
x[k] = obj[k];
188186
});
189187

@@ -206,7 +204,7 @@ export class Credentials {
206204
var self = this;
207205

208206
var x = {};
209-
_.each(Credentials.FIELDS, function(k) {
207+
_.each(Credentials.FIELDS, function (k) {
210208
x[k] = self[k];
211209
});
212210
return x;

packages/bitcore-wallet-client/src/lib/key.ts

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
var $ = require('preconditions').singleton();
44
import * as _ from 'lodash';
5-
import { Common } from './common';
5+
import { Constants, Utils } from './common';
66
import { Credentials } from './credentials';
77

88
var Bitcore = require('bitcore-lib');
@@ -13,8 +13,6 @@ const async = require('async');
1313
const Uuid = require('uuid');
1414

1515
var Errors = require('./errors');
16-
var Constants = Common.Constants;
17-
var Utils = Common.Utils;
1816

1917
const wordsForLang: any = {
2018
en: Mnemonic.Words.ENGLISH,
@@ -63,7 +61,7 @@ export class Key {
6361
return a.id == b.id;
6462
}
6563

66-
static create = function(opts) {
64+
static create = function (opts) {
6765
opts = opts || {};
6866
if (opts.language && !wordsForLang[opts.language])
6967
throw new Error('Unsupported language');
@@ -90,7 +88,7 @@ export class Key {
9088
return x;
9189
};
9290

93-
static fromMnemonic = function(words, opts) {
91+
static fromMnemonic = function (words, opts) {
9492
$.checkArgument(words);
9593
if (opts) $.shouldBeObject(opts);
9694
opts = opts || {};
@@ -111,7 +109,7 @@ export class Key {
111109
return x;
112110
};
113111

114-
static fromExtendedPrivateKey = function(xPriv, opts) {
112+
static fromExtendedPrivateKey = function (xPriv, opts) {
115113
$.checkArgument(xPriv);
116114
opts = opts || {};
117115

@@ -136,37 +134,37 @@ export class Key {
136134
return x;
137135
};
138136

139-
static fromObj = function(obj) {
137+
static fromObj = function (obj) {
140138
$.shouldBeObject(obj);
141139

142140
var x: any = new Key();
143141
if (obj.version != x.version) {
144142
throw new Error('Bad Key version');
145143
}
146144

147-
_.each(Key.FIELDS, function(k) {
145+
_.each(Key.FIELDS, function (k) {
148146
x[k] = obj[k];
149147
});
150148

151149
$.checkState(x.xPrivKey || x.xPrivKeyEncrypted, 'invalid input');
152150
return x;
153151
};
154152

155-
toObj = function() {
153+
toObj = function () {
156154
var self = this;
157155

158156
var x = {};
159-
_.each(Key.FIELDS, function(k) {
157+
_.each(Key.FIELDS, function (k) {
160158
x[k] = self[k];
161159
});
162160
return x;
163161
};
164162

165-
isPrivKeyEncrypted = function() {
163+
isPrivKeyEncrypted = function () {
166164
return !!this.xPrivKeyEncrypted && !this.xPrivKey;
167165
};
168166

169-
checkPassword = function(password) {
167+
checkPassword = function (password) {
170168
if (this.isPrivKeyEncrypted()) {
171169
try {
172170
sjcl.decrypt(password, this.xPrivKeyEncrypted);
@@ -178,7 +176,7 @@ export class Key {
178176
return null;
179177
};
180178

181-
get = function(password) {
179+
get = function (password) {
182180
var keys: any = {};
183181
let fingerPrintUpdated = false;
184182

@@ -213,7 +211,7 @@ export class Key {
213211
return keys;
214212
};
215213

216-
encrypt = function(password, opts) {
214+
encrypt = function (password, opts) {
217215
if (this.xPrivKeyEncrypted)
218216
throw new Error('Private key already encrypted');
219217

@@ -229,7 +227,7 @@ export class Key {
229227
delete this.mnemonic;
230228
};
231229

232-
decrypt = function(password) {
230+
decrypt = function (password) {
233231
if (!this.xPrivKeyEncrypted)
234232
throw new Error('Private key is not encrypted');
235233

@@ -246,7 +244,7 @@ export class Key {
246244
}
247245
};
248246

249-
derive = function(password, path) {
247+
derive = function (password, path) {
250248
$.checkArgument(path, 'no path at derive()');
251249
var xPrivKey = new Bitcore.HDPrivateKey(
252250
this.get(password).xPrivKey,
@@ -306,7 +304,7 @@ export class Key {
306304
* opts.n
307305
*/
308306

309-
createCredentials = function(password, opts) {
307+
createCredentials = function (password, opts) {
310308
opts = opts || {};
311309

312310
if (password) $.shouldBeString(password, 'provide password');
@@ -357,7 +355,7 @@ export class Key {
357355
* opts.requestPrivKey
358356
*/
359357

360-
createAccess = function(password, opts) {
358+
createAccess = function (password, opts) {
361359
opts = opts || {};
362360
$.shouldBeString(opts.path);
363361

@@ -374,7 +372,7 @@ export class Key {
374372
};
375373
};
376374

377-
sign = function(rootPath, txp, password, cb) {
375+
sign = function (rootPath, txp, password, cb) {
378376
$.shouldBeString(rootPath);
379377
if (this.isPrivKeyEncrypted() && !password) {
380378
return cb(new Errors.ENCRYPTED_PRIVATE_KEY());
@@ -385,7 +383,7 @@ export class Key {
385383
var derived = this.derive(password, rootPath);
386384
var xpriv = new Bitcore.HDPrivateKey(derived);
387385

388-
_.each(txp.inputs, function(i) {
386+
_.each(txp.inputs, function (i) {
389387
$.checkState(
390388
i.path,
391389
'Input derivation path not available (signing transaction)'
@@ -397,11 +395,11 @@ export class Key {
397395
});
398396

399397
var t = Utils.buildTx(txp);
400-
var signatures = _.map(privs, function(priv, i) {
398+
var signatures = _.map(privs, function (priv, i) {
401399
return t.getSignatures(priv);
402400
});
403401

404-
signatures = _.map(_.sortBy(_.flatten(signatures), 'inputIndex'), function(
402+
signatures = _.map(_.sortBy(_.flatten(signatures), 'inputIndex'), function (
405403
s
406404
) {
407405
return s.signature.toDER().toString('hex');

packages/bitcore-wallet-client/src/lib/request.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as _ from 'lodash';
2-
import { Common } from './common';
2+
import { Utils } from './common';
33

44
const request = require('superagent');
55
const async = require('async');
@@ -8,7 +8,6 @@ var log = require('./log');
88

99
const util = require('util');
1010
var Errors = require('./errors');
11-
const Utils = Common.Utils;
1211

1312
export class Request {
1413
baseUrl: any;
@@ -155,10 +154,10 @@ export class Request {
155154
} else {
156155
ret = new Error(
157156
body.code +
158-
': ' +
159-
(_.isObject(body.message)
160-
? JSON.stringify(body.message)
161-
: body.message)
157+
': ' +
158+
(_.isObject(body.message)
159+
? JSON.stringify(body.message)
160+
: body.message)
162161
);
163162
}
164163
} else {

packages/bitcore-wallet-client/src/lib/verifier.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import * as _ from 'lodash';
2-
import { Common } from "./common";
2+
import { Utils } from './common';
33
var $ = require('preconditions').singleton();
44

55
var Bitcore = require('bitcore-lib');
66
var BCHAddress = require('bitcore-lib-cash').Address;
7-
const Utils = Common.Utils;
87

98
var log = require('./log');
109

packages/bitcore-wallet-client/test/api.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ var Bitcore_ = {
2323

2424
var BWS = require('bitcore-wallet-service');
2525

26-
var { Common } = require('../ts_build/common');
27-
var Constants = Common.Constants;
26+
var { Constants } = require('../ts_build/common');
2827
var Client = require('../ts_build').default;
2928
var Key = Client.Key;
3029
var { Request } = require('../ts_build/request.js');
31-
var Utils = Common.Utils;
30+
var { Utils } = require('../ts_build/common');
31+
3232
var ExpressApp = BWS.ExpressApp;
3333
var Storage = BWS.Storage;
3434
var TestData = require('./testdata');

packages/bitcore-wallet-client/test/utils.test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ var _ = require('lodash');
44
var chai = require('chai');
55
var should = chai.should();
66
var Bitcore = require('bitcore-lib');
7-
var { Common } = require('../ts_build/common');
8-
var Utils = Common.Utils;
9-
7+
var { Utils } = require('../ts_build/common');
108

119
describe('Utils', () => {
1210

0 commit comments

Comments
 (0)