Skip to content

Commit

Permalink
Build 1.1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
emiliorizzo committed Jan 29, 2021
1 parent 2030d02 commit b1eb117
Show file tree
Hide file tree
Showing 19 changed files with 357 additions and 280 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# Changelog
## [1.1.8] - 2021-01-28
#### Changed

- Dependencies: nod3 to @rsksmart/nod3
- Dependencies: rsk-contract-parser to @rsksmart/rsk-contract-parser
- Replace: lib/cli with @rsksmart/rsk-js-cli

## [1.1.7] - 2021-01-07

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion dist/dbPatches/tokenAccountBalances.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";
var _dataSource = _interopRequireDefault(require("../lib/dataSource.js"));
var _nod3Connect = _interopRequireDefault(require("../lib/nod3Connect"));
var _rskContractParser = _interopRequireDefault(require("rsk-contract-parser"));
var _rskContractParser = _interopRequireDefault(require("@rsksmart/rsk-contract-parser"));
var _rskUtils = require("@rsksmart/rsk-utils");function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}

const parser = new _rskContractParser.default({ nod3: _nod3Connect.default });
Expand Down
38 changes: 0 additions & 38 deletions dist/lib/cli.js

This file was deleted.

2 changes: 1 addition & 1 deletion dist/lib/nod3Connect.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default = exports.nod3Router = exports.nod3 = exports.nod3Log = exports.nod3Instance = exports.createNod3Router = exports.nod3BySource = exports.nod3Connect = void 0;var _nod = require("nod3");
"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default = exports.nod3Router = exports.nod3 = exports.nod3Log = exports.nod3Instance = exports.createNod3Router = exports.nod3BySource = exports.nod3Connect = void 0;var _nod = require("@rsksmart/nod3");
var _config = _interopRequireDefault(require("./config"));
var _utils = require("../lib/utils");function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}

Expand Down
2 changes: 1 addition & 1 deletion dist/services/classes/Address.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
var _utils = require("../../lib/utils");
var _types = require("../../lib/types");
var _Contract = _interopRequireDefault(require("./Contract"));
var _rskContractParser = require("rsk-contract-parser");
var _rskContractParser = require("@rsksmart/rsk-contract-parser");
var _Tx = require("./Tx");
var _InternalTx = require("./InternalTx");
var _rskUtils = require("@rsksmart/rsk-utils");function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}
Expand Down
2 changes: 1 addition & 1 deletion dist/services/classes/BcStats.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.BcStats = void 0;var _BlocksBase = require("../../lib/BlocksBase");
var _getCirculatingSupply = _interopRequireDefault(require("../../api/lib/getCirculatingSupply"));
var _getActiveAccounts = _interopRequireDefault(require("../../api/lib/getActiveAccounts"));
var _rskContractParser = require("rsk-contract-parser");
var _rskContractParser = require("@rsksmart/rsk-contract-parser");
var _utils = require("../../lib/utils");function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}

class BcStats extends _BlocksBase.BlocksBase {
Expand Down
2 changes: 1 addition & 1 deletion dist/services/classes/Contract.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default = void 0;var _BcThing = require("./BcThing");
var _rskContractParser = _interopRequireDefault(require("rsk-contract-parser"));
var _rskContractParser = _interopRequireDefault(require("@rsksmart/rsk-contract-parser"));
var _types = require("../../lib/types");
var _TokenAddress = _interopRequireDefault(require("./TokenAddress"));
var _utils = require("../../lib/utils");function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}
Expand Down
2 changes: 1 addition & 1 deletion dist/services/classes/UpdateTokenAccountBalances.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.updateTokenAccountBalances = updateTokenAccountBalances;
var _rskUtils = require("@rsksmart/rsk-utils");
var _rskContractParser = _interopRequireDefault(require("rsk-contract-parser"));function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}
var _rskContractParser = _interopRequireDefault(require("@rsksmart/rsk-contract-parser"));function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}

async function updateTokenAccountBalances(block, { nod3, collections, log }) {
const parser = new _rskContractParser.default({ nod3 });
Expand Down
2 changes: 1 addition & 1 deletion dist/tools/cacheBlocksTraces.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
var _dataSource = require("../lib/dataSource");
var _config = _interopRequireDefault(require("../lib/config"));
var _nod3Connect = require(".././lib/nod3Connect");
var _nod = require("nod3");
var _nod = require("@rsksmart/nod3");
var _BlockTrace = _interopRequireDefault(require("../services/classes/BlockTrace"));
var _Logger = require("../lib/Logger");function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}

Expand Down
16 changes: 8 additions & 8 deletions dist/tools/deleteBlocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
var _Block = require("../services/classes/Block");
var _BlockSummary = require("../services/classes/BlockSummary");
var _BlocksBase = require("../lib/BlocksBase");
var _cli = require("../lib/cli");function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}
var _rskJsCli = require("@rsksmart/rsk-js-cli");function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}

(0, _dataSource.default)({ skipCheck: true }).then(async ({ db }) => {
const options = new _BlocksBase.BlocksBase(db);
const { collections } = options;
const p = path => path.split('/').pop();
const help = () => {
const myName = p(process.argv[1]);
(0, _cli.info)(`Use: ${p(process.argv[0])} ${myName} [blockNumber] | [fromBlock-toBlock]`);
(0, _cli.info)(`e.g. ${_cli.orange} ${myName} 400`);
(0, _cli.info)(`e.g. ${_cli.orange} ${myName} 400-456`);
_rskJsCli.log.info(`Use: ${p(process.argv[0])} ${myName} [blockNumber] | [fromBlock-toBlock]`);
_rskJsCli.log.info(`e.g. ${_rskJsCli.orange} ${myName} 400`);
_rskJsCli.log.info(`e.g. ${_rskJsCli.orange} ${myName} 400-456`);
process.exit(0);
};

Expand All @@ -31,17 +31,17 @@ var _cli = require("../lib/cli");function _interopRequireDefault(obj) {return ob
let Q = [];
while (t >= f) {
let b = await (0, _Block.getBlockFromDb)(t, collections.Blocks);
let color = (0, _cli.ansiCode)(Number(t.toString().split('').pop()) + 30);
let color = (0, _rskJsCli.ansiCode)(Number(t.toString().split('').pop()) + 30);
if (b) {
let { hash, number } = b;
console.log(`${_cli.reset} ${color} ● ● ● Removing block ${number} ${hash}`);
console.log(`${_rskJsCli.reset} ${color} ● ● ● Removing block ${number} ${hash}`);
Q.push((0, _Block.deleteBlockDataFromDb)(b.hash, number, collections));
}
if (deleteSummary) {
if (b) {
Q.push((0, _BlockSummary.deleteBlockSummaryFromDb)(b.hash, options.collections));
} else {
console.log(`${_cli.reset} ${color} ● ● ● Removing ALL summaries for blockNumber: ${t}`);
console.log(`${_rskJsCli.reset} ${color} ● ● ● Removing ALL summaries for blockNumber: ${t}`);
let summaries = await (0, _BlockSummary.getBlockSummariesByNumber)(t, collections);
if (summaries.length) {
for (let summary of summaries) {
Expand All @@ -54,6 +54,6 @@ var _cli = require("../lib/cli");function _interopRequireDefault(obj) {return ob
}
Promise.all(Q).then(() => process.exit());
} catch (err) {
(0, _cli.error)(err);
(0, _rskJsCli.error)(err);
}
});
10 changes: 5 additions & 5 deletions dist/tools/getBlock.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";var _dataSource = _interopRequireDefault(require("../lib/dataSource.js"));
var _Block = _interopRequireDefault(require("../services/classes/Block"));
var _BlocksBase = _interopRequireDefault(require("../lib/BlocksBase"));
var _cli = require("../lib/cli");
var _rskJsCli = require("@rsksmart/rsk-js-cli");
var _util = _interopRequireDefault(require("util"));function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}

const hashOrNumber = process.argv[2];
Expand All @@ -10,14 +10,14 @@ const save = opt === '--save';
const json = opt === '--json';
if (!hashOrNumber) help();
(0, _dataSource.default)().then(({ db, initConfig }) => {
if (!json) (0, _cli.info)(`Getting block ${hashOrNumber}`);
if (!json) _rskJsCli.log.info(`Getting block ${hashOrNumber}`);
getBlock(hashOrNumber, { db, initConfig }).then(block => {
if (json) console.log(JSON.stringify(block));else
{
console.log(_util.default.inspect(block, { showHidden: false, depth: null, colors: true }));
console.log('');
(0, _cli.info)(` Get time: ${block.time}ms`);
if (save) (0, _cli.info)(` Save time: ${block.saved}ms`);
_rskJsCli.log.info(` Get time: ${block.time}ms`);
if (save) _rskJsCli.log.info(` Save time: ${block.saved}ms`);
}
process.exit(0);
});
Expand Down Expand Up @@ -47,7 +47,7 @@ async function getBlock(hashOrNumber, { db, initConfig }) {

function help() {
const myName = process.argv[1].split('/').pop();
(0, _cli.info)(`Usage: ${process.argv[0]} ${myName} number|hash|latest [--json | --save ]`);
_rskJsCli.log.info(`Usage: ${process.argv[0]} ${myName} number|hash|latest [--json | --save ]`);
process.exit(0);
}

Expand Down
34 changes: 17 additions & 17 deletions dist/tools/statusClient.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
"use strict";var _socket = _interopRequireDefault(require("socket.io-client"));
var _config = _interopRequireDefault(require("../lib/config"));
var _cli = require("../lib/cli");function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}
var _rskJsCli = require("@rsksmart/rsk-js-cli");function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}

const url = process.env.URL || `ws://localhost:${_config.default.api.port}`;
const socket = _socket.default.connect(url, { reconnect: true });
let blocksPerSecond;
let stats = { time: 0, blocks: 0 };
let mark = '●';

(0, _cli.info)(`Waiting for: ${url}`);
_rskJsCli.log.info(`Waiting for: ${url}`);

socket.emit('subscribe', { to: 'status' });

socket.on('connect', socket => {
(0, _cli.ok)('Connected! ✌');
_rskJsCli.log.ok('Connected! ✌');
});

socket.on('disconnect', socket => {
(0, _cli.warn)('Disconnected ☹');
_rskJsCli.log.warn('Disconnected ☹');
});

socket.on('data', data => {
Expand All @@ -35,33 +35,33 @@ socket.on('data', data => {
let { dbMissingBlocks, nodeDown, requestingBlocks, dbHighBlock, dbBlocks } = status;
console.clear();
console.log();
(0, _cli.info)(url);
_rskJsCli.log.info(url);
console.log();
console.log(` Api ${socket.connected ? _cli.green : _cli.red} ${mark} ${_cli.reset}`);
console.log(` Node ${!nodeDown ? _cli.green : _cli.red} ${mark} ${_cli.reset}`);
console.log(` Db ${dbMissingBlocks > 0 ? _cli.red : requestingBlocks > 5 ? _cli.orange : _cli.green} ${mark} ${_cli.reset}`);
console.log(` Api ${socket.connected ? _rskJsCli.green : _rskJsCli.red} ${mark} ${_rskJsCli.reset}`);
console.log(` Node ${!nodeDown ? _rskJsCli.green : _rskJsCli.red} ${mark} ${_rskJsCli.reset}`);
console.log(` Db ${dbMissingBlocks > 0 ? _rskJsCli.red : requestingBlocks > 5 ? _rskJsCli.orange : _rskJsCli.green} ${mark} ${_rskJsCli.reset}`);
console.log();
console.dir(status, { colors: true });
if (blocksPerSecond) {
let color = blocksPerSecond < 10 ? _cli.red : blocksPerSecond < 20 ? _cli.orange : _cli.green;
let color = blocksPerSecond < 10 ? _rskJsCli.red : blocksPerSecond < 20 ? _rskJsCli.orange : _rskJsCli.green;
let endTime = Math.floor(dbMissingBlocks / blocksPerSecond);
let end = new Date(Date.now() + endTime * 1000);
console.log();
console.log(`${color}${blocksPerSecond} B/s${_cli.reset}`);
console.log(`${color}${parseInt(blocksPerSecond * 3600)} B/h${_cli.reset}`);
console.log(`${_cli.blue} ≈ Remaining Time:${_cli.reset} ${Math.round(endTime / 3600)} H${_cli.reset}`);
console.log(`${_cli.blue} ≈ End:${_cli.reset} ${end.toUTCString()}${_cli.reset}`);
console.log(`${color}${blocksPerSecond} B/s${_rskJsCli.reset}`);
console.log(`${color}${parseInt(blocksPerSecond * 3600)} B/h${_rskJsCli.reset}`);
console.log(`${_rskJsCli.blue} ≈ Remaining Time:${_rskJsCli.reset} ${Math.round(endTime / 3600)} H${_rskJsCli.reset}`);
console.log(`${_rskJsCli.blue} ≈ End:${_rskJsCli.reset} ${end.toUTCString()}${_rskJsCli.reset}`);
}
if (nodeDown) (0, _cli.error)('The node is down... ☹ ');
if (nodeDown) _rskJsCli.log.error('The node is down... ☹ ');
// show progress bar
if (dbMissingBlocks > 1) {
let bar = (0, _cli.progressBar)(dbHighBlock, dbBlocks, { steps: 30 });
let bar = (0, _rskJsCli.progressBar)(dbHighBlock, dbBlocks, { steps: 30 });
console.log();
console.log(` ${_cli.blue}${bar}${_cli.reset}`);
console.log(` ${_rskJsCli.blue}${bar}${_rskJsCli.reset}`);
}
}
});

socket.on('error', err => {
(0, _cli.error)(err);
_rskJsCli.log.error(err);
});
1 change: 0 additions & 1 deletion dist/tools/txStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
var _blocksCollections = require("../lib/blocksCollections");
var _utils = require("../lib/utils");function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}

// import { info, orange, reset, error, ansiCode } from '../lib/cli'
const fromBlock = parseInt(process.argv[2]);
const toBlock = parseInt(process.argv[3]);
if (!fromBlock || !toBlock) help();
Expand Down
10 changes: 5 additions & 5 deletions dist/tools/updateBalances.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";var _dataSource = _interopRequireDefault(require("../lib/dataSource.js"));
var _Address = require("../services/classes/Address");
var _nod3Connect = require("../lib/nod3Connect");
var _cli = require("../lib/cli");function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}
var _rskJsCli = require("@rsksmart/rsk-js-cli");function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}

const save = process.argv[2] === '--save';
main().then(res => {
Expand Down Expand Up @@ -31,10 +31,10 @@ async function main() {

let { address, balance } = await cursor.next();
checked++;
_cli.log.info(`${address} -- ${checked} / ${addresses}`);
_rskJsCli.log.info(`${address} -- ${checked} / ${addresses}`);
let newBalance = await _nod3Connect.nod3.eth.getBalance(address, 'latest');
if (newBalance === balance) {
_cli.log.ok(`${logTime()} The balance for ${address} is up to date`);
_rskJsCli.log.ok(`${logTime()} The balance for ${address} is up to date`);
} else {
outdated++;
if (save) {
Expand All @@ -43,12 +43,12 @@ async function main() {
if (parseInt(blockNumber) < parseInt(lastBlock.number)) {
throw new Error(`Invalid block number ${blockNumber}`);
}
_cli.log.info(`${logTime()} Updating balance of: ${address} to ${newBalance}`);
_rskJsCli.log.info(`${logTime()} Updating balance of: ${address} to ${newBalance}`);
let result = await (0, _Address.saveAddressToDb)({ address, blockNumber, balance: newBalance }, collection);
if (!result.ok) throw new Error(`Error updating balance for ${address}`);
updated++;
} else {
_cli.log.warn(`${logTime()} The balance of ${address} is outdated, balance:${balance} newBalance:${newBalance}`);
_rskJsCli.log.warn(`${logTime()} The balance of ${address} is outdated, balance:${balance} newBalance:${newBalance}`);
}
}
}
Expand Down
20 changes: 10 additions & 10 deletions dist/tools/wsChannel.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use strict";var _socket = _interopRequireDefault(require("socket.io-client"));
var c = _interopRequireWildcard(require("../lib/cli"));function _getRequireWildcardCache() {if (typeof WeakMap !== "function") return null;var cache = new WeakMap();_getRequireWildcardCache = function () {return cache;};return cache;}function _interopRequireWildcard(obj) {if (obj && obj.__esModule) {return obj;}if (obj === null || typeof obj !== "object" && typeof obj !== "function") {return { default: obj };}var cache = _getRequireWildcardCache();if (cache && cache.has(obj)) {return cache.get(obj);}var newObj = {};var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;for (var key in obj) {if (Object.prototype.hasOwnProperty.call(obj, key)) {var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;if (desc && (desc.get || desc.set)) {Object.defineProperty(newObj, key, desc);} else {newObj[key] = obj[key];}}}newObj.default = obj;if (cache) {cache.set(obj, newObj);}return newObj;}function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}
var _rskJsCli = require("@rsksmart/rsk-js-cli");function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}

const url = process.argv[2];
let channel = process.argv[3];
Expand All @@ -8,37 +8,37 @@ if (!url || !channel) help();

const socket = _socket.default.connect(url, { reconnect: true });

c.info(`Waiting for WS on ${url}`);
_rskJsCli.log.info(`Waiting for WS on ${url}`);

socket.on('connect', data => {
c.ok('Connected! ✌');
c.info(`subscribing to channel: ${channel}`);
_rskJsCli.log.ok('Connected! ✌');
_rskJsCli.log.info(`subscribing to channel: ${channel}`);
socket.emit('subscribe', { to: channel });
});

socket.on('subscription', data => {
if (channel === data.channel) {
c.info(`subscribed to channel: ${channel}`);
_rskJsCli.log.info(`subscribed to channel: ${channel}`);
}
});

socket.on('disconnect', socket => {
c.warn('Disconnected ☹');
_rskJsCli.log.warn('Disconnected ☹');
});

socket.on('data', async res => {
try {
console.log(res);
} catch (err) {
c.error(err);
_rskJsCli.log.error(err);
process.exit(9);
}
});

socket.on('Error', err => {
let error = err.error || '';
c.error(`ERROR: ${error}`);
c.warn(err);
_rskJsCli.log.error(`ERROR: ${error}`);
_rskJsCli.log.warn(err);
});

process.on('unhandledRejection', err => {
Expand All @@ -47,6 +47,6 @@ process.on('unhandledRejection', err => {
});

function help() {
c.info(`Usage: ${process.argv[0]} ${process.argv[1]} [url] [channel]`);
_rskJsCli.log.info(`Usage: ${process.argv[0]} ${process.argv[1]} [url] [channel]`);
process.exit(0);
}
Loading

0 comments on commit b1eb117

Please sign in to comment.