Skip to content

Commit f667986

Browse files
committed
added fix to commands in package.json and fixed linting errors
1 parent 27c7ec6 commit f667986

File tree

91 files changed

+1019
-1087
lines changed

Some content is hidden

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

91 files changed

+1019
-1087
lines changed

packages/bitcore-wallet-service/bws.example.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ module.exports = {
1313
// https: true,
1414
// privateKeyFile: 'private.pem',
1515
// certificateFile: 'cert.pem',
16-
////// The following is only for certs which are not
17-
////// trusted by nodejs 'https' by default
18-
////// CAs like Verisign do not require this
16+
// //// The following is only for certs which are not
17+
// //// trusted by nodejs 'https' by default
18+
// //// CAs like Verisign do not require this
1919
// CAinter1: '', // ex. 'COMODORSADomainValidationSecureServerCA.crt'
2020
// CAinter2: '', // ex. 'COMODORSAAddTrustCA.crt'
2121
// CAroot: '', // ex. 'AddTrustExternalCARoot.crt'
@@ -56,7 +56,7 @@ module.exports = {
5656
url: 'https://api.bitcore.io',
5757
regtestEnabled: false
5858
},
59-
testnet3:{
59+
testnet3: {
6060
url: 'https://api.bitcore.io'
6161
},
6262
testnet4: {

packages/bitcore-wallet-service/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@
3434
"clean": "rm -rf ./ts_build",
3535
"compile": "npm run clean && npm run build",
3636
"pub": "npm run build && npm publish",
37-
"precommit": "echo 'TODO: npm run fix && npm run lint'",
37+
"precommit": "npm run lint; npm run fix:errors",
3838
"lint": "eslint .",
39-
"fix": "eslint --fix --quiet .",
39+
"fix:errors": "eslint --fix --quiet .",
40+
"fix:all": "eslint --fix .",
4041
"update:stats": "npm run clean && npm run build && chmod +x ./ts_build/updatestats/updatestats.js && ./ts_build/updatestats/updatestats.js",
4142
"clean:fiatrates": "npm run clean && npm run build && chmod +x ./ts_build/cleanfiatrates/cleanfiatrates.js && ./ts_build/cleanfiatrates/cleanfiatrates.js",
4243
"cp:templates": "cp -r ./templates ./ts_build/templates"

packages/bitcore-wallet-service/scripts/checkCopayerIds.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#!/usr/bin/env node
22

3-
const config = require('../../ts_build/src/config').default;
4-
const { Storage } = require('../../ts_build/src').default;
5-
const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout });
6-
const fs = require('fs');
7-
const os = require('os');
8-
const CWC = require('crypto-wallet-core');
3+
import fs from 'fs';
4+
import os from 'os';
5+
import readline from 'readline';
6+
import CWC from 'crypto-wallet-core';
7+
import pkg from '../../ts_build/src';
8+
import config from '../../ts_build/src/config';
99

10-
const startDate = new Date('2011-01-01T00:00:00.000Z');
11-
const endDate = new Date();
10+
const { Storage } = pkg;
11+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
1212

1313
function usage(errMsg) {
1414
console.log('USAGE: ./checkCopayerIds.js [options]');
@@ -55,7 +55,7 @@ storage.connect(config.storageOpts, async (err) => {
5555
}
5656

5757
function done(err) {
58-
if (err) { console.log(err) }
58+
if (err) { console.log(err); }
5959
rl.close();
6060
storage.disconnect(() => { console.log('done'); });
6161
}
@@ -99,7 +99,7 @@ storage.connect(config.storageOpts, async (err) => {
9999
const str = chain === 'btc' ? xpub : (chain + xpub);
100100

101101
const hash = CWC.BitcoreLib.crypto.Hash.sha256(Buffer.from(str));
102-
const computed = hash.toString('hex');
102+
const computed = hash.toString('hex');
103103
if (copayerId !== computed) {
104104
mismatches++;
105105
fs.appendFileSync(outFile, `${wallet.id}:${copayerId} -> expected: ${computed}\n`);

packages/bitcore-wallet-service/scripts/fixAddressType.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
2-
const config = require('../../ts_build/src/config').default;
3-
const { Storage } = require('../../ts_build/src').default;
4-
const { ObjectId } = require('mongodb');
2+
import { ObjectId } from 'mongodb';
3+
import { Storage } from '../../ts_build/src';
4+
import config from '../../ts_build/src/config';
55

66
if (!process.argv[2]) {
77
console.log('Usage: fixAddressType.js <chain> [--doit]');
@@ -38,7 +38,7 @@ storage.connect(config.storageOpts, async (err) => {
3838
}
3939

4040
function done(err) {
41-
if (err) { console.log(err) }
41+
if (err) { console.log(err); }
4242
storage.disconnect(() => { console.log('done'); });
4343
}
4444

packages/bitcore-wallet-service/scripts/migrateToNamedTestnets.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env node
2-
const config = require('../../ts_build/src/config').default;
3-
const { Storage } = require('../../ts_build/src').default;
2+
import pkg from '../../ts_build/src';
3+
import config from '../../ts_build/src/config';
4+
5+
const { Storage } = pkg;
46

57
const startDate = new Date('2011-01-01T00:00:00.000Z');
68
const endDate = new Date();
@@ -52,7 +54,7 @@ storage.connect(config.storageOpts, async (err) => {
5254
}
5355

5456
function done(err) {
55-
if (err) { console.log(err) }
57+
if (err) { console.log(err); }
5658
storage.disconnect(() => { console.log('done'); });
5759
}
5860

@@ -100,7 +102,7 @@ storage.connect(config.storageOpts, async (err) => {
100102
if (resWallet?.result?.nModified > 0) {
101103
fixWalletsCount++;
102104
} else if (!resWallet?.result?.ok) {
103-
console.log(JSON.stringify(res));
105+
console.log(JSON.stringify(resWallet));
104106
}
105107

106108
// Update Addresses collection
@@ -115,7 +117,7 @@ storage.connect(config.storageOpts, async (err) => {
115117
if (resAddress?.result?.nModified > 0) {
116118
fixAddressCount++;
117119
} else if (!resAddress?.result?.ok) {
118-
console.log(JSON.stringify(res));
120+
console.log(JSON.stringify(resAddress));
119121
}
120122

121123
// Update Wallets collection
@@ -146,7 +148,7 @@ storage.connect(config.storageOpts, async (err) => {
146148
if (resTxs?.result?.nModified > 0) {
147149
fixTxsCount++;
148150
} else if (!resTxs?.result?.ok) {
149-
console.log(JSON.stringify(res));
151+
console.log(JSON.stringify(resTxs));
150152
}
151153
} else {
152154
// Update Wallets collection

packages/bitcore-wallet-service/scripts/migrateWalletsNetwork.js

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#!/usr/bin/env node
22

3-
const config = require('../../ts_build/src/config').default;
4-
const { Storage } = require('../../ts_build/src').default;
5-
const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout });
6-
const fs = require('fs');
7-
const os = require('os');
3+
import fs from 'fs';
4+
import os from 'os';
5+
import readline from 'readline';
6+
import config from '../ts_build/src/config';
7+
import { Storage } from '../ts_build/src/lib/storage';
8+
9+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
810

911
const startDate = new Date('2011-01-01T00:00:00.000Z');
1012
const endDate = new Date();
@@ -76,7 +78,7 @@ storage.connect(config.storageOpts, async (err) => {
7678
}
7779

7880
function done(err) {
79-
if (err) { console.log(err) }
81+
if (err) { console.log(err); }
8082
rl.close();
8183
storage.disconnect(() => { console.log('done'); });
8284
}
@@ -89,7 +91,6 @@ storage.connect(config.storageOpts, async (err) => {
8991
let fixAddressCount = 0;
9092
let fixWalletsCount = 0;
9193
let fixTxsCount = 0;
92-
let fixCacheCount = 0;
9394
let count = 0;
9495

9596
console.log(` ${doit ? 'REAL:' : 'DRY RUN:'} Found ${Intl.NumberFormat().format(walletCnt)} total wallets to scan`);
@@ -159,9 +160,7 @@ storage.connect(config.storageOpts, async (err) => {
159160
const resCache = await storage.db.collection(Storage.collections.CACHE).deleteMany({
160161
walletId: wallet.id
161162
});
162-
if (resCache?.result?.n > 0) {
163-
fixCacheCount++;
164-
} else if (!resCache?.result?.ok) {
163+
if (resCache?.result?.n <= 0 && !resCache?.result?.ok) {
165164
console.log(JSON.stringify(resTxs));
166165
}
167166
} else {
@@ -190,13 +189,6 @@ storage.connect(config.storageOpts, async (err) => {
190189
});
191190

192191
fixTxsCount += txsCount;
193-
194-
// Delete Cache collection
195-
const cacheCount = await storage.db.collection(Storage.collections.CACHE).countDocuments({
196-
walletId: wallet.id
197-
});
198-
199-
fixCacheCount += cacheCount;
200192
}
201193
}
202194
process.stdout.write('\n');

packages/bitcore-wallet-service/scripts/preview-email.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#!/usr/bin/env node
22

3-
require('ts-node/register');
4-
const config = require('../src/config');
5-
const fs = require('fs');
6-
const path = require('path');
7-
const Mustache = require('mustache');
8-
const os = require('os');
9-
const { exec } = require('child_process');
10-
const sgMail = require('@sendgrid/mail');
11-
const juice = require('juice');
3+
import 'ts-node/register';
4+
import { exec } from 'child_process';
5+
import fs from 'fs';
6+
import os from 'os';
7+
import path from 'path';
8+
import sgMail from '@sendgrid/mail';
9+
import juice from 'juice';
10+
import Mustache from 'mustache';
11+
import config from '../src/config';
1212

1313

1414
const iconMap = {
@@ -34,7 +34,7 @@ function getIconHtml (templateName) {
3434
const staticUrl = config.baseUrl || 'https://bws.bitpay.com';
3535
const iconUrl = `${staticUrl}/bws/static/images/${iconFile}`;
3636

37-
return `<img src="${iconUrl}" alt="${templateName} icon" style="width: 50px; height: 50px;" />`
37+
return `<img src="${iconUrl}" alt="${templateName} icon" style="width: 50px; height: 50px;" />`;
3838
};
3939

4040
// Parse command line arguments
@@ -75,7 +75,9 @@ if (!templateName || !TEMPLATE_TYPES.includes(templateName)) {
7575
console.log(' - send: Set to "send" to send an actual email');
7676
console.log(' - recipientEmail: Email address to send to (required if send=true)');
7777
console.log('\nAvailable templates:');
78-
TEMPLATE_TYPES.forEach(type => console.log(`- ${type}`));
78+
for (const type of TEMPLATE_TYPES) {
79+
console.log(`- ${type}`);
80+
}
7981
process.exit(1);
8082
}
8183

@@ -110,8 +112,7 @@ const createSampleData = (templateName) => {
110112
if (firstLine && firstLine.startsWith('{{subjectPrefix}}')) {
111113
commonData.title = firstLine.replace('{{subjectPrefix}}', '');
112114
}
113-
} catch (err) {
114-
}
115+
} catch { /* ignore error */ }
115116

116117
switch (templateName) {
117118
case 'new_copayer':
@@ -227,7 +228,7 @@ function createBasicHtmlFromPlain(templateName) {
227228
.slice(2) // Skip the subject line and empty line
228229
.join('\n')
229230
.trim();
230-
} catch (err) {
231+
} catch {
231232
plainContent = `This is a sample email template for ${templateName}`;
232233
}
233234

packages/bitcore-wallet-service/scripts/purgeNotifications.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/usr/bin/env node
22

3-
const config = require('../../ts_build/src/config').default;
4-
const { Storage } = require('../../ts_build/src').default;
5-
const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout });
3+
import readline from 'readline';
4+
import { Storage } from '../../ts_build/src';
5+
import config from '../../ts_build/src/config';
6+
7+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
68

79

810
let stop = false;
@@ -58,7 +60,7 @@ storage.connect(config.storageOpts, async (err) => {
5860
}
5961

6062
function done(err) {
61-
if (err) { console.log(err) }
63+
if (err) { console.log(err); }
6264
rl.close();
6365
storage.disconnect(() => { console.log('done'); });
6466
}
@@ -96,7 +98,7 @@ storage.connect(config.storageOpts, async (err) => {
9698
process.stdout.write('\n');
9799

98100
console.log(`\u2713 Purged ${Intl.NumberFormat().format(count)} notifications`);
99-
stop && console.log('Stopped prematurely by user');
101+
if (stop) console.log('Stopped prematurely by user');
100102

101103
return done();
102104
} catch (err) {

packages/bitcore-wallet-service/scripts/v8tool-list.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22

3-
import _ from 'lodash';
43
import { BitcoreLib } from 'crypto-wallet-core';
4+
import _ from 'lodash';
55
import requestStream from 'request';
66
import { Client } from '../src/lib//blockchainexplorers/v8/client';
77

@@ -24,7 +24,7 @@ if (!authKey) throw new Error('provide authKey');
2424
//
2525
const authKeyObj = BitcoreLib.PrivateKey(authKey);
2626

27-
let tmp = authKeyObj.toObject();
27+
const tmp = authKeyObj.toObject();
2828
tmp.compressed = false;
2929
const pubKey = BitcoreLib.PrivateKey(tmp).toPublicKey();
3030

@@ -41,9 +41,9 @@ const BASE = {
4141
LTC: `https://api.bitcore.io/api/${coin}/${network}`
4242
};
4343

44-
let baseUrl = BASE[coin];
44+
const baseUrl = BASE[coin];
4545

46-
let client = new Client({
46+
const client = new Client({
4747
baseUrl,
4848
authKey: authKeyObj
4949
});
@@ -59,10 +59,9 @@ if (extra) {
5959

6060
console.log('[v8tool.37:url:]', url);
6161
const signature = client.sign({ method: 'GET', url });
62-
const payload = {};
63-
var acum = '';
62+
let acum = '';
6463

65-
let r = requestStream.get(url, {
64+
const r = requestStream.get(url, {
6665
headers: { 'x-signature': signature },
6766
json: true
6867
});
@@ -73,8 +72,7 @@ r.on('data', raw => {
7372

7473
r.on('end', () => {
7574
let txs = [],
76-
unconf = [],
77-
err;
75+
unconf = [];
7876
_.each(acum.split(/\r?\n/), rawTx => {
7977
if (!rawTx) return;
8078

packages/bitcore-wallet-service/scripts/v8tool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22

3-
import request from 'request';
43
import { BitcoreLib } from 'crypto-wallet-core';
4+
import request from 'request';
55
import { Client } from '../src/lib//blockchainexplorers/v8/client';
66

77
const coin = process.argv[2];

0 commit comments

Comments
 (0)