diff --git a/README.md b/README.md index 07cc9b4ffe..1250263998 100644 --- a/README.md +++ b/README.md @@ -22,19 +22,18 @@ Lisk Service comprises of multiple microservices that can operate independently Every microservice is independently managed and placed in a separate directory under the [`services`](services) directory. They contain their own `package.json` and `Dockerfile` that are beneficial when running the applications. - -| Service | Description | -| --------------------------------------------------------- | ----------- | -| [Gateway](services/gateway) | The Gateway exposes the API for Lisk Service users to access and use over HTTP and WS protocols. Its main purpose is to proxy API requests from users to the concerned Lisk Service microservices. It provides the users with a central point of data access that ensures existing application compatibility. | -| [Connector](services/blockchain-connector) | The Blockchain Connector connects with the node running a Lisk protocol-compliant blockchain application. It is primarily responsible for data transformation and caching, thus reducing the number of calls made to the node. | -| [Coordinator](services/blockchain-coordinator) | The Blockchain Coordinator service is primarily responsible for ensuring the completeness of the index. It performs periodic checks for any gaps in the index and schedules tasks to update it, along with the latest block updates. | +| Service | Description | +| --------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| [Gateway](services/gateway) | The Gateway exposes the API for Lisk Service users to access and use over HTTP and WS protocols. Its main purpose is to proxy API requests from users to the concerned Lisk Service microservices. It provides the users with a central point of data access that ensures existing application compatibility. | +| [Connector](services/blockchain-connector) | The Blockchain Connector connects with the node running a Lisk protocol-compliant blockchain application. It is primarily responsible for data transformation and caching, thus reducing the number of calls made to the node. | +| [Coordinator](services/blockchain-coordinator) | The Blockchain Coordinator service is primarily responsible for ensuring the completeness of the index. It performs periodic checks for any gaps in the index and schedules tasks to update it, along with the latest block updates. | | [Indexer](services/blockchain-indexer) | The Blockchain Indexer service, in the indexing mode, is primarily responsible to update the index, based on the scheduled jobs by the Blockchain Coordinator. In the data service mode, it serves user request queries made via the RESTful API or WebSocket-based RPC calls. It can run both the indexer and data service modes simultaneously, which is enabled by default. | -| [App Registry](services/blockchain-app-registry) | The Blockchain Application Registry service is primarily responsible for regularly synchronizing and providing off-chain metadata information for known blockchain applications in the Lisk ecosystem. The metadata is maintained in the Lisk [Application Registry](https://github.com/LiskHQ/app-registry) repository. | -| [Fee Estimator](services/fee-estimator) | The Fee Estimator service implements the [dynamic fee system](https://github.com/LiskHQ/lips/blob/main/proposals/lip-0013.md) algorithm to offer users transaction fee recommendations based on the network traffic. | -| [Transaction Statistics](services/transaction-statistics) | The Transaction Statistics service, as the name suggests, is primarily responsible to compute various transaction statistics to offer users various real-time network insights. | -| [Market](services/market) | The Market service allows price data retrieval. It supports multiple sources to keep the current Lisk token price up-to-date and available to the clients in real time. | -| [Export](services/export) | The Export service enables users to download the transaction history as a CSV file for any given account on the blockchain. | -| [Template](services/template) | The Template service is an abstract microservice from which all Lisk Service services are inherited. It allows all services to share a similar interface and design pattern. Its purpose is to reduce code duplication and increase consistency between each service, hence, simplifying code maintenance and testing. | +| [App Registry](services/blockchain-app-registry) | The Blockchain Application Registry service is primarily responsible for regularly synchronizing and providing off-chain metadata information for known blockchain applications in the Lisk ecosystem. The metadata is maintained in the Lisk [Application Registry](https://github.com/LiskHQ/app-registry) repository. | +| [Fee Estimator](services/fee-estimator) | The Fee Estimator service implements the [dynamic fee system](https://github.com/LiskHQ/lips/blob/main/proposals/lip-0013.md) algorithm to offer users transaction fee recommendations based on the network traffic. | +| [Transaction Statistics](services/transaction-statistics) | The Transaction Statistics service, as the name suggests, is primarily responsible to compute various transaction statistics to offer users various real-time network insights. | +| [Market](services/market) | The Market service allows price data retrieval. It supports multiple sources to keep the current Lisk token price up-to-date and available to the clients in real time. | +| [Export](services/export) | The Export service enables users to download the transaction history as a CSV file for any given account on the blockchain. | +| [Template](services/template) | The Template service is an abstract microservice from which all Lisk Service services are inherited. It allows all services to share a similar interface and design pattern. Its purpose is to reduce code duplication and increase consistency between each service, hence, simplifying code maintenance and testing. | **Remarks** @@ -48,14 +47,15 @@ Every microservice is independently managed and placed in a separate directory u Inter-microservice communications are enabled with a message broker, typically an instance of Redis or NATS. ![Lisk Service Architecture](./docs/assets/architecture.png) + ## API documentation The Gateway service provides the following APIs, which all users of Lisk Service can access and use. -| API | Description | -| ---------------------------------------------------- | ----------- | -| [HTTP API](docs/api/version3.md) | HTTP API is the public RESTful API that provides blockchain data in standardized JSON format. | -| [WebSocket JSON-RPC API](docs/api/version3.md) | The WebSocket-based JSON-RPC API provides blockchain data in standardized JSON format. The API uses the Socket.IO library and is compatible with JSON-RPC 2.0 standards. | +| API | Description | +| ---------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [HTTP API](docs/api/version3.md) | HTTP API is the public RESTful API that provides blockchain data in standardized JSON format. | +| [WebSocket JSON-RPC API](docs/api/version3.md) | The WebSocket-based JSON-RPC API provides blockchain data in standardized JSON format. The API uses the Socket.IO library and is compatible with JSON-RPC 2.0 standards. | | [Subscribe API](docs/api/websocket_subscribe_api.md) | The Subscribe API is an event-driven API. It uses a two-way streaming connection, which can notify the client about new data instantly as it arrives. It is responsible for updating users regarding changes in the blockchain network and markets. | ## Installation @@ -65,7 +65,8 @@ The default port for REST API requests and Socket.IO-based communication is `990 WebSocket-based APIs can be used through the [Socket.IO](https://socket.io/) library available for many modern programming languages and frameworks. To continue the installation ensure that you have the following dependencies installed: -- [NodeJS Active LTS - ^v16.15.0](https://nodejs.org/en/about/releases/) + +- [NodeJS Active LTS - ^v18.16](https://nodejs.org/en/about/releases/) - [MySQL - ^v8.0.29](https://dev.mysql.com/doc/relnotes/mysql/8.0/en/) - [Docker](https://www.docker.com/) with [Docker compose](https://docs.docker.com/compose/install/) - [GNU Make](https://www.gnu.org/software/make/) and [GNU Tar](https://www.gnu.org/software/tar/) diff --git a/docs/api/version3.md b/docs/api/version3.md index 937a59df3a..5613f48df6 100644 --- a/docs/api/version3.md +++ b/docs/api/version3.md @@ -315,7 +315,7 @@ _Supports pagination._ | blockID | String | `/^\b(?:[A-Fa-f0-9]){64}\b$/` | *(empty)* | | | height | String | `/^(?:(?:\d+)\|(?::(?:\d+))\|(?:(?:\d+):(?:\d+)?))$/` | *(empty)* | Query by height or a height range. Can be expressed as an interval i.e. `1:20` or `1:` or `:20`. Specified values are inclusive. | | timestamp | String | `/^(?:(?:\d+)\|(?::(?:\d+))\|(?:(?:\d+):(?:\d+)?))$/` | *(empty)* | Query by timestamp or a timestamp range. Can be expressed as an interval i.e. `1000000:2000000` or `1000000:` or `:2000000`. Specified values are inclusive. | -| executionStatus | String | `/^\b(?:pending\|success\|fail\|,){0,5}\b$/` | *(empty)* | Can be expressed as a CSV. | +| executionStatus | String | `/^\b(?:pending\|successful\|failed\|,){0,5}\b$/` | *(empty)* | Can be expressed as a CSV. | | nonce | Number | `/^\d+$/` | *(empty)* | | | limit | Number | `[1,100]` | 10 | | | offset | Number | `[0,Inf)` | 0 | | @@ -360,7 +360,7 @@ _Supports pagination._ "name": null } }, - "executionStatus": "success", + "executionStatus": "successful", "index": 0 }, ], @@ -454,7 +454,7 @@ or { "data": { "result": 1, - "status": "ok", + "status": "valid", "events": [ { "data": { @@ -5631,7 +5631,7 @@ _Supports pagination._ | --------- | ---- | ---------- | ------- | ------- | | chainID | String | `/^\b(?:[a-fA-F0-9]{8}\|,)+\b$/` | *(empty)* | Can be expressed as a CSV. | | name | String | `/^[\w!@$&.]{3,20}$/` | *(empty)* | | -| status | String | `/^\b(?:registered\|active\|terminated\|unregistered\|,){1,7}\b$/` | *(empty)* | Can be expressed as a CSV. | +| status | String | `/^\b(?:registered\|activated\|terminated\|unregistered\|,){1,7}\b$/` | *(empty)* | Can be expressed as a CSV. | | search | String | `/^[\w!@$&.]{1,20}$/` | *(empty)* | Case-insensitive search by chain name. Supports both partial and full text search. | | limit | Number | `[1,100]` | 10 | | | offset | Number | `[0,Inf)` | 0 | | @@ -5646,7 +5646,7 @@ _Supports pagination._ { "name": "Lisk", "chainID": "00000000", - "status": "active", + "status": "activated", "address": "lskdwsyfmcko6mcd357446yatromr9vzgu7eb8y99", "lastCertificateHeight": 160, "lastUpdated": 1616008148 @@ -5697,7 +5697,7 @@ No parameters are required. { "data": { "registered": 2503, - "active": 2328, + "activated": 2328, "terminated": 35, "totalSupplyLSK": "5000000", "totalStakedLSK": "3000000", @@ -5964,7 +5964,7 @@ _Supports pagination._ "displayName": "Lisk", "chainID": "00000000", "title": "Lisk blockchain application", - "status": "active", + "status": "activated", "description": "Lisk is a blockchain application platform.", "networkType": "mainnet", "isDefault": true, diff --git a/docs/api/websocket_subscribe_api.md b/docs/api/websocket_subscribe_api.md index f8b59c6516..a4e89702c0 100644 --- a/docs/api/websocket_subscribe_api.md +++ b/docs/api/websocket_subscribe_api.md @@ -213,7 +213,7 @@ Updates about included transactions within a newly generated block. "name": null } }, - "executionStatus": "success", + "executionStatus": "successful", "index": 0 }, ], @@ -265,7 +265,7 @@ Updates about deleted transactions within a deleted block. This usually happens "name": null } }, - "executionStatus": "success", + "executionStatus": "successful", "index": 0 }, ], diff --git a/framework/bin/socket_io_rpc_multirequest.js b/framework/bin/socket_io_rpc_multirequest.js index 5bb0cc14ac..56ca90ce43 100644 --- a/framework/bin/socket_io_rpc_multirequest.js +++ b/framework/bin/socket_io_rpc_multirequest.js @@ -16,8 +16,8 @@ */ /* eslint-disable no-console */ -const io = require('socket.io-client'); const util = require('util'); +const io = require('socket.io-client'); const colorize = require('json-colorizer'); if (process.argv.length < 3) { diff --git a/framework/src/http.js b/framework/src/http.js index 5be1ce607b..e22fb06afa 100644 --- a/framework/src/http.js +++ b/framework/src/http.js @@ -13,10 +13,10 @@ * Removal or modification of this copyright notice is prohibited. * */ +const util = require('util'); const axios = require('axios'); const HttpStatus = require('http-status-codes'); const debug = require('debug')('http'); -const util = require('util'); const delay = require('./delay'); @@ -83,8 +83,7 @@ const request = async (url, params = {}) => { if (!httpParams.method) httpParams.method = 'get'; - if (httpParams.method.toLowerCase() === 'get' - && params.cacheTTL && params.cacheTTL > 0) { + if (httpParams.method.toLowerCase() === 'get' && params.cacheTTL && params.cacheTTL > 0) { key = `${encodeURI(url)}:ttl=${params.cacheTTL}`; response = await cache.get(key); } diff --git a/framework/src/requireAllJs.js b/framework/src/requireAllJs.js index 79ae9a3052..17ecce86ee 100644 --- a/framework/src/requireAllJs.js +++ b/framework/src/requireAllJs.js @@ -13,8 +13,8 @@ * Removal or modification of this copyright notice is prohibited. * */ -const requireAll = require('require-all'); const path = require('path'); +const requireAll = require('require-all'); const requireAllJs = absolutePath => requireAll({ filter: /(.+)\.js$/, diff --git a/framework/src/socketClient.js b/framework/src/socketClient.js index ee47f3d14a..b9faa117a3 100644 --- a/framework/src/socketClient.js +++ b/framework/src/socketClient.js @@ -13,9 +13,9 @@ * Removal or modification of this copyright notice is prohibited. * */ +const util = require('util'); const io = require('socket.io-client'); const debug = require('debug')('framework:socket'); -const util = require('util'); const connectionPool = {}; @@ -65,19 +65,25 @@ const SocketClient = endpoint => { }); const emit = (event, data) => new Promise(resolve => { - socket.emit(event, data, answer => { - debug(`Emitting socket event ${event} with data ${util.inspect(data)}: ${util.inspect(answer)}`); - resolve(answer); + socket.emit(event, data, answer => { + debug( + `Emitting socket event ${event} with data ${util.inspect(data)}: ${util.inspect(answer)}`, + ); + resolve(answer); + }); }); - }); const requestRpc = params => new Promise(resolve => { - debug(`Emitting RPC request ${params}`); - socket.emit('request', params, answer => { - debug(`Received RPC answer for method ${params.method} with params ${params}: ${util.inspect(answer)}`); - answer(resolve); + debug(`Emitting RPC request ${params}`); + socket.emit('request', params, answer => { + debug( + `Received RPC answer for method ${params.method} with params ${params}: ${util.inspect( + answer, + )}`, + ); + answer(resolve); + }); }); - }); return { emit, diff --git a/services/blockchain-app-registry/shared/database/init.js b/services/blockchain-app-registry/shared/database/init.js index d05a5c182d..ee0b6e0a62 100644 --- a/services/blockchain-app-registry/shared/database/init.js +++ b/services/blockchain-app-registry/shared/database/init.js @@ -13,8 +13,8 @@ * Removal or modification of this copyright notice is prohibited. * */ -const BluebirdPromise = require('bluebird'); const path = require('path'); +const BluebirdPromise = require('bluebird'); const { Logger, diff --git a/services/blockchain-app-registry/shared/metadata.js b/services/blockchain-app-registry/shared/metadata.js index 92fd6a35c2..c159a2df6d 100644 --- a/services/blockchain-app-registry/shared/metadata.js +++ b/services/blockchain-app-registry/shared/metadata.js @@ -40,7 +40,7 @@ const MYSQL_ENDPOINT = config.endpoints.mysql; const APP_STATUS = { DEFAULT: 'unregistered', - ACTIVE: 'active', + ACTIVATED: 'activated', }; const knownMainchainIDs = Object @@ -213,7 +213,7 @@ const getBlockchainAppsMetadata = async (params) => { if (await isMainchain() && knownMainchainIDs.includes(appMeta.chainID)) { - appMeta.status = APP_STATUS.ACTIVE; + appMeta.status = APP_STATUS.ACTIVATED; } else { const [blockchainApp] = (await requestIndexer('blockchain.apps', { chainID: appMeta.chainID })).data; appMeta.status = blockchainApp ? blockchainApp.status : APP_STATUS.DEFAULT; diff --git a/services/blockchain-app-registry/shared/metadataIndex.js b/services/blockchain-app-registry/shared/metadataIndex.js index 887e4d9818..7d20c1605c 100644 --- a/services/blockchain-app-registry/shared/metadataIndex.js +++ b/services/blockchain-app-registry/shared/metadataIndex.js @@ -13,8 +13,8 @@ * Removal or modification of this copyright notice is prohibited. * */ -const BluebirdPromise = require('bluebird'); const path = require('path'); +const BluebirdPromise = require('bluebird'); const { Utils: { diff --git a/services/blockchain-app-registry/shared/utils/downloadRepository.js b/services/blockchain-app-registry/shared/utils/downloadRepository.js index edb230c1d4..bc74ea6122 100644 --- a/services/blockchain-app-registry/shared/utils/downloadRepository.js +++ b/services/blockchain-app-registry/shared/utils/downloadRepository.js @@ -13,8 +13,8 @@ * Removal or modification of this copyright notice is prohibited. * */ -const BluebirdPromise = require('bluebird'); const path = require('path'); +const BluebirdPromise = require('bluebird'); const { Octokit } = require('octokit'); const { diff --git a/services/blockchain-app-registry/tests/functional/shared/utils/downloadRepository.test.js b/services/blockchain-app-registry/tests/functional/shared/utils/downloadRepository.test.js index 611521485c..93ddc30469 100644 --- a/services/blockchain-app-registry/tests/functional/shared/utils/downloadRepository.test.js +++ b/services/blockchain-app-registry/tests/functional/shared/utils/downloadRepository.test.js @@ -14,6 +14,7 @@ * */ /* eslint-disable mocha/max-top-level-suites */ +const path = require('path'); const _ = require('lodash'); jest.setTimeout(15000); @@ -24,14 +25,11 @@ const { }, DB: { MySQL: { - KVStore: { - getKeyValueTable, - }, + KVStore: { getKeyValueTable }, }, }, } = require('lisk-service-framework'); -const path = require('path'); const { getRepoDownloadURL, getLatestCommitHash, @@ -66,9 +64,7 @@ xdescribe('Test getCommitInfo method', () => { beforeAll(async () => { const keyValueTable = await getKeyValueTableInstance(); - keyValueTable.set( - KV_STORE_KEY.COMMIT_HASH_UNTIL_LAST_SYNC, - lastSyncedCommitHash); + keyValueTable.set(KV_STORE_KEY.COMMIT_HASH_UNTIL_LAST_SYNC, lastSyncedCommitHash); }); afterAll(async () => { const keyValueTable = await getKeyValueTableInstance(); @@ -86,7 +82,7 @@ xdescribe('Test getCommitInfo method', () => { xdescribe('Test getRepoDownloadURL method', () => { it('should return correct repository download url info', async () => { /* eslint-disable-next-line no-useless-escape */ - const repoUrlRegex = /^https:\/\/\w*\.github\.com\/LiskHQ\/app-registry\/legacy.tar.gz\/refs\/heads\/main(?:\?token=\w+)?$/; + const repoUrlRegex = /^https:\/\/\w*\.github\.com\/LiskHQ\/app-registry\/legacy.tar.gz\/refs\/heads\/main(?:\?token=\w+)?$/; const response = await getRepoDownloadURL(); expect(response.url).toMatch(repoUrlRegex); }); @@ -122,7 +118,10 @@ xdescribe('Test getFileDownloadURL method', () => { xdescribe('Test getDiff method', () => { it('should return list of file differences between two commits when commits are valid', async () => { - const response = await getDiff('838464896420410dcbade293980fe42ca95931d0', '5ca021f84cdcdb3b28d3766cf675d942887327c3'); + const response = await getDiff( + '838464896420410dcbade293980fe42ca95931d0', + '5ca021f84cdcdb3b28d3766cf675d942887327c3', + ); const fileNames = response.data.files.map(file => file.filename); expect(fileNames).toEqual([ 'alphanet/Lisk/nativetokens.json', @@ -132,15 +131,27 @@ xdescribe('Test getDiff method', () => { }); it('should throw error when both commits are invalid', async () => { - expect(() => getDiff('aaaa64896420410dcbade293980fe42ca95931d0', 'bbbb21f84cdcdb3b28d3766cf675d942887327c3')).rejects.toThrow(); + expect(() => getDiff( + 'aaaa64896420410dcbade293980fe42ca95931d0', + 'bbbb21f84cdcdb3b28d3766cf675d942887327c3', + ), + ).rejects.toThrow(); }); it('should throw error when lastSyncedCommitHash is invalid', async () => { - expect(() => getDiff('aaaa64896420410dcbade293980fe42ca95931d0', '5ca021f84cdcdb3b28d3766cf675d942887327c3')).rejects.toThrow(); + expect(() => getDiff( + 'aaaa64896420410dcbade293980fe42ca95931d0', + '5ca021f84cdcdb3b28d3766cf675d942887327c3', + ), + ).rejects.toThrow(); }); it('should throw error when both latestCommitHash is invalid', async () => { - expect(() => getDiff('838464896420410dcbade293980fe42ca95931d0', 'bbbb21f84cdcdb3b28d3766cf675d942887327c3')).rejects.toThrow(); + expect(() => getDiff( + '838464896420410dcbade293980fe42ca95931d0', + 'bbbb21f84cdcdb3b28d3766cf675d942887327c3', + ), + ).rejects.toThrow(); }); it('should throw error when one or both commits are undefined', async () => { @@ -218,10 +229,7 @@ xdescribe('Test downloadRepositoryToFS method', () => { await rmdir(enevtiAppFilePath); expect(await exists(enevtiAppFilePath)).toEqual(false); - await keyValueTable.set( - KV_STORE_KEY.COMMIT_HASH_UNTIL_LAST_SYNC, - lastSyncedCommitHash, - ); + await keyValueTable.set(KV_STORE_KEY.COMMIT_HASH_UNTIL_LAST_SYNC, lastSyncedCommitHash); await downloadRepositoryToFS(); expect(await exists(enevtiAppFilePath)).toEqual(true); await keyValueTable.delete(KV_STORE_KEY.COMMIT_HASH_UNTIL_LAST_SYNC); @@ -234,10 +242,7 @@ xdescribe('Test syncWithRemoteRepo method', () => { // Set last sync commit hash in db and remove existing file const keyValueTable = await getKeyValueTableInstance(); - await keyValueTable.set( - KV_STORE_KEY.COMMIT_HASH_UNTIL_LAST_SYNC, - lastSyncedCommitHash, - ); + await keyValueTable.set(KV_STORE_KEY.COMMIT_HASH_UNTIL_LAST_SYNC, lastSyncedCommitHash); await rmdir(enevtiAppFilePath); }); afterAll(async () => { diff --git a/services/blockchain-connector/shared/sdk/blocksUtils.js b/services/blockchain-connector/shared/sdk/blocksUtils.js index 047de6f009..c9e0357888 100644 --- a/services/blockchain-connector/shared/sdk/blocksUtils.js +++ b/services/blockchain-connector/shared/sdk/blocksUtils.js @@ -14,8 +14,8 @@ * */ const fs = require('fs'); -const json = require('big-json'); const path = require('path'); +const json = require('big-json'); const { Logger, diff --git a/services/blockchain-connector/shared/utils/download.js b/services/blockchain-connector/shared/utils/download.js index 2e35f3d63f..ef537727b1 100644 --- a/services/blockchain-connector/shared/utils/download.js +++ b/services/blockchain-connector/shared/utils/download.js @@ -16,9 +16,9 @@ const fs = require('fs'); const http = require('http'); const https = require('https'); -const tar = require('tar'); const zlib = require('zlib'); const crypto = require('crypto'); +const tar = require('tar'); const { Logger, diff --git a/services/blockchain-connector/tests/functional/genesisBlock.test.js b/services/blockchain-connector/tests/functional/genesisBlock.test.js index 609b1560d8..9a6f9f6535 100644 --- a/services/blockchain-connector/tests/functional/genesisBlock.test.js +++ b/services/blockchain-connector/tests/functional/genesisBlock.test.js @@ -14,9 +14,9 @@ * */ const path = require('path'); -const { ServiceBroker } = require('moleculer'); const fs = require('fs'); const crypto = require('crypto'); +const { ServiceBroker } = require('moleculer'); const { exists } = require('../../shared/utils/fs'); const config = require('../../config'); diff --git a/services/blockchain-indexer/shared/constants.js b/services/blockchain-indexer/shared/constants.js index cb7fd6568a..7459913fb8 100644 --- a/services/blockchain-indexer/shared/constants.js +++ b/services/blockchain-indexer/shared/constants.js @@ -164,8 +164,8 @@ const KV_STORE_KEY = Object.freeze({ }); const TRANSACTION_STATUS = Object.freeze({ - SUCCESS: 'success', - FAIL: 'fail', + SUCCESSFUL: 'successful', + FAILED: 'failed', PENDING: 'pending', }); @@ -180,7 +180,7 @@ const EVENT = Object.freeze({ const TRANSACTION_VERIFY_RESULT = { INVALID: -1, PENDING: 0, - OK: 1, + VALID: 1, }; module.exports = { diff --git a/services/blockchain-indexer/shared/dataService/blocks.js b/services/blockchain-indexer/shared/dataService/blocks.js index bf94bbd15b..4b1db28f6e 100644 --- a/services/blockchain-indexer/shared/dataService/blocks.js +++ b/services/blockchain-indexer/shared/dataService/blocks.js @@ -13,8 +13,8 @@ * Removal or modification of this copyright notice is prohibited. * */ -const { CacheRedis, Logger } = require('lisk-service-framework'); const util = require('util'); +const { CacheRedis, Logger } = require('lisk-service-framework'); const logger = Logger(); diff --git a/services/blockchain-indexer/shared/dataService/business/blocks.js b/services/blockchain-indexer/shared/dataService/business/blocks.js index ba3742b63e..ea90a190ae 100644 --- a/services/blockchain-indexer/shared/dataService/business/blocks.js +++ b/services/blockchain-indexer/shared/dataService/business/blocks.js @@ -13,9 +13,8 @@ * Removal or modification of this copyright notice is prohibited. * */ -const BluebirdPromise = require('bluebird'); - const util = require('util'); +const BluebirdPromise = require('bluebird'); const { CacheRedis, diff --git a/services/blockchain-indexer/shared/dataService/business/interoperability/blockchainAppsStats.js b/services/blockchain-indexer/shared/dataService/business/interoperability/blockchainAppsStats.js index e6bce8bf0f..753bb9268f 100644 --- a/services/blockchain-indexer/shared/dataService/business/interoperability/blockchainAppsStats.js +++ b/services/blockchain-indexer/shared/dataService/business/interoperability/blockchainAppsStats.js @@ -52,7 +52,7 @@ const reloadBlockchainAppsStats = async () => { // TODO: Update implementation once interoperability_getOwnChainAccount is available const blockchainAppsTable = await getBlockchainAppsTable(); - const numActiveChains = await blockchainAppsTable.count({ status: APP_STATUS.ACTIVE }); + const numActivatedChains = await blockchainAppsTable.count({ status: APP_STATUS.ACTIVATED }); const numRegisteredChains = await blockchainAppsTable.count({ status: APP_STATUS.REGISTERED }); const numTerminatedChains = await blockchainAppsTable.count({ status: APP_STATUS.TERMINATED }); @@ -65,7 +65,7 @@ const reloadBlockchainAppsStats = async () => { blockchainAppsStatsCache = { registered: numRegisteredChains, - active: numActiveChains, + activated: numActivatedChains, terminated: numTerminatedChains, totalSupplyLSK: totalSupply, totalStakedLSK: totalStaked, diff --git a/services/blockchain-indexer/shared/dataService/business/interoperability/constants.js b/services/blockchain-indexer/shared/dataService/business/interoperability/constants.js index 08c4af9918..11375be185 100644 --- a/services/blockchain-indexer/shared/dataService/business/interoperability/constants.js +++ b/services/blockchain-indexer/shared/dataService/business/interoperability/constants.js @@ -18,7 +18,7 @@ const { requestConnector } = require('../../../utils/request'); let moduleConstants; const APP_STATUS = { - ACTIVE: 'active', + ACTIVATED: 'activated', REGISTERED: 'registered', TERMINATED: 'terminated', }; @@ -26,7 +26,7 @@ const APP_STATUS = { // TODO: Update values from SDK once the discussion is concluded: https://github.com/LiskHQ/discussions/discussions/101 const CHAIN_STATUS = Object.freeze({ 0: 'registered', - 1: 'active', + 1: 'activated', 2: 'terminated', }); diff --git a/services/blockchain-indexer/shared/dataService/knownAccounts.js b/services/blockchain-indexer/shared/dataService/knownAccounts.js index f0a7bd2929..9f08c841b9 100644 --- a/services/blockchain-indexer/shared/dataService/knownAccounts.js +++ b/services/blockchain-indexer/shared/dataService/knownAccounts.js @@ -13,8 +13,8 @@ * Removal or modification of this copyright notice is prohibited. * */ -const { HTTP, Logger } = require('lisk-service-framework'); const util = require('util'); +const { HTTP, Logger } = require('lisk-service-framework'); const config = require('../../config'); const { LENGTH_NETWORK_ID } = require('../constants'); diff --git a/services/blockchain-indexer/shared/database/init.js b/services/blockchain-indexer/shared/database/init.js index 5373e0b474..ed852dd6ed 100644 --- a/services/blockchain-indexer/shared/database/init.js +++ b/services/blockchain-indexer/shared/database/init.js @@ -13,8 +13,8 @@ * Removal or modification of this copyright notice is prohibited. * */ -const BluebirdPromise = require('bluebird'); const path = require('path'); +const BluebirdPromise = require('bluebird'); const { Logger, diff --git a/services/blockchain-indexer/shared/indexer/transactionProcessor/0_moduleName/commandName1.js b/services/blockchain-indexer/shared/indexer/transactionProcessor/0_moduleName/commandName1.js index 319f96a5b3..df232fbfb9 100644 --- a/services/blockchain-indexer/shared/indexer/transactionProcessor/0_moduleName/commandName1.js +++ b/services/blockchain-indexer/shared/indexer/transactionProcessor/0_moduleName/commandName1.js @@ -40,7 +40,7 @@ const COMMAND_NAME = 'command'; // Implement the custom logic in the 'applyTransaction' method and export it const applyTransaction = async (blockHeader, tx, events, dbTrx) => { - if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESS) return; + if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESSFUL) return; const entityTable = await getEntityTable(); @@ -56,7 +56,7 @@ const applyTransaction = async (blockHeader, tx, events, dbTrx) => { // Implement the custom logic in the 'revertTransaction' method and export it // This logic is executed to revert the effect of 'applyTransaction' method in case of deleteBlock const revertTransaction = async (blockHeader, tx, events, dbTrx) => { - if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESS) return; + if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESSFUL) return; const entityTable = await getEntityTable(); diff --git a/services/blockchain-indexer/shared/indexer/transactionProcessor/0_moduleName/commandName2.js b/services/blockchain-indexer/shared/indexer/transactionProcessor/0_moduleName/commandName2.js index 464e1dfbe4..3d367ca45a 100644 --- a/services/blockchain-indexer/shared/indexer/transactionProcessor/0_moduleName/commandName2.js +++ b/services/blockchain-indexer/shared/indexer/transactionProcessor/0_moduleName/commandName2.js @@ -40,7 +40,7 @@ export const COMMAND_NAME = 'command'; // Implement the custom logic in the 'applyTransaction' method and export it export const applyTransaction = async (blockHeader, tx, events, dbTrx) => { - if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESS) return; + if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESSFUL) return; const entityTable = await getEntityTable(); @@ -56,7 +56,7 @@ export const applyTransaction = async (blockHeader, tx, events, dbTrx) => { // Implement the custom logic in the 'revertTransaction' method and export it // This logic is executed to revert the effect of 'applyTransaction' method in case of deleteBlock export const revertTransaction = async (blockHeader, tx, events, dbTrx) => { - if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESS) return; + if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESSFUL) return; const entityTable = await getEntityTable(); diff --git a/services/blockchain-indexer/shared/indexer/transactionProcessor/auth/registerMultisignature.js b/services/blockchain-indexer/shared/indexer/transactionProcessor/auth/registerMultisignature.js index 460e12f181..9f4002111d 100644 --- a/services/blockchain-indexer/shared/indexer/transactionProcessor/auth/registerMultisignature.js +++ b/services/blockchain-indexer/shared/indexer/transactionProcessor/auth/registerMultisignature.js @@ -56,7 +56,7 @@ const applyTransaction = async (blockHeader, tx, events, dbTrx) => { tx.params.mandatoryKeys.forEach((key) => indexAccountPublicKey(key)); tx.params.optionalKeys.forEach((key) => indexAccountPublicKey(key)); - if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESS) return; + if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESSFUL) return; const multisignatureTable = await getMultisignatureTable(); @@ -72,7 +72,7 @@ const revertTransaction = async (blockHeader, tx, events, dbTrx) => { tx.params.mandatoryKeys.forEach((key) => indexAccountPublicKey(key)); tx.params.optionalKeys.forEach((key) => indexAccountPublicKey(key)); - if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESS) return; + if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESSFUL) return; const multisignatureTable = await getMultisignatureTable(); diff --git a/services/blockchain-indexer/shared/indexer/transactionProcessor/interoperability/registerMainchain.js b/services/blockchain-indexer/shared/indexer/transactionProcessor/interoperability/registerMainchain.js index 58cf180e8e..f95d10a4b7 100644 --- a/services/blockchain-indexer/shared/indexer/transactionProcessor/interoperability/registerMainchain.js +++ b/services/blockchain-indexer/shared/indexer/transactionProcessor/interoperability/registerMainchain.js @@ -46,7 +46,7 @@ const getChainInfo = async chainID => { }; const applyTransaction = async (blockHeader, tx, events, dbTrx) => { - if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESS) return; + if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESSFUL) return; const blockchainAppsTable = await getBlockchainAppsTable(); const mainchainID = await getMainchainID(); @@ -68,7 +68,7 @@ const applyTransaction = async (blockHeader, tx, events, dbTrx) => { // eslint-disable-next-line no-unused-vars const revertTransaction = async (blockHeader, tx, events, dbTrx) => { - if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESS) return; + if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESSFUL) return; const blockchainAppsTable = await getBlockchainAppsTable(); const mainchainID = await getMainchainID(); diff --git a/services/blockchain-indexer/shared/indexer/transactionProcessor/interoperability/registerSidechain.js b/services/blockchain-indexer/shared/indexer/transactionProcessor/interoperability/registerSidechain.js index 6fd0fe276b..a8ac759947 100644 --- a/services/blockchain-indexer/shared/indexer/transactionProcessor/interoperability/registerSidechain.js +++ b/services/blockchain-indexer/shared/indexer/transactionProcessor/interoperability/registerSidechain.js @@ -35,7 +35,7 @@ const getBlockchainAppsTable = () => getTableInstance(blockchainAppsTableSchema, const COMMAND_NAME = 'registerSidechain'; const applyTransaction = async (blockHeader, tx, events, dbTrx) => { - if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESS) return; + if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESSFUL) return; const blockchainAppsTable = await getBlockchainAppsTable(); const chainInfo = await getChainInfo(tx.params.chainID); @@ -55,7 +55,7 @@ const applyTransaction = async (blockHeader, tx, events, dbTrx) => { }; const revertTransaction = async (blockHeader, tx, events, dbTrx) => { - if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESS) return; + if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESSFUL) return; const blockchainAppsTable = await getBlockchainAppsTable(); diff --git a/services/blockchain-indexer/shared/indexer/transactionProcessor/interoperability/submitSidechainCrossChainUpdate.js b/services/blockchain-indexer/shared/indexer/transactionProcessor/interoperability/submitSidechainCrossChainUpdate.js index 1c00dc6691..0e217625ab 100644 --- a/services/blockchain-indexer/shared/indexer/transactionProcessor/interoperability/submitSidechainCrossChainUpdate.js +++ b/services/blockchain-indexer/shared/indexer/transactionProcessor/interoperability/submitSidechainCrossChainUpdate.js @@ -41,7 +41,7 @@ const getCCUTable = () => getTableInstance(ccuTableSchema, MYSQL_ENDPOINT); const COMMAND_NAME = 'submitSidechainCrossChainUpdate'; const applyTransaction = async (blockHeader, tx, events, dbTrx) => { - if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESS) return; + if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESSFUL) return; const blockchainAppsTable = await getBlockchainAppsTable(); const ccuTable = await getCCUTable(); @@ -68,7 +68,7 @@ const applyTransaction = async (blockHeader, tx, events, dbTrx) => { }; const revertTransaction = async (blockHeader, tx, events, dbTrx) => { - if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESS) return; + if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESSFUL) return; const blockchainAppsTable = await getBlockchainAppsTable(); const ccuTable = await getCCUTable(); @@ -78,7 +78,7 @@ const revertTransaction = async (blockHeader, tx, events, dbTrx) => { let prevTransaction; const chainInfo = await getChainInfo(tx.params.sendingChainID); - if (chainInfo.status === APP_STATUS.ACTIVE) { + if (chainInfo.status === APP_STATUS.ACTIVATED) { const searchParams = { sendingChainID: tx.params.sendingChainID, propBetweens: [{ @@ -95,7 +95,7 @@ const revertTransaction = async (blockHeader, tx, events, dbTrx) => { const result = (await getTransactions({ height: resultSet[i].height, moduleCommand: tx.moduleCommand, - executionStatus: TRANSACTION_STATUS.SUCCESS, + executionStatus: TRANSACTION_STATUS.SUCCESSFUL, })).data; if (result.length) { @@ -110,7 +110,7 @@ const revertTransaction = async (blockHeader, tx, events, dbTrx) => { const result = (await getTransactions({ moduleCommand: `${MODULE_NAME}:${COMMAND}`, - executionStatus: TRANSACTION_STATUS.SUCCESS, + executionStatus: TRANSACTION_STATUS.SUCCESSFUL, propBetweens: [{ property: 'height', lowerThan: blockHeader.height, diff --git a/services/blockchain-indexer/shared/indexer/transactionProcessor/interoperability/terminateSidechainForLiveness.js b/services/blockchain-indexer/shared/indexer/transactionProcessor/interoperability/terminateSidechainForLiveness.js index e6fd706480..bb27894bd7 100644 --- a/services/blockchain-indexer/shared/indexer/transactionProcessor/interoperability/terminateSidechainForLiveness.js +++ b/services/blockchain-indexer/shared/indexer/transactionProcessor/interoperability/terminateSidechainForLiveness.js @@ -33,7 +33,7 @@ const COMMAND_NAME = 'terminateSidechainForLiveness'; // eslint-disable-next-line no-unused-vars const applyTransaction = async (blockHeader, tx, events, dbTrx) => { - if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESS) return; + if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESSFUL) return; const blockchainAppsTable = await getBlockchainAppsTable(); const chainInfo = await getChainInfo(tx.params.chainID); @@ -51,7 +51,7 @@ const applyTransaction = async (blockHeader, tx, events, dbTrx) => { // eslint-disable-next-line no-unused-vars const revertTransaction = async (blockHeader, tx, events, dbTrx) => { - if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESS) return; + if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESSFUL) return; const blockchainAppsTable = await getBlockchainAppsTable(); diff --git a/services/blockchain-indexer/shared/indexer/transactionProcessor/legacy/registerKeys.js b/services/blockchain-indexer/shared/indexer/transactionProcessor/legacy/registerKeys.js index 3dcae29565..e76fc1a367 100644 --- a/services/blockchain-indexer/shared/indexer/transactionProcessor/legacy/registerKeys.js +++ b/services/blockchain-indexer/shared/indexer/transactionProcessor/legacy/registerKeys.js @@ -38,7 +38,7 @@ const COMMAND_NAME = 'registerKeys'; // eslint-disable-next-line no-unused-vars const applyTransaction = async (blockHeader, tx, events, dbTrx) => { - if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESS) return; + if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESSFUL) return; const accountsTable = await getAccountsTable(); const validatorsTable = await getValidatorsTable(); @@ -63,7 +63,7 @@ const applyTransaction = async (blockHeader, tx, events, dbTrx) => { // eslint-disable-next-line no-unused-vars const revertTransaction = async (blockHeader, tx, events, dbTrx) => { - if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESS) return; + if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESSFUL) return; const accountsTable = await getAccountsTable(); const validatorsTable = await getValidatorsTable(); diff --git a/services/blockchain-indexer/shared/indexer/transactionProcessor/pos/changeCommission.js b/services/blockchain-indexer/shared/indexer/transactionProcessor/pos/changeCommission.js index 6887b81869..cf10e3e89d 100644 --- a/services/blockchain-indexer/shared/indexer/transactionProcessor/pos/changeCommission.js +++ b/services/blockchain-indexer/shared/indexer/transactionProcessor/pos/changeCommission.js @@ -47,7 +47,7 @@ const getCommissionIndexingInfo = (blockHeader, tx) => { }; const applyTransaction = async (blockHeader, tx, events, dbTrx) => { - if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESS) return; + if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESSFUL) return; const commissionsTable = await getCommissionsTable(); @@ -59,7 +59,7 @@ const applyTransaction = async (blockHeader, tx, events, dbTrx) => { }; const revertTransaction = async (blockHeader, tx, events, dbTrx) => { - if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESS) return; + if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESSFUL) return; const commissionsTable = await getCommissionsTable(); diff --git a/services/blockchain-indexer/shared/indexer/transactionProcessor/pos/registerValidator.js b/services/blockchain-indexer/shared/indexer/transactionProcessor/pos/registerValidator.js index 51da78ea89..c9f5ed5871 100644 --- a/services/blockchain-indexer/shared/indexer/transactionProcessor/pos/registerValidator.js +++ b/services/blockchain-indexer/shared/indexer/transactionProcessor/pos/registerValidator.js @@ -57,7 +57,7 @@ const getCommissionIndexingInfo = async (blockHeader, tx) => { // eslint-disable-next-line no-unused-vars const applyTransaction = async (blockHeader, tx, events, dbTrx) => { - if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESS) return; + if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESSFUL) return; const accountsTable = await getAccountsTable(); const transactionsTable = await getTransactionsTable(); @@ -101,7 +101,7 @@ const applyTransaction = async (blockHeader, tx, events, dbTrx) => { // eslint-disable-next-line no-unused-vars const revertTransaction = async (blockHeader, tx, events, dbTrx) => { - if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESS) return; + if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESSFUL) return; const accountsTable = await getAccountsTable(); const validatorsTable = await getValidatorsTable(); diff --git a/services/blockchain-indexer/shared/indexer/transactionProcessor/pos/reportMisbehavior.js b/services/blockchain-indexer/shared/indexer/transactionProcessor/pos/reportMisbehavior.js index 57af2cd8b2..08daec035d 100644 --- a/services/blockchain-indexer/shared/indexer/transactionProcessor/pos/reportMisbehavior.js +++ b/services/blockchain-indexer/shared/indexer/transactionProcessor/pos/reportMisbehavior.js @@ -27,7 +27,7 @@ const COMMAND_NAME = 'reportMisbehavior'; // eslint-disable-next-line no-unused-vars const applyTransaction = async (blockHeader, tx, events, dbTrx) => { - if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESS) return; + if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESSFUL) return; logger.debug('Reloading validators cache on reportMisbehavior transaction.'); await reloadValidatorCache(); @@ -35,7 +35,7 @@ const applyTransaction = async (blockHeader, tx, events, dbTrx) => { // eslint-disable-next-line no-unused-vars const revertTransaction = async (blockHeader, tx, events, dbTrx) => { - if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESS) return; + if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESSFUL) return; logger.debug('Reloading validators cache on reversal of reportMisbehavior transaction.'); await reloadValidatorCache(); diff --git a/services/blockchain-indexer/shared/indexer/transactionProcessor/pos/stake.js b/services/blockchain-indexer/shared/indexer/transactionProcessor/pos/stake.js index 5f4e4d8351..0e5cd73405 100644 --- a/services/blockchain-indexer/shared/indexer/transactionProcessor/pos/stake.js +++ b/services/blockchain-indexer/shared/indexer/transactionProcessor/pos/stake.js @@ -118,7 +118,7 @@ const updateTotalSelfStake = async (changeAmount, dbTrx) => { // eslint-disable-next-line no-unused-vars const applyTransaction = async (blockHeader, tx, events, dbTrx) => { - if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESS) return; + if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESSFUL) return; const stakes = await getStakeIndexingInfo(tx); let totalStakeChange = BigInt(0); @@ -145,7 +145,7 @@ const applyTransaction = async (blockHeader, tx, events, dbTrx) => { // eslint-disable-next-line no-unused-vars const revertTransaction = async (blockHeader, tx, events, dbTrx) => { - if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESS) return; + if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESSFUL) return; const stakes = await getStakeIndexingInfo(tx); let totalStakeChange = BigInt(0); diff --git a/services/blockchain-indexer/shared/indexer/transactionProcessor/pos/updateGeneratorKey.js b/services/blockchain-indexer/shared/indexer/transactionProcessor/pos/updateGeneratorKey.js index e799328da3..5d66f23426 100644 --- a/services/blockchain-indexer/shared/indexer/transactionProcessor/pos/updateGeneratorKey.js +++ b/services/blockchain-indexer/shared/indexer/transactionProcessor/pos/updateGeneratorKey.js @@ -38,7 +38,7 @@ const COMMAND_NAME = 'updateGeneratorKey'; // eslint-disable-next-line no-unused-vars const applyTransaction = async (blockHeader, tx, events, dbTrx) => { - if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESS) return; + if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESSFUL) return; const accountsTable = await getAccountsTable(); const validatorsTable = await getValidatorsTable(); @@ -61,7 +61,7 @@ const applyTransaction = async (blockHeader, tx, events, dbTrx) => { // eslint-disable-next-line no-unused-vars const revertTransaction = async (blockHeader, tx, events, dbTrx) => { - if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESS) return; + if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESSFUL) return; const validatorsTable = await getValidatorsTable(); diff --git a/services/blockchain-indexer/shared/indexer/transactionProcessor/token/transfer.js b/services/blockchain-indexer/shared/indexer/transactionProcessor/token/transfer.js index de066537a0..95fe28dbfc 100644 --- a/services/blockchain-indexer/shared/indexer/transactionProcessor/token/transfer.js +++ b/services/blockchain-indexer/shared/indexer/transactionProcessor/token/transfer.js @@ -41,7 +41,7 @@ const applyTransaction = async (blockHeader, tx, events, dbTrx) => { logger.trace(`Updating index for the account with address ${tx.params.recipientAddress} asynchronously.`); indexAccountAddress(tx.params.recipientAddress); - if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESS) return; + if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESSFUL) return; tx = { ...tx, diff --git a/services/blockchain-indexer/shared/indexer/transactionProcessor/token/transferCrossChain.js b/services/blockchain-indexer/shared/indexer/transactionProcessor/token/transferCrossChain.js index 7019654935..5fb7d3dc58 100644 --- a/services/blockchain-indexer/shared/indexer/transactionProcessor/token/transferCrossChain.js +++ b/services/blockchain-indexer/shared/indexer/transactionProcessor/token/transferCrossChain.js @@ -41,7 +41,7 @@ const applyTransaction = async (blockHeader, tx, events, dbTrx) => { logger.trace(`Updating index for the account with address ${tx.params.recipientAddress} asynchronously.`); indexAccountAddress(tx.params.recipientAddress); - if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESS) return; + if (tx.executionStatus !== TRANSACTION_STATUS.SUCCESSFUL) return; tx = { ...tx, diff --git a/services/blockchain-indexer/shared/utils/transactions.js b/services/blockchain-indexer/shared/utils/transactions.js index 9b6e419925..afa478d8cd 100644 --- a/services/blockchain-indexer/shared/utils/transactions.js +++ b/services/blockchain-indexer/shared/utils/transactions.js @@ -27,7 +27,9 @@ const getTransactionExecutionStatus = (tx, events) => { const txExecResultEvent = commandExecResultEvents.find(e => e.topics.includes(tx.id)); if (!txExecResultEvent) throw Error(`Event unavailable to determine execution status for transaction: ${tx.id}.`); - return txExecResultEvent.data.success ? TRANSACTION_STATUS.SUCCESS : TRANSACTION_STATUS.FAIL; + return txExecResultEvent.data.success + ? TRANSACTION_STATUS.SUCCESSFUL + : TRANSACTION_STATUS.FAILED; }; module.exports = { diff --git a/services/blockchain-indexer/tests/constants/validators.js b/services/blockchain-indexer/tests/constants/validators.js index 2af0739709..caffd8b477 100644 --- a/services/blockchain-indexer/tests/constants/validators.js +++ b/services/blockchain-indexer/tests/constants/validators.js @@ -20,9 +20,7 @@ const posValidators = [ selfStake: '100000000000', lastGeneratedHeight: 0, isBanned: false, - reportMisbehaviorHeights: [ - - ], + reportMisbehaviorHeights: [], consecutiveMissedBlocks: 2720, commission: 5000, lastCommissionIncreaseHeight: 0, @@ -33,13 +31,10 @@ const posValidators = [ }, ], address: 'lskzzw334cgd7cew5mb9bbayjmojbodgmw9pdym6p', - punishmentPeriods: [ - - ], + punishmentPeriods: [], validatorWeight: 100000000000, rank: 1, status: 'active', - valiatorWeight: 100000000000, }, { name: 'genesis_45', @@ -47,9 +42,7 @@ const posValidators = [ selfStake: '100000000000', lastGeneratedHeight: 0, isBanned: false, - reportMisbehaviorHeights: [ - - ], + reportMisbehaviorHeights: [], consecutiveMissedBlocks: 2720, commission: 5000, lastCommissionIncreaseHeight: 0, @@ -60,13 +53,10 @@ const posValidators = [ }, ], address: 'lskz6x7dzjr547cv42gk7suw76ojpwhu8q43ydhdp', - punishmentPeriods: [ - - ], + punishmentPeriods: [], validatorWeight: 100000000000, rank: 2, status: 'active', - valiatorWeight: 100000000000, }, { name: 'genesis_10', @@ -74,9 +64,7 @@ const posValidators = [ selfStake: '100000000000', lastGeneratedHeight: 0, isBanned: false, - reportMisbehaviorHeights: [ - - ], + reportMisbehaviorHeights: [], consecutiveMissedBlocks: 2720, commission: 5000, lastCommissionIncreaseHeight: 0, @@ -87,13 +75,10 @@ const posValidators = [ }, ], address: 'lskzr72jsfyvrj66krxg7tjmzhs28ko6okc9ufubj', - punishmentPeriods: [ - - ], + punishmentPeriods: [], validatorWeight: 100000000000, rank: 3, status: 'active', - valiatorWeight: 100000000000, }, { name: 'genesis_33', @@ -101,9 +86,7 @@ const posValidators = [ selfStake: '100000000000', lastGeneratedHeight: 0, isBanned: false, - reportMisbehaviorHeights: [ - - ], + reportMisbehaviorHeights: [], consecutiveMissedBlocks: 2720, commission: 5000, lastCommissionIncreaseHeight: 0, @@ -114,13 +97,10 @@ const posValidators = [ }, ], address: 'lskzkkm35mnozqckwzt8ajeg2j47tpu2x9bnh4d7a', - punishmentPeriods: [ - - ], + punishmentPeriods: [], validatorWeight: 100000000000, rank: 4, status: 'active', - valiatorWeight: 100000000000, }, { name: 'genesis_101', @@ -128,9 +108,7 @@ const posValidators = [ selfStake: '100000000000', lastGeneratedHeight: 0, isBanned: false, - reportMisbehaviorHeights: [ - - ], + reportMisbehaviorHeights: [], consecutiveMissedBlocks: 0, commission: 5000, lastCommissionIncreaseHeight: 0, @@ -141,13 +119,10 @@ const posValidators = [ }, ], address: 'lskxvhb3f52hye5huvyzbe6hoq2mrd4qrackdthht', - punishmentPeriods: [ - - ], + punishmentPeriods: [], validatorWeight: 100000000000, rank: 5, status: 'standby', - valiatorWeight: 100000000000, }, { name: 'genesis_98', @@ -155,9 +130,7 @@ const posValidators = [ selfStake: '100000000000', lastGeneratedHeight: 0, isBanned: false, - reportMisbehaviorHeights: [ - - ], + reportMisbehaviorHeights: [], consecutiveMissedBlocks: 2720, commission: 5000, lastCommissionIncreaseHeight: 0, @@ -168,13 +141,10 @@ const posValidators = [ }, ], address: 'lskx6f4vp5n9vmdwdkf7fynov42tzugsn29sj545s', - punishmentPeriods: [ - - ], + punishmentPeriods: [], validatorWeight: 100000000000, rank: 6, status: 'active', - valiatorWeight: 100000000000, }, { name: 'genesis_1', @@ -182,9 +152,7 @@ const posValidators = [ selfStake: '100000000000', lastGeneratedHeight: 0, isBanned: false, - reportMisbehaviorHeights: [ - - ], + reportMisbehaviorHeights: [], consecutiveMissedBlocks: 2720, commission: 5000, lastCommissionIncreaseHeight: 0, @@ -195,13 +163,10 @@ const posValidators = [ }, ], address: 'lskx7rscmxc3k9yokbqpxspjj92zz6fue84e2xw92', - punishmentPeriods: [ - - ], + punishmentPeriods: [], validatorWeight: 100000000000, rank: 7, status: 'active', - valiatorWeight: 100000000000, }, { name: 'genesis_85', @@ -209,9 +174,7 @@ const posValidators = [ selfStake: '100000000000', lastGeneratedHeight: 0, isBanned: false, - reportMisbehaviorHeights: [ - - ], + reportMisbehaviorHeights: [], consecutiveMissedBlocks: 2720, commission: 5000, lastCommissionIncreaseHeight: 0, @@ -222,13 +185,10 @@ const posValidators = [ }, ], address: 'lskvp52wg4co7rt634r7wq4qgc4xfzmztszv2pyn2', - punishmentPeriods: [ - - ], + punishmentPeriods: [], validatorWeight: 100000000000, rank: 8, status: 'active', - valiatorWeight: 100000000000, }, { name: 'genesis_40', @@ -236,9 +196,7 @@ const posValidators = [ selfStake: '100000000000', lastGeneratedHeight: 0, isBanned: false, - reportMisbehaviorHeights: [ - - ], + reportMisbehaviorHeights: [], consecutiveMissedBlocks: 2720, commission: 5000, lastCommissionIncreaseHeight: 0, @@ -249,13 +207,10 @@ const posValidators = [ }, ], address: 'lskvdf7k9d9jcefmz8o4t4odz825hh3q26o6mvbjy', - punishmentPeriods: [ - - ], + punishmentPeriods: [], validatorWeight: 100000000000, rank: 9, status: 'active', - valiatorWeight: 100000000000, }, { name: 'genesis_93', @@ -263,9 +218,7 @@ const posValidators = [ selfStake: '100000000000', lastGeneratedHeight: 0, isBanned: false, - reportMisbehaviorHeights: [ - - ], + reportMisbehaviorHeights: [], consecutiveMissedBlocks: 2720, commission: 5000, lastCommissionIncreaseHeight: 0, @@ -276,13 +229,10 @@ const posValidators = [ }, ], address: 'lskvfe2ug6bkb5jdwzoq48nx4dbd4n88brewo6s5c', - punishmentPeriods: [ - - ], + punishmentPeriods: [], validatorWeight: 100000000000, rank: 10, status: 'active', - valiatorWeight: 100000000000, }, ]; diff --git a/services/blockchain-indexer/tests/unit/shared/constants/transactionsDryRun.js b/services/blockchain-indexer/tests/unit/shared/constants/transactionsDryRun.js index f0285b6a0c..c98f772517 100644 --- a/services/blockchain-indexer/tests/unit/shared/constants/transactionsDryRun.js +++ b/services/blockchain-indexer/tests/unit/shared/constants/transactionsDryRun.js @@ -183,7 +183,7 @@ const mockTransactionsDryRunResult = { height: 29137, }, ], - status: 'ok', + status: 'valid', }, meta: {}, }; diff --git a/services/blockchain-indexer/tests/unit/shared/dataservice/transactions.test.js b/services/blockchain-indexer/tests/unit/shared/dataservice/transactions.test.js index f0e2167351..f3d5e1263b 100644 --- a/services/blockchain-indexer/tests/unit/shared/dataservice/transactions.test.js +++ b/services/blockchain-indexer/tests/unit/shared/dataservice/transactions.test.js @@ -47,7 +47,7 @@ describe('dryRunTransactions', () => { }); it('should return response on successful operation', async () => { - const mockResponse = { data: 'Success' }; + const mockResponse = { data: { success: true } }; const business = require(mockBusinessFilePath); jest.mock(mockBusinessFilePath, () => ({ @@ -104,7 +104,7 @@ describe('dryRunTransactions', () => { describe('Test isIncludePendingTransactions method', () => { it('should return true when called with pending execution status', async () => { - const executionStatus = 'pending,success'; + const executionStatus = 'pending,successful'; const { isIncludePendingTransactions } = require(transactionsFilePath); const result = isIncludePendingTransactions(executionStatus); expect(typeof result).toBe('boolean'); @@ -112,7 +112,7 @@ describe('Test isIncludePendingTransactions method', () => { }); it('should return false when called without pending execution status', async () => { - const executionStatus = 'success,fail'; + const executionStatus = 'successful,failed'; const { isIncludePendingTransactions } = require(transactionsFilePath); const result = isIncludePendingTransactions(executionStatus); expect(typeof result).toBe('boolean'); diff --git a/services/blockchain-indexer/tests/unit/shared/utils/transactions.test.js b/services/blockchain-indexer/tests/unit/shared/utils/transactions.test.js index c1a93ae6ca..a25d2e845a 100644 --- a/services/blockchain-indexer/tests/unit/shared/utils/transactions.test.js +++ b/services/blockchain-indexer/tests/unit/shared/utils/transactions.test.js @@ -14,6 +14,7 @@ * */ const { normalizeTransaction, getTransactionExecutionStatus } = require('../../../../shared/utils/transactions'); +const { TRANSACTION_STATUS } = require('../../../../shared/constants'); const { inputTransaction, @@ -26,11 +27,6 @@ const { eventsWithFailStatus, } = require('../../../constants/events'); -const TRANSACTION_STATUS = Object.freeze({ - SUCCESS: 'success', - FAIL: 'fail', -}); - describe('Test normalizeTransaction method', () => { it('should return normalizedTransaction -> valid tx', async () => { const normalizedTransaction = await normalizeTransaction(inputTransaction); @@ -48,14 +44,14 @@ describe('Test normalizeTransaction method', () => { }); describe('Test getTransactionExecutionStatus method', () => { - it('should return transaction execution status -> success', async () => { + it('should return transaction execution status -> successful', async () => { const executionStatus = await getTransactionExecutionStatus(validTx, eventsForValidTx); - expect(executionStatus).toBe(TRANSACTION_STATUS.SUCCESS); + expect(executionStatus).toBe(TRANSACTION_STATUS.SUCCESSFUL); }); - it('should return transaction execution status -> fail', async () => { + it('should return transaction execution status -> failed', async () => { const executionStatus = await getTransactionExecutionStatus(validTx, eventsWithFailStatus); - expect(executionStatus).toBe(TRANSACTION_STATUS.FAIL); + expect(executionStatus).toBe(TRANSACTION_STATUS.FAILED); }); it('should throw error when event is not available for the transaction', async () => { diff --git a/services/export/shared/helpers/file.js b/services/export/shared/helpers/file.js index 9997c19126..a46ea28a21 100644 --- a/services/export/shared/helpers/file.js +++ b/services/export/shared/helpers/file.js @@ -13,8 +13,8 @@ * Removal or modification of this copyright notice is prohibited. * */ -const BluebirdPromise = require('bluebird'); const fs = require('fs'); +const BluebirdPromise = require('bluebird'); const { Utils: { fs: { diff --git a/services/export/shared/helpers/s3.js b/services/export/shared/helpers/s3.js index 63a0e3bd48..ad167c880c 100644 --- a/services/export/shared/helpers/s3.js +++ b/services/export/shared/helpers/s3.js @@ -13,12 +13,11 @@ * Removal or modification of this copyright notice is prohibited. * */ -const Minio = require('minio'); -const moment = require('moment'); - const { Readable, } = require('stream'); +const Minio = require('minio'); +const moment = require('moment'); const { Logger, diff --git a/services/export/tests/constants/csvExport.js b/services/export/tests/constants/csvExport.js index 8de7a1aeeb..f7492e1d09 100644 --- a/services/export/tests/constants/csvExport.js +++ b/services/export/tests/constants/csvExport.js @@ -50,7 +50,7 @@ const tokenTransferTransaction = { name: 'genesis_0', }, }, - executionStatus: 'success', + executionStatus: 'successful', index: 0, }; @@ -85,7 +85,7 @@ const selfTokenTransferTransaction = { name: 'genesis_0', }, }, - executionStatus: 'success', + executionStatus: 'successful', index: 0, }; diff --git a/services/export/tests/constants/transaction.js b/services/export/tests/constants/transaction.js index 3836a1a703..e61eb4866d 100644 --- a/services/export/tests/constants/transaction.js +++ b/services/export/tests/constants/transaction.js @@ -37,7 +37,7 @@ const reclaimTransaction = { params: { amount: '16500000000', }, - executionStatus: 'success', + executionStatus: 'successful', index: 0, }; @@ -72,7 +72,7 @@ const tokenTransferTransaction = { name: 'genesis_0', }, }, - executionStatus: 'success', + executionStatus: 'successful', index: 0, }; @@ -107,7 +107,7 @@ const tokenTransferTransactionSelf = { name: 'genesis_0', }, }, - executionStatus: 'success', + executionStatus: 'successful', index: 0, }; @@ -137,7 +137,7 @@ const stakeTransaction = { timestamp: 1689775110, isFinal: true, }, - executionStatus: 'success', + executionStatus: 'successful', index: 1, }; @@ -173,7 +173,7 @@ const tokenTransferCrossChainTransaction = { address: 'lskyvvam5rxyvbvofxbdfcupxetzmqxu22phm4yuo', }, }, - executionStatus: 'success', + executionStatus: 'successful', index: 1, }; diff --git a/services/export/tests/unit/shared/transactionsExport.test.js b/services/export/tests/unit/shared/transactionsExport.test.js index 14723229a1..4a634aaa4a 100644 --- a/services/export/tests/unit/shared/transactionsExport.test.js +++ b/services/export/tests/unit/shared/transactionsExport.test.js @@ -15,8 +15,8 @@ */ /* eslint-disable mocha/max-top-level-suites */ -const moment = require('moment'); const { resolve } = require('path'); +const moment = require('moment'); const { interval, diff --git a/services/fee-estimator/shared/dynamicFees.js b/services/fee-estimator/shared/dynamicFees.js index fc1d8b3556..86fa913bb2 100644 --- a/services/fee-estimator/shared/dynamicFees.js +++ b/services/fee-estimator/shared/dynamicFees.js @@ -13,13 +13,13 @@ * Removal or modification of this copyright notice is prohibited. * */ +const util = require('util'); const { CacheRedis, Logger, Signals, } = require('lisk-service-framework'); -const util = require('util'); const { requestConnector } = require('./utils/request'); const config = require('../config'); diff --git a/services/gateway/apis/http-version3/swagger/definitions/blockchainApps.json b/services/gateway/apis/http-version3/swagger/definitions/blockchainApps.json index 77d4e766ae..c7e93537a8 100644 --- a/services/gateway/apis/http-version3/swagger/definitions/blockchainApps.json +++ b/services/gateway/apis/http-version3/swagger/definitions/blockchainApps.json @@ -22,7 +22,7 @@ }, "status": { "type": "string", - "example": "active", + "example": "activated", "description": "Current status of the application." }, "address": { @@ -99,17 +99,17 @@ "registered": { "type": "integer", "example": 2503, - "description": "List of registered blockchain applications" + "description": "List of registered blockchain applications." }, - "active": { + "activated": { "type": "integer", "example": 2328, - "description": "List of active blockchain applications" + "description": "List of activated blockchain applications." }, "terminated": { "type": "integer", "example": 35, - "description": "List of terminated blockchain applications" + "description": "List of terminated blockchain applications." }, "totalSupplyLSK": { "type": "string", @@ -210,7 +210,7 @@ }, "status": { "type": "string", - "example": "active", + "example": "activated", "description": "Current status of the application." }, "description": { diff --git a/services/gateway/apis/http-version3/swagger/definitions/blocks.json b/services/gateway/apis/http-version3/swagger/definitions/blocks.json index 70c1d0ecf5..f9d35f3cca 100644 --- a/services/gateway/apis/http-version3/swagger/definitions/blocks.json +++ b/services/gateway/apis/http-version3/swagger/definitions/blocks.json @@ -87,7 +87,7 @@ "stateRoot": { "type": "string", "example": "95d9b1773b78034b8df9ac741c903b881da761d8ba002a939de28a4b86982c04", - "description": "The root of the sparse Merkle tree that is computed from the state of the blockchain." + "description": "The root of the Sparse Merkle Tree that is computed from the state of the blockchain." }, "maxHeightGenerated": { "type": "integer", @@ -100,7 +100,7 @@ "validatorsHash": { "type": "string", "example": "ad0076aa444f6cda608bb163c3bd77d9bf172f1d2803d53095bc0f277db6bcb3", - "description": "Hash to authenticates the active set of validators" + "description": "Hash to authenticate the active set of validators." }, "aggregateCommit": { "type": "object", diff --git a/services/gateway/apis/http-version3/swagger/definitions/invoke.json b/services/gateway/apis/http-version3/swagger/definitions/invoke.json index e626f250e0..91292e0f28 100644 --- a/services/gateway/apis/http-version3/swagger/definitions/invoke.json +++ b/services/gateway/apis/http-version3/swagger/definitions/invoke.json @@ -62,7 +62,7 @@ "stateRoot": { "type": "string", "example": "95d9b1773b78034b8df9ac741c903b881da761d8ba002a939de28a4b86982c04", - "description": "The root of the sparse Merkle tree that is computed from the state of the blockchain." + "description": "The root of the Sparse Merkle Tree that is computed from the state of the blockchain." }, "maxHeightGenerated": { "type": "integer", @@ -75,7 +75,7 @@ "validatorsHash": { "type": "string", "example": "ad0076aa444f6cda608bb163c3bd77d9bf172f1d2803d53095bc0f277db6bcb3", - "description": "Hash to authenticates the active set of validators" + "description": "Hash to authenticate the active set of validators." }, "aggregateCommit": { "type": "object", diff --git a/services/gateway/apis/http-version3/swagger/definitions/schemas.json b/services/gateway/apis/http-version3/swagger/definitions/schemas.json index 4b72586661..ddb6445278 100644 --- a/services/gateway/apis/http-version3/swagger/definitions/schemas.json +++ b/services/gateway/apis/http-version3/swagger/definitions/schemas.json @@ -458,7 +458,7 @@ "type": "integer", "example": 2 } - } + } }, "certificateSignature": { "type": "object", @@ -1414,7 +1414,7 @@ "example": "array" }, "items": { - "type":"object", + "type": "object", "properties": { "dataType": { "type": "string", diff --git a/services/gateway/apis/http-version3/swagger/definitions/transactions.json b/services/gateway/apis/http-version3/swagger/definitions/transactions.json index b7b0b6eb15..de366cff67 100644 --- a/services/gateway/apis/http-version3/swagger/definitions/transactions.json +++ b/services/gateway/apis/http-version3/swagger/definitions/transactions.json @@ -262,8 +262,8 @@ }, "executionStatus": { "type": "string", - "example": "success", - "description": "Execution status of the transaction.\nAccepted values: pending, success, fail." + "example": "successful", + "description": "Execution status of the transaction.\nAccepted values: pending, successful, failed." }, "index": { "type": "integer", @@ -473,7 +473,7 @@ }, "status": { "type": "string", - "example": "ok", + "example": "valid", "description": "Transaction verification status." }, "events": { diff --git a/services/gateway/apis/http-version3/swagger/parameters/blockchainApps.json b/services/gateway/apis/http-version3/swagger/parameters/blockchainApps.json index 06507f39d5..94151d2013 100644 --- a/services/gateway/apis/http-version3/swagger/parameters/blockchainApps.json +++ b/services/gateway/apis/http-version3/swagger/parameters/blockchainApps.json @@ -27,7 +27,7 @@ "blockchainAppStatus": { "name": "status", "in": "query", - "description": "Status of the blockchain application. Can be expressed as CSV.\nAccepted values: 'registered', 'active', 'terminated'.", + "description": "Status of the blockchain application. Can be expressed as CSV.\nAccepted values: 'registered', 'activated', 'terminated'.", "type": "string" }, "network": { @@ -38,12 +38,12 @@ "minLength": 1 }, "blockchainAppSearch": { - "name": "search", - "in": "query", - "description": "Search by name. Supports both partial and full text search.", - "type": "string", - "minLength": 1, - "maxLength": 20 + "name": "search", + "in": "query", + "description": "Search by name. Supports both partial and full text search.", + "type": "string", + "minLength": 1, + "maxLength": 20 }, "chainName": { "name": "chainName", diff --git a/services/gateway/apis/http-version3/swagger/parameters/transactions.json b/services/gateway/apis/http-version3/swagger/parameters/transactions.json index dcc51c54cb..7760056a94 100644 --- a/services/gateway/apis/http-version3/swagger/parameters/transactions.json +++ b/services/gateway/apis/http-version3/swagger/parameters/transactions.json @@ -2,7 +2,7 @@ "executionStatus": { "name": "executionStatus", "in": "query", - "description": "Retrieve pending transactions.\nAccepted values: pending, success, fail.", + "description": "Query transactions by their executionStatus.\nAccepted values: pending, successful, failed.", "type": "string", "minLength": 1 }, diff --git a/services/gateway/shared/generateDocs.js b/services/gateway/shared/generateDocs.js index 72baecec5a..56bb044b58 100644 --- a/services/gateway/shared/generateDocs.js +++ b/services/gateway/shared/generateDocs.js @@ -13,10 +13,10 @@ * Removal or modification of this copyright notice is prohibited. * */ +const path = require('path'); const { Utils, } = require('lisk-service-framework'); -const path = require('path'); const BluebirdPromise = require('bluebird'); const { requireAllJson } = require('./utils'); const config = require('../config'); diff --git a/services/gateway/shared/moleculer-io/index.js b/services/gateway/shared/moleculer-io/index.js index 445b1f1824..b5e1706672 100755 --- a/services/gateway/shared/moleculer-io/index.js +++ b/services/gateway/shared/moleculer-io/index.js @@ -1,17 +1,18 @@ /* eslint-disable import/no-extraneous-dependencies,no-restricted-syntax,guard-for-in,no-use-before-define,prefer-const,no-unused-vars,eqeqeq,consistent-return,max-len,array-callback-return,no-const-assign */ +const util = require('util'); const IO = require('socket.io'); const _ = require('lodash'); const { ServiceNotFoundError } = require('moleculer').Errors; const chalk = require('chalk'); -const util = require('util'); - const BluebirdPromise = require('bluebird'); const { RateLimiterMemory } = require('rate-limiter-flexible'); const { - Constants: { JSON_RPC: { INVALID_REQUEST, METHOD_NOT_FOUND, SERVER_ERROR } }, + Constants: { + JSON_RPC: { INVALID_REQUEST, METHOD_NOT_FOUND, SERVER_ERROR }, + }, Utils, CacheRedis, } = require('lisk-service-framework'); @@ -21,7 +22,7 @@ const { BadRequestError } = require('./errors'); const { isValidNonEmptyResponse } = require('../utils'); const rpcCache = CacheRedis('rpcCache', config.volatileRedis); -const expireMiliseconds = config.rpcCache.ttl * 1000; +const expireMilliseconds = config.rpcCache.ttl * 1000; const rateLimiter = new RateLimiterMemory(config.websocket.rateLimit); @@ -86,7 +87,9 @@ module.exports = { if (item.authorization) { this.logger.debug('Add authorization to handler:', item); if (!_.isFunction(this.socketAuthorize)) { - this.logger.warn("Define 'socketAuthorize' method in the service to enable authorization."); + this.logger.warn( + "Define 'socketAuthorize' method in the service to enable authorization.", + ); item.authorization = false; } else { // add authorize middleware @@ -161,13 +164,16 @@ module.exports = { throw new ServiceNotFoundError({ action }); } // get callOptions - const opts = _.assign({ - meta: this.socketGetMeta(socket), - callOptions: { - timeout: 30000, - retries: 3, + const opts = _.assign( + { + meta: this.socketGetMeta(socket), + callOptions: { + timeout: 30000, + retries: 3, + }, }, - }, handlerItem.callOptions); + handlerItem.callOptions, + ); this.logger.debug('Call action:', action, params, opts); const request = { action, @@ -189,7 +195,7 @@ module.exports = { res = (await handlerItem.onAfterCall.call(this, ctx, socket, request, res)) || res; } // Store tranformed response in redis cache - if (isValidNonEmptyResponse(res)) await rpcCache.set(rpcRequestCacheKey, JSON.stringify(res), expireMiliseconds); + if (isValidNonEmptyResponse(res)) await rpcCache.set(rpcRequestCacheKey, JSON.stringify(res), expireMilliseconds); } } else { res = await ctx.call(action, request.params, opts); @@ -247,12 +253,15 @@ module.exports = { }, handler(ctx) { return new Promise((resolve, reject) => { - this.io.of(ctx.params.namespaces || '/').to(ctx.params.room).clients((err, clients) => { - if (err) { - return reject(err); - } - resolve(clients); - }); + this.io + .of(ctx.params.namespaces || '/') + .to(ctx.params.room) + .clients((err, clients) => { + if (err) { + return reject(err); + } + resolve(clients); + }); }); }, }, @@ -308,7 +317,7 @@ module.exports = { }, socketJoinRooms(socket, rooms) { this.logger.debug(`socket ${socket.id} join room:`, rooms); - return new Promise(((resolve, reject) => { + return new Promise((resolve, reject) => { socket.join(rooms, err => { if (err) { reject(err); @@ -316,10 +325,10 @@ module.exports = { resolve(); } }); - })); + }); }, socketLeaveRoom(socket, room) { - return new Promise(((resolve, reject) => { + return new Promise((resolve, reject) => { socket.leave(room, err => { if (err) { reject(err); @@ -327,7 +336,7 @@ module.exports = { resolve(); } }); - })); + }); }, }, }; @@ -338,7 +347,9 @@ function checkOrigin(origin, settings) { if (settings.indexOf('*') !== -1) { // Based on: https://github.com/hapijs/hapi - const wildcard = new RegExp(`^${_.escapeRegExp(settings).replace(/\\\*/g, '.*').replace(/\\\?/g, '.')}$`); + const wildcard = new RegExp( + `^${_.escapeRegExp(settings).replace(/\\\*/g, '.*').replace(/\\\?/g, '.')}$`, + ); return origin.match(wildcard); } } else if (Array.isArray(settings)) { @@ -396,8 +407,13 @@ function makeHandler(svc, handlerItem) { return async function (requests, respond, socket, eventName) { if (config.websocket.enableRateLimit) await rateLimiter.consume(this.handshake.address); const performClientRequest = async (jsonRpcInput, id = 1) => { - if (config.jsonRpcStrictMode === 'true' && (!jsonRpcInput.jsonrpc || jsonRpcInput.jsonrpc !== '2.0')) { - const message = `The given data is not a proper JSON-RPC 2.0 request: ${util.inspect(jsonRpcInput)}`; + if ( + config.jsonRpcStrictMode === 'true' + && (!jsonRpcInput.jsonrpc || jsonRpcInput.jsonrpc !== '2.0') + ) { + const message = `The given data is not a proper JSON-RPC 2.0 request: ${util.inspect( + jsonRpcInput, + )}`; svc.logger.debug(message); return addErrorEnvelope(id, INVALID_REQUEST[0], `Client input error: ${message}`); } @@ -415,18 +431,39 @@ function makeHandler(svc, handlerItem) { respond = params; params = null; } - const res = await svc.actions.call({ socket: this, action, params: jsonRpcInput, handlerItem }); + const res = await svc.actions.call({ + socket: this, + action, + params: jsonRpcInput, + handlerItem, + }); svc.logger.info(` <= ${chalk.green.bold('Success')} ${action}`); const output = addJsonRpcEnvelope(id, res); respond(output); } catch (err) { - if (svc.settings.log4XXResponses || Utils.isProperObject(err) && !_.inRange(err.code, 400, 500)) { - svc.logger.error(' Request error!', err.name, ':', err.message, '\n', err.stack, '\nData:', err.data); + if ( + svc.settings.log4XXResponses + || (Utils.isProperObject(err) && !_.inRange(err.code, 400, 500)) + ) { + svc.logger.error( + ' Request error!', + err.name, + ':', + err.message, + '\n', + err.stack, + '\nData:', + err.data, + ); } if (typeof err.message === 'string') { if (!err.code || err.code === 500) { - return addErrorEnvelope(id, translateHttpToRpcCode(err.code), `Server error: ${err.message}`); + return addErrorEnvelope( + id, + translateHttpToRpcCode(err.code), + `Server error: ${err.message}`, + ); } return addErrorEnvelope(id, translateHttpToRpcCode(err.code), err.message); } @@ -445,10 +482,12 @@ function makeHandler(svc, handlerItem) { try { const data = await BluebirdPromise.map( requests, - async (request) => { - const id = request.id || (requests.indexOf(request)) + 1; + async request => { + const id = request.id || requests.indexOf(request) + 1; const response = await performClientRequest(request, id); - svc.logger.debug(`Requested ${request.method} with params ${JSON.stringify(request.params)}`); + svc.logger.debug( + `Requested ${request.method} with params ${JSON.stringify(request.params)}`, + ); if (response.error) { svc.logger.warn(`${response.error.code} ${response.error.message}`); } @@ -464,7 +503,10 @@ function makeHandler(svc, handlerItem) { if (respond) respond(response); else socket.emit('request', response); } catch (err) { - svc.socketOnError(addErrorEnvelope(null, translateHttpToRpcCode(err.code), `Server error: ${err.message}`), respond); + svc.socketOnError( + addErrorEnvelope(null, translateHttpToRpcCode(err.code), `Server error: ${err.message}`), + respond, + ); } }; } diff --git a/services/gateway/shared/moleculer-web/methods.js b/services/gateway/shared/moleculer-web/methods.js index 6599248af3..c69af43602 100644 --- a/services/gateway/shared/moleculer-web/methods.js +++ b/services/gateway/shared/moleculer-web/methods.js @@ -1,14 +1,14 @@ /* eslint-disable import/no-extraneous-dependencies,eqeqeq,consistent-return */ /* -* moleculer + * moleculer * Copyright (c) 2020 MoleculerJS (https://github.com/moleculerjs/moleculer) * MIT Licensed */ +const util = require('util'); const { MoleculerError, MoleculerServerError } = require('moleculer').Errors; const _ = require('lodash'); const kleur = require('kleur'); -const util = require('util'); module.exports = { methods: { @@ -43,16 +43,23 @@ module.exports = { } } catch (err) { if (this.settings.log4XXResponses || (err && !_.inRange(err.code, 400, 500))) { - const reqParams = Object - .fromEntries(new Map(Object.entries(req.$params).filter(([, v]) => v))); - if (err && err.name !== 'ValidationException') this.logger.error(`<= ${this.coloringStatusCode(err.code)} Request error: ${err.name}: ${err.message} \n${err.stack} \nData: \nRequest params: ${util.inspect(reqParams)} \nRequest body: ${util.inspect(req.body)}`); + const reqParams = Object.fromEntries( + new Map(Object.entries(req.$params).filter(([, v]) => v)), + ); + if (err && err.name !== 'ValidationException') this.logger.error( + `<= ${this.coloringStatusCode(err.code)} Request error: ${err.name}: ${ + err.message + } \n${err.stack} \nData: \nRequest params: ${util.inspect( + reqParams, + )} \nRequest body: ${util.inspect(req.body)}`, + ); } if (err && err.name === 'ValidationException') { const molecularError = new MoleculerError(err.message, 400); this.sendError(req, res, molecularError); } else { - const errMessage = (err && err.message) ? err.message : 'Internal server error'; + const errMessage = err && err.message ? err.message : 'Internal server error'; const molecularError = new MoleculerServerError(errMessage, 500); this.sendError(req, res, molecularError); } @@ -72,7 +79,11 @@ module.exports = { if (this.settings.enable2XXResponses) { if (this.settings.log2XXResponses && this.settings.log2XXResponses in this.logger) { - this.logger[this.settings.log2XXResponses](`<= ${this.coloringStatusCode(res.statusCode)} ${req.method} ${kleur.bold(req.originalUrl)} ${time}`); + this.logger[this.settings.log2XXResponses]( + `<= ${this.coloringStatusCode(res.statusCode)} ${req.method} ${kleur.bold( + req.originalUrl, + )} ${time}`, + ); } if (this.settings.logResponseData && this.settings.logResponseData in this.logger) { this.logger[this.settings.logResponseData](' Data:', data); @@ -131,5 +142,4 @@ module.exports = { } }, }, - }; diff --git a/services/gateway/shared/regex.js b/services/gateway/shared/regex.js index 643774c012..83d7da6872 100644 --- a/services/gateway/shared/regex.js +++ b/services/gateway/shared/regex.js @@ -32,12 +32,12 @@ const NAME = /^[\w!@$&.]{3,20}$/; const NAME_CSV = /^\b[\w!@$&.,]{3,}\b$/; const NETWORK_VERSION = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(.\+[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*)?$/; const TRANSACTION = /^\b[0-9a-fA-F]+\b$/; -const TRANSACTION_EXECUTION_STATUS = /^\b(?:pending|success|fail|,){0,5}\b$/; +const TRANSACTION_EXECUTION_STATUS = /^\b(?:pending|successful|failed|,){0,5}\b$/; const POS_VALIDATOR_STATUS = /^\b(?:active|standby|banned|punished|ineligible|,){0,9}\b$/; const CCM_STATUS = /^\b(?:ok|module_not_supported|module_not_supported|channel_unavailable|recovered|,){0,9}\b$/; const DATE_INTERVAL = /^\b(?:(?:\d{4})-(?:(?:1[012])|(?:0?[1-9]))-(?:(?:[012][1-9])|(?:[123]0)|31))(?::(?:(?:\d{4})-(?:(?:1[012])|(?:0?[1-9]))-(?:(?:[012][1-9])|(?:[123]0)|31)))?\b$/; const NETWORK_CSV = /^\b(?:mainnet|testnet|betanet|devnet|,){0,7}\b$/; -const APPLICATION_STATUS = /^\b(?:registered|active|terminated|unregistered|,){1,7}\b$/; +const APPLICATION_STATUS = /^\b(?:registered|activated|terminated|unregistered|,){1,7}\b$/; const MODULE_COMMAND = /^[0-9a-zA-Z]{0,32}:[0-9a-zA-Z]{0,32}$/; const CHAIN_ID = /^\b[a-fA-F0-9]{8}\b$/; const CHAIN_ID_CSV = /^\b(?:[a-fA-F0-9]{8}|,)+\b$/; diff --git a/services/gateway/shared/registerHttpApi.js b/services/gateway/shared/registerHttpApi.js index fdeea446de..723d60b050 100644 --- a/services/gateway/shared/registerHttpApi.js +++ b/services/gateway/shared/registerHttpApi.js @@ -13,6 +13,7 @@ * Removal or modification of this copyright notice is prohibited. * */ +const path = require('path'); const { Utils, HTTP: { StatusCodes }, @@ -21,7 +22,6 @@ const { Logger, } = require('lisk-service-framework'); -const path = require('path'); const gatewayConfig = require('../config'); const { transformPath, transformRequest, transformResponse } = require('./apiUtils'); const { validate, dropEmptyProps } = require('./paramValidator'); diff --git a/services/gateway/shared/registerRpcApi.js b/services/gateway/shared/registerRpcApi.js index 4fd30d7148..6e93559a5c 100644 --- a/services/gateway/shared/registerRpcApi.js +++ b/services/gateway/shared/registerRpcApi.js @@ -13,14 +13,16 @@ * Removal or modification of this copyright notice is prohibited. * */ +const path = require('path'); const { Utils, - Constants: { JSON_RPC: { INVALID_PARAMS, INVALID_REQUEST, SERVICE_UNAVAILABLE } }, + Constants: { + JSON_RPC: { INVALID_PARAMS, INVALID_REQUEST, SERVICE_UNAVAILABLE }, + }, Logger, } = require('lisk-service-framework'); const { MoleculerClientError } = require('moleculer').Errors; -const path = require('path'); const { transformPath, transformRequest, transformResponse } = require('./apiUtils'); const { validate } = require('./paramValidator'); @@ -42,12 +44,11 @@ const configureApi = (apiNames, apiPrefix, registeredModuleNames) => { registeredModuleNames.forEach(moduleName => { const dirPath = `../apis/${apiName}/methods/modules/${moduleName}`; try { - Object.assign( - allMethods, - Utils.requireAllJs(path.resolve(__dirname, dirPath)), - ); + Object.assign(allMethods, Utils.requireAllJs(path.resolve(__dirname, dirPath))); } catch (err) { - logger.warn(`Moleculer method definitions (RPC endpoints) missing for module: ${module}. Is this expected?\nWas expected at: ${dirPath}.`); + logger.warn( + `Moleculer method definitions (RPC endpoints) missing for module: ${module}. Is this expected?\nWas expected at: ${dirPath}.`, + ); } }); }); @@ -61,17 +62,26 @@ const configureApi = (apiNames, apiPrefix, registeredModuleNames) => { return { ...acc, [key]: method }; }, {}); - const whitelist = Object.keys(methods).reduce((acc, key) => [ - ...acc, methods[key].source.method, - ], []); + const whitelist = Object.keys(methods).reduce( + (acc, key) => [...acc, methods[key].source.method], + [], + ); - const aliases = Object.keys(methods).reduce((acc, key) => ({ - ...acc, [`${transformPath(methods[key].rpcMethod)}`]: methods[key].source.method, - }), {}); + const aliases = Object.keys(methods).reduce( + (acc, key) => ({ + ...acc, + [`${transformPath(methods[key].rpcMethod)}`]: methods[key].source.method, + }), + {}, + ); - const methodPaths = Object.keys(methods).reduce((acc, key) => ({ - ...acc, [`${transformPath(methods[key].rpcMethod)}`]: methods[key], - }), {}); + const methodPaths = Object.keys(methods).reduce( + (acc, key) => ({ + ...acc, + [`${transformPath(methods[key].rpcMethod)}`]: methods[key], + }), + {}, + ); const meta = { apiPrefix, @@ -103,10 +113,7 @@ const registerApi = (apiNames, config, registeredModuleNames) => { ...config, mappingPolicy: 'restrict', - whitelist: [ - ...config.whitelist, - ...whitelist, - ], + whitelist: [...config.whitelist, ...whitelist], aliases: { ...config.aliases, ...aliases, @@ -116,21 +123,37 @@ const registerApi = (apiNames, config, registeredModuleNames) => { const paramReport = validate(request.params, methodPaths[request.method]); if (paramReport.missing.length > 0) { - throw new MoleculerClientError({ code: INVALID_PARAMS[0], message: `Missing parameter(s): ${paramReport.missing.join(', ')}` }); + throw new MoleculerClientError({ + code: INVALID_PARAMS[0], + message: `Missing parameter(s): ${paramReport.missing.join(', ')}`, + }); } const unknownList = Object.keys(paramReport.unknown); if (unknownList.length > 0) { - throw new MoleculerClientError({ code: INVALID_PARAMS[0], message: `Unknown input parameter(s): ${unknownList.join(', ')}` }); + throw new MoleculerClientError({ + code: INVALID_PARAMS[0], + message: `Unknown input parameter(s): ${unknownList.join(', ')}`, + }); } if (paramReport.required.length) { - throw new MoleculerClientError({ code: INVALID_REQUEST[0], message: `Require one of the following parameter combination(s): ${paramReport.required.join(', ')}` }); + throw new MoleculerClientError({ + code: INVALID_REQUEST[0], + message: `Require one of the following parameter combination(s): ${paramReport.required.join( + ', ', + )}`, + }); } const invalidList = paramReport.invalid; if (invalidList.length > 0) { - throw new MoleculerClientError({ code: INVALID_PARAMS[0], message: `Invalid input parameter values: ${invalidList.map(o => o.message).join(', ')}` }); + throw new MoleculerClientError({ + code: INVALID_PARAMS[0], + message: `Invalid input parameter values: ${invalidList + .map(o => o.message) + .join(', ')}`, + }); } request.params = transformRequest(methodPaths[request.method], paramReport.valid); @@ -139,8 +162,14 @@ const registerApi = (apiNames, config, registeredModuleNames) => { onAfterCall: async (ctx, socket, req, data) => { if (data.data && data.status) { if (data.status === 'INVALID_PARAMS') throw new MoleculerClientError({ code: INVALID_PARAMS[0], message: data.data.error }); - if (data.status === 'SERVICE_UNAVAILABLE') throw new MoleculerClientError({ code: SERVICE_UNAVAILABLE[0], message: data.data.error }); - if (data.status !== 'ACCEPTED') throw new MoleculerClientError({ code: INVALID_REQUEST[0], message: data.data.error }); + if (data.status === 'SERVICE_UNAVAILABLE') throw new MoleculerClientError({ + code: SERVICE_UNAVAILABLE[0], + message: data.data.error, + }); + if (data.status !== 'ACCEPTED') throw new MoleculerClientError({ + code: INVALID_REQUEST[0], + message: data.data.error, + }); } return transformResponse(methodPaths[req.method], data); diff --git a/services/gateway/sources/version3/blockchainAppsStatsSchema.js b/services/gateway/sources/version3/blockchainAppsStatsSchema.js index 3c1a0f4fa2..cee37763d4 100644 --- a/services/gateway/sources/version3/blockchainAppsStatsSchema.js +++ b/services/gateway/sources/version3/blockchainAppsStatsSchema.js @@ -20,7 +20,7 @@ module.exports = { definition: { data: { registered: '=,number', - active: '=,number', + activated: '=,number', terminated: '=,number', totalSupplyLSK: '=,string', totalStakedLSK: '=,string', diff --git a/services/gateway/tests/unit/shared/status.test.js b/services/gateway/tests/unit/shared/status.test.js index d372526c81..03f02d387d 100644 --- a/services/gateway/tests/unit/shared/status.test.js +++ b/services/gateway/tests/unit/shared/status.test.js @@ -13,15 +13,15 @@ * Removal or modification of this copyright notice is prohibited. * */ + +const fs = require('fs'); +const path = require('path'); const { Utils: { fs: { exists, rmdir }, }, } = require('lisk-service-framework'); -const fs = require('fs'); -const path = require('path'); - const { getBuildTimestamp } = require('../../../shared/status'); describe('Test getBuildTimestamp method', () => { diff --git a/services/transaction-statistics/shared/database/init.js b/services/transaction-statistics/shared/database/init.js index 375965e283..710f2afb7a 100644 --- a/services/transaction-statistics/shared/database/init.js +++ b/services/transaction-statistics/shared/database/init.js @@ -13,8 +13,8 @@ * Removal or modification of this copyright notice is prohibited. * */ -const BluebirdPromise = require('bluebird'); const path = require('path'); +const BluebirdPromise = require('bluebird'); const { Logger, diff --git a/tests/integration/api_v3/http/postTransactions.test.js b/tests/integration/api_v3/http/postTransactions.test.js index bf6da7dc58..0e1bc53929 100644 --- a/tests/integration/api_v3/http/postTransactions.test.js +++ b/tests/integration/api_v3/http/postTransactions.test.js @@ -45,7 +45,7 @@ describe('Post transactions API', () => { } }); - it('should post transaction succesfully', async () => { + it('should post transaction successfully', async () => { if (isDevnet) { const transaction = await createTokenTransferTx(authEndpoint); const encodedTx = await encodeTransaction(transaction, baseUrlV3); diff --git a/tests/integration/api_v3/http/transactionsDryRun.test.js b/tests/integration/api_v3/http/transactionsDryRun.test.js index 363d6e8537..355935775e 100644 --- a/tests/integration/api_v3/http/transactionsDryRun.test.js +++ b/tests/integration/api_v3/http/transactionsDryRun.test.js @@ -28,10 +28,7 @@ const { } = require('../constants/transactionsDryRun'); const { waitMs } = require('../../../helpers/utils'); -const { - badRequestSchema, - wrongInputParamSchema, -} = require('../../../schemas/httpGenerics.schema'); +const { badRequestSchema, wrongInputParamSchema } = require('../../../schemas/httpGenerics.schema'); const { dryrunTransactionSuccessResponseSchema, @@ -62,7 +59,7 @@ describe('Post dryrun transactions API', () => { } }); - it('should return proper response (fail) when transaction object has less than required fee', async () => { + it('should return proper response (pending) when transaction object has less than required fee', async () => { if (isDevnet) { const response = await api.post(endpoint, { transaction: TRANSACTION_OBJECT_PENDING }); expect(response).toMap(goodRequestSchemaForTransactionsDryRun); @@ -71,7 +68,7 @@ describe('Post dryrun transactions API', () => { } }); - it('should return proper response (fail) when transaction string has less than required fee', async () => { + it('should return proper response (pending) when transaction string has less than required fee', async () => { if (isDevnet) { const response = await api.post(endpoint, { transaction: TRANSACTION_ENCODED_PENDING }); expect(response).toMap(goodRequestSchemaForTransactionsDryRun); @@ -80,7 +77,7 @@ describe('Post dryrun transactions API', () => { } }); - it('should post dryrun transaction succesfully with only transaction object', async () => { + it('should post dryrun transaction successfully with only transaction object', async () => { if (isDevnet) { const response = await api.post(endpoint, { transaction: TRANSACTION_OBJECT_VALID }); expect(response).toMap(goodRequestSchemaForTransactionsDryRun); @@ -89,7 +86,7 @@ describe('Post dryrun transactions API', () => { } }); - it('should post dryrun transaction succesfully with only transaction string', async () => { + it('should post dryrun transaction successfully with only transaction string', async () => { if (isDevnet) { const response = await api.post(endpoint, { transaction: TRANSACTION_ENCODED_VALID }); expect(response).toMap(goodRequestSchemaForTransactionsDryRun); @@ -98,12 +95,12 @@ describe('Post dryrun transactions API', () => { } }); - it('should return proper response (success) when posting unsigned transaction with strict: false', async () => { + it('should return proper response (valid) when posting unsigned transaction with strict: false', async () => { if (isDevnet) { - const response = await api.post( - endpoint, - { transaction: UNSIGNED_TRANSACTION_OBJECT, strict: false }, - ); + const response = await api.post(endpoint, { + transaction: UNSIGNED_TRANSACTION_OBJECT, + strict: false, + }); expect(response).toMap(goodRequestSchemaForTransactionsDryRun); expect(response.data).toMap(dryrunTransactionSuccessResponseSchema); expect(response.data.events.length).toBeGreaterThan(0); @@ -113,22 +110,22 @@ describe('Post dryrun transactions API', () => { it('should return proper response (invalid) when posting unsigned transaction with strict: true', async () => { if (isDevnet) { - const response = await api.post( - endpoint, - { transaction: UNSIGNED_TRANSACTION_OBJECT, strict: true }, - ); + const response = await api.post(endpoint, { + transaction: UNSIGNED_TRANSACTION_OBJECT, + strict: true, + }); expect(response).toMap(goodRequestSchemaForTransactionsDryRun); expect(response.data).toMap(dryrunTransactionInvalidResponseSchema); expect(response.meta).toMap(metaSchema); } }); - it('should post dryrun transaction succesfully with only transaction skipping verification', async () => { + it('should post dryrun transaction successfully with only transaction skipping verification', async () => { if (isDevnet) { - const response = await api.post( - endpoint, - { transaction: TRANSACTION_OBJECT_VALID, skipVerify: true }, - ); + const response = await api.post(endpoint, { + transaction: TRANSACTION_OBJECT_VALID, + skipVerify: true, + }); expect(response).toMap(goodRequestSchemaForTransactionsDryRun); expect(response.data).toMap(dryrunTransactionSuccessResponseSchema); expect(response.data.events.length).toBeGreaterThan(0); @@ -136,12 +133,12 @@ describe('Post dryrun transactions API', () => { } }); - it('should post dryrun transaction succesfully with skipDecode: true', async () => { + it('should post dryrun transaction successfully with skipDecode: true', async () => { if (isDevnet) { - const response = await api.post( - endpoint, - { transaction: TRANSACTION_ENCODED_VALID, skipDecode: true }, - ); + const response = await api.post(endpoint, { + transaction: TRANSACTION_ENCODED_VALID, + skipDecode: true, + }); expect(response).toMap(goodRequestSchemaForTransactionsDryRun); expect(response.data).toMap(dryrunTxSuccessSchemaWithSkipDecode); expect(response.meta).toMap(metaSchema); diff --git a/tests/integration/api_v3/rpc/postTransactions.test.js b/tests/integration/api_v3/rpc/postTransactions.test.js index 33cef3956a..3bb5b04242 100644 --- a/tests/integration/api_v3/rpc/postTransactions.test.js +++ b/tests/integration/api_v3/rpc/postTransactions.test.js @@ -49,7 +49,7 @@ describe('Method post.transactions', () => { } }); - it('should post transaction succesfully', async () => { + it('should post transaction successfully', async () => { if (isDevnet) { const transaction = await createTokenTransferTx(authEndpoint); const encodedTx = await encodeTransaction(transaction, baseUrlV3); diff --git a/tests/integration/api_v3/rpc/transactionsDryRun.test.js b/tests/integration/api_v3/rpc/transactionsDryRun.test.js index ce06dbe6f7..0b13ffab12 100644 --- a/tests/integration/api_v3/rpc/transactionsDryRun.test.js +++ b/tests/integration/api_v3/rpc/transactionsDryRun.test.js @@ -27,9 +27,7 @@ const { } = require('../constants/transactionsDryRun'); const { waitMs } = require('../../../helpers/utils'); -const { - request, -} = require('../../../helpers/socketIoRpcRequest'); +const { request } = require('../../../helpers/socketIoRpcRequest'); const { invalidParamsSchema, @@ -68,7 +66,7 @@ describe('Method post.transactions.dryrun', () => { } }); - it('should return proper response (fail) when transaction string has less than required fee', async () => { + it('should return proper response (pending) when transaction string has less than required fee', async () => { if (isDevnet) { const response = await postDryrunTransaction({ transaction: TRANSACTION_ENCODED_PENDING }); expect(response).toMap(jsonRpcEnvelopeSchema); @@ -81,7 +79,7 @@ describe('Method post.transactions.dryrun', () => { } }); - it('should return proper response (fail) when transaction object has less than required fee', async () => { + it('should return proper response (pending) when transaction object has less than required fee', async () => { if (isDevnet) { const response = await postDryrunTransaction({ transaction: TRANSACTION_OBJECT_PENDING }); expect(response).toMap(jsonRpcEnvelopeSchema); @@ -94,7 +92,7 @@ describe('Method post.transactions.dryrun', () => { } }); - it('should post dryrun transaction succesfully with only transaction object', async () => { + it('should post dryrun transaction successfully with only transaction object', async () => { if (isDevnet) { const response = await postDryrunTransaction({ transaction: TRANSACTION_OBJECT_VALID }); expect(response).toMap(jsonRpcEnvelopeSchema); @@ -107,7 +105,7 @@ describe('Method post.transactions.dryrun', () => { } }); - it('should post dryrun transaction succesfully with only transaction string', async () => { + it('should post dryrun transaction successfully with only transaction string', async () => { if (isDevnet) { const response = await postDryrunTransaction({ transaction: TRANSACTION_ENCODED_VALID }); expect(response).toMap(jsonRpcEnvelopeSchema); @@ -120,14 +118,12 @@ describe('Method post.transactions.dryrun', () => { } }); - it('should post dryrun transaction succesfully skipping verification', async () => { + it('should post dryrun transaction successfully skipping verification', async () => { if (isDevnet) { - const response = await postDryrunTransaction( - { - transaction: TRANSACTION_OBJECT_VALID, - skipVerify: true, - }, - ); + const response = await postDryrunTransaction({ + transaction: TRANSACTION_OBJECT_VALID, + skipVerify: true, + }); expect(response).toMap(jsonRpcEnvelopeSchema); const { result } = response; @@ -138,13 +134,12 @@ describe('Method post.transactions.dryrun', () => { } }); - it('should post dryrun transaction succesfully with skipDecode: true', async () => { + it('should post dryrun transaction successfully with skipDecode: true', async () => { if (isDevnet) { - const response = await postDryrunTransaction( - { - transaction: TRANSACTION_ENCODED_VALID, skipDecode: true, - }, - ); + const response = await postDryrunTransaction({ + transaction: TRANSACTION_ENCODED_VALID, + skipDecode: true, + }); expect(response).toMap(jsonRpcEnvelopeSchema); const { result } = response; @@ -155,14 +150,12 @@ describe('Method post.transactions.dryrun', () => { } }); - it('should return proper response (success) when calling with unsigned transaction with strict: false', async () => { + it('should return proper response (valid) when calling with unsigned transaction with strict: false', async () => { if (isDevnet) { - const response = await postDryrunTransaction( - { - transaction: UNSIGNED_TRANSACTION_OBJECT, - strict: false, - }, - ); + const response = await postDryrunTransaction({ + transaction: UNSIGNED_TRANSACTION_OBJECT, + strict: false, + }); expect(response).toMap(jsonRpcEnvelopeSchema); const { result } = response; @@ -175,12 +168,10 @@ describe('Method post.transactions.dryrun', () => { it('should return proper response (invalid) when calling with unsigned transaction with strict: true', async () => { if (isDevnet) { - const response = await postDryrunTransaction( - { - transaction: UNSIGNED_TRANSACTION_OBJECT, - strict: true, - }, - ); + const response = await postDryrunTransaction({ + transaction: UNSIGNED_TRANSACTION_OBJECT, + strict: true, + }); expect(response).toMap(jsonRpcEnvelopeSchema); const { result } = response; diff --git a/tests/schemas/api_v3/blockchainApps.schema.js b/tests/schemas/api_v3/blockchainApps.schema.js index 70a2e622b7..f597ca6fcd 100644 --- a/tests/schemas/api_v3/blockchainApps.schema.js +++ b/tests/schemas/api_v3/blockchainApps.schema.js @@ -18,7 +18,7 @@ import regex from './regex'; const { metaSchema } = require('../generics.schema'); -const validStatuses = ['registered', 'active', 'terminated', 'any']; +const validStatuses = ['registered', 'activated', 'terminated', 'any']; const getCurrentTimestamp = () => Math.floor(Date.now() / 1000); const goodRequestSchemaForStats = { @@ -29,7 +29,7 @@ const goodRequestSchemaForStats = { const blockchainAppsStatsSchema = { registered: Joi.number().integer().min(0).required(), - active: Joi.number().integer().min(0).required(), + activated: Joi.number().integer().min(0).required(), terminated: Joi.number().integer().min(0).required(), totalSupplyLSK: Joi.string().required(), totalStakedLSK: Joi.string().required(), diff --git a/tests/schemas/api_v3/blockchainAppsMetadataSchema.schema.js b/tests/schemas/api_v3/blockchainAppsMetadataSchema.schema.js index b63c8bf5d9..9426d99021 100644 --- a/tests/schemas/api_v3/blockchainAppsMetadataSchema.schema.js +++ b/tests/schemas/api_v3/blockchainAppsMetadataSchema.schema.js @@ -17,7 +17,7 @@ import Joi from 'joi'; import regex from './regex'; const EMPTY_STRING = ''; -const validStatuses = ['registered', 'active', 'terminated', 'unregistered']; +const validStatuses = ['registered', 'activated', 'terminated', 'unregistered']; const logo = { png: Joi.string().required(), diff --git a/tests/schemas/api_v3/constants/transactions.js b/tests/schemas/api_v3/constants/transactions.js index e60878dfef..8c3ba3ba15 100644 --- a/tests/schemas/api_v3/constants/transactions.js +++ b/tests/schemas/api_v3/constants/transactions.js @@ -16,8 +16,8 @@ const TRANSACTION_EXECUTION_STATUSES = [ 'pending', - 'success', - 'fail', + 'successful', + 'failed', ]; module.exports = { diff --git a/tests/schemas/api_v3/transactionsDryRun.schema.js b/tests/schemas/api_v3/transactionsDryRun.schema.js index 4bfe6855af..be3ab7dd7c 100644 --- a/tests/schemas/api_v3/transactionsDryRun.schema.js +++ b/tests/schemas/api_v3/transactionsDryRun.schema.js @@ -16,12 +16,7 @@ import Joi from 'joi'; const regex = require('./regex'); - -const TRANSACTION_VERIFY_RESULT = { - INVALID: -1, - PENDING: 0, - OK: 1, -}; +const { TRANSACTION_VERIFY_RESULT } = require('../../../services/blockchain-indexer/shared/constants'); const TRANSACTION_VERIFY_STATUSES = Object .keys(TRANSACTION_VERIFY_RESULT).map(e => e.toLowerCase()); @@ -42,13 +37,13 @@ const eventSchemaWithSkipDecode = { }; const dryrunTransactionSuccessResponseSchema = { - result: Joi.number().integer().valid(TRANSACTION_VERIFY_RESULT.OK).required(), + result: Joi.number().integer().valid(TRANSACTION_VERIFY_RESULT.VALID).required(), status: Joi.string().valid(...TRANSACTION_VERIFY_STATUSES).required(), events: Joi.array().items(Joi.object(event).required()).min(1).required(), }; const dryrunTxSuccessSchemaWithSkipDecode = { - result: Joi.number().integer().valid(TRANSACTION_VERIFY_RESULT.OK).required(), + result: Joi.number().integer().valid(TRANSACTION_VERIFY_RESULT.VALID).required(), status: Joi.string().valid(...TRANSACTION_VERIFY_STATUSES).required(), events: Joi.array().items(Joi.object(eventSchemaWithSkipDecode).required()).min(1).required(), };