From 0c97bf2fd5163d14d461bb6323700a7966dcb9fd Mon Sep 17 00:00:00 2001 From: emi Date: Thu, 27 Feb 2020 21:49:06 +0100 Subject: [PATCH] Build 1.0.3 --- dist/api/Api.js | 106 +- dist/api/HttpServer.js | 8 +- dist/api/Status.js | 12 +- dist/api/channels.js | 1 + dist/api/docs.yaml | 8 + dist/api/index.js | 18 +- dist/api/lib/Channel.js | 4 +- dist/api/lib/DataCollector/DataCollector.js | 2 +- .../lib/DataCollector/DataCollectorItem.js | 25 +- dist/api/lib/DataCollector/pagination.js | 14 +- dist/api/lib/apiTools.js | 33 +- dist/api/lib/blocksMetadata.js | 21 + dist/api/lib/getActiveAccounts.js | 12 + dist/api/modules/Block.js | 48 +- dist/api/modules/ContractVerification.js | 109 +- dist/api/modules/Event.js | 20 +- dist/api/modules/Tx.js | 6 +- dist/api/modules/index.js | 4 +- dist/lib/BlocksBase.js | 9 +- dist/lib/ContractParser/Abi.js | 2 - dist/lib/ContractParser/ContractParser.js | 222 -- dist/lib/ContractParser/Readme.md | 6 - dist/lib/ContractParser/RemascEvents.js | 56 - dist/lib/ContractParser/compileJsonAbis.js | 80 - dist/lib/ContractParser/compiled_abi.json | 2416 ----------------- dist/lib/ContractParser/interfacesIds.js | 51 - dist/lib/ContractParser/jsonAbis/ERC165.json | 21 - dist/lib/ContractParser/jsonAbis/ERC20.json | 222 -- .../jsonAbis/ERC677plusToErc20.json | 58 - dist/lib/ContractParser/jsonAbis/ERC721.json | 254 -- .../jsonAbis/ERC721Enumerable.json | 310 --- .../jsonAbis/ERC721Metadata.json | 301 -- .../ContractParser/jsonAbis/GnosisWallet.json | 533 ---- .../jsonAbis/PoolBlockReward.json | 554 ---- .../jsonAbis/eventTransferNotIndexed.json | 24 - .../jsonAbis/event_OwnershipTransfered.json | 19 - .../jsonAbis/method_ApproveAndCall.json | 28 - dist/lib/ContractParser/lib.js | 63 - dist/lib/Db.js | 40 +- dist/lib/NativeContracts.js | 5 +- dist/lib/Setup.js | 23 +- dist/lib/btcUtils.js | 51 + dist/lib/collections.js | 336 ++- dist/lib/config.js | 78 +- dist/lib/defaultConfig.js | 2 +- dist/lib/types.js | 14 +- dist/lib/utils.js | 87 +- dist/lib/web3Connect.js | 13 - dist/services/blocks/blocksRequester.js | 8 +- dist/services/blocks/index.js | 3 +- dist/services/classes/Address.js | 7 +- dist/services/classes/BcStats.js | 21 +- dist/services/classes/BcThing.js | 7 +- dist/services/classes/Block.js | 23 +- dist/services/classes/CheckBlocks.js | 1 + dist/services/classes/Contract.js | 8 +- dist/services/classes/Event.js | 1 - dist/services/classes/RequestBlocks.js | 12 +- dist/services/classes/TokenAddress.js | 3 +- dist/services/classes/Tx.js | 30 +- dist/services/userEvents/AddressModule.js | 8 +- dist/services/userEvents/userEventsService.js | 4 +- dist/tools/checkDbBlocks.js | 6 +- dist/tools/getBlock.js | 8 +- dist/tools/updateContractAccounts.js | 57 - package-lock.json | 2 +- package.json | 2 +- public/swagger.json | 126 +- 68 files changed, 895 insertions(+), 5771 deletions(-) create mode 100644 dist/api/lib/blocksMetadata.js create mode 100644 dist/api/lib/getActiveAccounts.js delete mode 100644 dist/lib/ContractParser/Abi.js delete mode 100644 dist/lib/ContractParser/ContractParser.js delete mode 100644 dist/lib/ContractParser/Readme.md delete mode 100644 dist/lib/ContractParser/RemascEvents.js delete mode 100644 dist/lib/ContractParser/compileJsonAbis.js delete mode 100644 dist/lib/ContractParser/compiled_abi.json delete mode 100644 dist/lib/ContractParser/interfacesIds.js delete mode 100644 dist/lib/ContractParser/jsonAbis/ERC165.json delete mode 100644 dist/lib/ContractParser/jsonAbis/ERC20.json delete mode 100644 dist/lib/ContractParser/jsonAbis/ERC677plusToErc20.json delete mode 100644 dist/lib/ContractParser/jsonAbis/ERC721.json delete mode 100644 dist/lib/ContractParser/jsonAbis/ERC721Enumerable.json delete mode 100644 dist/lib/ContractParser/jsonAbis/ERC721Metadata.json delete mode 100644 dist/lib/ContractParser/jsonAbis/GnosisWallet.json delete mode 100644 dist/lib/ContractParser/jsonAbis/PoolBlockReward.json delete mode 100644 dist/lib/ContractParser/jsonAbis/eventTransferNotIndexed.json delete mode 100644 dist/lib/ContractParser/jsonAbis/event_OwnershipTransfered.json delete mode 100644 dist/lib/ContractParser/jsonAbis/method_ApproveAndCall.json delete mode 100644 dist/lib/ContractParser/lib.js create mode 100644 dist/lib/btcUtils.js delete mode 100644 dist/lib/web3Connect.js delete mode 100644 dist/tools/updateContractAccounts.js diff --git a/dist/api/Api.js b/dist/api/Api.js index ec8ff8fa..7f438cad 100644 --- a/dist/api/Api.js +++ b/dist/api/Api.js @@ -1,38 +1,43 @@ "use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default = void 0;var _DataCollector = require("./lib/DataCollector"); var _modules = require("./modules"); var _types = require("../lib/types"); -var _getCirculatingSupply = _interopRequireDefault(require("./lib/getCirculatingSupply")); var _blocksCollections = require("../lib/blocksCollections"); var _apiTools = require("./lib/apiTools"); -var _config = _interopRequireDefault(require("../lib/config"));function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} +var _config = _interopRequireDefault(require("../lib/config")); +var _NativeContracts = _interopRequireDefault(require("../lib/NativeContracts")); + +var _getCirculatingSupply = _interopRequireDefault(require("./lib/getCirculatingSupply"));function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} // It is used only in case Stats cannot provide the circulating supply class Api extends _DataCollector.DataCollector { - constructor({ db, initConfig, nativeContracts }, { modules, collectionsNames, lastBlocks } = {}) { + constructor({ db, initConfig }, { modules, collectionsNames, lastBlocks } = {}) { const collectionName = collectionsNames.Blocks; super(db, { collectionName }); this.collectionsNames = collectionsNames; this.collections = (0, _blocksCollections.getDbBlocksCollections)(db); - this.lastLimit = lastBlocks || 10; - this.latest = 0; - this.lastBlocks = []; - this.lastTransactions = []; + this.lastLimit = lastBlocks || 100; + this.latest = undefined; + this.lastBlocks = { data: [] }; + this.lastTransactions = { data: [] }; this.circulatingSupply = null; this.stats = { timestamp: 0 }; this.loadModules((0, _modules.getEnabledApiModules)(modules)); this.initConfig = initConfig; - const { isNativeContract } = nativeContracts; + const { isNativeContract } = (0, _NativeContracts.default)(initConfig); this.isNativeContract = isNativeContract; + this.tick(); } tick() { this.setLastBlocks(); - this.setCirculatingSupply(); } loadModules(modules) { Object.keys(modules).forEach(name => { - const module = new modules[name](this.collections, name); - this.log.info(`Loading module ${name}`); - this.addModule(module, name); + const constructor = modules[name]; + if (typeof constructor === 'function') { + const module = new constructor(this.collections, name); + this.log.info(`Loading module ${name}`); + this.addModule(module, name); + } }); } @@ -67,51 +72,48 @@ class Api extends _DataCollector.DataCollector { async setLastBlocks() { try { - let { collection, lastLimit } = this; + const Block = this.getModule('Block'); const Tx = this.getModule('Tx'); - let blocks = await collection.find().sort({ number: -1 }).limit(lastLimit).toArray(); - let txs = await Tx.db.find({ txType: { $in: [_types.txTypes.default, _types.txTypes.contract] } }). - sort({ blockNumber: -1, transactionIndex: -1 }). - limit(this.lastLimit). - toArray(); - - this.updateLastBlocks(blocks, txs); + let limit = this.lastLimit; + let blocks = await Block.run('getBlocks', { limit, addMetadata: true }); + let query = { txType: [_types.txTypes.default, _types.txTypes.contract] }; + let transactions = await Tx.run('getTransactions', { query, limit }); + this.updateLastBlocks(blocks, transactions); } catch (err) { this.log.debug(err); } } - - async setCirculatingSupply() { - try { - const collection = this.collections.Addrs; - let circulating = await (0, _getCirculatingSupply.default)(collection, this.initConfig.nativeContracts); - this.circulatingSupply = Object.assign({}, circulating); - } catch (err) { - this.log.debug(err); - } + getStats() { + return this.formatData(this.stats); } getCirculatingSupply() { return this.formatData(this.circulatingSupply); } getLastBlocks() { - let blocks = this.lastBlocks; - let transactions = this.lastTransactions; - return this.formatData({ blocks, transactions }); + let data = this.lastBlocks; + return this.formatData(data); + } + + getLastTransactions() { + let data = this.lastTransactions; + return this.formatData(data); } getLastBlock() { - return this.lastBlocks[0] || null; + let { data } = this.lastBlocks; + return data[0] || null; } updateLastBlocks(blocks, transactions) { + let blockData = blocks.data; this.lastBlocks = blocks; this.lastTransactions = transactions; let latest; - if (blocks && blocks[0]) latest = blocks[0].number; + if (blockData && blockData[0]) latest = blockData[0].number; if (latest !== this.latest) { this.latest = latest; - this.events.emit('newBlocks', this.formatData({ blocks, transactions })); + this.events.emit('newBlocks', this.getLastBlocks()); this.updateStats(); } } @@ -132,19 +134,33 @@ class Api extends _DataCollector.DataCollector { async updateStats() { const oldStats = this.stats; - const stats = await this.getModule('Stats').run('getLatest'); + const Stats = await this.getModule('Stats'); + if (!Stats) return; + const stats = await Stats.run('getLatest'); if (!stats) return; - const ExtendedStats = this.getModule('ExtendedStats'); - if (ExtendedStats) { - const blockNumber = parseInt(stats.blockNumber); - const extendedStats = await ExtendedStats.getExtendedStats(blockNumber); - Object.assign(stats, extendedStats); - } - + /* const ExtendedStats = this.getModule('ExtendedStats') + if (ExtendedStats) { + const blockNumber = parseInt(stats.blockNumber) + const extendedStats = await ExtendedStats.getExtendedStats(blockNumber) + Object.assign(stats, extendedStats) + } */ + let circulatingSupply = stats.circulatingSupply || (await this.getCirculatingSupplyFromDb()); + this.circulatingSupply = circulatingSupply; this.stats = Object.assign({}, stats); - if (stats.timestamp !== oldStats.timestamp) { - this.events.emit('newStats', this.stats); + let timestamp = stats.timestamp || 0; + if (timestamp > oldStats.timestamp) { + this.events.emit('newStats', this.getStats()); + } + } + async getCirculatingSupplyFromDb() { + try { + const collection = this.collections.Addrs; + const { nativeContracts } = this.initConfig; + let circulating = await (0, _getCirculatingSupply.default)(collection, nativeContracts); + return circulating; + } catch (err) { + this.log.debug(err); } }}var _default = diff --git a/dist/api/HttpServer.js b/dist/api/HttpServer.js index 6c9ed819..22fdad08 100644 --- a/dist/api/HttpServer.js +++ b/dist/api/HttpServer.js @@ -10,13 +10,17 @@ const HttpServer = ({ api, status, log }) => { app.set('etag', false); app.set('x-powered-by', false); + // status app.get('/status', (req, res) => { const data = status.getState().data; res.send(data); }); - app.get('/circulating', (req, res) => { - const data = api.getCirculatingSupply().data; + // circulating supply + app.get('/circulating/:field?', (req, res) => { + let { field } = req.params; + let { data } = api.getCirculatingSupply(); + data = field ? `${data[field]}` : data; res.send(data); }); diff --git a/dist/api/Status.js b/dist/api/Status.js index e77b0dd5..0cb39af4 100644 --- a/dist/api/Status.js +++ b/dist/api/Status.js @@ -1,15 +1,15 @@ "use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default = exports.Status = void 0;var _DataCollector = require("./lib/DataCollector/"); -var _config = _interopRequireDefault(require("../lib/config"));function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} -const { collectionsNames } = _config.default; +var _blocksCollections = require("../lib/blocksCollections"); class Status extends _DataCollector.DataCollector { constructor(db) { - const collectionName = collectionsNames.Status; - super(db, { collectionName }); + const collections = (0, _blocksCollections.getDbBlocksCollections)(db); + const { Status, Blocks } = collections; + super(db, { collectionName: 'Status' }); this.tickDelay = 5000; this.state = {}; - this.addModule(new _DataCollector.DataCollectorItem(db.collection(collectionsNames.Status), 'Status')); - this.addModule(new _DataCollector.DataCollectorItem(db.collection(collectionsNames.Blocks), 'Blocks')); + this.addModule(new _DataCollector.DataCollectorItem(Status, 'Status')); + this.addModule(new _DataCollector.DataCollectorItem(Blocks, 'Blocks')); } tick() { this.updateState().then(newState => { diff --git a/dist/api/channels.js b/dist/api/channels.js index 6d70c215..7d7296d7 100644 --- a/dist/api/channels.js +++ b/dist/api/channels.js @@ -3,6 +3,7 @@ var _Channel = _interopRequireDefault(require("./lib/Channel"));function _intero const CHANNELS = { blocksChannel: 'blocks', + txsChannel: 'transactions', statusChannel: 'status', txPoolChannel: 'txpool', statsChannel: 'stats' };exports.CHANNELS = CHANNELS; diff --git a/dist/api/docs.yaml b/dist/api/docs.yaml index b363d1b5..02cbd443 100644 --- a/dist/api/docs.yaml +++ b/dist/api/docs.yaml @@ -68,6 +68,14 @@ definitions: type: integer next: type: string + fields: + type: + oneOf: + - array + - object + + + Response: type: object diff --git a/dist/api/index.js b/dist/api/index.js index 61a9f70a..dbf396a0 100644 --- a/dist/api/index.js +++ b/dist/api/index.js @@ -14,11 +14,11 @@ var _evaluateError = require("./lib/evaluateError");function _interopRequireDefa const port = _config.default.api.port || '3003'; const address = _config.default.api.address || 'localhost'; -(0, _dataSource.setup)({ log: _log.default, skipCheck: true }).then(({ db, initConfig, nativeContracts }) => { +(0, _dataSource.setup)({ log: _log.default, skipCheck: true }).then(({ db, initConfig }) => { _log.default.info('Database connected'); // data collectors - const api = new _Api.default({ db, initConfig, nativeContracts }, _config.default.api); + const api = new _Api.default({ db, initConfig }, _config.default.api); const status = new _Status.default(db); const txPool = new _TxPool.default(db); api.start(); @@ -39,7 +39,7 @@ const address = _config.default.api.address || 'localhost'; // create channels const channels = (0, _channels.createChannels)(io); - const { blocksChannel, statusChannel, txPoolChannel, statsChannel } = channels.channels; + const { blocksChannel, statusChannel, txPoolChannel, statsChannel, txsChannel } = channels.channels; // send blocks on join blocksChannel.on('join', socket => { @@ -57,9 +57,19 @@ const address = _config.default.api.address || 'localhost'; socket.emit('data', (0, _apiTools.formatRes)({ action: 'txPoolChart', result: txPool.getPoolChart() })); }); - // send new blocks to channel + // send transactions on join + txsChannel.on('join', socket => { + socket.emit('data', (0, _apiTools.formatRes)({ action: 'newTransactions', result: api.getLastTransactions() })); + }); + // send new blocks & transactions to channels api.events.on('newBlocks', result => { blocksChannel.emit('newBlocks', result); + txsChannel.emit('newTransactions', api.getLastTransactions()); + }); + + // send stats on join + statsChannel.on('join', socket => { + socket.emit('data', (0, _apiTools.formatRes)({ action: 'stats', result: api.getStats() })); }); // send status to channel diff --git a/dist/api/lib/Channel.js b/dist/api/lib/Channel.js index 77aa5e28..1fc65ee1 100644 --- a/dist/api/lib/Channel.js +++ b/dist/api/lib/Channel.js @@ -28,12 +28,12 @@ function Channel(channelName, io) { } }; - const confirmSubsctption = socket => { + const confirmSubscription = socket => { socket.emit('subscription', { channel: channelName }); }; const join = socket => { channelEvent('join', socket); - confirmSubsctption(socket); + confirmSubscription(socket); }; const leave = socket => { diff --git a/dist/api/lib/DataCollector/DataCollector.js b/dist/api/lib/DataCollector/DataCollector.js index 0b849ae4..e4f5bafe 100644 --- a/dist/api/lib/DataCollector/DataCollector.js +++ b/dist/api/lib/DataCollector/DataCollector.js @@ -71,7 +71,7 @@ class DataCollector { } formatData(data) { - return { data: data }; + return { data }; }}exports.DataCollector = DataCollector;var _default = diff --git a/dist/api/lib/DataCollector/DataCollectorItem.js b/dist/api/lib/DataCollector/DataCollectorItem.js index 9985e971..5457dae3 100644 --- a/dist/api/lib/DataCollector/DataCollectorItem.js +++ b/dist/api/lib/DataCollector/DataCollectorItem.js @@ -1,4 +1,4 @@ -"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.formatResponse = formatResponse;exports.getFieldsTypes = getFieldsTypes;exports.filterSort = filterSort;exports.fieldFilterParse = fieldFilterParse;exports.default = exports.DataCollectorItem = void 0;var _mongodb = require("mongodb"); +"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.formatResponse = formatResponse;exports.getFieldsTypes = getFieldsTypes;exports.filterSort = filterSort;exports.fieldFilterParse = fieldFilterParse;exports.getCursorData = getCursorData;exports.default = exports.DataCollectorItem = void 0;var _mongodb = require("mongodb"); var _pagination = require("./pagination"); var _types = require("../../../lib/types"); class DataCollectorItem { @@ -37,6 +37,12 @@ class DataCollectorItem { } } + async count(query) { + let collection = this.db; + let data = await (0, _pagination.countDocuments)(collection, query); + return { data }; + } + async find(query, sort, limit, project) { let collection = this.db; project = project || this.getDefaultsFields(); @@ -84,10 +90,9 @@ class DataCollectorItem { } async setCursorData() { - const cursorField = this.cursorField; + let { cursorField } = this; const types = await this.getFieldsTypes(); - const cursorType = types[cursorField]; - this.cursorData = { cursorField, cursorType, fields: types }; + this.cursorData = await getCursorData(this.db, cursorField, types); return this.cursorData; } @@ -101,15 +106,15 @@ class DataCollectorItem { async getPrevNext(query, project, data) { try { - let { cursorField } = this; + let { cursorField, db } = this; project = project || this.getDefaultsFields(); if (!data) data = await this.getOne(query); if (data) data = data.data; if (!data) return; let value = query[cursorField] || data[cursorField]; if (undefined === value) throw new Error(`Missing ${cursorField} value`); - let prev = (await (0, _pagination.find)(this.db, { [cursorField]: { $lt: value } }, { [cursorField]: -1 }, 1, project))[0]; - let next = (await (0, _pagination.find)(this.db, { [cursorField]: { $gt: value } }, { [cursorField]: 1 }, 1, project))[0]; + let prev = (await (0, _pagination.find)(db, { [cursorField]: { $lt: value } }, { [cursorField]: -1 }, 1, project))[0]; + let next = (await (0, _pagination.find)(db, { [cursorField]: { $gt: value } }, { [cursorField]: 1 }, 1, project))[0]; return { prev, data, next }; } catch (err) { return Promise.reject(err); @@ -185,6 +190,12 @@ function fieldFilterParse(field, value, query) { if (ninArr.length) fieldQuery['$nin'] = ninArr; if (fieldQuery) query[field] = fieldQuery; return query; +} + +async function getCursorData(collection, cursorField, types) { + types = types || (await getFieldsTypes(collection)); + const cursorType = types[cursorField]; + return { cursorField, cursorType, fields: types }; }var _default = DataCollectorItem;exports.default = _default; \ No newline at end of file diff --git a/dist/api/lib/DataCollector/pagination.js b/dist/api/lib/DataCollector/pagination.js index bd424ab3..45689415 100644 --- a/dist/api/lib/DataCollector/pagination.js +++ b/dist/api/lib/DataCollector/pagination.js @@ -1,9 +1,19 @@ -"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.generateCursorQuery = generateCursorQuery;exports.formatSearchValue = formatSearchValue;exports.generateSort = generateSort;exports.generateQuery = generateQuery;exports.parseParams = parseParams;exports.findPages = findPages;exports.aggregatePages = aggregatePages;exports.modifyAggregate = modifyAggregate;exports.getAggregateTotal = getAggregateTotal;exports.paginationResponse = paginationResponse;exports.find = find;exports.encodeValue = encodeValue;exports.generateCursor = generateCursor;var _types = require("../../../lib/types"); +"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.countDocuments = countDocuments;exports.generateCursorQuery = generateCursorQuery;exports.formatSearchValue = formatSearchValue;exports.generateSort = generateSort;exports.generateQuery = generateQuery;exports.parseParams = parseParams;exports.findPages = findPages;exports.aggregatePages = aggregatePages;exports.modifyAggregate = modifyAggregate;exports.getAggregateTotal = getAggregateTotal;exports.paginationResponse = paginationResponse;exports.find = find;exports.encodeValue = encodeValue;exports.generateCursor = generateCursor;var _types = require("../../../lib/types"); var _mongodb = require("mongodb"); var _config = _interopRequireDefault(require("../../../lib/config"));function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} const { MAX_LIMIT, MAX_PAGES } = _config.default.api; const SEPARATOR = '__'; +async function countDocuments(collection, query) { + query = query || {}; + try { + let result = await collection.countDocuments(query); + return result; + } catch (err) { + return Promise.reject(err); + } +} + function generateCursorQuery({ cursorField, sortDir, value, sortField }) { if (!value) return; const op = sortDir === -1 ? '$lt' : '$gt'; @@ -113,7 +123,7 @@ async function findPages(collection, cursorData, query, params) { const $query = generateQuery(params, query); const $sort = generateSort(params); let data = !countOnly ? await find(collection, $query, $sort, queryLimit + 1, fields) : null; - let total = count ? await collection.countDocuments(query) : null; + let total = count ? await countDocuments(collection, query) : null; return paginationResponse(params, data, total); } catch (err) { return Promise.reject(err); diff --git a/dist/api/lib/apiTools.js b/dist/api/lib/apiTools.js index 99dfbe9b..91343659 100644 --- a/dist/api/lib/apiTools.js +++ b/dist/api/lib/apiTools.js @@ -1,19 +1,10 @@ -"use strict";Object.defineProperty(exports, "__esModule", { value: true });Object.defineProperty(exports, "errors", { enumerable: true, get: function () {return _types.errors;} });Object.defineProperty(exports, "MODULES", { enumerable: true, get: function () {return _types.MODULES;} });exports.getModulesNames = exports.getEnabledModules = exports.getModuleKey = exports.getDelayedFields = exports.formatError = exports.formatRes = exports.remove$ = exports.filterSort = exports.filterQuery = exports.filterFields = exports.getLimit = exports.filterParams = void 0;var _types = require("../../lib/types"); -var _config = _interopRequireDefault(require("../../lib/config"));function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} +"use strict";Object.defineProperty(exports, "__esModule", { value: true });Object.defineProperty(exports, "errors", { enumerable: true, get: function () {return _types.errors;} });Object.defineProperty(exports, "MODULES", { enumerable: true, get: function () {return _types.MODULES;} });exports.getModulesNames = exports.getEnabledModules = exports.getModuleKey = exports.getDelayedFields = exports.formatError = exports.formatRes = exports.remove$ = exports.filterParams = exports.sanitizeQuery = exports.filterSort = exports.filterQuery = exports.filterFields = exports.getLimit = void 0;var _types = require("../../lib/types"); +var _config = _interopRequireDefault(require("../../lib/config")); +var _utils = require("../../lib/utils");function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} const delayedFields = _config.default.api.delayedFields || {}; const { MAX_LIMIT, LIMIT, MIN_LIMIT } = _config.default.api; -const filterParams = params => { - params = params || {}; - let { limit, sort, fields, query } = params; - params.limit = getLimit(limit); - params.query = filterQuery(query); - params.sort = filterSort(sort); - params.fields = filterFields(fields); - return params; -};exports.filterParams = filterParams; - const getLimit = limit => { limit = limit || LIMIT; limit = limit > MAX_LIMIT ? MAX_LIMIT : limit; @@ -58,16 +49,28 @@ const filterSort = sort => { const sanitizeQuery = query => { let filtered = {}; for (let p in query) { - let k = remove$(p); - if (k === p) filtered[k] = query[p]; + if (p.replace('$') === p) { + let value = query[p]; + filtered[p] = (0, _utils.isObj)(value) ? sanitizeQuery(value) : value; + } } return retFiltered(filtered); -}; +};exports.sanitizeQuery = sanitizeQuery; const retFiltered = filtered => { return filtered && Object.keys(filtered).length > 0 ? filtered : null; }; +const filterParams = params => { + params = params || {}; + let { limit, sort, fields, query } = params; + params.limit = getLimit(limit); + params.query = filterQuery(query); + params.sort = filterSort(sort); + params.fields = filterFields(fields); + return params; +};exports.filterParams = filterParams; + const remove$ = value => value.replace('$', '');exports.remove$ = remove$; const formatRes = payload => { diff --git a/dist/api/lib/blocksMetadata.js b/dist/api/lib/blocksMetadata.js new file mode 100644 index 00000000..7656ce5b --- /dev/null +++ b/dist/api/lib/blocksMetadata.js @@ -0,0 +1,21 @@ +"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.addMetadataToBlocks = addMetadataToBlocks;exports.BLOCK_METADATA_FIELD = void 0; +var _utils = require("../../lib/utils"); +const BLOCK_METADATA_FIELD = '_metadata';exports.BLOCK_METADATA_FIELD = BLOCK_METADATA_FIELD; + +function addMetadataToBlocks(blocks) { + if (!Array.isArray(blocks)) throw new Error(`blocks must be an array`); + if (blocks.length < 2) return []; + let newBlocks = blocks.slice(1); + newBlocks = newBlocks.map((block, index) => { + let prevBlock = blocks[index]; + if (prevBlock.number >= block.number) throw new Error('blocks must be in ascending order'); + let time = block.timestamp - prevBlock.timestamp; + let txDensity = block.transactions.length / time; + let { difficulty } = block; + let blockHashrate = (0, _utils.newBigNumber)(difficulty).dividedBy((0, _utils.newBigNumber)(time)); + blockHashrate = (0, _utils.add0x)(blockHashrate.dp(0).toString(16)); + block[BLOCK_METADATA_FIELD] = { time, txDensity, blockHashrate }; + return block; + }); + return newBlocks; +} \ No newline at end of file diff --git a/dist/api/lib/getActiveAccounts.js b/dist/api/lib/getActiveAccounts.js new file mode 100644 index 00000000..b9aac0ed --- /dev/null +++ b/dist/api/lib/getActiveAccounts.js @@ -0,0 +1,12 @@ +"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default = getActiveAccounts;var _types = require("../../lib/types"); +async function getActiveAccounts(collections) { + try { + let collection = collections.Addrs; + let type = _types.addrTypes.ADDRESS; + let query = { $and: [{ type }, { balance: { $ne: '0x0' } }, { balance: { $ne: '0' } }] }; + let result = await collection.countDocuments(query); + return result; + } catch (err) { + return Promise.reject(err); + } +} \ No newline at end of file diff --git a/dist/api/modules/Block.js b/dist/api/modules/Block.js index 778f7f9f..9bef31f2 100644 --- a/dist/api/modules/Block.js +++ b/dist/api/modules/Block.js @@ -1,5 +1,6 @@ "use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default = exports.Block = void 0;var _DataCollector = require("../lib/DataCollector"); var _utils = require("../../lib/utils"); +var _blocksMetadata = require("../lib/blocksMetadata"); class Block extends _DataCollector.DataCollectorItem { constructor(collections, key) { const { Blocks } = collections; @@ -38,7 +39,7 @@ class Block extends _DataCollector.DataCollectorItem { * $ref: '#/responses/NotFound' */ - getBlock: params => { + getBlock: async params => { const hashOrNumber = params.hashOrNumber || params.hash || params.number; let query = {}; if ((0, _utils.isBlockHash)(hashOrNumber)) { @@ -46,7 +47,16 @@ class Block extends _DataCollector.DataCollectorItem { } else { query = { number: parseInt(hashOrNumber) }; } - return this.getPrevNext(query, { number: 1 }); + let result = await this.getPrevNext(query, {}); + if (result) { + let { prev, data, next } = result; + if (prev) { + result.data = (0, _blocksMetadata.addMetadataToBlocks)([prev, data]).pop(); + result.prev = filterBlockFields(prev); + } + if (next) result.next = filterBlockFields(next); + } + return result; }, /** * @swagger @@ -79,13 +89,39 @@ class Block extends _DataCollector.DataCollectorItem { * $ref: '#/responses/NotFound' */ - getBlocks: params => { - const { miner } = params; + getBlocks: async params => { + let { miner, addMetadata } = params; const query = miner ? { miner } : {}; - return this.getPageData(query, params); + let result = await this.getPageData(query, params); + // add blocks metadata + if (result.data && addMetadata) { + try { + let reverse = result.pages.sortDir === -1; + let data = result.data.slice(); + if (reverse) data.reverse(); + let { number } = data[0]; + let { prev } = await this.getPrevNext({ number }, {}); + let topBlock = data[0]; + // insert block at begin to compute first block metadata + if (prev) result.data.unshift(prev); + data = (0, _blocksMetadata.addMetadataToBlocks)(data); + // restore first block without metadata + if (!prev) data.unshift(topBlock); + if (reverse) data.reverse(); + result.data = data; + } catch (err) { + return result; + } + } + return result; } }; - }}exports.Block = Block;var _default = + }}exports.Block = Block; + +function filterBlockFields(block) { + let { number, _id } = block; + return { number, _id }; +}var _default = Block;exports.default = _default; \ No newline at end of file diff --git a/dist/api/modules/ContractVerification.js b/dist/api/modules/ContractVerification.js index 3b8c9025..90754c64 100644 --- a/dist/api/modules/ContractVerification.js +++ b/dist/api/modules/ContractVerification.js @@ -11,6 +11,25 @@ class ContractVerification extends _DataCollector.DataCollectorItem { super(ContractVerification, name); this.verificationsCollection = VerificationsResults; this.publicActions = { + /** + * @swagger + * /api?module=contractVerifier&action=verify: + * get: + * description: Verify contract source + * tags: + * - contract verifier + * parameters: + * - name: request + * in: query + * required: true + * responses: + * 200: + * $ref: '#/definitions/Response' + * 400: + * $ref: '#/responses/BadRequest' + * 404: + * $ref: '#/responses/NotFound' + */ verify: async params => { try { const { request } = params; @@ -33,17 +52,63 @@ class ContractVerification extends _DataCollector.DataCollectorItem { return Promise.reject(err); } }, - + /** + * @swagger + * /api?module=contractVerifier&action=getSolcVersions: + * get: + * description: Gets solidity compiler versions + * tags: + * - contract verifier + * responses: + * 200: + * $ref: '#/definitions/Response' + * 400: + * $ref: '#/responses/BadRequest' + * 404: + * $ref: '#/responses/NotFound' + */ getSolcVersions: async () => { const data = await (0, _StoredConfig.StoredConfig)(this.parent.db).get(_ContractVerifierModule.versionsId); return { data }; }, - + /** + * @swagger + * /api?module=contractVerifier&action=getEvmVersions: + * get: + * description: Gets evm versions + * tags: + * - contract verifier + * responses: + * 200: + * $ref: '#/definitions/Response' + * 400: + * $ref: '#/responses/BadRequest' + * 404: + * $ref: '#/responses/NotFound' + */ getEvmVersions: async () => { const data = _types.EVMversions; return { data }; }, - + /** + * @swagger + * /api?module=contractVerifier&action=getVersificationResult: + * get: + * description: Gets the result of source code verification + * tags: + * - contract verifier + * parameters: + * - name: id + * in: query + * required: true + * responses: + * 200: + * $ref: '#/definitions/Response' + * 400: + * $ref: '#/responses/BadRequest' + * 404: + * $ref: '#/responses/NotFound' + */ getVerificationResult: async params => { try { let { id } = params; @@ -58,30 +123,32 @@ class ContractVerification extends _DataCollector.DataCollectorItem { return Promise.reject(err); } }, - - /* getVerifications: async (params) => { - const query = verificationQuery(params) - const data = await this.getPageData(query) - return { data } - }, - getLatestVerification: async (params) => { - const query = verificationQuery(params) - return this.getLatest(query) - }, */ - + /** + * @swagger + * /api?module=contractVerifier&action=isVerified: + * get: + * description: Checks if a contract was verified + * tags: + * - contract verifier + * parameters: + * - name: address + * in: query + * required: true + * responses: + * 200: + * $ref: '#/definitions/Response' + * 400: + * $ref: '#/responses/BadRequest' + * 404: + * $ref: '#/responses/NotFound' + */ isVerified: async params => { const { address } = params; const data = await this.verificationsCollection.findOne({ address }); return { data }; } }; - }} - + }}exports.ContractVerification = ContractVerification;var _default = -/* function verificationQuery (params) { - const { address, match } = params - const query = (undefined !== match) ? { address, match: !!match } : { address } - return query - } */exports.ContractVerification = ContractVerification;var _default = ContractVerification;exports.default = _default; \ No newline at end of file diff --git a/dist/api/modules/Event.js b/dist/api/modules/Event.js index 2f76f98c..cd090c15 100644 --- a/dist/api/modules/Event.js +++ b/dist/api/modules/Event.js @@ -1,9 +1,11 @@ "use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default = exports.Event = void 0;var _DataCollector = require("../lib/DataCollector"); class Event extends _DataCollector.DataCollectorItem { constructor(collections, key) { - // const sortable = { timestamp: -1 } + const sortable = { eventId: -1 }; const { Events } = collections; - super(Events, key); + let cursorField = 'eventId'; + let sortDir = -1; + super(Events, key, { cursorField, sortDir, sortable }); this.publicActions = { /** * @swagger @@ -21,7 +23,7 @@ class Event extends _DataCollector.DataCollectorItem { * in: query * required: true * enum: [getEvent] - * - name: _id + * - name: eventId * in: query * schema: * type: string @@ -35,10 +37,10 @@ class Event extends _DataCollector.DataCollectorItem { */ getEvent: async params => { try { - const { _id } = params; - if (!_id) throw new Error('invalid _id'); - let data = await this.getOne({ _id }); - if (!data || !data.data) throw new Error(`Event ${_id} does not exist`); + const { eventId } = params; + if (!eventId) throw new Error('invalid eventId'); + let data = await this.getOne({ eventId }); + if (!data || !data.data) throw new Error(`Event ${eventId} does not exist`); const address = data.data.address; data = await this.parent.addAddressData(address, data); return data; @@ -91,7 +93,7 @@ class Event extends _DataCollector.DataCollectorItem { getEventsByAddress: async params => { const { address, signatures, contract } = params; if (address) { - let query = { args: address }; + let query = { _addresses: address }; // search by events signatures if (Array.isArray(signatures)) { @@ -154,7 +156,7 @@ class Event extends _DataCollector.DataCollectorItem { getAllEventsByAddress: async params => { const { address } = params; if (address) { - return this.getPageData({ $or: [{ address }, { args: address }] }, params); + return this.getPageData({ $or: [{ address }, { _addresses: address }] }, params); } } }; diff --git a/dist/api/modules/Tx.js b/dist/api/modules/Tx.js index 376063cd..38bb75d4 100644 --- a/dist/api/modules/Tx.js +++ b/dist/api/modules/Tx.js @@ -4,8 +4,10 @@ var _utils = require("../../lib/utils"); class Tx extends _DataCollector.DataCollectorItem { constructor(collections, key) { const { Txs } = collections; - // const sortable = { timestamp: -1 } - super(Txs, key); + let cursorField = 'txId'; + let sortDir = -1; + const sortable = { txId: -1 }; + super(Txs, key, { cursorField, sortDir, sortable }); this.publicActions = { /** * @swagger diff --git a/dist/api/modules/index.js b/dist/api/modules/index.js index 6f95ffb5..18de2a72 100644 --- a/dist/api/modules/index.js +++ b/dist/api/modules/index.js @@ -6,11 +6,11 @@ var _Token = require("./Token"); var _TxPending = require("./TxPending"); var _Stats = require("./Stats"); var _Summary = require("./Summary"); -var _ExtendedStats = require("./ExtendedStats"); + var _ContractVerification = require("./ContractVerification"); var _apiTools = require("../lib/apiTools"); -const apiModules = { Block: _Block.Block, Tx: _Tx.Tx, Address: _Address.Address, Event: _Event.Event, Token: _Token.Token, TxPending: _TxPending.TxPending, Stats: _Stats.Stats, Summary: _Summary.Summary, ExtendedStats: _ExtendedStats.ExtendedStats, ContractVerification: _ContractVerification.ContractVerification }; +const apiModules = { Block: _Block.Block, Tx: _Tx.Tx, Address: _Address.Address, Event: _Event.Event, Token: _Token.Token, TxPending: _TxPending.TxPending, Stats: _Stats.Stats, Summary: _Summary.Summary, ContractVerification: _ContractVerification.ContractVerification }; const getEnabledApiModules = modules => { const enabled = (0, _apiTools.getModulesNames)((0, _apiTools.getEnabledModules)(modules)); diff --git a/dist/lib/BlocksBase.js b/dist/lib/BlocksBase.js index f98a5563..d2cbbb15 100644 --- a/dist/lib/BlocksBase.js +++ b/dist/lib/BlocksBase.js @@ -1,16 +1,19 @@ "use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default = exports.BlocksBase = void 0;var _blocksCollections = require("./blocksCollections"); var _types = require("./types"); -var _nod3Connect = _interopRequireDefault(require("./nod3Connect"));function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} +var _nod3Connect = _interopRequireDefault(require("./nod3Connect")); +var _NativeContracts = _interopRequireDefault(require("./NativeContracts"));function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} class BlocksBase { - constructor(db, { log, nativeContracts }) { + constructor(db, { log, initConfig } = {}) { + this.initConfig = initConfig || {}; this.db = db; this.collections = db ? (0, _blocksCollections.getDbBlocksCollections)(db) : undefined; this.nod3 = _nod3Connect.default; this.log = log || console; this.et = _types.events; this.actions = _types.actions; - this.nativeContracts = nativeContracts; + this.nativeContracts = (0, _NativeContracts.default)(initConfig); + this.net = this.initConfig.net; }}exports.BlocksBase = BlocksBase;var _default = diff --git a/dist/lib/ContractParser/Abi.js b/dist/lib/ContractParser/Abi.js deleted file mode 100644 index 8be56234..00000000 --- a/dist/lib/ContractParser/Abi.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default = void 0;var _compiled_abi = _interopRequireDefault(require("./compiled_abi.json"));function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}var _default = -_compiled_abi.default;exports.default = _default; \ No newline at end of file diff --git a/dist/lib/ContractParser/ContractParser.js b/dist/lib/ContractParser/ContractParser.js deleted file mode 100644 index 5934d559..00000000 --- a/dist/lib/ContractParser/ContractParser.js +++ /dev/null @@ -1,222 +0,0 @@ -"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default = exports.ContractParser = void 0;var _event = _interopRequireDefault(require("web3/lib/web3/event.js")); -var _Abi = _interopRequireDefault(require("./Abi")); -var _web3Connect = require("../web3Connect"); -var _types = require("../types"); -var _interfacesIds = _interopRequireDefault(require("./interfacesIds")); -var _utils = require("../../lib/utils"); -var _RemascEvents = _interopRequireDefault(require("./RemascEvents")); -var _lib = require("./lib");function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} - - - - - - - - - -class ContractParser { - constructor({ abi, log, nativeContracts } = {}) { - if (!nativeContracts) throw new Error('Missing native contracts'); - this.abi = null; - this.abi = (0, _lib.setAbi)(abi || _Abi.default); - this.eventsAbi = (0, _lib.abiEvents)(this.abi); - this.web3 = _web3Connect.web3; - this.log = log || console; - this.nativeContracts = nativeContracts; - } - - getRemascAddress() { - const { nativeContracts } = this; - if (nativeContracts) { - return nativeContracts.getNativeContractAddress('remasc'); - } - } - - setAbi(abi) { - this.abi = (0, _lib.setAbi)(abi); - this.eventsAbi = (0, _lib.abiEvents)(this.abi); - } - - setWeb3(web3) { - if (web3) this.web3 = web3; - } - getMethodsSelectors() { - let selectors = {}; - let methods = this.getAbiMethods(); - for (let m in methods) { - let method = methods[m]; - let signature = method.signature || (0, _lib.soliditySignature)(m); - selectors[m] = (0, _lib.soliditySelector)(signature); - } - return selectors; - } - - getAbiMethods() { - let methods = {}; - this.abi.filter(def => def.type === 'function'). - map(m => { - let sig = m[_lib.ABI_SIGNATURE] || (0, _lib.abiSignatureData)(m); - sig.name = m.name; - methods[sig.method] = sig; - }); - return methods; - } - - parseTxLogs(logs) { - return logs.map(log => { - // non-standard remasc events - const remascAddress = this.getRemascAddress(); - if (log.address === remascAddress) return _RemascEvents.default.decode(log); - - let back = Object.assign({}, log); - let decoder = this.getLogDecoder(log.topics || []); - let decoded = decoder ? decoder.event.decode(log) : log; - decoded.topics = back.topics; - decoded.data = back.data; - if (decoder) { - let signature = Object.assign({}, decoder.abi[_lib.ABI_SIGNATURE]); - decoded.signature = signature.signature; - decoded.abi = (0, _lib.removeAbiSignaureData)(decoder.abi); - // convert args object to array to remove properties names - if (decoded.args) { - let inputs = decoded.abi.inputs || []; - let args = inputs.map(i => i.name).map(i => decoded.args[i]); - decoded.args = args; - } - } - return decoded; - }).map(log => { - let abi = log.abi; - if (abi && abi.inputs) { - abi.inputs.forEach(param => { - if (param.type === 'bytes32') { - log.args[param.name] = this.web3.toAscii(log.args[param.name]); - } - }); - } - return log; - }); - } - - getLogDecoder(topics) { - if (!topics.length) return null; - let events = this.eventsAbi; - let signature = topics[0].slice(2); - let indexed = topics.length - 1; - let decoders = events. - filter(e => { - let s = e[_lib.ABI_SIGNATURE]; - return s.signature === signature && s.indexed === indexed; - }); - if (decoders.length) { - if (decoders[1]) this.log.error(`ERROR, dupplicated event: ${decoders[0].name}`); - return this.createLogDecoder(decoders[0]); - } - } - - createLogDecoder(abi) { - abi = Object.assign({}, abi); - const event = new _event.default(null, abi, null); - return { abi, event }; - } - - makeContract(address, abi) { - abi = abi || this.abi; - return this.web3.eth.contract(abi).at(address); - } - - call(method, contract, params = []) { - return new Promise((resolve, reject) => { - if (!Array.isArray(params)) reject(new Error(`Params must be an array`)); - contract[method].call(...params, (err, res) => { - if (err !== null) { - this.log.warn(`Method ${method} call ${err}`); - resolve(null); - // return reject(err) - } else { - resolve(res); - } - }); - }); - } - - async getTokenData(contract) { - const methods = ['name', 'symbol', 'decimals', 'totalSupply']; - let [name, symbol, decimals, totalSupply] = await Promise.all( - methods.map((m) => - this.call(m, contract). - then(res => res). - catch(err => this.log.debug(`[${contract.address}] Error executing ${m} Error: ${err}`)))); - - return { name, symbol, decimals, totalSupply }; - } - - hasMethodSelector(txInputData, selector) { - return selector && txInputData ? txInputData.includes(selector) : null; - } - - getMethodsBySelectors(txInputData) { - let methods = this.getMethodsSelectors(); - return Object.keys(methods). - filter(method => this.hasMethodSelector(txInputData, methods[method]) === true); - } - - async getContractInfo(txInputData, contract) { - let methods = this.getMethodsBySelectors(txInputData); - let isErc165 = false; - // skip non-erc165 conrtacts - if ((0, _utils.includesAll)(methods, ['supportsInterface(bytes4)'])) { - isErc165 = await this.implementsErc165(contract); - } - let interfaces; - if (isErc165) interfaces = await this.getInterfacesERC165(contract);else - interfaces = this.getInterfacesByMethods(methods); - interfaces = Object.keys(interfaces). - filter(k => interfaces[k] === true). - map(t => _types.contractsInterfaces[t] || t); - return { methods, interfaces }; - } - - async getInterfacesERC165(contract) { - let ifaces = {}; - let keys = Object.keys(_interfacesIds.default); - for (let i of keys) { - ifaces[i] = await this.supportsInterface(contract, _interfacesIds.default[i].id); - } - return ifaces; - } - - getInterfacesByMethods(methods, isErc165) { - return Object.keys(_interfacesIds.default). - map(i => { - return [i, (0, _utils.includesAll)(methods, _interfacesIds.default[i].methods)]; - }). - reduce((obj, value) => { - obj[value[0]] = value[1]; - return obj; - }, {}); - } - - async supportsInterface(contract, interfaceId) { - // fixed gas to prevent infinite loops - let options = { gas: 30000 }; - let res = await this.call('supportsInterface', contract, [interfaceId, options]); - return res; - } - - async implementsErc165(contract) { - try { - let first = await this.supportsInterface(contract, _interfacesIds.default.ERC165.id); - if (first === true) { - let second = await this.supportsInterface(contract, '0xffffffff'); - return !(second === true || second === null); - } - return false; - } catch (err) { - return Promise.reject(err); - } - }}exports.ContractParser = ContractParser;var _default = - - -ContractParser;exports.default = _default; \ No newline at end of file diff --git a/dist/lib/ContractParser/Readme.md b/dist/lib/ContractParser/Readme.md deleted file mode 100644 index 03941428..00000000 --- a/dist/lib/ContractParser/Readme.md +++ /dev/null @@ -1,6 +0,0 @@ -# Contract Parser - -To add an abi: - -- Copy json to **./jsonAbis** -- Run: **compileJsonAbis.js** \ No newline at end of file diff --git a/dist/lib/ContractParser/RemascEvents.js b/dist/lib/ContractParser/RemascEvents.js deleted file mode 100644 index c4041bda..00000000 --- a/dist/lib/ContractParser/RemascEvents.js +++ /dev/null @@ -1,56 +0,0 @@ -"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default = exports.RemascEvents = void 0;var rlp = _interopRequireWildcard(require("rlp"));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;}var cache = _getRequireWildcardCache();if (cache && cache.has(obj)) {return cache.get(obj);}var newObj = {};if (obj != null) {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;} - -class RemascEvents { - decode(log) { - let event = this.decodeEventName(log.topics[0]); - // at the moment remasc emits only one event - if (event === 'mining_fee_topic') { - let [blockHash, value] = this.decodeData(log.data); - let to = this.decodeAddress(log.topics[1]); - log.event = event; - log.args = [to, blockHash, value]; - log.abi = this.fakeAbi(); - } - return log; - } - - decodeEventName(name) { - name = name.slice(0, 2) === '0x' ? name.slice(2, name.length) : name; - return Buffer.from(name, 'hex').toString('ascii').replace(/\0/g, ''); - } - - decodeData(data) { - return rlp.decode(data).map(d => '0x' + d.toString('hex').replace(/^0+/, '')); - } - - decodeAddress(address) { - return '0x' + address.slice(-40); - } - fakeAbi() { - return { - anonymous: false, - inputs: [ - { - indexed: true, - name: 'to', - type: 'address' }, - - { - indexed: false, - name: 'blockHash', - type: 'address' }, - - { - indexed: false, - name: 'value', - type: 'uint256' }], - - - name: 'mining_fee_topic', - type: 'event' }; - - }}exports.RemascEvents = RemascEvents; - - -const remascEvents = new RemascEvents();var _default = -remascEvents;exports.default = _default; \ No newline at end of file diff --git a/dist/lib/ContractParser/compileJsonAbis.js b/dist/lib/ContractParser/compileJsonAbis.js deleted file mode 100644 index 58a76a5c..00000000 --- a/dist/lib/ContractParser/compileJsonAbis.js +++ /dev/null @@ -1,80 +0,0 @@ -"use strict";var _fs = _interopRequireDefault(require("fs")); -var _util = _interopRequireDefault(require("util")); -var _path = _interopRequireDefault(require("path")); -var _lib = require("./lib");function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} - -const readDir = _util.default.promisify(_fs.default.readdir); -const readFile = _util.default.promisify(_fs.default.readFile); -const writeFile = _util.default.promisify(_fs.default.writeFile); - -const jsonPath = `${__dirname}/jsonAbis`; -const destinationFile = `${__dirname}/compiled_abi.json`; - -compileAbi().then(abi => { - writeFile(destinationFile, JSON.stringify(abi, null, 2)). - then(() => { - console.log(`new abi saved on ${destinationFile}`); - process.exit(0); - }); -}); - -async function compileAbi() { - try { - let files = await readDir(jsonPath); - files = files.filter(file => _path.default.extname(file) === '.json'); - if (!files || !files.length) throw new Error('No json files'); - let abi = await Promise.all(files.map(file => readJson(`${jsonPath}/${file}`))); - abi = abi.reduce((a, v, i, array) => v.concat(a)); - abi = processAbi(abi); - return abi; - } catch (err) { - console.log('Compile Error', err); - process.exit(9); - } -} - -async function readJson(file) { - console.log(`Reading file ${file}`); - try { - let json = await readFile(file, 'utf-8'); - return JSON.parse(json); - } catch (err) { - console.log(file, err); - return Promise.reject(err); - } -} - -function processAbi(abi) { - // remove fallbacks - abi = abi.filter(a => a.type !== 'fallback'); - // remove duplicates - abi = [...new Set(abi.map(a => JSON.stringify(a)))].map(a => JSON.parse(a)); - // add signatures - abi = (0, _lib.addSignatureDataToAbi)(abi); - // detect 4 bytes collisions - let signatures = abi.map(a => a[_lib.ABI_SIGNATURE].signature).filter(v => v); - signatures = [...new Set(signatures)]; - let fourBytes = signatures.map(s => s.slice(0, 8)); - if (fourBytes.length !== [...new Set(fourBytes)].length) { - console.log(fourBytes.filter((v, i) => fourBytes.indexOf(v) !== i)); - throw new Error('4bytes collision'); - } - // check events - let duppEvents = searchDupplicatedEvents(abi); - if (duppEvents) throw new Error('Dupplicated events'); - return abi; -} - -function searchDupplicatedEvents(abi) { - let events = (0, _lib.abiEvents)(abi).map(e => { - let s = e[_lib.ABI_SIGNATURE]; - return `${s.signature}_${s.indexed}`; - }); - let unique = [...new Set(events)]; - return events.length !== unique.length; -} - -process.on('unhandledRejection', err => { - console.error(err); - process.exit(9); -}); \ No newline at end of file diff --git a/dist/lib/ContractParser/compiled_abi.json b/dist/lib/ContractParser/compiled_abi.json deleted file mode 100644 index 899baf5b..00000000 --- a/dist/lib/ContractParser/compiled_abi.json +++ /dev/null @@ -1,2416 +0,0 @@ -[ - { - "constant": false, - "inputs": [ - { - "name": "_spender", - "type": "address" - }, - { - "name": "_value", - "type": "uint256" - }, - { - "name": "_extraData", - "type": "bytes" - } - ], - "name": "approveAndCall", - "outputs": [ - { - "name": "success", - "type": "bool" - } - ], - "payable": false, - "type": "function", - "__signatureData": { - "method": "approveAndCall(address,uint256,bytes)", - "signature": "cae9ca5133009d821214ac8231b3d170f22d822ee165adb631578070b6316fc9", - "index": null, - "indexed": 0 - } - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "from", - "type": "address" - }, - { - "indexed": true, - "name": "to", - "type": "address" - } - ], - "name": "OwnershipTransferred", - "type": "event", - "__signatureData": { - "method": "OwnershipTransferred(address,address)", - "signature": "8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", - "index": [ - true, - true - ], - "indexed": 2 - } - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "from", - "type": "address" - }, - { - "indexed": false, - "name": "to", - "type": "address" - }, - { - "indexed": false, - "name": "value", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event", - "__signatureData": { - "method": "Transfer(address,address,uint256)", - "signature": "ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", - "index": [ - false, - false, - false - ], - "indexed": 0 - } - }, - { - "constant": false, - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "__signatureData": { - "method": "renounceOwnership()", - "signature": "715018a616b5f2044428f6fadb7deef4ce9ca76ef60ea57978964ad137bbe7ae", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [], - "name": "owner", - "outputs": [ - { - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "owner()", - "signature": "8da5cb5b36e7f68c1d2e56001220cdbdd3ba2616072f718acfda4a06441a807d", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [], - "name": "isOwner", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "isOwner()", - "signature": "8f32d59b339b0965093e9a53b00f4400c41d72f026df85c0beaa1d49d97802ef", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [], - "name": "moneyToPayPerBlock", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "moneyToPayPerBlock()", - "signature": "94eaa46b6c4a6677c8f49b080d56276204fe453436ffffd2aecf2b68ae319385", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [], - "name": "maxMiners", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "maxMiners()", - "signature": "db6fccda07b2e6bad5d478a794d378d354ca434f3c94b1b7fc514a919aed92b9", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [], - "name": "maxBlocksToPayPerCall", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "maxBlocksToPayPerCall()", - "signature": "e32683dff52aff29d263721de20831e5fe2d2c748ab6567b6efac21a9bde1823", - "index": null, - "indexed": 0 - } - }, - { - "constant": false, - "inputs": [ - { - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "__signatureData": { - "method": "transferOwnership(address)", - "signature": "f2fde38b092330466c661fc723d5289b90272a3e580e3187d1d7ef788506c557", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [], - "name": "lastPaidBlock", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "lastPaidBlock()", - "signature": "f6aced518ca2df90e95db514f2e0f737010a2ac304bc5c27c911099fab41eda7", - "index": null, - "indexed": 0 - } - }, - { - "inputs": [ - { - "name": "_blockInfoProvider", - "type": "address" - }, - { - "name": "_moneyToPayPerBlock", - "type": "uint256" - }, - { - "name": "_maxBlocksToPayPerCall", - "type": "uint256" - }, - { - "name": "_maxMiners", - "type": "uint256" - }, - { - "name": "_lockupInMonths", - "type": "uint256" - }, - { - "name": "_dateTimeContract", - "type": "address" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "constructor", - "__signatureData": { - "method": null, - "signature": null, - "index": null, - "indexed": 0 - } - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "miner", - "type": "address" - }, - { - "indexed": false, - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "name": "period", - "type": "uint256" - } - ], - "name": "PayToMiner", - "type": "event", - "__signatureData": { - "method": "PayToMiner(address,uint256,uint256)", - "signature": "95460d5668d84b3e4997ca15219ed0e18bf56a8330e21379e011e771c6a4b05a", - "index": [ - false, - false, - false - ], - "indexed": 0 - } - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "miner", - "type": "address" - }, - { - "indexed": false, - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "name": "period", - "type": "uint256" - } - ], - "name": "PayToMinerFailed", - "type": "event", - "__signatureData": { - "method": "PayToMinerFailed(address,uint256,uint256)", - "signature": "c41773826985aa9ab71a9ab07150c777355f4bdc9c86683a5e4fde65825fc6e6", - "index": [ - false, - false, - false - ], - "indexed": 0 - } - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "name": "period", - "type": "uint256" - } - ], - "name": "PayToMiners", - "type": "event", - "__signatureData": { - "method": "PayToMiners(uint256,uint256)", - "signature": "a4790ab3a9e0de65862e8f110f85694b812c416e3b890ca5b8f97253de160ef6", - "index": [ - false, - false - ], - "indexed": 0 - } - }, - { - "anonymous": false, - "inputs": [], - "name": "DonationReceived", - "type": "event", - "__signatureData": { - "method": "DonationReceived()", - "signature": "e554fffbd0e5c2a35b0a24fef85d4297554111caf74cc33cb4cc85a117bbe6e0", - "index": [], - "indexed": 0 - } - }, - { - "anonymous": false, - "inputs": [], - "name": "InsufficientBalance", - "type": "event", - "__signatureData": { - "method": "InsufficientBalance()", - "signature": "f4d678b8ce6b5157126b1484a53523762a93571537a7d5ae97d8014a44715c94", - "index": [], - "indexed": 0 - } - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "from", - "type": "uint256" - }, - { - "indexed": false, - "name": "to", - "type": "uint256" - }, - { - "indexed": false, - "name": "totalBlocksCollected", - "type": "uint256" - } - ], - "name": "BlockRangeCollected", - "type": "event", - "__signatureData": { - "method": "BlockRangeCollected(uint256,uint256,uint256)", - "signature": "07b5de8b7d8ad88823dc9d5d13a26a58dd5dad9d7431c971916e8a3e545ac2d0", - "index": [ - false, - false, - false - ], - "indexed": 0 - } - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "maxBlocks", - "type": "uint256" - } - ], - "name": "MaxBlocksToPayPerCallChanged", - "type": "event", - "__signatureData": { - "method": "MaxBlocksToPayPerCallChanged(uint256)", - "signature": "f555ad19dea6b98762181791eb417d88f243ecd03499b619a7717cb90d0c45aa", - "index": [ - false - ], - "indexed": 0 - } - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "payPerBlock", - "type": "uint256" - } - ], - "name": "MoneyToPayPerBlockChanged", - "type": "event", - "__signatureData": { - "method": "MoneyToPayPerBlockChanged(uint256)", - "signature": "9ebb25db5b630f64c0d0d91015131a75ccc571e42d39d0c56235159250c5df53", - "index": [ - false - ], - "indexed": 0 - } - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "maxMiners", - "type": "uint256" - } - ], - "name": "MaxMinersChanged", - "type": "event", - "__signatureData": { - "method": "MaxMinersChanged(uint256)", - "signature": "8ea7d9e1dc593608262e6b63ccdd384a9c7896b58b6a5d7aa697894f997b6e71", - "index": [ - false - ], - "indexed": 0 - } - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "miner", - "type": "address" - }, - { - "indexed": false, - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "name": "releasePeriod", - "type": "uint256" - } - ], - "name": "DepositedToMiner", - "type": "event", - "__signatureData": { - "method": "DepositedToMiner(address,uint256,uint256)", - "signature": "21d923e6f2fbbc9222c3e08fcd16385f84e92f57e4bf87b4ba7c01e55bba0143", - "index": [ - false, - false, - false - ], - "indexed": 0 - } - }, - { - "anonymous": false, - "inputs": [], - "name": "SomethingIsWorkingWrong", - "type": "event", - "__signatureData": { - "method": "SomethingIsWorkingWrong()", - "signature": "2639447ed8a758326ec0f5fe15ab74cfd2cb4d50af58738e0e6708cad40bdd8d", - "index": [], - "indexed": 0 - } - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "from", - "type": "uint256" - }, - { - "indexed": false, - "name": "to", - "type": "uint256" - }, - { - "indexed": false, - "name": "totalBlocksSkipped", - "type": "uint256" - } - ], - "name": "SkipPayments", - "type": "event", - "__signatureData": { - "method": "SkipPayments(uint256,uint256,uint256)", - "signature": "f0a7b16521cf748ba983ff8836c578b6f720adc41be8f24d8077e5e4dff001d5", - "index": [ - false, - false, - false - ], - "indexed": 0 - } - }, - { - "anonymous": false, - "inputs": [], - "name": "NothingToPay", - "type": "event", - "__signatureData": { - "method": "NothingToPay()", - "signature": "4d63c252538ab708dc54228436ccda748d3924f239d20604ecbd55e56c4f3138", - "index": [], - "indexed": 0 - } - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "blockNumber", - "type": "uint256" - }, - { - "indexed": false, - "name": "minerAddress", - "type": "address" - } - ], - "name": "CollectedBlock", - "type": "event", - "__signatureData": { - "method": "CollectedBlock(uint256,address)", - "signature": "92f093463674e24ff71c6c27f365d19218384e825d461f5c464bc7b2d4c868d6", - "index": [ - false, - false - ], - "indexed": 0 - } - }, - { - "anonymous": false, - "inputs": [], - "name": "NothingToCollect", - "type": "event", - "__signatureData": { - "method": "NothingToCollect()", - "signature": "7b2c2feff2da1aeb7690a0c70beceb7ffc6cce3734d3f5b1f282b23bd12dd5f3", - "index": [], - "indexed": 0 - } - }, - { - "constant": false, - "inputs": [ - { - "name": "_newMax", - "type": "uint256" - } - ], - "name": "setMaxBlocksToPayPerCall", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "__signatureData": { - "method": "setMaxBlocksToPayPerCall(uint256)", - "signature": "3da9f4f0be6d5a05fdd4ae3d265666192154601089c96e51424bf2e08b980f66", - "index": null, - "indexed": 0 - } - }, - { - "constant": false, - "inputs": [ - { - "name": "_newPay", - "type": "uint256" - } - ], - "name": "setMoneyToPayPerBlock", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "__signatureData": { - "method": "setMoneyToPayPerBlock(uint256)", - "signature": "8edf2dff8c8c2a4630befeeb98ac035037bb40ad051b21b800ba2969d3101941", - "index": null, - "indexed": 0 - } - }, - { - "constant": false, - "inputs": [ - { - "name": "_newMax", - "type": "uint256" - } - ], - "name": "setMaxMiners", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "__signatureData": { - "method": "setMaxMiners(uint256)", - "signature": "a9476edaee14f067c56f60c191ff6cef97c83294bb4a025246e32c9544901458", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [], - "name": "getBalance", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "getBalance()", - "signature": "12065fe058ec54d32b956897063181d660e7d27f9bb883d28d5cc5ab3423e23c", - "index": null, - "indexed": 0 - } - }, - { - "constant": false, - "inputs": [], - "name": "collectProfits", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "__signatureData": { - "method": "collectProfits()", - "signature": "c958e0d6d36792cce73cee987eb1db14f16672a928568c5e8db3291aaf59bf69", - "index": null, - "indexed": 0 - } - }, - { - "constant": false, - "inputs": [ - { - "name": "addressMiner", - "type": "address" - } - ], - "name": "payToMiner", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": true, - "stateMutability": "payable", - "type": "function", - "__signatureData": { - "method": "payToMiner(address)", - "signature": "ecb8ba13ba7492306cb8a8d48607f34b4ca61cd281ca9ad8cfc29a0b54e52f32", - "index": null, - "indexed": 0 - } - }, - { - "constant": false, - "inputs": [ - { - "name": "addressMiner", - "type": "address" - }, - { - "name": "month", - "type": "uint8" - }, - { - "name": "year", - "type": "uint16" - } - ], - "name": "payToMinerInPeriod", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "__signatureData": { - "method": "payToMinerInPeriod(address,uint8,uint16)", - "signature": "6035635e090457de6c725de5c71f5f51ebd9d23a91cfd8baf037978dd713bbd3", - "index": null, - "indexed": 0 - } - }, - { - "constant": false, - "inputs": [], - "name": "payToMiners", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": true, - "stateMutability": "payable", - "type": "function", - "__signatureData": { - "method": "payToMiners()", - "signature": "e033b84e34cd498593f20833ffe7a5e5c96f98962e186331e92913b144764e6e", - "index": null, - "indexed": 0 - } - }, - { - "constant": false, - "inputs": [ - { - "name": "month", - "type": "uint8" - }, - { - "name": "year", - "type": "uint16" - } - ], - "name": "payToMinersInPeriod", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "__signatureData": { - "method": "payToMinersInPeriod(uint8,uint16)", - "signature": "8cab0e8113c4443c80b67441f7273acb8d0acb4dd097cceabc13964ba36822a0", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [ - { - "name": "minerAddress", - "type": "address" - } - ], - "name": "getBalanceForCurrentPeriod", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "getBalanceForCurrentPeriod(address)", - "signature": "da69cdaf31c9bd523ce88f41e9052aa156c444505eb1b044c109a08dfb90e771", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [ - { - "name": "minerAddress", - "type": "address" - }, - { - "name": "month", - "type": "uint8" - }, - { - "name": "year", - "type": "uint16" - } - ], - "name": "getBalanceForPeriod", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "getBalanceForPeriod(address,uint8,uint16)", - "signature": "500e07ea01ee3fe029dfe9b632b4934b74f96e097e4a64aaf0b978288fb00f56", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [ - { - "name": "", - "type": "uint256" - } - ], - "name": "owners", - "outputs": [ - { - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "owners(uint256)", - "signature": "025e7c27eac939a1d6b87a08c3f39516072d58f65abdf6d1ca77156530d4cc35", - "index": null, - "indexed": 0 - } - }, - { - "constant": false, - "inputs": [ - { - "name": "owner", - "type": "address" - } - ], - "name": "removeOwner", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "__signatureData": { - "method": "removeOwner(address)", - "signature": "173825d90d5095783b384d0c08afb549944c4f4c89ad29a276da04db8e14ff9e", - "index": null, - "indexed": 0 - } - }, - { - "constant": false, - "inputs": [ - { - "name": "transactionId", - "type": "uint256" - } - ], - "name": "revokeConfirmation", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "__signatureData": { - "method": "revokeConfirmation(uint256)", - "signature": "20ea8d86087397d6737ff70ebe94a8ed7065f3e7db4534a9523ae818a3fe01b7", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [ - { - "name": "", - "type": "address" - } - ], - "name": "isOwner", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "isOwner(address)", - "signature": "2f54bf6efe3c885d4f7c60dd2b62f9e1c8e834c7152c314a797c4d0e05c447cf", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [ - { - "name": "", - "type": "uint256" - }, - { - "name": "", - "type": "address" - } - ], - "name": "confirmations", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "confirmations(uint256,address)", - "signature": "3411c81c46ee3d7cf872c1145662928d2120e74c6d45b79c2d87092372f7c84a", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [ - { - "name": "pending", - "type": "bool" - }, - { - "name": "executed", - "type": "bool" - } - ], - "name": "getTransactionCount", - "outputs": [ - { - "name": "count", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "getTransactionCount(bool,bool)", - "signature": "5474152539dd948724b4cf552d5b1dd2789758b9698c5bdc66e2fdcf7c3cabde", - "index": null, - "indexed": 0 - } - }, - { - "constant": false, - "inputs": [ - { - "name": "owner", - "type": "address" - } - ], - "name": "addOwner", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "__signatureData": { - "method": "addOwner(address)", - "signature": "7065cb489ab3e47058ef9c048a2255f3e0dc15732bc16897592e2e8d246a0414", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [ - { - "name": "transactionId", - "type": "uint256" - } - ], - "name": "isConfirmed", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "isConfirmed(uint256)", - "signature": "784547a768b57de63c01309e9534f8339f117d1469fee08fcaadd193742686c6", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [ - { - "name": "transactionId", - "type": "uint256" - } - ], - "name": "getConfirmationCount", - "outputs": [ - { - "name": "count", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "getConfirmationCount(uint256)", - "signature": "8b51d13f1bf42439587b478dcbb3c1c7b41d364e7e61f430d823fb5844597435", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [ - { - "name": "", - "type": "uint256" - } - ], - "name": "transactions", - "outputs": [ - { - "name": "destination", - "type": "address" - }, - { - "name": "value", - "type": "uint256" - }, - { - "name": "data", - "type": "bytes" - }, - { - "name": "executed", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "transactions(uint256)", - "signature": "9ace38c2d967ad67e6abb390955f4fa15d49d10dc79b0b602cb97d942b537041", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [], - "name": "getOwners", - "outputs": [ - { - "name": "", - "type": "address[]" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "getOwners()", - "signature": "a0e67e2bdc0a6d8a09ccd6c353c9df590807ad66ff5e6630c4f31a86dfa84821", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [ - { - "name": "from", - "type": "uint256" - }, - { - "name": "to", - "type": "uint256" - }, - { - "name": "pending", - "type": "bool" - }, - { - "name": "executed", - "type": "bool" - } - ], - "name": "getTransactionIds", - "outputs": [ - { - "name": "_transactionIds", - "type": "uint256[]" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "getTransactionIds(uint256,uint256,bool,bool)", - "signature": "a8abe69a30f0243194c6d9cd7b301fbf510ca7fa157488f505e08e138e2a5b25", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [ - { - "name": "transactionId", - "type": "uint256" - } - ], - "name": "getConfirmations", - "outputs": [ - { - "name": "_confirmations", - "type": "address[]" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "getConfirmations(uint256)", - "signature": "b5dc40c3b5620210adf51dca4154c224fa8bea2847510e80bb45632e9f88427b", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [], - "name": "transactionCount", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "transactionCount()", - "signature": "b77bf6009627e15897d3198ef815426bb9543fa4e37a6f6c8b82da0703b372c4", - "index": null, - "indexed": 0 - } - }, - { - "constant": false, - "inputs": [ - { - "name": "_required", - "type": "uint256" - } - ], - "name": "changeRequirement", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "__signatureData": { - "method": "changeRequirement(uint256)", - "signature": "ba51a6df11ed2f9658b32100640ebce3ff8ed00be3830b92867b3e30629140ad", - "index": null, - "indexed": 0 - } - }, - { - "constant": false, - "inputs": [ - { - "name": "transactionId", - "type": "uint256" - } - ], - "name": "confirmTransaction", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "__signatureData": { - "method": "confirmTransaction(uint256)", - "signature": "c01a8c8473427a14639d2bc8bef9d7b2742747740ed212950f4e530781dbdf5d", - "index": null, - "indexed": 0 - } - }, - { - "constant": false, - "inputs": [ - { - "name": "destination", - "type": "address" - }, - { - "name": "value", - "type": "uint256" - }, - { - "name": "data", - "type": "bytes" - } - ], - "name": "submitTransaction", - "outputs": [ - { - "name": "transactionId", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "__signatureData": { - "method": "submitTransaction(address,uint256,bytes)", - "signature": "c6427474ff2c4baa130d285c9d32ec41c0e07b9cc4b5b273ab66f916faee964a", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [], - "name": "MAX_OWNER_COUNT", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "MAX_OWNER_COUNT()", - "signature": "d74f8edde535768f1ff54c90926dc3dbf92d9a622a8bef11a7b8190467308d77", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [], - "name": "required", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "required()", - "signature": "dc8452cd18861a7926d01a29fd774a76d0fc4e57278afa13cbc91639fcd16e1f", - "index": null, - "indexed": 0 - } - }, - { - "constant": false, - "inputs": [ - { - "name": "owner", - "type": "address" - }, - { - "name": "newOwner", - "type": "address" - } - ], - "name": "replaceOwner", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "__signatureData": { - "method": "replaceOwner(address,address)", - "signature": "e20056e60a9f58b726b610d5a8e40f97e687707f2f9b3f9ccdaabe2ee85aa6d4", - "index": null, - "indexed": 0 - } - }, - { - "constant": false, - "inputs": [ - { - "name": "transactionId", - "type": "uint256" - } - ], - "name": "executeTransaction", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "__signatureData": { - "method": "executeTransaction(uint256)", - "signature": "ee22610b57af59171fe491c7d4d59b4d01c283e32b93b77db36266c6ad1b5877", - "index": null, - "indexed": 0 - } - }, - { - "inputs": [ - { - "name": "_owners", - "type": "address[]" - }, - { - "name": "_required", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "constructor", - "__signatureData": { - "method": null, - "signature": null, - "index": null, - "indexed": 0 - } - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "sender", - "type": "address" - }, - { - "indexed": true, - "name": "transactionId", - "type": "uint256" - } - ], - "name": "Confirmation", - "type": "event", - "__signatureData": { - "method": "Confirmation(address,uint256)", - "signature": "4a504a94899432a9846e1aa406dceb1bcfd538bb839071d49d1e5e23f5be30ef", - "index": [ - true, - true - ], - "indexed": 2 - } - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "sender", - "type": "address" - }, - { - "indexed": true, - "name": "transactionId", - "type": "uint256" - } - ], - "name": "Revocation", - "type": "event", - "__signatureData": { - "method": "Revocation(address,uint256)", - "signature": "f6a317157440607f36269043eb55f1287a5a19ba2216afeab88cd46cbcfb88e9", - "index": [ - true, - true - ], - "indexed": 2 - } - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "transactionId", - "type": "uint256" - } - ], - "name": "Submission", - "type": "event", - "__signatureData": { - "method": "Submission(uint256)", - "signature": "c0ba8fe4b176c1714197d43b9cc6bcf797a4a7461c5fe8d0ef6e184ae7601e51", - "index": [ - true - ], - "indexed": 1 - } - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "transactionId", - "type": "uint256" - } - ], - "name": "Execution", - "type": "event", - "__signatureData": { - "method": "Execution(uint256)", - "signature": "33e13ecb54c3076d8e8bb8c2881800a4d972b792045ffae98fdf46df365fed75", - "index": [ - true - ], - "indexed": 1 - } - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "transactionId", - "type": "uint256" - } - ], - "name": "ExecutionFailure", - "type": "event", - "__signatureData": { - "method": "ExecutionFailure(uint256)", - "signature": "526441bb6c1aba3c9a4a6ca1d6545da9c2333c8c48343ef398eb858d72b79236", - "index": [ - true - ], - "indexed": 1 - } - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "sender", - "type": "address" - }, - { - "indexed": false, - "name": "value", - "type": "uint256" - } - ], - "name": "Deposit", - "type": "event", - "__signatureData": { - "method": "Deposit(address,uint256)", - "signature": "e1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c", - "index": [ - true, - false - ], - "indexed": 1 - } - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "owner", - "type": "address" - } - ], - "name": "OwnerAddition", - "type": "event", - "__signatureData": { - "method": "OwnerAddition(address)", - "signature": "f39e6e1eb0edcf53c221607b54b00cd28f3196fed0a24994dc308b8f611b682d", - "index": [ - true - ], - "indexed": 1 - } - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "owner", - "type": "address" - } - ], - "name": "OwnerRemoval", - "type": "event", - "__signatureData": { - "method": "OwnerRemoval(address)", - "signature": "8001553a916ef2f495d26a907cc54d96ed840d7bda71e73194bf5a9df7a76b90", - "index": [ - true - ], - "indexed": 1 - } - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "required", - "type": "uint256" - } - ], - "name": "RequirementChange", - "type": "event", - "__signatureData": { - "method": "RequirementChange(uint256)", - "signature": "a3f1ee9126a074d9326c682f561767f710e927faa811f7a99829d49dc421797a", - "index": [ - false - ], - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [ - { - "name": "tokenId", - "type": "uint256" - } - ], - "name": "getApproved", - "outputs": [ - { - "name": "operator", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "getApproved(uint256)", - "signature": "081812fc55e34fdc7cf5d8b5cf4e3621fa6423fde952ec6ab24afdc0d85c0b2e", - "index": null, - "indexed": 0 - } - }, - { - "constant": false, - "inputs": [ - { - "name": "to", - "type": "address" - }, - { - "name": "tokenId", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "__signatureData": { - "method": "approve(address,uint256)", - "signature": "095ea7b334ae44009aa867bfb386f5c3b4b443ac6f0ee573fa91c4608fbadfba", - "index": null, - "indexed": 0 - } - }, - { - "constant": false, - "inputs": [ - { - "name": "from", - "type": "address" - }, - { - "name": "to", - "type": "address" - }, - { - "name": "tokenId", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "__signatureData": { - "method": "transferFrom(address,address,uint256)", - "signature": "23b872dd7302113369cda2901243429419bec145408fa8b352b3dd92b66c680b", - "index": null, - "indexed": 0 - } - }, - { - "constant": false, - "inputs": [ - { - "name": "from", - "type": "address" - }, - { - "name": "to", - "type": "address" - }, - { - "name": "tokenId", - "type": "uint256" - } - ], - "name": "safeTransferFrom", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "__signatureData": { - "method": "safeTransferFrom(address,address,uint256)", - "signature": "42842e0eb38857a7775b4e7364b2775df7325074d088e7fb39590cd6281184ed", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [ - { - "name": "tokenId", - "type": "uint256" - } - ], - "name": "ownerOf", - "outputs": [ - { - "name": "owner", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "ownerOf(uint256)", - "signature": "6352211e6566aa027e75ac9dbf2423197fbd9b82b9d981a3ab367d355866aa1c", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [ - { - "name": "owner", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "name": "balance", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "balanceOf(address)", - "signature": "70a08231b98ef4ca268c9cc3f6b4590e4bfec28280db06bb5d45e689f2a360be", - "index": null, - "indexed": 0 - } - }, - { - "constant": false, - "inputs": [ - { - "name": "operator", - "type": "address" - }, - { - "name": "_approved", - "type": "bool" - } - ], - "name": "setApprovalForAll", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "__signatureData": { - "method": "setApprovalForAll(address,bool)", - "signature": "a22cb4651ab9570f89bb516380c40ce76762284fb1f21337ceaf6adab99e7d4a", - "index": null, - "indexed": 0 - } - }, - { - "constant": false, - "inputs": [ - { - "name": "from", - "type": "address" - }, - { - "name": "to", - "type": "address" - }, - { - "name": "tokenId", - "type": "uint256" - }, - { - "name": "data", - "type": "bytes" - } - ], - "name": "safeTransferFrom", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "__signatureData": { - "method": "safeTransferFrom(address,address,uint256,bytes)", - "signature": "b88d4fde60196325a28bb7f99a2582e0b46de55b18761e960c14ad7a32099465", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [ - { - "name": "owner", - "type": "address" - }, - { - "name": "operator", - "type": "address" - } - ], - "name": "isApprovedForAll", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "isApprovedForAll(address,address)", - "signature": "e985e9c5c6636c6879256001057b28ccac7718ef0ac56553ff9b926452cab8a3", - "index": null, - "indexed": 0 - } - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "from", - "type": "address" - }, - { - "indexed": true, - "name": "to", - "type": "address" - }, - { - "indexed": true, - "name": "tokenId", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event", - "__signatureData": { - "method": "Transfer(address,address,uint256)", - "signature": "ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", - "index": [ - true, - true, - true - ], - "indexed": 3 - } - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "name": "approved", - "type": "address" - }, - { - "indexed": true, - "name": "tokenId", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event", - "__signatureData": { - "method": "Approval(address,address,uint256)", - "signature": "8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", - "index": [ - true, - true, - true - ], - "indexed": 3 - } - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "name": "operator", - "type": "address" - }, - { - "indexed": false, - "name": "approved", - "type": "bool" - } - ], - "name": "ApprovalForAll", - "type": "event", - "__signatureData": { - "method": "ApprovalForAll(address,address,bool)", - "signature": "17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31", - "index": [ - true, - true, - false - ], - "indexed": 2 - } - }, - { - "constant": true, - "inputs": [], - "name": "name", - "outputs": [ - { - "name": "", - "type": "string" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "name()", - "signature": "06fdde0383f15d582d1a74511486c9ddf862a882fb7904b3d9fe9b8b8e58a796", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [], - "name": "symbol", - "outputs": [ - { - "name": "", - "type": "string" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "symbol()", - "signature": "95d89b41e2f5f391a79ec54e9d87c79d6e777c63e32c28da95b4e9e4a79250ec", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [ - { - "name": "tokenId", - "type": "uint256" - } - ], - "name": "tokenURI", - "outputs": [ - { - "name": "", - "type": "string" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "tokenURI(uint256)", - "signature": "c87b56dda752230262935940d907f047a9f86bb5ee6aa33511fc86db33fea6cc", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "totalSupply()", - "signature": "18160ddd7f15c72528c2f94fd8dfe3c8d5aa26e2c50c7d81f4bc7bee8d4b7932", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [ - { - "name": "owner", - "type": "address" - }, - { - "name": "index", - "type": "uint256" - } - ], - "name": "tokenOfOwnerByIndex", - "outputs": [ - { - "name": "tokenId", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "tokenOfOwnerByIndex(address,uint256)", - "signature": "2f745c59a57ba1667616e5a9707eeaa36ec97c283ee24190b75d9c8d14bcb215", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [ - { - "name": "index", - "type": "uint256" - } - ], - "name": "tokenByIndex", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "tokenByIndex(uint256)", - "signature": "4f6ccce7c41aed90ec1f1887c4a821594c0f73758d8941d0ccaa2cde813b7298", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [ - { - "indexed": false, - "name": "_to", - "type": "address" - }, - { - "indexed": false, - "name": "_value", - "type": "uint256" - }, - { - "indexed": false, - "name": "_data", - "type": "bytes" - } - ], - "name": "transferAndCall", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "type": "function", - "__signatureData": { - "method": "transferAndCall(address,uint256,bytes)", - "signature": "4000aea038e4acde4ff65b413088ec658ae209bdf83ccba2ffbbaa2d9ce48cde", - "index": null, - "indexed": 0 - } - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "from", - "type": "address" - }, - { - "indexed": true, - "name": "to", - "type": "address" - }, - { - "indexed": false, - "name": "value", - "type": "uint256" - }, - { - "indexed": false, - "name": "data", - "type": "bytes" - } - ], - "name": "Transfer", - "type": "event", - "__signatureData": { - "method": "Transfer(address,address,uint256,bytes)", - "signature": "e19260aff97b920c7df27010903aeb9c8d2be5d310a2c67824cf3f15396e4c16", - "index": [ - true, - true, - false, - false - ], - "indexed": 2 - } - }, - { - "constant": false, - "inputs": [ - { - "name": "_spender", - "type": "address" - }, - { - "name": "_value", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "__signatureData": { - "method": "approve(address,uint256)", - "signature": "095ea7b334ae44009aa867bfb386f5c3b4b443ac6f0ee573fa91c4608fbadfba", - "index": null, - "indexed": 0 - } - }, - { - "constant": false, - "inputs": [ - { - "name": "_from", - "type": "address" - }, - { - "name": "_to", - "type": "address" - }, - { - "name": "_value", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "__signatureData": { - "method": "transferFrom(address,address,uint256)", - "signature": "23b872dd7302113369cda2901243429419bec145408fa8b352b3dd92b66c680b", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [], - "name": "decimals", - "outputs": [ - { - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "decimals()", - "signature": "313ce567add4d438edf58b94ff345d7d38c45b17dfc0f947988d7819dca364f9", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [ - { - "name": "_owner", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "name": "balance", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "balanceOf(address)", - "signature": "70a08231b98ef4ca268c9cc3f6b4590e4bfec28280db06bb5d45e689f2a360be", - "index": null, - "indexed": 0 - } - }, - { - "constant": false, - "inputs": [ - { - "name": "_to", - "type": "address" - }, - { - "name": "_value", - "type": "uint256" - } - ], - "name": "transfer", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function", - "__signatureData": { - "method": "transfer(address,uint256)", - "signature": "a9059cbb2ab09eb219583f4a59a5d0623ade346d962bcd4e46b11da047c9049b", - "index": null, - "indexed": 0 - } - }, - { - "constant": true, - "inputs": [ - { - "name": "_owner", - "type": "address" - }, - { - "name": "_spender", - "type": "address" - } - ], - "name": "allowance", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "allowance(address,address)", - "signature": "dd62ed3e90e97b3d417db9c0c7522647811bafca5afc6694f143588d255fdfb4", - "index": null, - "indexed": 0 - } - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "name": "value", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event", - "__signatureData": { - "method": "Approval(address,address,uint256)", - "signature": "8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", - "index": [ - true, - true, - false - ], - "indexed": 2 - } - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "from", - "type": "address" - }, - { - "indexed": true, - "name": "to", - "type": "address" - }, - { - "indexed": false, - "name": "value", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event", - "__signatureData": { - "method": "Transfer(address,address,uint256)", - "signature": "ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", - "index": [ - true, - true, - false - ], - "indexed": 2 - } - }, - { - "constant": true, - "inputs": [ - { - "name": "interfaceID", - "type": "bytes4" - } - ], - "name": "supportsInterface", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function", - "__signatureData": { - "method": "supportsInterface(bytes4)", - "signature": "01ffc9a7a5cef8baa21ed3c5c0d7e23accb804b619e9333b597f47a0d84076e2", - "index": null, - "indexed": 0 - } - } -] \ No newline at end of file diff --git a/dist/lib/ContractParser/interfacesIds.js b/dist/lib/ContractParser/interfacesIds.js deleted file mode 100644 index 53f61fd1..00000000 --- a/dist/lib/ContractParser/interfacesIds.js +++ /dev/null @@ -1,51 +0,0 @@ -"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default = exports.interfacesIds = void 0;var _lib = require("./lib"); - -const erc20methods = [ -'totalSupply()', -'balanceOf(address)', -'allowance(address,address)', -'transfer(address,uint256)', -'approve(address,uint256)', -'transferFrom(address,address,uint256)']; - - -const erc677Methods = erc20methods.concat([ -'transferAndCall(address,uint256,bytes)']); - - -const interfacesIds = { - ERC20: makeInterface(erc20methods), - ERC677: makeInterface(erc677Methods), - ERC165: makeInterface(['supportsInterface(bytes4)']), - ERC721: makeInterface([ - 'balanceOf(address)', - 'ownerOf(uint256)', - 'approve(address,uint256)', - 'getApproved(uint256)', - 'setApprovalForAll(address,bool)', - 'isApprovedForAll(address,address)', - 'transferFrom(address,address,uint256)', - 'safeTransferFrom(address,address,uint256)', - 'safeTransferFrom(address,address,uint256,bytes)']), - - ERC721Enumerable: makeInterface([ - 'totalSupply()', - 'tokenOfOwnerByIndex(address,uint256)', - 'tokenByIndex(uint256)']), - - ERC721Metadata: makeInterface([ - 'name()', - 'symbol()', - 'tokenURI(uint256)']), - - ERC721Exists: makeInterface([ - 'exists(uint256)']) };exports.interfacesIds = interfacesIds; - - - -function makeInterface(methods) { - let id = (0, _lib.erc165IdFromMethods)(methods); - return { methods, id }; -}var _default = - -interfacesIds;exports.default = _default; \ No newline at end of file diff --git a/dist/lib/ContractParser/jsonAbis/ERC165.json b/dist/lib/ContractParser/jsonAbis/ERC165.json deleted file mode 100644 index 0777c4df..00000000 --- a/dist/lib/ContractParser/jsonAbis/ERC165.json +++ /dev/null @@ -1,21 +0,0 @@ -[ - { - "constant": true, - "inputs": [ - { - "name": "interfaceID", - "type": "bytes4" - } - ], - "name": "supportsInterface", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - } -] diff --git a/dist/lib/ContractParser/jsonAbis/ERC20.json b/dist/lib/ContractParser/jsonAbis/ERC20.json deleted file mode 100644 index 405d6b36..00000000 --- a/dist/lib/ContractParser/jsonAbis/ERC20.json +++ /dev/null @@ -1,222 +0,0 @@ -[ - { - "constant": true, - "inputs": [], - "name": "name", - "outputs": [ - { - "name": "", - "type": "string" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "_spender", - "type": "address" - }, - { - "name": "_value", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "_from", - "type": "address" - }, - { - "name": "_to", - "type": "address" - }, - { - "name": "_value", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "decimals", - "outputs": [ - { - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "_owner", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "name": "balance", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "symbol", - "outputs": [ - { - "name": "", - "type": "string" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "_to", - "type": "address" - }, - { - "name": "_value", - "type": "uint256" - } - ], - "name": "transfer", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "_owner", - "type": "address" - }, - { - "name": "_spender", - "type": "address" - } - ], - "name": "allowance", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "payable": true, - "stateMutability": "payable", - "type": "fallback" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "name": "value", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "from", - "type": "address" - }, - { - "indexed": true, - "name": "to", - "type": "address" - }, - { - "indexed": false, - "name": "value", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - } -] diff --git a/dist/lib/ContractParser/jsonAbis/ERC677plusToErc20.json b/dist/lib/ContractParser/jsonAbis/ERC677plusToErc20.json deleted file mode 100644 index ff2083b7..00000000 --- a/dist/lib/ContractParser/jsonAbis/ERC677plusToErc20.json +++ /dev/null @@ -1,58 +0,0 @@ -[ - { - "constant": true, - "inputs": [ - { - "indexed": false, - "name": "_to", - "type": "address" - }, - { - "indexed": false, - "name": "_value", - "type": "uint256" - }, - { - "indexed": false, - "name": "_data", - "type": "bytes" - } - ], - "name": "transferAndCall", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "type": "function" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "from", - "type": "address" - }, - { - "indexed": true, - "name": "to", - "type": "address" - }, - { - "indexed": false, - "name": "value", - "type": "uint256" - }, - { - "indexed": false, - "name": "data", - "type": "bytes" - } - ], - "name": "Transfer", - "type": "event" - } -] \ No newline at end of file diff --git a/dist/lib/ContractParser/jsonAbis/ERC721.json b/dist/lib/ContractParser/jsonAbis/ERC721.json deleted file mode 100644 index 08eadd8b..00000000 --- a/dist/lib/ContractParser/jsonAbis/ERC721.json +++ /dev/null @@ -1,254 +0,0 @@ -[ - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "from", - "type": "address" - }, - { - "indexed": true, - "name": "to", - "type": "address" - }, - { - "indexed": true, - "name": "tokenId", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "name": "approved", - "type": "address" - }, - { - "indexed": true, - "name": "tokenId", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "name": "operator", - "type": "address" - }, - { - "indexed": false, - "name": "approved", - "type": "bool" - } - ], - "name": "ApprovalForAll", - "type": "event" - }, - { - "constant": true, - "inputs": [ - { - "name": "owner", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "name": "balance", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "tokenId", - "type": "uint256" - } - ], - "name": "ownerOf", - "outputs": [ - { - "name": "owner", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "to", - "type": "address" - }, - { - "name": "tokenId", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "tokenId", - "type": "uint256" - } - ], - "name": "getApproved", - "outputs": [ - { - "name": "operator", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "operator", - "type": "address" - }, - { - "name": "_approved", - "type": "bool" - } - ], - "name": "setApprovalForAll", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "owner", - "type": "address" - }, - { - "name": "operator", - "type": "address" - } - ], - "name": "isApprovedForAll", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "from", - "type": "address" - }, - { - "name": "to", - "type": "address" - }, - { - "name": "tokenId", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "from", - "type": "address" - }, - { - "name": "to", - "type": "address" - }, - { - "name": "tokenId", - "type": "uint256" - } - ], - "name": "safeTransferFrom", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "from", - "type": "address" - }, - { - "name": "to", - "type": "address" - }, - { - "name": "tokenId", - "type": "uint256" - }, - { - "name": "data", - "type": "bytes" - } - ], - "name": "safeTransferFrom", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - } -] \ No newline at end of file diff --git a/dist/lib/ContractParser/jsonAbis/ERC721Enumerable.json b/dist/lib/ContractParser/jsonAbis/ERC721Enumerable.json deleted file mode 100644 index 345082de..00000000 --- a/dist/lib/ContractParser/jsonAbis/ERC721Enumerable.json +++ /dev/null @@ -1,310 +0,0 @@ -[ - { - "constant": true, - "inputs": [ - { - "name": "tokenId", - "type": "uint256" - } - ], - "name": "getApproved", - "outputs": [ - { - "name": "operator", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "to", - "type": "address" - }, - { - "name": "tokenId", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "from", - "type": "address" - }, - { - "name": "to", - "type": "address" - }, - { - "name": "tokenId", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "from", - "type": "address" - }, - { - "name": "to", - "type": "address" - }, - { - "name": "tokenId", - "type": "uint256" - } - ], - "name": "safeTransferFrom", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "tokenId", - "type": "uint256" - } - ], - "name": "ownerOf", - "outputs": [ - { - "name": "owner", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "owner", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "name": "balance", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "operator", - "type": "address" - }, - { - "name": "_approved", - "type": "bool" - } - ], - "name": "setApprovalForAll", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "from", - "type": "address" - }, - { - "name": "to", - "type": "address" - }, - { - "name": "tokenId", - "type": "uint256" - }, - { - "name": "data", - "type": "bytes" - } - ], - "name": "safeTransferFrom", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "owner", - "type": "address" - }, - { - "name": "operator", - "type": "address" - } - ], - "name": "isApprovedForAll", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "from", - "type": "address" - }, - { - "indexed": true, - "name": "to", - "type": "address" - }, - { - "indexed": true, - "name": "tokenId", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "name": "approved", - "type": "address" - }, - { - "indexed": true, - "name": "tokenId", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "name": "operator", - "type": "address" - }, - { - "indexed": false, - "name": "approved", - "type": "bool" - } - ], - "name": "ApprovalForAll", - "type": "event" - }, - { - "constant": true, - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "owner", - "type": "address" - }, - { - "name": "index", - "type": "uint256" - } - ], - "name": "tokenOfOwnerByIndex", - "outputs": [ - { - "name": "tokenId", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "index", - "type": "uint256" - } - ], - "name": "tokenByIndex", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - } -] \ No newline at end of file diff --git a/dist/lib/ContractParser/jsonAbis/ERC721Metadata.json b/dist/lib/ContractParser/jsonAbis/ERC721Metadata.json deleted file mode 100644 index 37686c1d..00000000 --- a/dist/lib/ContractParser/jsonAbis/ERC721Metadata.json +++ /dev/null @@ -1,301 +0,0 @@ -[ - { - "constant": true, - "inputs": [ - { - "name": "tokenId", - "type": "uint256" - } - ], - "name": "getApproved", - "outputs": [ - { - "name": "operator", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "to", - "type": "address" - }, - { - "name": "tokenId", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "from", - "type": "address" - }, - { - "name": "to", - "type": "address" - }, - { - "name": "tokenId", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "from", - "type": "address" - }, - { - "name": "to", - "type": "address" - }, - { - "name": "tokenId", - "type": "uint256" - } - ], - "name": "safeTransferFrom", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "tokenId", - "type": "uint256" - } - ], - "name": "ownerOf", - "outputs": [ - { - "name": "owner", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "owner", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "name": "balance", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "operator", - "type": "address" - }, - { - "name": "_approved", - "type": "bool" - } - ], - "name": "setApprovalForAll", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "from", - "type": "address" - }, - { - "name": "to", - "type": "address" - }, - { - "name": "tokenId", - "type": "uint256" - }, - { - "name": "data", - "type": "bytes" - } - ], - "name": "safeTransferFrom", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "owner", - "type": "address" - }, - { - "name": "operator", - "type": "address" - } - ], - "name": "isApprovedForAll", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "from", - "type": "address" - }, - { - "indexed": true, - "name": "to", - "type": "address" - }, - { - "indexed": true, - "name": "tokenId", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "name": "approved", - "type": "address" - }, - { - "indexed": true, - "name": "tokenId", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "name": "operator", - "type": "address" - }, - { - "indexed": false, - "name": "approved", - "type": "bool" - } - ], - "name": "ApprovalForAll", - "type": "event" - }, - { - "constant": true, - "inputs": [], - "name": "name", - "outputs": [ - { - "name": "", - "type": "string" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "symbol", - "outputs": [ - { - "name": "", - "type": "string" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "tokenId", - "type": "uint256" - } - ], - "name": "tokenURI", - "outputs": [ - { - "name": "", - "type": "string" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - } -] \ No newline at end of file diff --git a/dist/lib/ContractParser/jsonAbis/GnosisWallet.json b/dist/lib/ContractParser/jsonAbis/GnosisWallet.json deleted file mode 100644 index 48d4a124..00000000 --- a/dist/lib/ContractParser/jsonAbis/GnosisWallet.json +++ /dev/null @@ -1,533 +0,0 @@ -[ - { - "constant": true, - "inputs": [ - { - "name": "", - "type": "uint256" - } - ], - "name": "owners", - "outputs": [ - { - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "owner", - "type": "address" - } - ], - "name": "removeOwner", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "transactionId", - "type": "uint256" - } - ], - "name": "revokeConfirmation", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "", - "type": "address" - } - ], - "name": "isOwner", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "", - "type": "uint256" - }, - { - "name": "", - "type": "address" - } - ], - "name": "confirmations", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "pending", - "type": "bool" - }, - { - "name": "executed", - "type": "bool" - } - ], - "name": "getTransactionCount", - "outputs": [ - { - "name": "count", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "owner", - "type": "address" - } - ], - "name": "addOwner", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "transactionId", - "type": "uint256" - } - ], - "name": "isConfirmed", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "transactionId", - "type": "uint256" - } - ], - "name": "getConfirmationCount", - "outputs": [ - { - "name": "count", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "", - "type": "uint256" - } - ], - "name": "transactions", - "outputs": [ - { - "name": "destination", - "type": "address" - }, - { - "name": "value", - "type": "uint256" - }, - { - "name": "data", - "type": "bytes" - }, - { - "name": "executed", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getOwners", - "outputs": [ - { - "name": "", - "type": "address[]" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "from", - "type": "uint256" - }, - { - "name": "to", - "type": "uint256" - }, - { - "name": "pending", - "type": "bool" - }, - { - "name": "executed", - "type": "bool" - } - ], - "name": "getTransactionIds", - "outputs": [ - { - "name": "_transactionIds", - "type": "uint256[]" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "transactionId", - "type": "uint256" - } - ], - "name": "getConfirmations", - "outputs": [ - { - "name": "_confirmations", - "type": "address[]" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "transactionCount", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "_required", - "type": "uint256" - } - ], - "name": "changeRequirement", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "transactionId", - "type": "uint256" - } - ], - "name": "confirmTransaction", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "destination", - "type": "address" - }, - { - "name": "value", - "type": "uint256" - }, - { - "name": "data", - "type": "bytes" - } - ], - "name": "submitTransaction", - "outputs": [ - { - "name": "transactionId", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "MAX_OWNER_COUNT", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "required", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "owner", - "type": "address" - }, - { - "name": "newOwner", - "type": "address" - } - ], - "name": "replaceOwner", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "transactionId", - "type": "uint256" - } - ], - "name": "executeTransaction", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "name": "_owners", - "type": "address[]" - }, - { - "name": "_required", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "payable": true, - "stateMutability": "payable", - "type": "fallback" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "sender", - "type": "address" - }, - { - "indexed": true, - "name": "transactionId", - "type": "uint256" - } - ], - "name": "Confirmation", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "sender", - "type": "address" - }, - { - "indexed": true, - "name": "transactionId", - "type": "uint256" - } - ], - "name": "Revocation", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "transactionId", - "type": "uint256" - } - ], - "name": "Submission", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "transactionId", - "type": "uint256" - } - ], - "name": "Execution", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "transactionId", - "type": "uint256" - } - ], - "name": "ExecutionFailure", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "sender", - "type": "address" - }, - { - "indexed": false, - "name": "value", - "type": "uint256" - } - ], - "name": "Deposit", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "owner", - "type": "address" - } - ], - "name": "OwnerAddition", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "owner", - "type": "address" - } - ], - "name": "OwnerRemoval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "required", - "type": "uint256" - } - ], - "name": "RequirementChange", - "type": "event" - } -] \ No newline at end of file diff --git a/dist/lib/ContractParser/jsonAbis/PoolBlockReward.json b/dist/lib/ContractParser/jsonAbis/PoolBlockReward.json deleted file mode 100644 index fa6686f3..00000000 --- a/dist/lib/ContractParser/jsonAbis/PoolBlockReward.json +++ /dev/null @@ -1,554 +0,0 @@ -[ - { - "constant": false, - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "owner", - "outputs": [ - { - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "isOwner", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "moneyToPayPerBlock", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "maxMiners", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "maxBlocksToPayPerCall", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "lastPaidBlock", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "name": "_blockInfoProvider", - "type": "address" - }, - { - "name": "_moneyToPayPerBlock", - "type": "uint256" - }, - { - "name": "_maxBlocksToPayPerCall", - "type": "uint256" - }, - { - "name": "_maxMiners", - "type": "uint256" - }, - { - "name": "_lockupInMonths", - "type": "uint256" - }, - { - "name": "_dateTimeContract", - "type": "address" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "payable": true, - "stateMutability": "payable", - "type": "fallback" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "miner", - "type": "address" - }, - { - "indexed": false, - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "name": "period", - "type": "uint256" - } - ], - "name": "PayToMiner", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "miner", - "type": "address" - }, - { - "indexed": false, - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "name": "period", - "type": "uint256" - } - ], - "name": "PayToMinerFailed", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "name": "period", - "type": "uint256" - } - ], - "name": "PayToMiners", - "type": "event" - }, - { - "anonymous": false, - "inputs": [], - "name": "DonationReceived", - "type": "event" - }, - { - "anonymous": false, - "inputs": [], - "name": "InsufficientBalance", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "from", - "type": "uint256" - }, - { - "indexed": false, - "name": "to", - "type": "uint256" - }, - { - "indexed": false, - "name": "totalBlocksCollected", - "type": "uint256" - } - ], - "name": "BlockRangeCollected", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "maxBlocks", - "type": "uint256" - } - ], - "name": "MaxBlocksToPayPerCallChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "payPerBlock", - "type": "uint256" - } - ], - "name": "MoneyToPayPerBlockChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "maxMiners", - "type": "uint256" - } - ], - "name": "MaxMinersChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "miner", - "type": "address" - }, - { - "indexed": false, - "name": "amount", - "type": "uint256" - }, - { - "indexed": false, - "name": "releasePeriod", - "type": "uint256" - } - ], - "name": "DepositedToMiner", - "type": "event" - }, - { - "anonymous": false, - "inputs": [], - "name": "SomethingIsWorkingWrong", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "from", - "type": "uint256" - }, - { - "indexed": false, - "name": "to", - "type": "uint256" - }, - { - "indexed": false, - "name": "totalBlocksSkipped", - "type": "uint256" - } - ], - "name": "SkipPayments", - "type": "event" - }, - { - "anonymous": false, - "inputs": [], - "name": "NothingToPay", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "blockNumber", - "type": "uint256" - }, - { - "indexed": false, - "name": "minerAddress", - "type": "address" - } - ], - "name": "CollectedBlock", - "type": "event" - }, - { - "anonymous": false, - "inputs": [], - "name": "NothingToCollect", - "type": "event" - }, - { - "constant": false, - "inputs": [ - { - "name": "_newMax", - "type": "uint256" - } - ], - "name": "setMaxBlocksToPayPerCall", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "_newPay", - "type": "uint256" - } - ], - "name": "setMoneyToPayPerBlock", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "_newMax", - "type": "uint256" - } - ], - "name": "setMaxMiners", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getBalance", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [], - "name": "collectProfits", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "addressMiner", - "type": "address" - } - ], - "name": "payToMiner", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": true, - "stateMutability": "payable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "addressMiner", - "type": "address" - }, - { - "name": "month", - "type": "uint8" - }, - { - "name": "year", - "type": "uint16" - } - ], - "name": "payToMinerInPeriod", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [], - "name": "payToMiners", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": true, - "stateMutability": "payable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "month", - "type": "uint8" - }, - { - "name": "year", - "type": "uint16" - } - ], - "name": "payToMinersInPeriod", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "minerAddress", - "type": "address" - } - ], - "name": "getBalanceForCurrentPeriod", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "minerAddress", - "type": "address" - }, - { - "name": "month", - "type": "uint8" - }, - { - "name": "year", - "type": "uint16" - } - ], - "name": "getBalanceForPeriod", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - } -] diff --git a/dist/lib/ContractParser/jsonAbis/eventTransferNotIndexed.json b/dist/lib/ContractParser/jsonAbis/eventTransferNotIndexed.json deleted file mode 100644 index 6f147b0b..00000000 --- a/dist/lib/ContractParser/jsonAbis/eventTransferNotIndexed.json +++ /dev/null @@ -1,24 +0,0 @@ -[ - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "from", - "type": "address" - }, - { - "indexed": false, - "name": "to", - "type": "address" - }, - { - "indexed": false, - "name": "value", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - } -] \ No newline at end of file diff --git a/dist/lib/ContractParser/jsonAbis/event_OwnershipTransfered.json b/dist/lib/ContractParser/jsonAbis/event_OwnershipTransfered.json deleted file mode 100644 index 20e9d5c3..00000000 --- a/dist/lib/ContractParser/jsonAbis/event_OwnershipTransfered.json +++ /dev/null @@ -1,19 +0,0 @@ -[ - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "from", - "type": "address" - }, - { - "indexed": true, - "name": "to", - "type": "address" - } - ], - "name": "OwnershipTransferred", - "type": "event" - } -] diff --git a/dist/lib/ContractParser/jsonAbis/method_ApproveAndCall.json b/dist/lib/ContractParser/jsonAbis/method_ApproveAndCall.json deleted file mode 100644 index 54477fc7..00000000 --- a/dist/lib/ContractParser/jsonAbis/method_ApproveAndCall.json +++ /dev/null @@ -1,28 +0,0 @@ -[ - { - "constant": false, - "inputs": [ - { - "name": "_spender", - "type": "address" - }, - { - "name": "_value", - "type": "uint256" - }, - { - "name": "_extraData", - "type": "bytes" - } - ], - "name": "approveAndCall", - "outputs": [ - { - "name": "success", - "type": "bool" - } - ], - "payable": false, - "type": "function" - } -] diff --git a/dist/lib/ContractParser/lib.js b/dist/lib/ContractParser/lib.js deleted file mode 100644 index ecf975d4..00000000 --- a/dist/lib/ContractParser/lib.js +++ /dev/null @@ -1,63 +0,0 @@ -"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.erc165IdFromMethods = exports.erc165Id = exports.addSignatureDataToAbi = exports.abiSignatureData = exports.getInputsIndexes = exports.removeAbiSignaureData = exports.solidityName = exports.soliditySelector = exports.soliditySignature = exports.abiMethods = exports.abiEvents = exports.setAbi = exports.INTERFACE_ID_BYTES = exports.ABI_SIGNATURE = void 0;var _utils = require("../utils"); - -const ABI_SIGNATURE = '__signatureData';exports.ABI_SIGNATURE = ABI_SIGNATURE; - -const INTERFACE_ID_BYTES = 4;exports.INTERFACE_ID_BYTES = INTERFACE_ID_BYTES; - -const setAbi = abi => addSignatureDataToAbi(abi, true);exports.setAbi = setAbi; - -const abiEvents = abi => abi.filter(v => v.type === 'event');exports.abiEvents = abiEvents; - -const abiMethods = abi => abi.filter(v => v.type === 'function');exports.abiMethods = abiMethods; - -const soliditySignature = name => (0, _utils.keccak256)(name);exports.soliditySignature = soliditySignature; - -const soliditySelector = signature => signature.slice(0, 8);exports.soliditySelector = soliditySelector; - -const solidityName = abi => { - let { name, inputs } = abi; - inputs = inputs ? inputs.map(i => i.type) : []; - return name ? `${name}(${inputs.join(',')})` : null; -};exports.solidityName = solidityName; - -const removeAbiSignaureData = abi => { - if (undefined !== abi[ABI_SIGNATURE]) delete abi[ABI_SIGNATURE]; - return abi; -};exports.removeAbiSignaureData = removeAbiSignaureData; - -const getInputsIndexes = abi => { - let { inputs } = abi; - return inputs && abi.type === 'event' ? inputs.map(i => i.indexed) : null; -};exports.getInputsIndexes = getInputsIndexes; - -const abiSignatureData = abi => { - let method = solidityName(abi); - let signature = method ? soliditySignature(method) : null; - let index = getInputsIndexes(abi); - let indexed = index ? index.filter(i => i === true).length : 0; - return { method, signature, index, indexed }; -};exports.abiSignatureData = abiSignatureData; - -const addSignatureDataToAbi = (abi, skip) => { - abi.map((value, i) => { - if (!value[ABI_SIGNATURE] || !skip) { - value[ABI_SIGNATURE] = abiSignatureData(value); - } - }); - return abi; -};exports.addSignatureDataToAbi = addSignatureDataToAbi; - -const erc165Id = selectors => { - let id = selectors.map(s => Buffer.from(s, 'hex')). - reduce((a, bytes) => { - for (let i = 0; i < INTERFACE_ID_BYTES; i++) { - a[i] = a[i] ^ bytes[i]; - } - return a; - }, Buffer.alloc(INTERFACE_ID_BYTES)); - return (0, _utils.add0x)(id.toString('hex')); -};exports.erc165Id = erc165Id; - -const erc165IdFromMethods = methods => { - return erc165Id(methods.map(m => soliditySelector(soliditySignature(m)))); -};exports.erc165IdFromMethods = erc165IdFromMethods; \ No newline at end of file diff --git a/dist/lib/Db.js b/dist/lib/Db.js index 71cb894f..c2e0c19a 100644 --- a/dist/lib/Db.js +++ b/dist/lib/Db.js @@ -1,5 +1,7 @@ "use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default = exports.Db = void 0;var _mongodb = require("mongodb"); + +const connectionOptions = { useNewUrlParser: true, useUnifiedTopology: true }; class Db { constructor(config) { config = config || {}; @@ -17,28 +19,37 @@ class Db { this.log = config.Logger || console; this.connect(); } - connect() { - if (!this.client) this.client = _mongodb.MongoClient.connect(this.url, { useNewUrlParser: true, useUnifiedTopology: true }); - return this.client; + async connect() { + try { + if (!this.client) { + this.client = await _mongodb.MongoClient.connect(this.url, connectionOptions); + } + return this.client; + } catch (err) { + return Promise.reject(err); + } } async db() { - let client = await this.connect(); - let db = await client.db(this.dbName); - return db; + try { + let client = await this.connect(); + let db = client.db(this.dbName); + return db; + } catch (err) { + return Promise.reject(err); + } } setLogger(log) { this.log = log; } - async createCollection(collectionName, indexes, options) { + async createCollection(collectionName, { indexes, options }, { dropIndexes, validate } = {}) { try { const db = await this.db(); if (!collectionName) throw new Error('Invalid collection name'); - let collection = db.collection(collectionName); - - if (options.dropIndexes) { + let collection = await db.createCollection(collectionName, options); + if (dropIndexes) { this.log.info(`Removing indexes from ${collectionName}`); await collection.dropIndexes(); } @@ -46,7 +57,7 @@ class Db { this.log.info(`Creating indexes to ${collectionName}`); await collection.createIndexes(indexes); } - if (options.validate) { + if (validate) { this.log.info(`Validating collection: ${collectionName}`); await db.admin().validateCollection(collectionName); } @@ -56,13 +67,12 @@ class Db { } } - createCollections(collections, options) { + createCollections(collections, creationOptions = {}) { let queue = []; - let names = options.names || {}; + let names = creationOptions.names || {}; for (let c in collections) { let name = names[c] || c; - let indexes = collections[c]; - queue.push(this.createCollection(name, indexes, options). + queue.push(this.createCollection(name, collections[c], creationOptions). then(collection => { this.log.info(`Created collection ${name}`); return collection; diff --git a/dist/lib/NativeContracts.js b/dist/lib/NativeContracts.js index c7b4160a..53238129 100644 --- a/dist/lib/NativeContracts.js +++ b/dist/lib/NativeContracts.js @@ -1,6 +1,5 @@ -"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.NativeContracts = NativeContracts;exports.default = void 0;function NativeContracts({ nativeContracts }) { - if (Object.keys(nativeContracts) < 1) throw new Error(`nativeContracts is empty`); - +"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.NativeContracts = NativeContracts;exports.default = void 0;function NativeContracts({ nativeContracts } = {}) { + if (!nativeContracts) return null; const names = Object.keys(nativeContracts); const getNativeContractAddress = contractName => { diff --git a/dist/lib/Setup.js b/dist/lib/Setup.js index 6c1edc56..95a45922 100644 --- a/dist/lib/Setup.js +++ b/dist/lib/Setup.js @@ -1,13 +1,21 @@ -"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.Setup = Setup;exports.default = exports.dataBase = void 0;var _collections = _interopRequireDefault(require("./collections")); +"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.getNetInfo = getNetInfo;exports.Setup = Setup;exports.default = exports.dataBase = void 0;var _collections = _interopRequireDefault(require("./collections")); var _config = _interopRequireDefault(require("./config")); var _Db = _interopRequireDefault(require("./Db.js")); var _StoredConfig = require("./StoredConfig"); var _nod3Connect = _interopRequireDefault(require("./nod3Connect")); -var _initialConfiguration = _interopRequireDefault(require("./initialConfiguration")); -var _NativeContracts = _interopRequireDefault(require("./NativeContracts"));function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} +var _initialConfiguration = _interopRequireDefault(require("./initialConfiguration"));function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} const dataBase = new _Db.default(_config.default.db);exports.dataBase = dataBase; +async function getNetInfo(nod3) { + try { + let net = await nod3.net.version(); + return net; + } catch (err) { + return Promise.reject(err); + } +} + async function Setup({ log } = {}) { log = log || console; dataBase.setLogger(log); @@ -16,7 +24,7 @@ async function Setup({ log } = {}) { const createCollections = async () => { const names = _config.default.collectionsNames; - const validate = _config.default.validateCollections; + const validate = _config.default.blocks.validateCollections; return dataBase.createCollections(_collections.default, { names, validate }); }; @@ -26,7 +34,7 @@ async function Setup({ log } = {}) { log.debug(err); throw new Error(`Cannot connect to the node`); }); - const net = await _nod3Connect.default.net.version(); + const net = await getNetInfo(_nod3Connect.default); return Object.assign(_initialConfiguration.default, { net }); } catch (err) { return Promise.reject(err); @@ -57,14 +65,13 @@ async function Setup({ log } = {}) { if (skipCheck) initConfig = await storedConfig.getConfig();else initConfig = await checkSetup(); if (!initConfig) throw new Error(`invalid init config, run checkSetup first`); - const nativeContracts = (0, _NativeContracts.default)(initConfig); - return { initConfig, db, nativeContracts }; + return { initConfig, db }; } catch (err) { log.error(err); process.exit(9); } }; - return Object.freeze({ start, createCollections, checkSetup }); + return Object.freeze({ start, createCollections, checkSetup, getInitConfig }); }var _default = Setup;exports.default = _default; \ No newline at end of file diff --git a/dist/lib/btcUtils.js b/dist/lib/btcUtils.js new file mode 100644 index 00000000..c31c8cbd --- /dev/null +++ b/dist/lib/btcUtils.js @@ -0,0 +1,51 @@ +"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.rskAddressFromBtcPublicKey = exports.compressPublic = exports.decompressPublic = exports.parsePublic = exports.pubToAddress = exports.h160toAddress = exports.h160 = exports.sha256 = void 0;var _crypto = _interopRequireDefault(require("crypto")); +var bs58 = _interopRequireWildcard(require("bs58")); +var _utils = require("./utils"); +var _secp256k = _interopRequireDefault(require("secp256k1"));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;}var cache = _getRequireWildcardCache();if (cache && cache.has(obj)) {return cache.get(obj);}var newObj = {};if (obj != null) {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 };} + +const PREFIXES = { + mainnet: { + pubKeyHash: '00', + scriptHash: '05' }, + + testnet: { + pubKeyHash: '6F', + scriptHash: 'C4' } }; + + +const getNetPrefix = netName => { + let prefixes = PREFIXES[netName]; + if (!prefixes) throw new Error(`Unknown network ${netName}`); + return prefixes; +}; + +const createHash = (a, val, from = 'hex', to = 'hex') => _crypto.default.createHash(a).update(val, from).digest(to); + +const sha256 = (val, from, to) => createHash('sha256', (0, _utils.remove0x)(val), from, to);exports.sha256 = sha256; + +const h160 = (val, from, to) => createHash('ripemd160', (0, _utils.remove0x)(val), from, to);exports.h160 = h160; + +const h160toAddress = (hash160, { network, prefixKey }) => { + network = network || 'mainnet'; + prefixKey = prefixKey || 'pubKeyHash'; + const prefix = getNetPrefix(network)[prefixKey]; + hash160 = Buffer.isBuffer(hash160) ? hash160.toString('hex') : (0, _utils.remove0x)(hash160); + hash160 = `${prefix}${hash160}`; + let check = sha256(sha256(hash160)).slice(0, 8); + return bs58.encode(Buffer.from(`${hash160}${check}`, 'hex')); +};exports.h160toAddress = h160toAddress; + +const pubToAddress = (pub, network) => { + return h160toAddress(h160(sha256((0, _utils.remove0x)(pub))), { network }); +};exports.pubToAddress = pubToAddress; + +const parsePublic = (pub, compressed) => { + pub = !Buffer.isBuffer(pub) ? Buffer.from((0, _utils.remove0x)(pub), 'hex') : pub; + return _secp256k.default.publicKeyConvert(pub, compressed); +};exports.parsePublic = parsePublic; + +const decompressPublic = compressed => parsePublic(compressed, false).toString('hex');exports.decompressPublic = decompressPublic; + +const compressPublic = pub => parsePublic(pub, true).toString('hex');exports.compressPublic = compressPublic; + +const rskAddressFromBtcPublicKey = cpk => (0, _utils.add0x)((0, _utils.keccak256)(parsePublic(cpk, false).slice(1)).slice(-40));exports.rskAddressFromBtcPublicKey = rskAddressFromBtcPublicKey; \ No newline at end of file diff --git a/dist/lib/collections.js b/dist/lib/collections.js index aabba622..f5a85fcf 100644 --- a/dist/lib/collections.js +++ b/dist/lib/collections.js @@ -1,209 +1,251 @@ "use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default = void 0;var _default = { - Config: [], - Blocks: [ - { - key: { number: -1 }, - unique: true, - name: 'blockNumber' }, + Config: { + indexes: [] }, - { - key: { hash: 1 }, - unique: true }, + Blocks: { + indexes: [ + { + key: { number: -1 }, + unique: true, + name: 'blockNumber' }, - { - key: { timestamp: -1 }, - name: 'blocksTimestamp' }, + { + key: { hash: 1 }, + unique: true }, - { - key: { miner: 1 }, - name: 'blocksMiner' }, + { + key: { timestamp: -1 }, + name: 'blocksTimestamp' }, - { - key: { txs: 1 }, - name: 'blocksTxs' }, + { + key: { miner: 1 }, + name: 'blocksMiner' }, - { - key: { size: 1 }, - name: 'blocksSize' }, + { + key: { txs: 1 }, + name: 'blocksTxs' }, - { - key: { _received: -1 }, - name: 'blockReceivedTime' }], + { + key: { size: 1 }, + name: 'blocksSize' }, + { + key: { _received: -1 }, + name: 'blockReceivedTime' }] }, - BlocksSummary: [ - { - key: { hash: 1 }, - unique: true }, - { - key: { number: -1 } }, - { - key: { timestamp: -1 } }], + BlocksSummary: { + indexes: [ + { + key: { hash: 1 }, + unique: true }, + { + key: { number: -1 } }, - Txs: [ - { - key: { hash: 1 }, - unique: true }, + { + key: { timestamp: -1 } }] }, - { - key: { blockNumber: -1 }, - name: 'txBlockNumberIndex' }, - { - key: { blockHash: 1 }, - name: 'txBlockHashIndex' }, - { - key: { timestamp: -1 }, - name: 'txTime' }, + Txs: { + indexes: [ + { + key: { txId: -1 }, + unique: true }, - { - key: { from: 1 }, - name: 'fromIndex' }, + { + key: { hash: 1 }, + unique: true }, - { - key: { to: 1 }, - name: 'toIndex' }, + { + key: { blockNumber: -1 }, + name: 'txBlockNumberIndex' }, - { - key: { txType: 1 }, - name: 'txTypeIndex' }], + { + key: { transactionIndex: -1 }, + name: 'txIndex' }, + { + key: { blockHash: 1 }, + name: 'txBlockHashIndex' }, - Addrs: [ - { - key: { address: 1 }, - unique: true }, + { + key: { timestamp: -1 }, + name: 'txTime' }, - { - key: { balance: 1 }, - name: 'balanceIndex' }, + { + key: { from: 1 }, + name: 'fromIndex' }, - { - key: { type: 1 }, - name: 'addTypeIndex' }, + { + key: { to: 1 }, + name: 'toIndex' }, - { - key: { name: 1 }, - name: 'addressNameIndex' }, + { + key: { txType: 1 }, + name: 'txTypeIndex' }] }, - { - key: { 'createdByTx.timestamp': -1 }, - name: 'contractCreated' }], - Status: [ - { - key: { timestamp: -1 }, - partialFilterExpression: { - timestamp: { $exists: true } } }], + Addrs: { + indexes: [ + { + key: { address: 1 }, + unique: true }, + { + key: { balance: 1 }, + name: 'balanceIndex' }, + { + key: { type: 1 }, + name: 'addTypeIndex' }, - Events: [ - { - key: { address: 1 }, - name: 'eventAddressIndex' }, + { + key: { name: 1 }, + name: 'addressNameIndex' }, - { - key: { event: 1 }, - name: 'eventEvIndex' }, + { + key: { 'createdByTx.timestamp': -1 }, + name: 'contractCreated' }] }, - { - key: { timestamp: 1 }, - name: 'eventTsIndex' }, - { - key: { blockNumber: 1 }, - name: 'eventBlockNumberIndex' }, - { - key: { txHash: 1 }, - name: 'eventTxHashIndex' }, + Status: { + options: { + capped: true, + size: 262144, + max: 100 }, - { - key: { blockHash: 1 }, - name: 'eventBlockHashIndex' }, + indexes: [ + { + key: { timestamp: -1 }, + partialFilterExpression: { + timestamp: { $exists: true } } }] }, - { - key: { args: 1 }, - name: 'eventsArgsIndex' }, - { - key: { signature: 1 }, - name: 'eventSignatureIndex' }], - TokensAddrs: [ - { - key: { - address: 1, - contract: 1 }, + Events: { + indexes: [ + { + key: { eventId: -1 }, + unique: true }, - unique: true }, + { + key: { address: 1 }, + name: 'eventAddressIndex' }, - { - key: { address: 1 }, - name: 'addressIndx' }, + { + key: { event: 1 }, + name: 'eventEvIndex' }, - { - key: { contract: 1 }, - name: 'contractIndx' }], + { + key: { timestamp: 1 }, + name: 'eventTsIndex' }, + { + key: { blockNumber: 1 }, + name: 'eventBlockNumberIndex' }, + { + key: { txHash: 1 }, + name: 'eventTxHashIndex' }, - OrphanBlocks: [ - { - key: { - hash: 1 }, + { + key: { blockHash: 1 }, + name: 'eventBlockHashIndex' }, - unique: true }], + { + key: { signature: 1 }, + name: 'eventSignatureIndex' }, + { + key: { _addresses: 1 }, + name: 'eventAddressesIndex' }] }, - TxPool: [ - { - key: { - timestamp: -1 } }], + TokensAddrs: { + indexes: [ + { + key: { + address: 1, + contract: 1 }, - PendingTxs: [ - { - key: { - hash: 1 }, + unique: true }, - unique: true }, + { + key: { address: 1 }, + name: 'addressIndx' }, - { - key: { from: 1 }, - name: 'pendingTxFrom' }, + { + key: { contract: 1 }, + name: 'contractIndx' }] }, - { - key: { to: 1 }, - name: 'pendingTxTo' }], - Stats: [ - { - key: { timestamp: 1 }, - name: 'statsTime' }, - { - key: { blockNumber: -1 }, - name: 'statsBlockNumber' }], + OrphanBlocks: { + indexes: [ + { + key: { + hash: 1 }, + unique: true }], - ContractVerification: [ - { - key: { address: 1 } }], + TxPool: [ + { + key: { + timestamp: -1 } }] }, - VerificationsResults: [ - { - key: { address: 1 } }, - { - key: { match: 1 } }] };exports.default = _default; \ No newline at end of file + + + PendingTxs: { + indexes: [ + { + key: { + hash: 1 }, + + unique: true }, + + { + key: { from: 1 }, + name: 'pendingTxFrom' }, + + { + key: { to: 1 }, + name: 'pendingTxTo' }] }, + + + + Stats: { + indexes: [ + { + key: { timestamp: 1 }, + name: 'statsTime' }, + + { + key: { blockNumber: -1 }, + name: 'statsBlockNumber' }] }, + + + + ContractVerification: { + indexes: [ + { + key: { address: 1 } }] }, + + + + VerificationsResults: { + indexes: [ + { + key: { address: 1 } }, + + { + key: { match: 1 } }] } };exports.default = _default; \ No newline at end of file diff --git a/dist/lib/config.js b/dist/lib/config.js index 948c2257..fc454c9e 100644 --- a/dist/lib/config.js +++ b/dist/lib/config.js @@ -1,52 +1,60 @@ -"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default = void 0;var _path = _interopRequireDefault(require("path")); +"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.createConfig = createConfig;exports.default = exports.config = void 0;var _path = _interopRequireDefault(require("path")); var _fs = _interopRequireDefault(require("fs")); var _defaultConfig = _interopRequireDefault(require("./defaultConfig"));function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} -const keys = Object.keys(_defaultConfig.default); -const config = loadConfig(); -for (let key of keys) { - config[key] = config[key] || _defaultConfig.default[key]; - for (let p in _defaultConfig.default[key]) { - if (undefined === config[key][p]) config[key][p] = _defaultConfig.default[key][p]; +const config = createConfig('../../config.json');exports.config = config; + +function createConfig(file) { + const defaultLogs = key => { + const dir = config.log.dir; + if (!dir) return; + config[key].log = config[key].log || {}; + config[key].log.file = config[key].log.file || `${dir}/${key}.json`; + config[key].log.level = config[key].log.level || config.log.level || 'info'; + }; + + const config = loadConfig(file); + const keys = Object.keys(_defaultConfig.default); + + for (let key of keys) { + config[key] = config[key] || _defaultConfig.default[key]; + for (let p in _defaultConfig.default[key]) { + if (undefined === config[key][p]) config[key][p] = _defaultConfig.default[key][p]; + } } -} - -// enable undefined modules -for (let module in _defaultConfig.default.api.modules) { - config.api.modules[module] = config.api.modules[module] !== false; -} -// defaults servers/ports + // enable undefined modules + for (let module in _defaultConfig.default.api.modules) { + config.api.modules[module] = config.api.modules[module] !== false; + } -config.blocks.node = config.blocks.node || config.source.node; -config.blocks.port = config.blocks.port || config.source.port; + // defaults servers/ports -let s = config.source; -config.source.url = config.source.url || `${s.protocol}://${s.node}:${s.port}`; + config.blocks.node = config.blocks.node || config.source.node; + config.blocks.port = config.blocks.port || config.source.port; -// defaults log files + let s = config.source; + config.source.url = config.source.url || `${s.protocol}://${s.node}:${s.port}`; -defaultLogs('api'); -defaultLogs('blocks'); + // defaults log files -config.api.collectionsNames = config.collectionsNames; + defaultLogs('api'); + defaultLogs('blocks'); -function defaultLogs(key) { - const dir = config.log.dir; - if (!dir) return; - config[key].log = config[key].log || {}; - config[key].log.file = config[key].log.file || `${dir}/${key}.json`; - config[key].log.level = config[key].log.level || config.log.level || 'info'; + config.api.collectionsNames = config.collectionsNames; + return config; } -function loadConfig() { +function loadConfig(file) { let config = {}; - try { - let file = _path.default.resolve(__dirname, '../../config.json'); - if (_fs.default.existsSync(file)) config = JSON.parse(_fs.default.readFileSync(file, 'utf-8')); - } catch (err) { - console.log(err); - process.exit(8); + if (file) { + try { + file = _path.default.resolve(__dirname, file); + if (_fs.default.existsSync(file)) config = JSON.parse(_fs.default.readFileSync(file, 'utf-8')); + } catch (err) { + console.log(err); + process.exit(8); + } } return config; }var _default = diff --git a/dist/lib/defaultConfig.js b/dist/lib/defaultConfig.js index 20e4f7cb..565e1073 100644 --- a/dist/lib/defaultConfig.js +++ b/dist/lib/defaultConfig.js @@ -59,7 +59,7 @@ reduce((a, v, i) => { OrphanBlocks: 'orphanBlocks', TxPool: 'txPool', PendingTxs: 'transactionsPending', - Stats: 'stats', + Stats: 'statsCollection', BlocksSummary: 'blocksSummary', ContractVerification: 'contractsVerifications', VerificationsResults: 'verificationResults' } };exports.default = _default; \ No newline at end of file diff --git a/dist/lib/types.js b/dist/lib/types.js index 8fcb7889..615be39e 100644 --- a/dist/lib/types.js +++ b/dist/lib/types.js @@ -1,4 +1,4 @@ -"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default = exports.EVMversions = exports.fields = exports.TOTAL_SUPPLY = exports.OBJECT_ID = exports.BIG_NUMBER = exports.MODULES = exports.actions = exports.events = exports.tokensInterfaces = exports.contractsInterfaces = exports.addrTypes = exports.errors = exports.txTypes = void 0;var _errors = require("../lib/errors"); +"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default = exports.bitcoinRskNetWorks = exports.bitcoinNetworks = exports.EVMversions = exports.fields = exports.TOTAL_SUPPLY = exports.OBJECT_ID = exports.BIG_NUMBER = exports.MODULES = exports.actions = exports.events = exports.tokensInterfaces = exports.contractsInterfaces = exports.addrTypes = exports.errors = exports.txTypes = void 0;var _errors = require("../lib/errors"); const txTypes = { default: 'normal', @@ -83,6 +83,16 @@ const EVMversions = [ 'spuriousDragon', 'byzantium', 'constantinople', -'petersburg'];exports.EVMversions = EVMversions;var _default = +'petersburg'];exports.EVMversions = EVMversions; + +const bitcoinNetworks = { + TESTNET: 'testnet', + MAINNET: 'mainnet' };exports.bitcoinNetworks = bitcoinNetworks; + + +const bitcoinRskNetWorks = { + 31: bitcoinNetworks.TESTNET, + 30: bitcoinNetworks.MAINNET };exports.bitcoinRskNetWorks = bitcoinRskNetWorks;var _default = + { txTypes, errors, addrTypes, contractsInterfaces };exports.default = _default; \ No newline at end of file diff --git a/dist/lib/utils.js b/dist/lib/utils.js index 6873c791..205464fe 100644 --- a/dist/lib/utils.js +++ b/dist/lib/utils.js @@ -1,44 +1,8 @@ -"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.isNullData = exports.sumDigits = exports.isBlockObject = exports.isValidBlockNumber = exports.jsonDecode = exports.jsonEncode = exports.keccak256 = exports.applyDecimals = exports.base64toHex = exports.btoa = exports.atob = exports.includesAll = exports.hasValue = exports.arraySymmetricDifference = exports.arrayDifference = exports.arrayIntersection = exports.getBestBlock = exports.blockQuery = exports.isBlockHash = exports.checkBlockHash = exports.serialize = exports.newBigNumber = exports.bigNumberDifference = exports.bigNumberSum = exports.bigNumberToSring = exports.unSerializeBigNumber = exports.isSerializedBigNumber = exports.serializeBigNumber = exports.isBigNumber = exports.bigNumberDoc = exports.isValidAddress = exports.isAddress = exports.remove0x = exports.add0x = exports.isHexString = void 0;var _bignumber = require("bignumber.js"); +"use strict";Object.defineProperty(exports, "__esModule", { value: true });var _exportNames = { bigNumberDoc: true, isBigNumber: true, serializeBigNumber: true, isSerializedBigNumber: true, unSerializeBigNumber: true, bigNumberToSring: true, bigNumberSum: true, bigNumberDifference: true, newBigNumber: true, isObj: true, serialize: true, checkBlockHash: true, isBlockHash: true, blockQuery: true, getBestBlock: true, applyDecimals: true, isValidBlockNumber: true, isBlockObject: true, toAscii: true };exports.toAscii = exports.isBlockObject = exports.isValidBlockNumber = exports.applyDecimals = exports.getBestBlock = exports.blockQuery = exports.isBlockHash = exports.checkBlockHash = exports.serialize = exports.isObj = exports.newBigNumber = exports.bigNumberDifference = exports.bigNumberSum = exports.bigNumberToSring = exports.unSerializeBigNumber = exports.isSerializedBigNumber = exports.serializeBigNumber = exports.isBigNumber = exports.bigNumberDoc = void 0;var _bignumber = require("bignumber.js"); var _types = require("./types"); var _mongodb = require("mongodb"); -var _keccak = _interopRequireDefault(require("keccak"));function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} - -const isHexString = str => { - str = str.substring(0, 2) === '0x' ? str.substring(2) : str; - return /^[0-9a-f]+$/i.test(str); -};exports.isHexString = isHexString; - -const add0x = str => { - let s = str; - let prefix = s[0] === '-' ? '-' : ''; - if (prefix) s = s.substring(prefix.length); - if (isHexString(s) && s.substring(0, 2) !== '0x') { - return `${prefix}0x${s}`; - } - return str; -};exports.add0x = add0x; - -const remove0x = value => { - if (!value) return value; - if (typeof value === 'object') return value; - if (typeof value === 'boolean') return value; - if (value === '0x') return ''; - let s = `${value}`; - let prefix = s[0] === '-' ? '-' : ''; - if (prefix) s = s.substring(prefix.length); - if (isHexString(s)) { - if (s.substring(0, 2) === '0x') return prefix + s.substr(2); - } - return value; -};exports.remove0x = remove0x; - -const isAddress = address => { - return /^(0x)?[0-9a-f]{40}$/i.test(address); -};exports.isAddress = isAddress; - -const isValidAddress = address => { - throw new Error('Not impemented'); -};exports.isValidAddress = isValidAddress; +var _rskUtils = require("rsk-utils"); +Object.keys(_rskUtils).forEach(function (key) {if (key === "default" || key === "__esModule") return;if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;Object.defineProperty(exports, key, { enumerable: true, get: function () {return _rskUtils[key];} });}); const bigNumberDoc = bigNumber => { return '0x' + bigNumber.toString(16); @@ -89,11 +53,8 @@ const bigNumberDifference = (a, b) => { const newBigNumber = value => isBigNumber(value) ? value : new _bignumber.BigNumber(value);exports.newBigNumber = newBigNumber; const isObj = value => { - if (undefined === value || value === null) return false; - let is = typeof value === 'object'; - is = is ? value instanceof Array === false : is; - return is; -}; + return !Array.isArray(value) && typeof value === 'object' && value !== null; +};exports.isObj = isObj; const serialize = obj => { if (typeof obj !== 'object') return obj; @@ -147,28 +108,6 @@ const getBestBlock = blocks => { return blocks[0]; };exports.getBestBlock = getBestBlock; -const arrayIntersection = (a, b) => a.filter(v => b.includes(v));exports.arrayIntersection = arrayIntersection; - -const arrayDifference = (a, b) => a.filter(x => !b.includes(x));exports.arrayDifference = arrayDifference; - -const arraySymmetricDifference = (a, b) => arrayDifference(a, b).concat(b.filter(x => !a.includes(x)));exports.arraySymmetricDifference = arraySymmetricDifference; - -const hasValue = (arr, search) => arrayIntersection(arr, search).length > 0;exports.hasValue = hasValue; - -const includesAll = (arr, search) => !search.map(t => arr.indexOf(t)).filter(i => i < 0).length;exports.includesAll = includesAll; - -const atob = str => Buffer.from(str, 'base64').toString('binary');exports.atob = atob; - -const btoa = base64 => Buffer.from(base64, 'binary').toString('base64');exports.btoa = btoa; - -const base64toHex = base64 => { - let raw = atob(base64); - return '0x' + [...new Array(raw.length)].map((c, i) => { - let h = raw.charCodeAt(i).toString(16); - return h.length === 2 ? h : `0${h}`; - }).join('').toLowerCase(); -};exports.base64toHex = base64toHex; - const applyDecimals = (value, decimals = 18) => { value = newBigNumber(value); const divisor = new _bignumber.BigNumber(10).exponentiatedBy(parseInt(decimals)); @@ -176,25 +115,13 @@ const applyDecimals = (value, decimals = 18) => { return result; };exports.applyDecimals = applyDecimals; -const keccak256 = (input, format = 'hex') => (0, _keccak.default)('keccak256').update(input).digest(format);exports.keccak256 = keccak256; - -const jsonEncode = value => btoa(JSON.stringify(value));exports.jsonEncode = jsonEncode; - -const jsonDecode = value => JSON.parse(atob(value));exports.jsonDecode = jsonDecode; - const isValidBlockNumber = number => parseInt(number) === number && number >= 0;exports.isValidBlockNumber = isValidBlockNumber; const isBlockObject = block => { if (typeof block !== 'object') return false; const { hash, number, transactions, miner } = block; if (!transactions) return false; - return isBlockHash(hash) && isAddress(miner) && isValidBlockNumber(number); + return isBlockHash(hash) && (0, _rskUtils.isAddress)(miner) && isValidBlockNumber(number); };exports.isBlockObject = isBlockObject; -const sumDigits = value => `${value}`.split('').map(Number).reduce((a, b) => a + b, 0);exports.sumDigits = sumDigits; - -const isNullData = value => { - const test = value && remove0x(value); - if (sumDigits(test) === 0) return true; - return test === '' ? true : !test; -};exports.isNullData = isNullData; \ No newline at end of file +const toAscii = hexString => (0, _rskUtils.toBuffer)((0, _rskUtils.remove0x)(hexString), 'hex').toString('ascii').replace(/\0/g, '');exports.toAscii = toAscii; \ No newline at end of file diff --git a/dist/lib/web3Connect.js b/dist/lib/web3Connect.js deleted file mode 100644 index a2742060..00000000 --- a/dist/lib/web3Connect.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default = exports.web3 = exports.web3Connect = void 0;var _web = _interopRequireDefault(require("web3")); -var _config = _interopRequireDefault(require("./config"));function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} -const url = _config.default.source.url; - -const web3Connect = url => { - return new _web.default( - new _web.default.providers.HttpProvider(url)); - -};exports.web3Connect = web3Connect; - -const web3 = web3Connect(url);exports.web3 = web3;var _default = - -web3;exports.default = _default; \ No newline at end of file diff --git a/dist/services/blocks/blocksRequester.js b/dist/services/blocks/blocksRequester.js index 4d500e29..e92475c1 100644 --- a/dist/services/blocks/blocksRequester.js +++ b/dist/services/blocks/blocksRequester.js @@ -6,10 +6,12 @@ var _dataSource = require("../../lib/dataSource"); var _Logger = _interopRequireDefault(require("../../lib/Logger")); var _config = _interopRequireDefault(require("../../lib/config"));function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} -const log = (0, _Logger.default)('Blocks', _config.default.blocks.log); +const config = Object.assign({}, _config.default.blocks); -(0, _dataSource.dataSource)().then(({ db, nativeContracts }) => { - let Requester = new _RequestBlocks.RequestBlocks(db, { log, nativeContracts }); +const log = (0, _Logger.default)('Blocks', config.log); + +(0, _dataSource.dataSource)().then(({ db, initConfig }) => { + let Requester = new _RequestBlocks.RequestBlocks(db, Object.assign(config, { log, initConfig })); const blocksCollection = Requester.collections.Blocks; Requester.updateStatus = function (state) { diff --git a/dist/services/blocks/index.js b/dist/services/blocks/index.js index 278655bb..4b177793 100644 --- a/dist/services/blocks/index.js +++ b/dist/services/blocks/index.js @@ -16,7 +16,8 @@ startBlocks(); async function startBlocks() { const setup = await (0, _Setup.default)({ log }); await setup.createCollections(); - const { db } = await setup.start(); + const { db, initConfig } = await setup.start(); + config.initConfig = initConfig; const Status = new _BlocksStatus.BlocksStatus(db, config); const Stats = new _BcStats.BcStats(db, config); const listenToMessage = (msg, service) => { diff --git a/dist/services/classes/Address.js b/dist/services/classes/Address.js index 582c6c79..613b4ff4 100644 --- a/dist/services/classes/Address.js +++ b/dist/services/classes/Address.js @@ -4,15 +4,16 @@ var _utils = require("../../lib/utils"); var _types = require("../../lib/types"); class Address extends _BcThing.BcThing { - constructor(address, { nod3, nativeContracts, db, collections, block = 'latest' } = {}) { - super({ nod3, nativeContracts, collections }); + constructor(address, { nod3, initConfig, db, collections, block = 'latest' } = {}) { + super({ nod3, initConfig, collections }); if (!this.isAddress(address)) throw new Error(`Invalid address: ${address}`); this.address = address; this.db = db || this.collections.Addrs; this.codeIsSaved = false; this.TxsBalance = new _GetTxBalance.GetTxBalance(this.collections.Txs); this.data = new Proxy( - { address, type: _types.addrTypes.ADDRESS }, { + { address, type: _types.addrTypes.ADDRESS }, + { set(obj, prop, val) { if (prop === 'code') { val = val || null; diff --git a/dist/services/classes/BcStats.js b/dist/services/classes/BcStats.js index d1f9cce5..42d500c6 100644 --- a/dist/services/classes/BcStats.js +++ b/dist/services/classes/BcStats.js @@ -1,4 +1,6 @@ "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"));function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} class BcStats extends _BlocksBase.BlocksBase { constructor(db, options) { @@ -7,6 +9,17 @@ class BcStats extends _BlocksBase.BlocksBase { this.stats = { blockHash: undefined, blockNumber: undefined }; } + async getCirculating() { + try { + const collection = this.collections.Addrs; + const { nativeContracts } = this.initConfig; + let circulating = await (0, _getCirculatingSupply.default)(collection, nativeContracts); + return circulating; + } catch (err) { + this.log.debug(err); + } + } + async getStats(blockHash, blockNumber) { try { if (undefined === blockHash || undefined === blockNumber) { @@ -15,9 +28,11 @@ class BcStats extends _BlocksBase.BlocksBase { blockNumber = block.number; } if (this.skip(blockHash, blockNumber)) return; - const hashRate = await this.nod3.eth.netHashrate(); + const hashrate = await this.nod3.eth.netHashrate(); + const circulating = await this.getCirculating(); + let activeAccounts = await (0, _getActiveAccounts.default)(this.collections); const timestamp = Date.now(); - return { hashRate, timestamp, blockHash, blockNumber }; + return Object.assign({}, { circulating, activeAccounts, hashrate, timestamp, blockHash, blockNumber }); } catch (err) { this.log.error(err); return Promise.reject(err); @@ -36,7 +51,7 @@ class BcStats extends _BlocksBase.BlocksBase { async save(stats) { try { - const result = this.collection.insertOne(stats); + const result = await this.collection.insertOne(stats); return result; } catch (err) { return Promise.reject(err); diff --git a/dist/services/classes/BcThing.js b/dist/services/classes/BcThing.js index 54869867..83110509 100644 --- a/dist/services/classes/BcThing.js +++ b/dist/services/classes/BcThing.js @@ -1,10 +1,13 @@ "use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default = exports._methodNotImplemented = exports.BcThing = void 0;var _utils = require("../../lib/utils"); +var _NativeContracts = _interopRequireDefault(require("../../lib/NativeContracts"));function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} class BcThing { - constructor({ nod3, nativeContracts, collections } = {}) { + constructor({ nod3, initConfig, collections } = {}) { + if (!initConfig) throw new Error('missing init config'); + this.initConfig = initConfig; this.nod3 = nod3; this.collections = collections; - this.nativeContracts = nativeContracts; + this.nativeContracts = (0, _NativeContracts.default)(initConfig); this.data = {}; } getData(serialize = false) { diff --git a/dist/services/classes/Block.js b/dist/services/classes/Block.js index 1b5557dd..2c09760b 100644 --- a/dist/services/classes/Block.js +++ b/dist/services/classes/Block.js @@ -6,8 +6,8 @@ var _utils = require("../../lib/utils"); var _ids = require("../../lib/ids");function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} class Block extends _BcThing.BcThing { - constructor(hashOrNumber, { nod3, nativeContracts, collections, log }) { - super({ nod3, nativeContracts, collections }); + constructor(hashOrNumber, { nod3, collections, log, initConfig }) { + super({ nod3, collections, initConfig }); this.Blocks = this.collections.Blocks; this.fetched = false; this.log = log || console; @@ -24,6 +24,7 @@ class Block extends _BcThing.BcThing { events: [] }; } + async fetch(forceFetch) { if (this.fetched && !forceFetch) { return Promise.resolve(this.getData()); @@ -34,12 +35,13 @@ class Block extends _BcThing.BcThing { return Promise.reject(new Error('nod3 is not connected')); } try { - let blockData = await this.getBlock(this.hashOrNumber); + let blockData = await this.getBlock(this.hashOrNumber, true); + const { transactions, timestamp } = blockData; + blockData.transactions = transactions.map(tx => tx.hash); this.data.block = blockData; this.addAddress(blockData.miner, blockData); - - let { transactions, timestamp } = blockData; - let txs = transactions.map(hash => new _Tx.default(hash, timestamp, this)); + const { nod3, initConfig } = this; + let txs = transactions.map(txData => new _Tx.default(txData.hash, timestamp, { txData, nod3, initConfig })); let txsData = await this.fetchItems(txs); this.data.txs = txsData.map(d => d.tx); this.data.txs.forEach(tx => this.addTxAddresses(tx)); @@ -120,7 +122,7 @@ class Block extends _BcThing.BcThing { // insert events await Promise.all( events.map(e => db.Events.updateOne( - { _id: e._id }, + { eventId: e.eventId }, { $set: e }, { upsert: true }))). then(res => {result.events = res;}); @@ -287,8 +289,8 @@ class Block extends _BcThing.BcThing { addAddress(address, block) { if (!this.isAddress(address) || this.addresses[address]) return; - let { nod3, collections, nativeContracts } = this; - const Addr = new _Address.default(address, { nativeContracts, collections, nod3, block }); + let { nod3, collections, initConfig } = this; + const Addr = new _Address.default(address, { initConfig, collections, nod3, block }); this.addresses[address] = Addr; } @@ -307,7 +309,8 @@ class Block extends _BcThing.BcThing { } newContract(address, data) { - let contract = new _Contract.default(address, data, this.nod3, this.nativeContracts); + const { nod3, initConfig } = this; + let contract = new _Contract.default(address, data, { nod3, initConfig }); this.contracts[address] = contract; return contract; } diff --git a/dist/services/classes/CheckBlocks.js b/dist/services/classes/CheckBlocks.js index 5a02b293..c98217c4 100644 --- a/dist/services/classes/CheckBlocks.js +++ b/dist/services/classes/CheckBlocks.js @@ -27,6 +27,7 @@ class CheckBlocks extends _BlocksBase.BlocksBase { async checkDb(checkOrphans, lastBlock, firstBlock) { if (!lastBlock || !lastBlock.number) lastBlock = await this.getHighDbBlock(); + if (!lastBlock) return; lastBlock = lastBlock.number; let blocks = await this.countDbBlocks(); diff --git a/dist/services/classes/Contract.js b/dist/services/classes/Contract.js index 59aa408f..0ebb4563 100644 --- a/dist/services/classes/Contract.js +++ b/dist/services/classes/Contract.js @@ -1,14 +1,14 @@ "use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default = void 0;var _BcThing = require("./BcThing"); -var _ContractParser = _interopRequireDefault(require("../../lib/ContractParser/ContractParser")); +var _rskContractParser = _interopRequireDefault(require("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 };} class Contract extends _BcThing.BcThing { - constructor(address, creationData, nod3, nativeContracts) { - super({ nod3, nativeContracts }); + constructor(address, creationData, { nod3, initConfig }) { + super({ nod3, initConfig }); if (!this.isAddress(address)) throw new Error(`Contract: invalid address ${address}`); - this.parser = new _ContractParser.default({ nativeContracts }); + this.parser = new _rskContractParser.default({ initConfig, nod3 }); this.address = address; this.creationData = creationData; const createdByTx = creationData && creationData.tx ? creationData.tx : null; diff --git a/dist/services/classes/Event.js b/dist/services/classes/Event.js index b0986247..e67f61b6 100644 --- a/dist/services/classes/Event.js +++ b/dist/services/classes/Event.js @@ -3,7 +3,6 @@ const formatEvent = (event, tx) => { let { timestamp, receipt } = tx; let id = (0, _ids.eventId)(event, tx); - event._id = id; event.eventId = id; event.timestamp = timestamp; event.txStatus = receipt.status; diff --git a/dist/services/classes/RequestBlocks.js b/dist/services/classes/RequestBlocks.js index 044d868a..7dba54b0 100644 --- a/dist/services/classes/RequestBlocks.js +++ b/dist/services/classes/RequestBlocks.js @@ -9,8 +9,8 @@ class Emitter extends _events.EventEmitter {} class RequestBlocks extends _BlocksBase.BlocksBase { constructor(db, options) { - let { nativeContracts, log } = options; - super(db, { nativeContracts, log }); + let { log, initConfig } = options; + super(db, { log, initConfig }); this.queueSize = options.blocksQueueSize || 50; this.pending = new Set(); this.requested = new Map(); @@ -90,8 +90,8 @@ class RequestBlocks extends _BlocksBase.BlocksBase { this.log.debug(`${hashOrNumber}: ${hash}`); } hash = hash || hashOrNumber; - const { nod3, collections, log, nativeContracts } = this; - let block = await getBlock(hash, { nod3, collections, log, nativeContracts }); + const { nod3, collections, log, initConfig } = this; + let block = await getBlock(hash, { nod3, collections, log, initConfig }); return block; } catch (err) { return Promise.reject(err); @@ -133,13 +133,13 @@ class RequestBlocks extends _BlocksBase.BlocksBase { }}exports.RequestBlocks = RequestBlocks; -async function getBlock(hashOrNumber, { nod3, collections, log, nativeContracts }) { +async function getBlock(hashOrNumber, { nod3, collections, log, initConfig }) { if ((0, _utils.isBlockHash)(hashOrNumber)) { let block = await (0, _Block.getBlockFromDb)(hashOrNumber, collections.Blocks); if (block) return { block, key: hashOrNumber }; } try { - let newBlock = new _Block.Block(hashOrNumber, { nod3, collections, log, nativeContracts }); + let newBlock = new _Block.Block(hashOrNumber, { nod3, collections, log, initConfig }); let block = await newBlock.save().then(res => { if (!res || !res.data) return; return res.data.block; diff --git a/dist/services/classes/TokenAddress.js b/dist/services/classes/TokenAddress.js index 9d60fb8a..0dd7596e 100644 --- a/dist/services/classes/TokenAddress.js +++ b/dist/services/classes/TokenAddress.js @@ -3,10 +3,11 @@ var _Contract = _interopRequireDefault(require("./Contract"));function _interopR class TokenAddress extends _BcThing.BcThing { constructor(address, contract) { - super(); if (!(contract instanceof _Contract.default)) { throw new Error('contract is not instance of Contract'); } + const { initConfig } = contract; + super({ initConfig }); if (!this.isAddress(address)) { throw new Error(`TokenAddress: invalid address: ${address}`); } diff --git a/dist/services/classes/Tx.js b/dist/services/classes/Tx.js index 2642a05c..7d4dcae9 100644 --- a/dist/services/classes/Tx.js +++ b/dist/services/classes/Tx.js @@ -1,16 +1,17 @@ "use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default = exports.Tx = void 0;var _BcThing = require("./BcThing"); var _Event = require("./Event"); -var _ContractParser = _interopRequireDefault(require("../../lib/ContractParser/ContractParser")); +var _rskContractParser = _interopRequireDefault(require("rsk-contract-parser")); var _types = require("../../lib/types"); var _ids = require("../../lib/ids"); var _utils = require("../../lib/utils");function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} class Tx extends _BcThing.BcThing { - constructor(hash, timestamp, { nod3, nativeContracts } = {}) { + constructor(hash, timestamp, { txData, nod3, initConfig } = {}) { if (!hash || !timestamp) throw new Error(`Tx, missing arguments`); - super({ nod3, nativeContracts }); + super({ nod3, initConfig }); this.hash = hash; this.timestamp = timestamp; - this.contractParser = new _ContractParser.default({ nativeContracts }); + this.contractParser = new _rskContractParser.default({ initConfig, nod3 }); + this.txData = txData; } async fetch() { try { @@ -21,12 +22,14 @@ class Tx extends _BcThing.BcThing { } catch (err) { return Promise.reject(err); } + } async getTx() { try { let txHash = this.hash; - let tx = await this.getTransactionByHash(txHash); + let tx = this.txData; + if (!this.isTxData(tx)) tx = await this.getTransactionByHash(txHash); if (tx.hash !== txHash) throw new Error(`Error getting tx: ${txHash}, hash received:${tx.hash}`); let receipt = await this.getTxReceipt(txHash); if (!receipt) throw new Error(`The Tx ${txHash} .receipt is: ${receipt} `); @@ -49,12 +52,11 @@ class Tx extends _BcThing.BcThing { } async parseEvents(tx) { try { - let topics = await this.parseLogs(tx.receipt.logs); - return topics.map(topic => { - topic = (0, _Event.formatEvent)(topic, tx); - let event = Object.assign({}, topic); - delete event.eventId; - delete topic._id; + let logs = await this.parseLogs(tx.receipt.logs); + return logs.map(l => { + l = (0, _Event.formatEvent)(l, tx); + let event = Object.assign({}, l); + delete l._id; return event; }); } catch (err) { @@ -68,7 +70,7 @@ class Tx extends _BcThing.BcThing { let nativeType = _types.txTypes[toIsNative]; if (nativeType) tx.txType = nativeType; if ((0, _utils.isAddress)(receipt.contractAddress)) tx.txType = _types.txTypes.contract; - tx._id = (0, _ids.getTxOrEventId)(tx); + tx.txId = (0, _ids.getTxOrEventId)(tx); return tx; } @@ -77,6 +79,10 @@ class Tx extends _BcThing.BcThing { return new Promise((resolve, reject) => { process.nextTick(() => resolve(parser.parseTxLogs(logs))); }); + } + isTxData(data) { + if (!data || typeof data !== 'object') return; + return data.hash && data.blockHash && data.input; }}exports.Tx = Tx;var _default = diff --git a/dist/services/userEvents/AddressModule.js b/dist/services/userEvents/AddressModule.js index 122ebccd..d2a8f80c 100644 --- a/dist/services/userEvents/AddressModule.js +++ b/dist/services/userEvents/AddressModule.js @@ -2,7 +2,7 @@ var _nod3Connect = _interopRequireDefault(require("../../lib/nod3Connect")); var _Address = _interopRequireDefault(require("../classes/Address"));function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} -function AddressModule({ db, collections, nativeContracts, log }) { +function AddressModule({ db, collections, initConfig, log }) { log = log || console; const updateAddress = async ({ msg, cache }, { address }) => { @@ -14,7 +14,7 @@ function AddressModule({ db, collections, nativeContracts, log }) { msg.data = cached; return msg; } else { - const Addr = new _Address.default(address, { nativeContracts, nod3: _nod3Connect.default, collections }); + const Addr = new _Address.default(address, { initConfig, nod3: _nod3Connect.default, collections }); let result = await Addr.fetch().catch(err => { log.error(err); msg.error = _types.errors.TEMPORARILY_UNAVAILABLE; @@ -25,9 +25,9 @@ function AddressModule({ db, collections, nativeContracts, log }) { const newBalance = result.balance ? result.balance.toString() : 0; const dbData = Addr.dbData || {}; const { balance, txBalance } = dbData; - if (newBalance > 0 || balance) { + const code = dbData.code || Addr.data.code; + if (newBalance > 0 || balance || code) { if (!parseInt(txBalance)) await Addr.updateTxBalance(); - await Addr.save().catch(err => { log.error(`Error saving address ${address}, ${err}`); return msg; diff --git a/dist/services/userEvents/userEventsService.js b/dist/services/userEvents/userEventsService.js index 6fb6129d..a9b31376 100644 --- a/dist/services/userEvents/userEventsService.js +++ b/dist/services/userEvents/userEventsService.js @@ -11,12 +11,12 @@ var _types = require("../../lib/types");function _interopRequireDefault(obj) {re const log = (0, _Logger.default)('UserRequests', _config.default.blocks.log); const verifierConfig = _config.default.api.contractVerifier; -(0, _dataSource.default)({ log, skipCheck: true }).then(({ db, nativeContracts }) => { +(0, _dataSource.default)({ log, skipCheck: true }).then(({ db, initConfig }) => { const collections = (0, _blocksCollections.getDbBlocksCollections)(db); const cache = new _RequestCache.RequestCache(); // TODO, conditional creation const verifierModule = (0, _ContractVerifierModule.default)(db, collections, verifierConfig, { log }); - const addressModule = (0, _AddressModule.default)({ db, collections, nativeContracts, log }); + const addressModule = (0, _AddressModule.default)({ db, collections, initConfig, log }); process.on('message', async msg => { try { diff --git a/dist/tools/checkDbBlocks.js b/dist/tools/checkDbBlocks.js index 2ca5d834..fc1468a6 100644 --- a/dist/tools/checkDbBlocks.js +++ b/dist/tools/checkDbBlocks.js @@ -1,15 +1,13 @@ "use strict";var _dataSource = _interopRequireDefault(require("../lib/dataSource.js")); -var _config = _interopRequireDefault(require("../lib/config")); +var _blocksCollections = require("../lib/blocksCollections"); var _fs = _interopRequireDefault(require("fs")); var _util = _interopRequireDefault(require("util")); var _CheckBlocks = require("../services/classes/CheckBlocks");function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} -const config = Object.assign({}, _config.default.blocks); const writeFile = _util.default.promisify(_fs.default.writeFile); const outFile = process.argv[2] || '/tmp/blocksLog.json'; (0, _dataSource.default)({ skipCheck: true }).then(async ({ db }) => { try { - const Blocks = db.collection(config.collections.Blocks); - const Txs = db.collection(config.collections.Txs); + const { Blocks, Txs } = (0, _blocksCollections.getDbBlocksCollections)(db); console.log('Getting blocks....'); let res = await (0, _CheckBlocks.checkBlocksCongruence)(Blocks); res.missingTxs = await (0, _CheckBlocks.checkBlocksTransactions)(Blocks, Txs); diff --git a/dist/tools/getBlock.js b/dist/tools/getBlock.js index 9eb918ec..f497e6b1 100644 --- a/dist/tools/getBlock.js +++ b/dist/tools/getBlock.js @@ -9,9 +9,9 @@ const opt = process.argv[3]; const save = opt === '--save'; const json = opt === '--json'; if (!hashOrNumber) help(); -(0, _dataSource.default)().then(({ db, nativeContracts }) => { +(0, _dataSource.default)().then(({ db, initConfig }) => { if (!json) (0, _cli.info)(`Getting block ${hashOrNumber}`); - getBlock(hashOrNumber, { db, nativeContracts }).then(block => { + 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 })); @@ -23,11 +23,11 @@ if (!hashOrNumber) help(); }); }); -async function getBlock(hashOrNumber, { db, nativeContracts }) { +async function getBlock(hashOrNumber, { db, initConfig }) { try { let time = getTime(); let saved = null; - let block = new _Block.default(hashOrNumber, new _BlocksBase.default(db, { nativeContracts })); + let block = new _Block.default(hashOrNumber, new _BlocksBase.default(db, { initConfig })); await block.fetch(); let blockData = block.getData(true); time = getTime(time); diff --git a/dist/tools/updateContractAccounts.js b/dist/tools/updateContractAccounts.js deleted file mode 100644 index 872ca3d4..00000000 --- a/dist/tools/updateContractAccounts.js +++ /dev/null @@ -1,57 +0,0 @@ -"use strict";var _Contract = _interopRequireDefault(require("../services/classes/Contract")); -var _nod3Connect = _interopRequireDefault(require("../lib/nod3Connect")); -var _bignumber = _interopRequireDefault(require("bignumber.js")); -var _utils = require("../lib/utils"); -var _dataSource = _interopRequireDefault(require("../lib/dataSource")); -var _cli = require("../lib/cli");function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} - -const contractAddress = process.argv[2]; -if (!(0, _utils.isAddress)(contractAddress)) help(); - -const contract = new _Contract.default(contractAddress, null, _nod3Connect.default); - -(0, _dataSource.default)().then(async ({ db }) => { - const collection = db.collection('tokensAddresses'); - let accounts = await collection.find({ contract: contractAddress }).toArray(); - let { errors, totalDiff } = await updateBalances(accounts, collection); - if (errors) { - (0, _cli.warn)(`Total Diff: ${totalDiff}`); - (0, _cli.error)(JSON.stringify(errors, null, 2)); - } - process.exit(0); -}); - -async function updateBalances(accounts, collection) { - const errors = []; - const total = accounts.length; - let result = {}; - for (let i = 0; i < total; i++) { - let account = accounts[i]; - let { address, balance } = account; - let msg = `${i + 1}/${total} ${address} `; - let Address = contract.addAddress(address); - let newBalance = await Address.getBalance(); - newBalance = (0, _utils.add0x)(newBalance.toString(16)); - if (balance !== newBalance) { - let difference = (0, _utils.add0x)(new _bignumber.default(newBalance).minus(new _bignumber.default(balance)).toString(16)); - const error = { address, balance, newBalance, difference }; - (0, _cli.warn)(`ERROR: ${msg}`); - (0, _cli.warn)(`${JSON.stringify(error, null, 2)}`); - errors.push(error); - await collection.updateOne({ address, contract: contractAddress }, { $set: { balance: newBalance } }); - } else { - (0, _cli.info)(msg); - } - } - if (errors.length) { - let totalDiff = (0, _utils.bigNumberSum)(errors.map(error => error.difference)).toString(16); - result = { errors, totalDiff }; - } - return result; -} - -function help() { - const myName = process.argv[1].split('/').pop(); - (0, _cli.info)(`Usage: ${process.argv[0]} ${myName} [address]`); - process.exit(0); -} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 629a772d..bb8c6946 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "rsk-explorer-api", - "version": "1.0.2", + "version": "1.0.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index a4064a3f..c1d273e6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rsk-explorer-api", - "version": "1.0.2", + "version": "1.0.3", "description": "", "main": "index.js", "scripts": { diff --git a/public/swagger.json b/public/swagger.json index eebd8dd4..62811b7f 100644 --- a/public/swagger.json +++ b/public/swagger.json @@ -362,6 +362,122 @@ } } }, + "/api?module=contractVerifier&action=verify": { + "get": { + "description": "Verify contract source", + "tags": [ + "contract verifier" + ], + "parameters": [ + { + "name": "request", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/definitions/Response" + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + } + } + } + }, + "/api?module=contractVerifier&action=getSolcVersions": { + "get": { + "description": "Gets solidity compiler versions", + "tags": [ + "contract verifier" + ], + "responses": { + "200": { + "$ref": "#/definitions/Response" + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + } + } + } + }, + "/api?module=contractVerifier&action=getEvmVersions": { + "get": { + "description": "Gets evm versions", + "tags": [ + "contract verifier" + ], + "responses": { + "200": { + "$ref": "#/definitions/Response" + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + } + } + } + }, + "/api?module=contractVerifier&action=getVersificationResult": { + "get": { + "description": "Gets the result of source code verification", + "tags": [ + "contract verifier" + ], + "parameters": [ + { + "name": "id", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/definitions/Response" + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + } + } + } + }, + "/api?module=contractVerifier&action=isVerified": { + "get": { + "description": "Checks if a contract was verified", + "tags": [ + "contract verifier" + ], + "parameters": [ + { + "name": "address", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/definitions/Response" + }, + "400": { + "$ref": "#/responses/BadRequest" + }, + "404": { + "$ref": "#/responses/NotFound" + } + } + } + }, "/api?module=events&action=getEvent": { "get": { "description": "get event data", @@ -386,7 +502,7 @@ ] }, { - "name": "_id", + "name": "eventId", "in": "query", "schema": { "type": "string" @@ -1317,6 +1433,14 @@ }, "next": { "type": "string" + }, + "fields": { + "type": { + "oneOf": [ + "array", + "object" + ] + } } } }