From 1ae1796bd9db17230f062f7566b2d72c4d81b341 Mon Sep 17 00:00:00 2001 From: Hamid HK Date: Tue, 6 Jun 2023 22:29:34 +0330 Subject: [PATCH 01/12] Add profile event constants to connector --- .../shared/sdk/constants/eventTopics.js | 6 ++++++ .../blockchain-connector/shared/sdk/constants/names.js | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/services/blockchain-connector/shared/sdk/constants/eventTopics.js b/services/blockchain-connector/shared/sdk/constants/eventTopics.js index 4bd0aa4a9..54fd3c810 100644 --- a/services/blockchain-connector/shared/sdk/constants/eventTopics.js +++ b/services/blockchain-connector/shared/sdk/constants/eventTopics.js @@ -85,6 +85,9 @@ const { MODULE_NAME_AUDIO, EVENT_NAME_AUDIO_CREATED, + + MODULE_NAME_PROFILE, + EVENT_NAME_PROFILE_CREATED, } = require('./names'); const COMMAND_EXECUTION_RESULT_TOPICS = ['transactionID']; @@ -164,6 +167,9 @@ const EVENT_TOPIC_MAPPINGS_BY_MODULE = { [MODULE_NAME_AUDIO]: { [EVENT_NAME_AUDIO_CREATED]: ['transactionID', 'senderAddress'], }, + [MODULE_NAME_PROFILE]: { + [EVENT_NAME_PROFILE_CREATED]: ['transactionID', 'senderAddress'], + }, }; module.exports = { diff --git a/services/blockchain-connector/shared/sdk/constants/names.js b/services/blockchain-connector/shared/sdk/constants/names.js index cfe3934f4..f328047d2 100644 --- a/services/blockchain-connector/shared/sdk/constants/names.js +++ b/services/blockchain-connector/shared/sdk/constants/names.js @@ -100,6 +100,10 @@ const EVENT_NAME_COLLECTION_TRANSFERED = 'collectionTransfered'; const MODULE_NAME_AUDIO = 'audio'; const EVENT_NAME_AUDIO_CREATED = 'audioCreated'; +// Audios +const MODULE_NAME_PROFILE = 'profile'; +const EVENT_NAME_PROFILE_CREATED = 'profileCreated'; + module.exports = { MODULE_NAME_AUTH, EVENT_NAME_MULTISIGNATURE_REGISTERED, @@ -173,4 +177,7 @@ module.exports = { MODULE_NAME_AUDIO, EVENT_NAME_AUDIO_CREATED, + + MODULE_NAME_PROFILE, + EVENT_NAME_PROFILE_CREATED, }; From 7b45d0a7ff95575a28df6a518375710c5e91e59e Mon Sep 17 00:00:00 2001 From: Hamid HK Date: Tue, 6 Jun 2023 22:36:15 +0330 Subject: [PATCH 02/12] Add profile data service logic to indexer --- .../dataService/controllers/profiles.js | 31 ++++++++++++++++ .../methods/dataService/modules/profile.js | 16 +++++++++ .../shared/dataService/business/index.js | 6 ++++ .../shared/dataService/business/profiles.js | 36 +++++++++++++++++++ .../shared/dataService/index.js | 4 +++ .../shared/dataService/profiles.js | 22 ++++++++++++ 6 files changed, 115 insertions(+) create mode 100644 services/blockchain-indexer/methods/dataService/controllers/profiles.js create mode 100644 services/blockchain-indexer/methods/dataService/modules/profile.js create mode 100644 services/blockchain-indexer/shared/dataService/business/profiles.js create mode 100644 services/blockchain-indexer/shared/dataService/profiles.js diff --git a/services/blockchain-indexer/methods/dataService/controllers/profiles.js b/services/blockchain-indexer/methods/dataService/controllers/profiles.js new file mode 100644 index 000000000..512ea767a --- /dev/null +++ b/services/blockchain-indexer/methods/dataService/controllers/profiles.js @@ -0,0 +1,31 @@ +const { + HTTP: { StatusCodes: { BAD_REQUEST } }, + Exceptions: { ValidationException, InvalidParamsException }, +} = require('lisk-service-framework'); + +const dataService = require('../../../shared/dataService'); + +const getProfiles = async params => { + const profiles = { + data: [], + meta: {}, + }; + + try { + const response = await dataService.getProfiles(params); + if (response.data) profiles.data = response.data; + if (response.meta) profiles.meta = response.meta; + + return profiles; + } catch (err) { + let status; + if (err instanceof InvalidParamsException) status = 'INVALID_PARAMS'; + if (err instanceof ValidationException) status = BAD_REQUEST; + if (status) return { status, data: { error: err.message } }; + throw err; + } +}; + +module.exports = { + getProfiles, +}; diff --git a/services/blockchain-indexer/methods/dataService/modules/profile.js b/services/blockchain-indexer/methods/dataService/modules/profile.js new file mode 100644 index 000000000..b09cf5875 --- /dev/null +++ b/services/blockchain-indexer/methods/dataService/modules/profile.js @@ -0,0 +1,16 @@ +const { + getProfiles, +} = require('../controllers/profiles'); + +module.exports = [ + { + name: 'profiles', + controller: getProfiles, + params: { + creatorAddress: { optional: true, type: 'string' }, + profileID: { optional: true, type: 'string' }, + limit: { optional: true, type: 'number' }, + offset: { optional: true, type: 'number' }, + }, + }, +]; diff --git a/services/blockchain-indexer/shared/dataService/business/index.js b/services/blockchain-indexer/shared/dataService/business/index.js index ff21d7467..55f285076 100644 --- a/services/blockchain-indexer/shared/dataService/business/index.js +++ b/services/blockchain-indexer/shared/dataService/business/index.js @@ -94,9 +94,12 @@ const { getNetworkDisconnectedPeers, getNetworkPeersStatistics, } = require('./network'); + +// Muzikie Dedicated Modules const { getSubscriptions } = require('./subscriptions'); const { getCollections } = require('./collections'); const { getAudios } = require('./audios'); +const { getProfiles } = require('./profiles'); module.exports = { // Generators @@ -187,4 +190,7 @@ module.exports = { // audios getAudios, + + // profiles + getProfiles, }; diff --git a/services/blockchain-indexer/shared/dataService/business/profiles.js b/services/blockchain-indexer/shared/dataService/business/profiles.js new file mode 100644 index 000000000..303b9a7db --- /dev/null +++ b/services/blockchain-indexer/shared/dataService/business/profiles.js @@ -0,0 +1,36 @@ +const { + MySQL: { getTableInstance }, +} = require('lisk-service-framework'); +const transactionsIndexSchema = require('../../database/schema/profiles'); +const config = require('../../../config'); + +const MYSQL_ENDPOINT = config.endpoints.mysql; + +const getProfilesIndex = () => getTableInstance( + transactionsIndexSchema.tableName, + transactionsIndexSchema, + MYSQL_ENDPOINT, +); + +const getProfiles = async (params = {}) => { + const profilesTable = await getProfilesIndex(); + const total = await profilesTable.count(params); + const resultSet = await profilesTable.find( + { ...params, limit: params.limit || 10 }, + ['profileID', 'name', 'nickName', 'description', 'socialAccounts', 'creatorAddress'], + ); + + const result = { + data: resultSet, + meta: { + count: resultSet.length, + offset: parseInt(params.offset, 10) || 0, + total, + }, + }; + return result; +}; + +module.exports = { + getProfiles, +}; diff --git a/services/blockchain-indexer/shared/dataService/index.js b/services/blockchain-indexer/shared/dataService/index.js index 38a2926c9..d6c93a838 100644 --- a/services/blockchain-indexer/shared/dataService/index.js +++ b/services/blockchain-indexer/shared/dataService/index.js @@ -96,6 +96,7 @@ const { getGenerators } = require('./generators'); const { getSubscriptions } = require('./subscriptions'); const { getCollections } = require('./collections'); const { getAudios } = require('./audios'); +const { getProfiles } = require('./profiles'); module.exports = { // Blocks @@ -192,4 +193,7 @@ module.exports = { // Audios getAudios, + + // Profiles + getProfiles, }; diff --git a/services/blockchain-indexer/shared/dataService/profiles.js b/services/blockchain-indexer/shared/dataService/profiles.js new file mode 100644 index 000000000..a6741da7a --- /dev/null +++ b/services/blockchain-indexer/shared/dataService/profiles.js @@ -0,0 +1,22 @@ +const { Logger } = require('lisk-service-framework'); +const util = require('util'); + +const logger = Logger(); + +const business = require('./business'); + +const getProfiles = async params => { + // Store logs + if (params.profileID) logger.debug(`Retrieved profile with ID ${params.profileID} from Lisk Core`); + else if (params.creatorAddress) logger.debug(`Retrieved profile with creatorAddress: ${params.creatorAddress} from Lisk Core`); + else logger.debug(`Retrieved profile with custom search: ${util.inspect(params)} from Lisk Core`); + + // Get data from server + const response = await business.getProfiles(params); + + return response; +}; + +module.exports = { + getProfiles, +}; From 1757937d8ec1e900e5d8574538a4d7755947af37 Mon Sep 17 00:00:00 2001 From: Hamid HK Date: Tue, 6 Jun 2023 22:38:41 +0330 Subject: [PATCH 03/12] Add profile database schema to indexer --- .../shared/database/schema/profiles.js | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 services/blockchain-indexer/shared/database/schema/profiles.js diff --git a/services/blockchain-indexer/shared/database/schema/profiles.js b/services/blockchain-indexer/shared/database/schema/profiles.js new file mode 100644 index 000000000..36b608b13 --- /dev/null +++ b/services/blockchain-indexer/shared/database/schema/profiles.js @@ -0,0 +1,24 @@ +module.exports = { + tableName: 'profiles', + primaryKey: 'profileID', + schema: { + name: { type: 'string', null: true, defaultValue: null }, + nickName: { type: 'string', null: true, defaultValue: null }, + description: { type: 'string', null: true, defaultValue: null }, + // socialAccounts: SocialAccount[]; + socialAccounts: [{ + username: { type: 'string', null: true, defaultValue: null }, + platform: { type: 'integer', null: true, defaultValue: null }, + }], + avatarHash: { type: 'string', null: true, defaultValue: null }, + avatarSignature: { type: 'string', null: true, defaultValue: null }, + bannerHash: { type: 'string', null: true, defaultValue: null }, + bannerSignature: { type: 'string', null: true, defaultValue: null }, + // @TODO: creationDate: { type: 'string', null: true, defaultValue: null }, + creatorAddress: { type: 'string', null: true, defaultValue: null }, + }, + indexes: { + creatorAddress: { type: 'string' }, + }, + purge: {}, +}; From f7138565e0f38e74b271914833a5866ae5416c28 Mon Sep 17 00:00:00 2001 From: Hamid HK Date: Tue, 6 Jun 2023 22:40:01 +0330 Subject: [PATCH 04/12] Add profile transaction processor into indexer --- .../transactionProcessor/profile/create.js | 75 +++++++++++++++++++ .../transactionProcessor/profile/index.js | 6 ++ 2 files changed, 81 insertions(+) create mode 100644 services/blockchain-indexer/shared/indexer/transactionProcessor/profile/create.js create mode 100644 services/blockchain-indexer/shared/indexer/transactionProcessor/profile/index.js diff --git a/services/blockchain-indexer/shared/indexer/transactionProcessor/profile/create.js b/services/blockchain-indexer/shared/indexer/transactionProcessor/profile/create.js new file mode 100644 index 000000000..a4048ef99 --- /dev/null +++ b/services/blockchain-indexer/shared/indexer/transactionProcessor/profile/create.js @@ -0,0 +1,75 @@ +const { + Logger, + MySQL: { getTableInstance }, +} = require('lisk-service-framework'); + +const { getLisk32AddressFromPublicKey } = require('../../../utils/account'); + +const config = require('../../../../config'); + +const logger = Logger(); + +const MYSQL_ENDPOINT = config.endpoints.mysql; +const accountsTableSchema = require('../../../database/schema/accounts'); +const collectionsTableSchema = require('../../../database/schema/collections'); +const { + MODULE_NAME_PROFILE, + EVENT_NAME_PROFILE_CREATED, +} = require('../../../../../blockchain-connector/shared/sdk/constants/names'); + +const getAccountsTable = () => getTableInstance( + accountsTableSchema.tableName, + accountsTableSchema, + MYSQL_ENDPOINT, +); + +const getProfilesTable = () => getTableInstance( + collectionsTableSchema.tableName, + collectionsTableSchema, + MYSQL_ENDPOINT, +); + +// Command specific constants +const COMMAND_NAME = 'create'; + +// eslint-disable-next-line no-unused-vars +const applyTransaction = async (blockHeader, tx, events, dbTrx) => { + const accountsTable = await getAccountsTable(); + const profilesTable = await getProfilesTable(); + + const senderAddress = getLisk32AddressFromPublicKey(tx.senderPublicKey); + + const account = { + address: senderAddress, + }; + + logger.trace(`Updating account index for the account with address ${account.address}.`); + await accountsTable.upsert(account, dbTrx); + logger.debug(`Updated account index for the account with address ${account.address}.`); + + logger.trace(`Indexing profiles with address ${account.address}.`); + + const { data: eventData = {} } = events.find( + ({ module, name }) => module === MODULE_NAME_PROFILE + && name === EVENT_NAME_PROFILE_CREATED, + ); + + const profile = { + ...eventData, + ...tx.params, + }; + console.log('eventData>>>', eventData); + console.log('tx.params>>>', tx.params); + + await profilesTable.upsert(profile, dbTrx); + logger.debug(`Indexed profile with ID ${eventData.profileID}.`); +}; + +// eslint-disable-next-line no-unused-vars +const revertTransaction = async (blockHeader, tx, events, dbTrx) => {}; + +module.exports = { + COMMAND_NAME, + applyTransaction, + revertTransaction, +}; diff --git a/services/blockchain-indexer/shared/indexer/transactionProcessor/profile/index.js b/services/blockchain-indexer/shared/indexer/transactionProcessor/profile/index.js new file mode 100644 index 000000000..290c852a1 --- /dev/null +++ b/services/blockchain-indexer/shared/indexer/transactionProcessor/profile/index.js @@ -0,0 +1,6 @@ +// Module specific constants +const MODULE_NAME = 'profile'; + +module.exports = { + MODULE_NAME, +}; From a0ff73d69c30e8c59ac89c2a2168e0be625da971 Mon Sep 17 00:00:00 2001 From: Hamid HK Date: Tue, 6 Jun 2023 23:43:06 +0330 Subject: [PATCH 05/12] Add profile:create command support into gateway --- .../apis/http-version3/methods/profiles.js | 38 +++++++ .../apis/http-version3/swagger/apiJson.json | 4 + .../swagger/definitions/profiles.json | 107 ++++++++++++++++++ .../swagger/parameters/profiles.json | 19 ++++ .../sources/version3/mappings/profile.js | 16 +++ services/gateway/sources/version3/profiles.js | 30 +++++ .../gateway/tests/constants/generateDocs.js | 30 +++++ .../gateway/tests/constants/registerApi.js | 4 + 8 files changed, 248 insertions(+) create mode 100644 services/gateway/apis/http-version3/methods/profiles.js create mode 100644 services/gateway/apis/http-version3/swagger/definitions/profiles.json create mode 100644 services/gateway/apis/http-version3/swagger/parameters/profiles.json create mode 100644 services/gateway/sources/version3/mappings/profile.js create mode 100644 services/gateway/sources/version3/profiles.js diff --git a/services/gateway/apis/http-version3/methods/profiles.js b/services/gateway/apis/http-version3/methods/profiles.js new file mode 100644 index 000000000..116882b5c --- /dev/null +++ b/services/gateway/apis/http-version3/methods/profiles.js @@ -0,0 +1,38 @@ +const profilesSource = require('../../../sources/version3/profiles'); +const envelope = require('../../../sources/version3/mappings/stdEnvelope'); +const regex = require('../../../shared/regex'); +const { transformParams, response, getSwaggerDescription } = require('../../../shared/utils'); + +module.exports = { + version: '2.0', + swaggerApiPath: '/profiles', + rpcMethod: 'get.profiles', + tags: ['Profiles'], + params: { + creatorAddress: { optional: true, type: 'string', min: 3, max: 41, pattern: regex.ADDRESS_LISK32 }, + profileID: { optional: true, type: 'string', min: 1, max: 64, pattern: regex.HASH_SHA256 }, + }, + get schema() { + const profileSchema = {}; + profileSchema[this.swaggerApiPath] = { get: {} }; + profileSchema[this.swaggerApiPath].get.tags = this.tags; + profileSchema[this.swaggerApiPath].get.summary = 'Requests profiles data'; + profileSchema[this.swaggerApiPath].get.description = getSwaggerDescription({ + rpcMethod: this.rpcMethod, + description: 'Returns profiles data', + }); + profileSchema[this.swaggerApiPath].get.parameters = transformParams('profiles', this.params); + profileSchema[this.swaggerApiPath].get.responses = { + 200: { + description: 'Returns a list of profiles', + schema: { + $ref: '#/definitions/profilesWithEnvelope', + }, + }, + }; + Object.assign(profileSchema[this.swaggerApiPath].get.responses, response); + return profileSchema; + }, + source: profilesSource, + envelope, +}; diff --git a/services/gateway/apis/http-version3/swagger/apiJson.json b/services/gateway/apis/http-version3/swagger/apiJson.json index d93731cfc..6434e49f9 100644 --- a/services/gateway/apis/http-version3/swagger/apiJson.json +++ b/services/gateway/apis/http-version3/swagger/apiJson.json @@ -98,6 +98,10 @@ { "name": "Audio", "description": "Audio module related API calls." + }, + { + "name": "Profile", + "description": "Profile module related API calls." } ], "schemes": [ diff --git a/services/gateway/apis/http-version3/swagger/definitions/profiles.json b/services/gateway/apis/http-version3/swagger/definitions/profiles.json new file mode 100644 index 000000000..3bba369c2 --- /dev/null +++ b/services/gateway/apis/http-version3/swagger/definitions/profiles.json @@ -0,0 +1,107 @@ +{ + "profile": { + "type": "object", + "required": [ + "profileID", + "name", + "nickName", + "description", + "socialAccounts", + "avatarHash", + "avatarSignature", + "bannerHash", + "bannerSignature", + "creatorAddress" + ], + "properties": { + "profileID": { + "type": "string", + "format": "id", + "example": "f9593f101c4acafc3ede650ab4c10fa2ecb59b225813eddbbb17b47e96932e9b", + "minLength": 1, + "maxLength": 64, + "description": "Unique identifier of the profile.\nDerived from the profile hash." + }, + "name": { + "type": "string", + "description": "name of the profile" + }, + "nickName": { + "type": "string", + "description": "nickName of the profile" + }, + "description": { + "type": "string", + "description": "description of the profile" + }, + "socialAccounts": { + "type": "array", + "items": { + "type": "object", + "properties": { + "username": { + "type": "string", + "description": "username of the social media platform" + }, + "platform": { + "type": "string", + "description": "name of the social media platform" + } + } + } + }, + "avatarHash": { + "type": "string", + "example": "hash of the profile avatar" + }, + "avatarSignature": { + "type": "string", + "example": "signature of the profile avatar" + }, + "bannerHash": { + "type": "string", + "example": "hash of the profile banner" + }, + "bannerSignature": { + "type": "string", + "example": "signature of the profile banner" + }, + "creatorAddress": { + "type": "string", + "example": "creator address of the profile" + } + } + }, + "ProfilesWithEnvelope": { + "type": "object", + "required": [ + "data", + "meta" + ], + "properties": { + "data": { + "description": "List of profiles", + "type": "array", + "items": { + "$ref": "#/definitions/Profiles" + } + }, + "meta": { + "$ref": "#/definitions/pagination" + } + } + }, + "serverErrorEnvelope": { + "type": "object", + "properties": { + "error": { + "type": "boolean", + "example": true + }, + "message": { + "type": "string", + "example": "Unable to reach a network node" + } + } + } +} diff --git a/services/gateway/apis/http-version3/swagger/parameters/profiles.json b/services/gateway/apis/http-version3/swagger/parameters/profiles.json new file mode 100644 index 000000000..488a2795c --- /dev/null +++ b/services/gateway/apis/http-version3/swagger/parameters/profiles.json @@ -0,0 +1,19 @@ +{ + "creatorAddress": { + "name": "creatorAddress", + "in": "query", + "description": "Lisk account address", + "type": "string", + "minLength": 3, + "maxLength": 41 + }, + "profileID": { + "name": "profileID", + "in": "query", + "description": "profile ID to query", + "type": "string", + "format": "id", + "minLength": 1, + "maxLength": 64 + } +} diff --git a/services/gateway/sources/version3/mappings/profile.js b/services/gateway/sources/version3/mappings/profile.js new file mode 100644 index 000000000..f17e9927a --- /dev/null +++ b/services/gateway/sources/version3/mappings/profile.js @@ -0,0 +1,16 @@ +module.exports = { + name: '=,string', + nickName: '=,string', + profileID: '=,string', + description: '=,string', + socialAccounts: ['socialAccounts', { + username: '=,string', + platform: '=,number', + }], + avatarHash: '=,string', + avatarSignature: '=,string', + bannerHash: '=,string', + bannerSignature: '=,string', + creatorAddress: '=,string', +}; + diff --git a/services/gateway/sources/version3/profiles.js b/services/gateway/sources/version3/profiles.js new file mode 100644 index 000000000..cb201fac2 --- /dev/null +++ b/services/gateway/sources/version3/profiles.js @@ -0,0 +1,30 @@ +const profile = require('./mappings/profile'); + +module.exports = { + type: 'moleculer', + method: 'indexer.profiles', + params: { + profileID: '=,string', + name: '=,string', + nickName: '=,string', + description: '=,string', + socialAccounts: ['socialAccounts', { + username: '=,string', + platform: '=,number', + }], + avatarHash: '=,string', + avatarSignature: '=,string', + bannerHash: '=,string', + bannerSignature: '=,string', + creatorAddress: '=,string', + }, + definition: { + data: ['data', profile], + meta: { + count: '=,number', + offset: '=,number', + total: '=,number', + }, + links: {}, + }, +}; diff --git a/services/gateway/tests/constants/generateDocs.js b/services/gateway/tests/constants/generateDocs.js index d86a223fd..47cb6219b 100644 --- a/services/gateway/tests/constants/generateDocs.js +++ b/services/gateway/tests/constants/generateDocs.js @@ -468,6 +468,36 @@ const createApiDocsExpectedResponse = { 'Collections', ], }, + '/profiles': { + get: { + description: 'Returns profiles data\n RPC => get.profiles', + parameters: [ + { + $ref: '#/parameters/creatorAddress', + }, + { + $ref: '#/parameters/profileID', + }, + ], + responses: { + 200: { + description: 'Returns a list of profiles', + schema: { + $ref: '#/definitions/profilesWithEnvelope', + }, + }, + 400: { + description: 'Bad request', + schema: { + $ref: '#/definitions/badRequest', + }, + }, + }, + summary: 'Requests profiles data', + tags: [ + 'Profiles', + ], + }, }, '/events': { get: { diff --git a/services/gateway/tests/constants/registerApi.js b/services/gateway/tests/constants/registerApi.js index 8e72f877d..ba6cbabdb 100644 --- a/services/gateway/tests/constants/registerApi.js +++ b/services/gateway/tests/constants/registerApi.js @@ -26,6 +26,7 @@ const expectedResponseForRegisterHttpApi = { 'app-registry.blockchain.apps.meta.tokens.supported', 'indexer.blocks', 'indexer.collections', + 'indexer.profiles', 'indexer.events', 'fees.estimates', 'indexer.generators', @@ -62,6 +63,7 @@ const expectedResponseForRegisterHttpApi = { aliases: { 'GET blocks/assets': 'indexer.blocks.assets', 'GET collections': 'indexer.collections', + 'GET profiles': 'indexer.profiles', 'GET audios': 'indexer.audios', 'GET blockchain/apps': 'indexer.blockchain.apps', 'GET blockchain/apps/meta/list': 'app-registry.blockchain.apps.meta.list', @@ -120,6 +122,7 @@ const expectedResponseForRegisterRpcApi = { 'app-registry.blockchain.apps.meta.tokens.supported', 'indexer.blocks', 'indexer.collections', + 'indexer.profiles', 'indexer.events', 'fees.estimates', 'indexer.generators', @@ -154,6 +157,7 @@ const expectedResponseForRegisterRpcApi = { aliases: { 'get.blocks.assets': 'indexer.blocks.assets', 'get.collections': 'indexer.collections', + 'get.profiles': 'indexer.profiles', 'get.audios': 'indexer.audios', 'get.blockchain.apps': 'indexer.blockchain.apps', 'get.blockchain.apps.meta.list': 'app-registry.blockchain.apps.meta.list', From 3a737302f58e6004aea33ec42f563f5978a90148 Mon Sep 17 00:00:00 2001 From: curvesy Date: Wed, 7 Jun 2023 16:38:00 +0330 Subject: [PATCH 06/12] Fix a mistake in profile/create.js that inserts data into the collectionTable --- .../shared/indexer/transactionProcessor/profile/create.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/blockchain-indexer/shared/indexer/transactionProcessor/profile/create.js b/services/blockchain-indexer/shared/indexer/transactionProcessor/profile/create.js index a4048ef99..96bb9c218 100644 --- a/services/blockchain-indexer/shared/indexer/transactionProcessor/profile/create.js +++ b/services/blockchain-indexer/shared/indexer/transactionProcessor/profile/create.js @@ -11,7 +11,7 @@ const logger = Logger(); const MYSQL_ENDPOINT = config.endpoints.mysql; const accountsTableSchema = require('../../../database/schema/accounts'); -const collectionsTableSchema = require('../../../database/schema/collections'); +const ProfilesTableSchema = require('../../../database/schema/profiles'); const { MODULE_NAME_PROFILE, EVENT_NAME_PROFILE_CREATED, @@ -24,8 +24,8 @@ const getAccountsTable = () => getTableInstance( ); const getProfilesTable = () => getTableInstance( - collectionsTableSchema.tableName, - collectionsTableSchema, + ProfilesTableSchema.tableName, + ProfilesTableSchema, MYSQL_ENDPOINT, ); From cff45088dd4739a2166eb220569013e1024bacc9 Mon Sep 17 00:00:00 2001 From: Hamid HK Date: Thu, 8 Jun 2023 13:07:12 +0330 Subject: [PATCH 07/12] Modify Social Accounts object in Profile schema --- .../shared/dataService/business/profiles.js | 1 + .../shared/database/schema/profiles.js | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/services/blockchain-indexer/shared/dataService/business/profiles.js b/services/blockchain-indexer/shared/dataService/business/profiles.js index 303b9a7db..26322db0e 100644 --- a/services/blockchain-indexer/shared/dataService/business/profiles.js +++ b/services/blockchain-indexer/shared/dataService/business/profiles.js @@ -18,6 +18,7 @@ const getProfiles = async (params = {}) => { const resultSet = await profilesTable.find( { ...params, limit: params.limit || 10 }, ['profileID', 'name', 'nickName', 'description', 'socialAccounts', 'creatorAddress'], + // ['profileID', 'name', 'nickName', 'description', 'creatorAddress'], ); const result = { diff --git a/services/blockchain-indexer/shared/database/schema/profiles.js b/services/blockchain-indexer/shared/database/schema/profiles.js index 36b608b13..a5ee76a4f 100644 --- a/services/blockchain-indexer/shared/database/schema/profiles.js +++ b/services/blockchain-indexer/shared/database/schema/profiles.js @@ -2,14 +2,19 @@ module.exports = { tableName: 'profiles', primaryKey: 'profileID', schema: { + profileID: { type: 'string' }, name: { type: 'string', null: true, defaultValue: null }, nickName: { type: 'string', null: true, defaultValue: null }, description: { type: 'string', null: true, defaultValue: null }, - // socialAccounts: SocialAccount[]; - socialAccounts: [{ - username: { type: 'string', null: true, defaultValue: null }, - platform: { type: 'integer', null: true, defaultValue: null }, - }], + socialAccounts: { type: 'array', + items: { + type: 'object', + props: { + username: { type: 'string', null: true, defaultValue: null }, + platform: { type: 'integer', null: true, defaultValue: null }, + }, + }, + }, avatarHash: { type: 'string', null: true, defaultValue: null }, avatarSignature: { type: 'string', null: true, defaultValue: null }, bannerHash: { type: 'string', null: true, defaultValue: null }, From 9c01da71021b7be2584d43e58ae258f9babf9ab3 Mon Sep 17 00:00:00 2001 From: Hamid HK Date: Fri, 9 Jun 2023 10:49:02 +0330 Subject: [PATCH 08/12] Modify Profile Schema & Indexer & DataService in order to write in DB temporarily --- .../shared/dataService/business/profiles.js | 4 ++-- .../shared/database/schema/profiles.js | 19 ++++++++++--------- .../transactionProcessor/profile/create.js | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/services/blockchain-indexer/shared/dataService/business/profiles.js b/services/blockchain-indexer/shared/dataService/business/profiles.js index 26322db0e..f95d242a3 100644 --- a/services/blockchain-indexer/shared/dataService/business/profiles.js +++ b/services/blockchain-indexer/shared/dataService/business/profiles.js @@ -17,8 +17,8 @@ const getProfiles = async (params = {}) => { const total = await profilesTable.count(params); const resultSet = await profilesTable.find( { ...params, limit: params.limit || 10 }, - ['profileID', 'name', 'nickName', 'description', 'socialAccounts', 'creatorAddress'], - // ['profileID', 'name', 'nickName', 'description', 'creatorAddress'], + // ['profileID', 'name', 'nickName', 'description', 'socialAccounts', 'creatorAddress'], + ['profileID', 'name', 'nickName', 'description', 'creatorAddress'], ); const result = { diff --git a/services/blockchain-indexer/shared/database/schema/profiles.js b/services/blockchain-indexer/shared/database/schema/profiles.js index a5ee76a4f..6b1903e70 100644 --- a/services/blockchain-indexer/shared/database/schema/profiles.js +++ b/services/blockchain-indexer/shared/database/schema/profiles.js @@ -6,15 +6,16 @@ module.exports = { name: { type: 'string', null: true, defaultValue: null }, nickName: { type: 'string', null: true, defaultValue: null }, description: { type: 'string', null: true, defaultValue: null }, - socialAccounts: { type: 'array', - items: { - type: 'object', - props: { - username: { type: 'string', null: true, defaultValue: null }, - platform: { type: 'integer', null: true, defaultValue: null }, - }, - }, - }, + // @TODO: Modify Schema in order to support social media accounts + // socialAccounts: { type: 'array', + // items: { + // type: 'object', + // props: { + // username: { type: 'string', null: true, defaultValue: null }, + // platform: { type: 'integer', null: true, defaultValue: null }, + // }, + // }, + // }, avatarHash: { type: 'string', null: true, defaultValue: null }, avatarSignature: { type: 'string', null: true, defaultValue: null }, bannerHash: { type: 'string', null: true, defaultValue: null }, diff --git a/services/blockchain-indexer/shared/indexer/transactionProcessor/profile/create.js b/services/blockchain-indexer/shared/indexer/transactionProcessor/profile/create.js index 96bb9c218..a7fb23486 100644 --- a/services/blockchain-indexer/shared/indexer/transactionProcessor/profile/create.js +++ b/services/blockchain-indexer/shared/indexer/transactionProcessor/profile/create.js @@ -36,7 +36,7 @@ const COMMAND_NAME = 'create'; const applyTransaction = async (blockHeader, tx, events, dbTrx) => { const accountsTable = await getAccountsTable(); const profilesTable = await getProfilesTable(); - + console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>> Start to write"); const senderAddress = getLisk32AddressFromPublicKey(tx.senderPublicKey); const account = { From 9f15e0e9497febc187090fd18cf0365b06a9f209 Mon Sep 17 00:00:00 2001 From: Hamid HK Date: Fri, 9 Jun 2023 11:04:27 +0330 Subject: [PATCH 09/12] Correct linting error --- services/gateway/tests/constants/generateDocs.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/gateway/tests/constants/generateDocs.js b/services/gateway/tests/constants/generateDocs.js index 47cb6219b..1f6ae408b 100644 --- a/services/gateway/tests/constants/generateDocs.js +++ b/services/gateway/tests/constants/generateDocs.js @@ -1123,8 +1123,8 @@ const createApiDocsExpectedResponse = { }, }, }, -}; +} module.exports = { createApiDocsExpectedResponse, -}; +} From 2142f5fded1f30c77f87669869bfc815aed5ef05 Mon Sep 17 00:00:00 2001 From: Hamid HK Date: Sat, 10 Jun 2023 23:10:08 +0330 Subject: [PATCH 10/12] Add social accounts schema to profile --- .../shared/sdk/constants/names.js | 2 +- .../shared/dataService/business/profiles.js | 31 ++++++++++++++-- .../shared/database/schema/socialAccounts.js | 13 +++++++ .../transactionProcessor/profile/create.js | 35 +++++++++++++++---- .../gateway/tests/constants/generateDocs.js | 4 +-- 5 files changed, 73 insertions(+), 12 deletions(-) create mode 100644 services/blockchain-indexer/shared/database/schema/socialAccounts.js diff --git a/services/blockchain-connector/shared/sdk/constants/names.js b/services/blockchain-connector/shared/sdk/constants/names.js index f328047d2..1e0331a2d 100644 --- a/services/blockchain-connector/shared/sdk/constants/names.js +++ b/services/blockchain-connector/shared/sdk/constants/names.js @@ -100,7 +100,7 @@ const EVENT_NAME_COLLECTION_TRANSFERED = 'collectionTransfered'; const MODULE_NAME_AUDIO = 'audio'; const EVENT_NAME_AUDIO_CREATED = 'audioCreated'; -// Audios +// Profiles const MODULE_NAME_PROFILE = 'profile'; const EVENT_NAME_PROFILE_CREATED = 'profileCreated'; diff --git a/services/blockchain-indexer/shared/dataService/business/profiles.js b/services/blockchain-indexer/shared/dataService/business/profiles.js index f95d242a3..a8349379d 100644 --- a/services/blockchain-indexer/shared/dataService/business/profiles.js +++ b/services/blockchain-indexer/shared/dataService/business/profiles.js @@ -1,7 +1,9 @@ const { MySQL: { getTableInstance }, } = require('lisk-service-framework'); +const BluebirdPromise = require('bluebird'); const transactionsIndexSchema = require('../../database/schema/profiles'); +const socialAccountsIndexSchema = require('../../database/schema/socialAccounts'); const config = require('../../../config'); const MYSQL_ENDPOINT = config.endpoints.mysql; @@ -12,19 +14,42 @@ const getProfilesIndex = () => getTableInstance( MYSQL_ENDPOINT, ); +const getSocialAccountsIndex = () => getTableInstance( + socialAccountsIndexSchema.tableName, + socialAccountsIndexSchema, + MYSQL_ENDPOINT, +); + const getProfiles = async (params = {}) => { const profilesTable = await getProfilesIndex(); const total = await profilesTable.count(params); - const resultSet = await profilesTable.find( + const profilesData = await profilesTable.find( { ...params, limit: params.limit || 10 }, // ['profileID', 'name', 'nickName', 'description', 'socialAccounts', 'creatorAddress'], ['profileID', 'name', 'nickName', 'description', 'creatorAddress'], ); + const socialAccountsTable = await getSocialAccountsIndex(); + + const data = await BluebirdPromise.map( + profilesData, + async (profile) => { + const socialData = await socialAccountsTable.find( + { profileID: profile.profileID }, + ['profileID', 'username', 'platform'], + ); + + return { + ...profile, + socialAccounts: socialData, + }; + }, + { concurrency: profilesData.length }, + ); const result = { - data: resultSet, + data, meta: { - count: resultSet.length, + count: data.length, offset: parseInt(params.offset, 10) || 0, total, }, diff --git a/services/blockchain-indexer/shared/database/schema/socialAccounts.js b/services/blockchain-indexer/shared/database/schema/socialAccounts.js new file mode 100644 index 000000000..c36801869 --- /dev/null +++ b/services/blockchain-indexer/shared/database/schema/socialAccounts.js @@ -0,0 +1,13 @@ +module.exports = { + tableName: 'socialAccounts', + primaryKey: 'profileID', + schema: { + profileID: { type: 'string' }, + username: { type: 'string', null: true, defaultValue: null }, + platform: { type: 'string', null: true, defaultValue: null }, + }, + indexes: { + profileID: { type: 'string' }, + }, + purge: {}, +}; diff --git a/services/blockchain-indexer/shared/indexer/transactionProcessor/profile/create.js b/services/blockchain-indexer/shared/indexer/transactionProcessor/profile/create.js index a7fb23486..00d78dc15 100644 --- a/services/blockchain-indexer/shared/indexer/transactionProcessor/profile/create.js +++ b/services/blockchain-indexer/shared/indexer/transactionProcessor/profile/create.js @@ -2,6 +2,7 @@ const { Logger, MySQL: { getTableInstance }, } = require('lisk-service-framework'); +const BluebirdPromise = require('bluebird'); const { getLisk32AddressFromPublicKey } = require('../../../utils/account'); @@ -11,7 +12,9 @@ const logger = Logger(); const MYSQL_ENDPOINT = config.endpoints.mysql; const accountsTableSchema = require('../../../database/schema/accounts'); -const ProfilesTableSchema = require('../../../database/schema/profiles'); +const profilesTableSchema = require('../../../database/schema/profiles'); +const socialAccountsTableSchema = require('../../../database/schema/socialAccounts'); + const { MODULE_NAME_PROFILE, EVENT_NAME_PROFILE_CREATED, @@ -24,8 +27,14 @@ const getAccountsTable = () => getTableInstance( ); const getProfilesTable = () => getTableInstance( - ProfilesTableSchema.tableName, - ProfilesTableSchema, + profilesTableSchema.tableName, + profilesTableSchema, + MYSQL_ENDPOINT, +); + +const getSocialAccountsTable = () => getTableInstance( + socialAccountsTableSchema.tableName, + socialAccountsTableSchema, MYSQL_ENDPOINT, ); @@ -36,7 +45,7 @@ const COMMAND_NAME = 'create'; const applyTransaction = async (blockHeader, tx, events, dbTrx) => { const accountsTable = await getAccountsTable(); const profilesTable = await getProfilesTable(); - console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>> Start to write"); + const socialAccountsTable = await getSocialAccountsTable(); const senderAddress = getLisk32AddressFromPublicKey(tx.senderPublicKey); const account = { @@ -58,8 +67,22 @@ const applyTransaction = async (blockHeader, tx, events, dbTrx) => { ...eventData, ...tx.params, }; - console.log('eventData>>>', eventData); - console.log('tx.params>>>', tx.params); + + await BluebirdPromise.map( + tx.params.socialAccounts, + async socialAccount => { + const socialInfo = { + profileID: eventData.profileID, + username: socialAccount.username, + platform: socialAccount.platform, + }; + logger.trace(`Inserting social sccounts for the profile with ID ${eventData.profileID}.`); + await socialAccountsTable.upsert(socialInfo, dbTrx); + logger.debug(`Inserted social sccounts for the profile with ID ${eventData.profileID}.`); + return true; + }, + { concurrency: tx.params.socialAccounts.length }, + ); await profilesTable.upsert(profile, dbTrx); logger.debug(`Indexed profile with ID ${eventData.profileID}.`); diff --git a/services/gateway/tests/constants/generateDocs.js b/services/gateway/tests/constants/generateDocs.js index 1f6ae408b..47cb6219b 100644 --- a/services/gateway/tests/constants/generateDocs.js +++ b/services/gateway/tests/constants/generateDocs.js @@ -1123,8 +1123,8 @@ const createApiDocsExpectedResponse = { }, }, }, -} +}; module.exports = { createApiDocsExpectedResponse, -} +}; From 9060bdbf876c698928203a6bcee0dba5e00cc970 Mon Sep 17 00:00:00 2001 From: Hamid HK Date: Tue, 13 Jun 2023 19:11:43 +0330 Subject: [PATCH 11/12] Fix issues with linting --- .../gateway/tests/constants/generateDocs.js | 1071 +++++++++-------- 1 file changed, 536 insertions(+), 535 deletions(-) diff --git a/services/gateway/tests/constants/generateDocs.js b/services/gateway/tests/constants/generateDocs.js index 47cb6219b..593e87e71 100644 --- a/services/gateway/tests/constants/generateDocs.js +++ b/services/gateway/tests/constants/generateDocs.js @@ -498,626 +498,627 @@ const createApiDocsExpectedResponse = { 'Profiles', ], }, - }, - '/events': { - get: { - tags: [ - 'Events', - ], - summary: 'Requests events data', - description: 'Returns events data\n RPC => get.events', - parameters: [ - { - $ref: '#/parameters/transactionID', - }, - { - $ref: '#/parameters/senderAddress', - }, - { - $ref: '#/parameters/topic', - }, - { - $ref: '#/parameters/blockID', - }, - { - $ref: '#/parameters/height', - }, - { - $ref: '#/parameters/timestamp', - }, - { - $ref: '#/parameters/limit', - }, - { - $ref: '#/parameters/offset', - }, - { - name: 'sort', - in: 'query', - description: 'Fields to sort results by.', - required: false, - type: 'string', - enum: [ - 'height:asc', - 'height:desc', - 'timestamp:asc', - 'timestamp:desc', - ], - default: 'timestamp:desc', - }, - { - name: 'order', - in: 'query', - description: 'Fields to order results by. The order condition is applied after the sort condition, usually to break ties when the sort condition results in collision.', - required: false, - type: 'string', - enum: [ - 'index:asc', - 'index:desc', - ], - default: 'index:asc', - }, - ], - responses: { - 200: { - description: 'Returns a list of events', - schema: { - $ref: '#/definitions/eventsWithEnvelope', + }, + '/events': { + get: { + tags: [ + 'Events', + ], + summary: 'Requests events data', + description: 'Returns events data\n RPC => get.events', + parameters: [ + { + $ref: '#/parameters/transactionID', }, - }, - 400: { - description: 'Bad request', - schema: { - $ref: '#/definitions/badRequest', + { + $ref: '#/parameters/senderAddress', + }, + { + $ref: '#/parameters/topic', + }, + { + $ref: '#/parameters/blockID', + }, + { + $ref: '#/parameters/height', + }, + { + $ref: '#/parameters/timestamp', + }, + { + $ref: '#/parameters/limit', + }, + { + $ref: '#/parameters/offset', + }, + { + name: 'sort', + in: 'query', + description: 'Fields to sort results by.', + required: false, + type: 'string', + enum: [ + 'height:asc', + 'height:desc', + 'timestamp:asc', + 'timestamp:desc', + ], + default: 'timestamp:desc', + }, + { + name: 'order', + in: 'query', + description: 'Fields to order results by. The order condition is applied after the sort condition, usually to break ties when the sort condition results in collision.', + required: false, + type: 'string', + enum: [ + 'index:asc', + 'index:desc', + ], + default: 'index:asc', + }, + ], + responses: { + 200: { + description: 'Returns a list of events', + schema: { + $ref: '#/definitions/eventsWithEnvelope', + }, + }, + 400: { + description: 'Bad request', + schema: { + $ref: '#/definitions/badRequest', + }, }, }, }, }, - }, - '/fees': { - get: { - tags: [ - 'Fee', - ], - summary: 'Requests fee estimates', - description: 'Returns fee estimates\n RPC => get.fees', - responses: { - 200: { - description: 'Returns the fee estimate per byte used for transaction fee calculation', - schema: { - $ref: '#/definitions/FeeEstimateEnvelope', + '/fees': { + get: { + tags: [ + 'Fee', + ], + summary: 'Requests fee estimates', + description: 'Returns fee estimates\n RPC => get.fees', + responses: { + 200: { + description: 'Returns the fee estimate per byte used for transaction fee calculation', + schema: { + $ref: '#/definitions/FeeEstimateEnvelope', + }, }, }, }, }, - }, - '/generators': { - get: { - tags: [ - 'Generators', - ], - summary: 'Requests generators list', - description: 'Returns generators list\n RPC => get.generators', - parameters: [ - { - $ref: '#/parameters/limit', - }, - { - $ref: '#/parameters/offset', - }, - ], - responses: { - 200: { - description: 'Returns a list of generators', - schema: { - $ref: '#/definitions/generatorsWithEnvelope', + '/generators': { + get: { + tags: [ + 'Generators', + ], + summary: 'Requests generators list', + description: 'Returns generators list\n RPC => get.generators', + parameters: [ + { + $ref: '#/parameters/limit', }, - }, - 400: { - description: 'Bad request', - schema: { - $ref: '#/definitions/badRequest', + { + $ref: '#/parameters/offset', + }, + ], + responses: { + 200: { + description: 'Returns a list of generators', + schema: { + $ref: '#/definitions/generatorsWithEnvelope', + }, + }, + 400: { + description: 'Bad request', + schema: { + $ref: '#/definitions/badRequest', + }, }, }, }, }, - }, - '/index/status': { - get: { - tags: [ - 'Index Status', - ], - summary: 'Requests current indexing status.', - description: 'Returns current indexing status.\n RPC => get.index.status', - responses: { - 200: { - description: 'Returns the current index status information.', - schema: { - $ref: '#/definitions/IndexStatus', + '/index/status': { + get: { + tags: [ + 'Index Status', + ], + summary: 'Requests current indexing status.', + description: 'Returns current indexing status.\n RPC => get.index.status', + responses: { + 200: { + description: 'Returns the current index status information.', + schema: { + $ref: '#/definitions/IndexStatus', + }, }, }, }, }, - }, - '/invoke': { - post: { - tags: [ - 'Proxy', - ], - summary: 'Proxy request to directly invoke application endpoint', - description: 'Returns endpoint response from the blockchain application in its original form.\n RPC => post.invoke', - parameters: [ - { - $ref: '#/parameters/invokeParams', - }, - ], - responses: { - 200: { - description: 'Returns endpoint response from the blockchain application in its original form.', - schema: { - $ref: '#/definitions/invokeWithEnvelope', + '/invoke': { + post: { + tags: [ + 'Proxy', + ], + summary: 'Proxy request to directly invoke application endpoint', + description: 'Returns endpoint response from the blockchain application in its original form.\n RPC => post.invoke', + parameters: [ + { + $ref: '#/parameters/invokeParams', }, - }, - 400: { - description: 'Bad request', - schema: { - $ref: '#/definitions/badRequest', + ], + responses: { + 200: { + description: 'Returns endpoint response from the blockchain application in its original form.', + schema: { + $ref: '#/definitions/invokeWithEnvelope', + }, + }, + 400: { + description: 'Bad request', + schema: { + $ref: '#/definitions/badRequest', + }, }, }, }, }, - }, - '/market/prices': { - get: { - tags: [ - 'Market', - ], - parameters: [ + '/market/prices': { + get: { + tags: [ + 'Market', + ], + parameters: [ - ], - summary: 'Requests market prices', - description: 'Returns market prices\n RPC => get.market.prices', - responses: { - 200: { - description: 'Returns a list of market prices by currency pairs', - schema: { - $ref: '#/definitions/MarketPricesWithEnvelope', + ], + summary: 'Requests market prices', + description: 'Returns market prices\n RPC => get.market.prices', + responses: { + 200: { + description: 'Returns a list of market prices by currency pairs', + schema: { + $ref: '#/definitions/MarketPricesWithEnvelope', + }, }, - }, - 400: { - description: 'Bad request', - schema: { - $ref: '#/definitions/badRequest', + 400: { + description: 'Bad request', + schema: { + $ref: '#/definitions/badRequest', + }, }, }, }, }, - }, - '/network/statistics': { - get: { - tags: [ - 'Network', - ], - summary: 'Requests network statistics', - description: 'Returns network statistics data\n RPC => get.network.statistics', - responses: { - 200: { - description: 'Returns the network statistics information', - schema: { - $ref: '#/definitions/NetworkStatistics', + '/network/statistics': { + get: { + tags: [ + 'Network', + ], + summary: 'Requests network statistics', + description: 'Returns network statistics data\n RPC => get.network.statistics', + responses: { + 200: { + description: 'Returns the network statistics information', + schema: { + $ref: '#/definitions/NetworkStatistics', + }, }, }, }, }, - }, - '/network/status': { - get: { - tags: [ - 'Network', - ], - summary: 'Requests network status', - description: 'Returns network status\n RPC => get.network.status', - responses: { - 200: { - description: 'Returns the network status information', - schema: { - $ref: '#/definitions/NetworkStatus', + '/network/status': { + get: { + tags: [ + 'Network', + ], + summary: 'Requests network status', + description: 'Returns network status\n RPC => get.network.status', + responses: { + 200: { + description: 'Returns the network status information', + schema: { + $ref: '#/definitions/NetworkStatus', + }, }, }, }, }, - }, - '/network/peers': { - get: { - tags: [ - 'Network', - ], - summary: 'Requests peers data', - description: 'Returns peers data\n RPC => get.network.peers', - parameters: [ - { - $ref: '#/parameters/ip', - }, - { - $ref: '#/parameters/networkVersion', - }, - { - $ref: '#/parameters/state', - }, - { - $ref: '#/parameters/height', - }, - { - $ref: '#/parameters/limit', - }, - { - $ref: '#/parameters/offset', - }, - { - name: 'sort', - in: 'query', - description: 'Fields to sort results by.', - required: false, - type: 'string', - enum: [ - 'height:asc', - 'height:desc', - 'networkVersion:asc', - 'networkVersion:desc', - ], - default: 'height:desc', - }, - ], - responses: { - 200: { - description: 'Returns a list of peer nodes in the network', - schema: { - $ref: '#/definitions/PeersWithEnvelope', + '/network/peers': { + get: { + tags: [ + 'Network', + ], + summary: 'Requests peers data', + description: 'Returns peers data\n RPC => get.network.peers', + parameters: [ + { + $ref: '#/parameters/ip', }, - }, - 400: { - description: 'Bad request', - schema: { - $ref: '#/definitions/badRequest', + { + $ref: '#/parameters/networkVersion', + }, + { + $ref: '#/parameters/state', + }, + { + $ref: '#/parameters/height', + }, + { + $ref: '#/parameters/limit', + }, + { + $ref: '#/parameters/offset', + }, + { + name: 'sort', + in: 'query', + description: 'Fields to sort results by.', + required: false, + type: 'string', + enum: [ + 'height:asc', + 'height:desc', + 'networkVersion:asc', + 'networkVersion:desc', + ], + default: 'height:desc', + }, + ], + responses: { + 200: { + description: 'Returns a list of peer nodes in the network', + schema: { + $ref: '#/definitions/PeersWithEnvelope', + }, + }, + 400: { + description: 'Bad request', + schema: { + $ref: '#/definitions/badRequest', + }, }, }, }, }, - }, - '/subscriptions': { - get: { - description: 'Returns subscriptions data\n RPC => get.subscriptions', - parameters: [ - { - $ref: '#/parameters/creatorAddress', - }, - { - $ref: '#/parameters/subscriptionID', - }, - ], - responses: { - 200: { - description: 'Returns a list of subscriptions', - schema: { - $ref: '#/definitions/subscriptionsWithEnvelope', + '/subscriptions': { + get: { + description: 'Returns subscriptions data\n RPC => get.subscriptions', + parameters: [ + { + $ref: '#/parameters/creatorAddress', }, - }, - 400: { - description: 'Bad request', - schema: { - $ref: '#/definitions/badRequest', + { + $ref: '#/parameters/subscriptionID', + }, + ], + responses: { + 200: { + description: 'Returns a list of subscriptions', + schema: { + $ref: '#/definitions/subscriptionsWithEnvelope', + }, + }, + 400: { + description: 'Bad request', + schema: { + $ref: '#/definitions/badRequest', + }, }, }, + summary: 'Requests subscriptions data', + tags: [ + 'Subscriptions', + ], }, - summary: 'Requests subscriptions data', - tags: [ - 'Subscriptions', - ], }, - }, - '/transactions': { - get: { - tags: [ - 'Transactions', - ], - summary: 'Requests transactions data', - description: 'Returns transactions data\n RPC => get.transactions', - parameters: [ - { - $ref: '#/parameters/transactionID', - }, - { - $ref: '#/parameters/moduleCommand', - }, - { - $ref: '#/parameters/senderAddress', - }, - { - $ref: '#/parameters/address', - }, - { - $ref: '#/parameters/recipientAddress', - }, - { - $ref: '#/parameters/blockID', - }, - { - $ref: '#/parameters/height', - }, - { - $ref: '#/parameters/timestamp', - }, - { - $ref: '#/parameters/executionStatus', - }, - { - $ref: '#/parameters/nonce', - }, - { - $ref: '#/parameters/limit', - }, - { - $ref: '#/parameters/offset', - }, - { - name: 'sort', - in: 'query', - description: 'Fields to sort results by.', - required: false, - type: 'string', - enum: [ - 'height:asc', - 'height:desc', - 'timestamp:asc', - 'timestamp:desc', - ], - default: 'timestamp:desc', - }, - { - name: 'order', - in: 'query', - description: 'Fields to order results by. The order condition is applied after the sort condition, usually to break ties when the sort condition results in collision.', - required: false, - type: 'string', - enum: [ - 'index:asc', - 'index:desc', - ], - default: 'index:asc', - }, - ], - responses: { - 200: { - description: 'Returns a list of transactions', - schema: { - $ref: '#/definitions/TransactionsWithEnvelope', + '/transactions': { + get: { + tags: [ + 'Transactions', + ], + summary: 'Requests transactions data', + description: 'Returns transactions data\n RPC => get.transactions', + parameters: [ + { + $ref: '#/parameters/transactionID', + }, + { + $ref: '#/parameters/moduleCommand', + }, + { + $ref: '#/parameters/senderAddress', + }, + { + $ref: '#/parameters/address', + }, + { + $ref: '#/parameters/recipientAddress', + }, + { + $ref: '#/parameters/blockID', + }, + { + $ref: '#/parameters/height', + }, + { + $ref: '#/parameters/timestamp', + }, + { + $ref: '#/parameters/executionStatus', + }, + { + $ref: '#/parameters/nonce', + }, + { + $ref: '#/parameters/limit', }, - }, - 400: { - description: 'Bad request', - schema: { - $ref: '#/definitions/badRequest', + { + $ref: '#/parameters/offset', + }, + { + name: 'sort', + in: 'query', + description: 'Fields to sort results by.', + required: false, + type: 'string', + enum: [ + 'height:asc', + 'height:desc', + 'timestamp:asc', + 'timestamp:desc', + ], + default: 'timestamp:desc', + }, + { + name: 'order', + in: 'query', + description: 'Fields to order results by. The order condition is applied after the sort condition, usually to break ties when the sort condition results in collision.', + required: false, + type: 'string', + enum: [ + 'index:asc', + 'index:desc', + ], + default: 'index:asc', + }, + ], + responses: { + 200: { + description: 'Returns a list of transactions', + schema: { + $ref: '#/definitions/TransactionsWithEnvelope', + }, + }, + 400: { + description: 'Bad request', + schema: { + $ref: '#/definitions/badRequest', + }, }, }, }, - }, - post: { - tags: [ - 'Transactions', - ], - summary: 'Post transactions', - description: 'Post transactions and return transactionID\n RPC => post.transactions', - parameters: [ - { - $ref: '#/parameters/transaction', - }, - ], - responses: { - 200: { - description: 'Broadcast transaction', - schema: { - $ref: '#/definitions/postTransactionWithEnvelope', + post: { + tags: [ + 'Transactions', + ], + summary: 'Post transactions', + description: 'Post transactions and return transactionID\n RPC => post.transactions', + parameters: [ + { + $ref: '#/parameters/transaction', }, - }, - 400: { - description: 'Bad request', - schema: { - $ref: '#/definitions/badRequestEnvelope', + ], + responses: { + 200: { + description: 'Broadcast transaction', + schema: { + $ref: '#/definitions/postTransactionWithEnvelope', + }, }, - }, - 500: { - description: 'Internal server error', - schema: { - $ref: '#/definitions/serverErrorEnvelope', + 400: { + description: 'Bad request', + schema: { + $ref: '#/definitions/badRequestEnvelope', + }, + }, + 500: { + description: 'Internal server error', + schema: { + $ref: '#/definitions/serverErrorEnvelope', + }, }, }, }, }, - }, - '/schemas': { - get: { - tags: [ - 'Schemas', - ], - summary: 'Requests schemas.', - description: 'Returns schemas.\n RPC => get.schemas', - responses: { - 200: { - description: 'Returns a list of schemas.', - schema: { - $ref: '#/definitions/SchemaWithEnvelope', + '/schemas': { + get: { + tags: [ + 'Schemas', + ], + summary: 'Requests schemas.', + description: 'Returns schemas.\n RPC => get.schemas', + responses: { + 200: { + description: 'Returns a list of schemas.', + schema: { + $ref: '#/definitions/SchemaWithEnvelope', + }, }, - }, - 400: { - description: 'Bad request', - schema: { - $ref: '#/definitions/badRequest', + 400: { + description: 'Bad request', + schema: { + $ref: '#/definitions/badRequest', + }, }, }, }, }, - }, - '/transactions/dryrun': { - post: { - tags: [ - 'Transactions', - ], - summary: 'Dry run transactions.', - description: 'Dry run transactions.\n RPC => post.transactions.dryrun', - parameters: [ - { - $ref: '#/parameters/dryrunTransaction', - }, - ], - responses: { - 200: { - description: "Dry run transactions. 'errorMessage' is available only when 'result: -1'.", - schema: { - $ref: '#/definitions/dryTransactionWithEnvelope', + '/transactions/dryrun': { + post: { + tags: [ + 'Transactions', + ], + summary: 'Dry run transactions.', + description: 'Dry run transactions.\n RPC => post.transactions.dryrun', + parameters: [ + { + $ref: '#/parameters/dryrunTransaction', }, - }, - 400: { - description: 'Bad request', - schema: { - $ref: '#/definitions/badRequest', + ], + responses: { + 200: { + description: "Dry run transactions. 'errorMessage' is available only when 'result: -1'.", + schema: { + $ref: '#/definitions/dryTransactionWithEnvelope', + }, }, - }, - 500: { - description: 'Internal server error', - schema: { - $ref: '#/definitions/serverErrorEnvelope', + 400: { + description: 'Bad request', + schema: { + $ref: '#/definitions/badRequest', + }, + }, + 500: { + description: 'Internal server error', + schema: { + $ref: '#/definitions/serverErrorEnvelope', + }, }, }, }, }, - }, - '/transactions/statistics': { - get: { - tags: [ - 'Transactions', - ], - summary: 'Requests transaction statistics', - description: 'Returns transaction statistics\n RPC => get.transactions.statistics', - parameters: [ - { - name: 'interval', - in: 'query', - description: 'interval to query statistics', - required: true, - type: 'string', - enum: [ - 'day', - 'month', - ], - }, - { - $ref: '#/parameters/limit', - }, - { - $ref: '#/parameters/offset', - }, - ], - responses: { - 200: { - description: 'Returns a list of transactions statistics by date or month', - schema: { - $ref: '#/definitions/TransactionsStatisticsWithEnvelope', + '/transactions/statistics': { + get: { + tags: [ + 'Transactions', + ], + summary: 'Requests transaction statistics', + description: 'Returns transaction statistics\n RPC => get.transactions.statistics', + parameters: [ + { + name: 'interval', + in: 'query', + description: 'interval to query statistics', + required: true, + type: 'string', + enum: [ + 'day', + 'month', + ], }, - }, - 400: { - description: 'Bad request', - schema: { - $ref: '#/definitions/badRequest', + { + $ref: '#/parameters/limit', }, - }, - 503: { - description: 'Service Unavailable', - schema: { - $ref: '#/definitions/serviceUnavailable', + { + $ref: '#/parameters/offset', + }, + ], + responses: { + 200: { + description: 'Returns a list of transactions statistics by date or month', + schema: { + $ref: '#/definitions/TransactionsStatisticsWithEnvelope', + }, + }, + 400: { + description: 'Bad request', + schema: { + $ref: '#/definitions/badRequest', + }, + }, + 503: { + description: 'Service Unavailable', + schema: { + $ref: '#/definitions/serviceUnavailable', + }, }, }, }, }, - }, - '/auth': { - get: { - tags: [ - 'Auth', - ], - summary: 'Requests auth details by address', - description: 'Returns auth details by address\n RPC => get.auth', - parameters: [ - { - $ref: '#/parameters/address', - }, - ], - responses: { - 200: { - description: 'Auth details', - schema: { - $ref: '#/definitions/authWithEnvelope', + '/auth': { + get: { + tags: [ + 'Auth', + ], + summary: 'Requests auth details by address', + description: 'Returns auth details by address\n RPC => get.auth', + parameters: [ + { + $ref: '#/parameters/address', }, - }, - 400: { - description: 'Bad request', - schema: { - $ref: '#/definitions/badRequest', + ], + responses: { + 200: { + description: 'Auth details', + schema: { + $ref: '#/definitions/authWithEnvelope', + }, + }, + 400: { + description: 'Bad request', + schema: { + $ref: '#/definitions/badRequest', + }, }, }, }, }, - }, - '/validator': { - get: { - tags: [ - 'Validator', - ], - summary: 'Requests validator information', - description: 'Returns validator information\n RPC => get.validator', - parameters: [ - { - $ref: '#/parameters/address', - }, - ], - responses: { - 200: { - description: 'Returns validator information by address', - schema: { - $ref: '#/definitions/validatorWithEnvelope', + '/validator': { + get: { + tags: [ + 'Validator', + ], + summary: 'Requests validator information', + description: 'Returns validator information\n RPC => get.validator', + parameters: [ + { + $ref: '#/parameters/address', }, - }, - 400: { - description: 'Bad request', - schema: { - $ref: '#/definitions/badRequest', + ], + responses: { + 200: { + description: 'Returns validator information by address', + schema: { + $ref: '#/definitions/validatorWithEnvelope', + }, + }, + 400: { + description: 'Bad request', + schema: { + $ref: '#/definitions/badRequest', + }, }, }, }, }, - }, - '/validator/validate-bls-key': { - post: { - tags: [ - 'Validator', - ], - summary: 'Validates a BLS key against its corresponding Proof of Possession.', - description: 'Validates a BLS key against its corresponding Proof of Possession.\n RPC => post.validator.validate-bls-key', - parameters: [ - { - $ref: '#/parameters/validateBLSKeyParams', - }, - ], - responses: { - 200: { - description: 'Returns a boolean representing the validity of the supplied BLS key and Proof of Possession.', - schema: { - $ref: '#/definitions/blsKeyValidationWithEnvelope', + '/validator/validate-bls-key': { + post: { + tags: [ + 'Validator', + ], + summary: 'Validates a BLS key against its corresponding Proof of Possession.', + description: 'Validates a BLS key against its corresponding Proof of Possession.\n RPC => post.validator.validate-bls-key', + parameters: [ + { + $ref: '#/parameters/validateBLSKeyParams', }, - }, - 400: { - description: 'Bad request', - schema: { - $ref: '#/definitions/badRequest', + ], + responses: { + 200: { + description: 'Returns a boolean representing the validity of the supplied BLS key and Proof of Possession.', + schema: { + $ref: '#/definitions/blsKeyValidationWithEnvelope', + }, + }, + 400: { + description: 'Bad request', + schema: { + $ref: '#/definitions/badRequest', + }, }, }, }, From 93fc54fc95cdaa2e2e975814a71af28b04116a0a Mon Sep 17 00:00:00 2001 From: Ali Haghighatkhah Date: Tue, 13 Jun 2023 19:03:52 +0200 Subject: [PATCH 12/12] Fix broken unit tests --- .../gateway/tests/constants/generateDocs.js | 1126 ++++++++--------- .../gateway/tests/constants/registerApi.js | 6 +- 2 files changed, 566 insertions(+), 566 deletions(-) diff --git a/services/gateway/tests/constants/generateDocs.js b/services/gateway/tests/constants/generateDocs.js index 593e87e71..cf57676dd 100644 --- a/services/gateway/tests/constants/generateDocs.js +++ b/services/gateway/tests/constants/generateDocs.js @@ -468,657 +468,657 @@ const createApiDocsExpectedResponse = { 'Collections', ], }, - '/profiles': { - get: { - description: 'Returns profiles data\n RPC => get.profiles', - parameters: [ - { - $ref: '#/parameters/creatorAddress', - }, - { - $ref: '#/parameters/profileID', - }, - ], - responses: { - 200: { - description: 'Returns a list of profiles', - schema: { - $ref: '#/definitions/profilesWithEnvelope', - }, - }, - 400: { - description: 'Bad request', - schema: { - $ref: '#/definitions/badRequest', - }, - }, + }, + '/events': { + get: { + tags: [ + 'Events', + ], + summary: 'Requests events data', + description: 'Returns events data\n RPC => get.events', + parameters: [ + { + $ref: '#/parameters/transactionID', }, - summary: 'Requests profiles data', - tags: [ - 'Profiles', - ], - }, - }, - '/events': { - get: { - tags: [ - 'Events', - ], - summary: 'Requests events data', - description: 'Returns events data\n RPC => get.events', - parameters: [ - { - $ref: '#/parameters/transactionID', - }, - { - $ref: '#/parameters/senderAddress', - }, - { - $ref: '#/parameters/topic', - }, - { - $ref: '#/parameters/blockID', - }, - { - $ref: '#/parameters/height', - }, - { - $ref: '#/parameters/timestamp', - }, - { - $ref: '#/parameters/limit', - }, - { - $ref: '#/parameters/offset', - }, - { - name: 'sort', - in: 'query', - description: 'Fields to sort results by.', - required: false, - type: 'string', - enum: [ - 'height:asc', - 'height:desc', - 'timestamp:asc', - 'timestamp:desc', - ], - default: 'timestamp:desc', - }, - { - name: 'order', - in: 'query', - description: 'Fields to order results by. The order condition is applied after the sort condition, usually to break ties when the sort condition results in collision.', - required: false, - type: 'string', - enum: [ - 'index:asc', - 'index:desc', - ], - default: 'index:asc', - }, - ], - responses: { - 200: { - description: 'Returns a list of events', - schema: { - $ref: '#/definitions/eventsWithEnvelope', - }, + { + $ref: '#/parameters/senderAddress', + }, + { + $ref: '#/parameters/topic', + }, + { + $ref: '#/parameters/blockID', + }, + { + $ref: '#/parameters/height', + }, + { + $ref: '#/parameters/timestamp', + }, + { + $ref: '#/parameters/limit', + }, + { + $ref: '#/parameters/offset', + }, + { + name: 'sort', + in: 'query', + description: 'Fields to sort results by.', + required: false, + type: 'string', + enum: [ + 'height:asc', + 'height:desc', + 'timestamp:asc', + 'timestamp:desc', + ], + default: 'timestamp:desc', + }, + { + name: 'order', + in: 'query', + description: 'Fields to order results by. The order condition is applied after the sort condition, usually to break ties when the sort condition results in collision.', + required: false, + type: 'string', + enum: [ + 'index:asc', + 'index:desc', + ], + default: 'index:asc', + }, + ], + responses: { + 200: { + description: 'Returns a list of events', + schema: { + $ref: '#/definitions/eventsWithEnvelope', }, - 400: { - description: 'Bad request', - schema: { - $ref: '#/definitions/badRequest', - }, + }, + 400: { + description: 'Bad request', + schema: { + $ref: '#/definitions/badRequest', }, }, }, }, - '/fees': { - get: { - tags: [ - 'Fee', - ], - summary: 'Requests fee estimates', - description: 'Returns fee estimates\n RPC => get.fees', - responses: { - 200: { - description: 'Returns the fee estimate per byte used for transaction fee calculation', - schema: { - $ref: '#/definitions/FeeEstimateEnvelope', - }, + }, + '/fees': { + get: { + tags: [ + 'Fee', + ], + summary: 'Requests fee estimates', + description: 'Returns fee estimates\n RPC => get.fees', + responses: { + 200: { + description: 'Returns the fee estimate per byte used for transaction fee calculation', + schema: { + $ref: '#/definitions/FeeEstimateEnvelope', }, }, }, }, - '/generators': { - get: { - tags: [ - 'Generators', - ], - summary: 'Requests generators list', - description: 'Returns generators list\n RPC => get.generators', - parameters: [ - { - $ref: '#/parameters/limit', - }, - { - $ref: '#/parameters/offset', - }, - ], - responses: { - 200: { - description: 'Returns a list of generators', - schema: { - $ref: '#/definitions/generatorsWithEnvelope', - }, + }, + '/generators': { + get: { + tags: [ + 'Generators', + ], + summary: 'Requests generators list', + description: 'Returns generators list\n RPC => get.generators', + parameters: [ + { + $ref: '#/parameters/limit', + }, + { + $ref: '#/parameters/offset', + }, + ], + responses: { + 200: { + description: 'Returns a list of generators', + schema: { + $ref: '#/definitions/generatorsWithEnvelope', }, - 400: { - description: 'Bad request', - schema: { - $ref: '#/definitions/badRequest', - }, + }, + 400: { + description: 'Bad request', + schema: { + $ref: '#/definitions/badRequest', }, }, }, }, - '/index/status': { - get: { - tags: [ - 'Index Status', - ], - summary: 'Requests current indexing status.', - description: 'Returns current indexing status.\n RPC => get.index.status', - responses: { - 200: { - description: 'Returns the current index status information.', - schema: { - $ref: '#/definitions/IndexStatus', - }, + }, + '/index/status': { + get: { + tags: [ + 'Index Status', + ], + summary: 'Requests current indexing status.', + description: 'Returns current indexing status.\n RPC => get.index.status', + responses: { + 200: { + description: 'Returns the current index status information.', + schema: { + $ref: '#/definitions/IndexStatus', }, }, }, }, - '/invoke': { - post: { - tags: [ - 'Proxy', - ], - summary: 'Proxy request to directly invoke application endpoint', - description: 'Returns endpoint response from the blockchain application in its original form.\n RPC => post.invoke', - parameters: [ - { - $ref: '#/parameters/invokeParams', - }, - ], - responses: { - 200: { - description: 'Returns endpoint response from the blockchain application in its original form.', - schema: { - $ref: '#/definitions/invokeWithEnvelope', - }, + }, + '/invoke': { + post: { + tags: [ + 'Proxy', + ], + summary: 'Proxy request to directly invoke application endpoint', + description: 'Returns endpoint response from the blockchain application in its original form.\n RPC => post.invoke', + parameters: [ + { + $ref: '#/parameters/invokeParams', + }, + ], + responses: { + 200: { + description: 'Returns endpoint response from the blockchain application in its original form.', + schema: { + $ref: '#/definitions/invokeWithEnvelope', }, - 400: { - description: 'Bad request', - schema: { - $ref: '#/definitions/badRequest', - }, + }, + 400: { + description: 'Bad request', + schema: { + $ref: '#/definitions/badRequest', }, }, }, }, - '/market/prices': { - get: { - tags: [ - 'Market', - ], - parameters: [ + }, + '/market/prices': { + get: { + tags: [ + 'Market', + ], + parameters: [ - ], - summary: 'Requests market prices', - description: 'Returns market prices\n RPC => get.market.prices', - responses: { - 200: { - description: 'Returns a list of market prices by currency pairs', - schema: { - $ref: '#/definitions/MarketPricesWithEnvelope', - }, + ], + summary: 'Requests market prices', + description: 'Returns market prices\n RPC => get.market.prices', + responses: { + 200: { + description: 'Returns a list of market prices by currency pairs', + schema: { + $ref: '#/definitions/MarketPricesWithEnvelope', }, - 400: { - description: 'Bad request', - schema: { - $ref: '#/definitions/badRequest', - }, + }, + 400: { + description: 'Bad request', + schema: { + $ref: '#/definitions/badRequest', }, }, }, }, - '/network/statistics': { - get: { - tags: [ - 'Network', - ], - summary: 'Requests network statistics', - description: 'Returns network statistics data\n RPC => get.network.statistics', - responses: { - 200: { - description: 'Returns the network statistics information', - schema: { - $ref: '#/definitions/NetworkStatistics', - }, + }, + '/network/statistics': { + get: { + tags: [ + 'Network', + ], + summary: 'Requests network statistics', + description: 'Returns network statistics data\n RPC => get.network.statistics', + responses: { + 200: { + description: 'Returns the network statistics information', + schema: { + $ref: '#/definitions/NetworkStatistics', }, }, }, }, - '/network/status': { - get: { - tags: [ - 'Network', - ], - summary: 'Requests network status', - description: 'Returns network status\n RPC => get.network.status', - responses: { - 200: { - description: 'Returns the network status information', - schema: { - $ref: '#/definitions/NetworkStatus', - }, + }, + '/network/status': { + get: { + tags: [ + 'Network', + ], + summary: 'Requests network status', + description: 'Returns network status\n RPC => get.network.status', + responses: { + 200: { + description: 'Returns the network status information', + schema: { + $ref: '#/definitions/NetworkStatus', }, }, }, }, - '/network/peers': { - get: { - tags: [ - 'Network', - ], - summary: 'Requests peers data', - description: 'Returns peers data\n RPC => get.network.peers', - parameters: [ - { - $ref: '#/parameters/ip', - }, - { - $ref: '#/parameters/networkVersion', - }, - { - $ref: '#/parameters/state', - }, - { - $ref: '#/parameters/height', - }, - { - $ref: '#/parameters/limit', - }, - { - $ref: '#/parameters/offset', - }, - { - name: 'sort', - in: 'query', - description: 'Fields to sort results by.', - required: false, - type: 'string', - enum: [ - 'height:asc', - 'height:desc', - 'networkVersion:asc', - 'networkVersion:desc', - ], - default: 'height:desc', - }, - ], - responses: { - 200: { - description: 'Returns a list of peer nodes in the network', - schema: { - $ref: '#/definitions/PeersWithEnvelope', - }, + }, + '/network/peers': { + get: { + tags: [ + 'Network', + ], + summary: 'Requests peers data', + description: 'Returns peers data\n RPC => get.network.peers', + parameters: [ + { + $ref: '#/parameters/ip', + }, + { + $ref: '#/parameters/networkVersion', + }, + { + $ref: '#/parameters/state', + }, + { + $ref: '#/parameters/height', + }, + { + $ref: '#/parameters/limit', + }, + { + $ref: '#/parameters/offset', + }, + { + name: 'sort', + in: 'query', + description: 'Fields to sort results by.', + required: false, + type: 'string', + enum: [ + 'height:asc', + 'height:desc', + 'networkVersion:asc', + 'networkVersion:desc', + ], + default: 'height:desc', + }, + ], + responses: { + 200: { + description: 'Returns a list of peer nodes in the network', + schema: { + $ref: '#/definitions/PeersWithEnvelope', }, - 400: { - description: 'Bad request', - schema: { - $ref: '#/definitions/badRequest', - }, + }, + 400: { + description: 'Bad request', + schema: { + $ref: '#/definitions/badRequest', }, }, }, }, - '/subscriptions': { - get: { - description: 'Returns subscriptions data\n RPC => get.subscriptions', - parameters: [ - { - $ref: '#/parameters/creatorAddress', - }, - { - $ref: '#/parameters/subscriptionID', - }, - ], - responses: { - 200: { - description: 'Returns a list of subscriptions', - schema: { - $ref: '#/definitions/subscriptionsWithEnvelope', - }, + }, + '/subscriptions': { + get: { + description: 'Returns subscriptions data\n RPC => get.subscriptions', + parameters: [ + { + $ref: '#/parameters/creatorAddress', + }, + { + $ref: '#/parameters/subscriptionID', + }, + ], + responses: { + 200: { + description: 'Returns a list of subscriptions', + schema: { + $ref: '#/definitions/subscriptionsWithEnvelope', }, - 400: { - description: 'Bad request', - schema: { - $ref: '#/definitions/badRequest', - }, + }, + 400: { + description: 'Bad request', + schema: { + $ref: '#/definitions/badRequest', }, }, - summary: 'Requests subscriptions data', - tags: [ - 'Subscriptions', - ], }, + summary: 'Requests subscriptions data', + tags: [ + 'Subscriptions', + ], }, - '/transactions': { - get: { - tags: [ - 'Transactions', - ], - summary: 'Requests transactions data', - description: 'Returns transactions data\n RPC => get.transactions', - parameters: [ - { - $ref: '#/parameters/transactionID', - }, - { - $ref: '#/parameters/moduleCommand', - }, - { - $ref: '#/parameters/senderAddress', - }, - { - $ref: '#/parameters/address', - }, - { - $ref: '#/parameters/recipientAddress', - }, - { - $ref: '#/parameters/blockID', - }, - { - $ref: '#/parameters/height', - }, - { - $ref: '#/parameters/timestamp', - }, - { - $ref: '#/parameters/executionStatus', - }, - { - $ref: '#/parameters/nonce', - }, - { - $ref: '#/parameters/limit', - }, - { - $ref: '#/parameters/offset', - }, - { - name: 'sort', - in: 'query', - description: 'Fields to sort results by.', - required: false, - type: 'string', - enum: [ - 'height:asc', - 'height:desc', - 'timestamp:asc', - 'timestamp:desc', - ], - default: 'timestamp:desc', - }, - { - name: 'order', - in: 'query', - description: 'Fields to order results by. The order condition is applied after the sort condition, usually to break ties when the sort condition results in collision.', - required: false, - type: 'string', - enum: [ - 'index:asc', - 'index:desc', - ], - default: 'index:asc', - }, - ], - responses: { - 200: { - description: 'Returns a list of transactions', - schema: { - $ref: '#/definitions/TransactionsWithEnvelope', - }, + }, + '/transactions': { + get: { + tags: [ + 'Transactions', + ], + summary: 'Requests transactions data', + description: 'Returns transactions data\n RPC => get.transactions', + parameters: [ + { + $ref: '#/parameters/transactionID', + }, + { + $ref: '#/parameters/moduleCommand', + }, + { + $ref: '#/parameters/senderAddress', + }, + { + $ref: '#/parameters/address', + }, + { + $ref: '#/parameters/recipientAddress', + }, + { + $ref: '#/parameters/blockID', + }, + { + $ref: '#/parameters/height', + }, + { + $ref: '#/parameters/timestamp', + }, + { + $ref: '#/parameters/executionStatus', + }, + { + $ref: '#/parameters/nonce', + }, + { + $ref: '#/parameters/limit', + }, + { + $ref: '#/parameters/offset', + }, + { + name: 'sort', + in: 'query', + description: 'Fields to sort results by.', + required: false, + type: 'string', + enum: [ + 'height:asc', + 'height:desc', + 'timestamp:asc', + 'timestamp:desc', + ], + default: 'timestamp:desc', + }, + { + name: 'order', + in: 'query', + description: 'Fields to order results by. The order condition is applied after the sort condition, usually to break ties when the sort condition results in collision.', + required: false, + type: 'string', + enum: [ + 'index:asc', + 'index:desc', + ], + default: 'index:asc', + }, + ], + responses: { + 200: { + description: 'Returns a list of transactions', + schema: { + $ref: '#/definitions/TransactionsWithEnvelope', }, - 400: { - description: 'Bad request', - schema: { - $ref: '#/definitions/badRequest', - }, + }, + 400: { + description: 'Bad request', + schema: { + $ref: '#/definitions/badRequest', }, }, }, - post: { - tags: [ - 'Transactions', - ], - summary: 'Post transactions', - description: 'Post transactions and return transactionID\n RPC => post.transactions', - parameters: [ - { - $ref: '#/parameters/transaction', - }, - ], - responses: { - 200: { - description: 'Broadcast transaction', - schema: { - $ref: '#/definitions/postTransactionWithEnvelope', - }, + }, + post: { + tags: [ + 'Transactions', + ], + summary: 'Post transactions', + description: 'Post transactions and return transactionID\n RPC => post.transactions', + parameters: [ + { + $ref: '#/parameters/transaction', + }, + ], + responses: { + 200: { + description: 'Broadcast transaction', + schema: { + $ref: '#/definitions/postTransactionWithEnvelope', }, - 400: { - description: 'Bad request', - schema: { - $ref: '#/definitions/badRequestEnvelope', - }, + }, + 400: { + description: 'Bad request', + schema: { + $ref: '#/definitions/badRequestEnvelope', }, - 500: { - description: 'Internal server error', - schema: { - $ref: '#/definitions/serverErrorEnvelope', - }, + }, + 500: { + description: 'Internal server error', + schema: { + $ref: '#/definitions/serverErrorEnvelope', }, }, }, }, - '/schemas': { - get: { - tags: [ - 'Schemas', - ], - summary: 'Requests schemas.', - description: 'Returns schemas.\n RPC => get.schemas', - responses: { - 200: { - description: 'Returns a list of schemas.', - schema: { - $ref: '#/definitions/SchemaWithEnvelope', - }, + }, + '/profiles': { + get: { + description: 'Returns profiles data\n RPC => get.profiles', + parameters: [ + { + $ref: '#/parameters/creatorAddress', + }, + { + $ref: '#/parameters/profileID', + }, + ], + responses: { + 200: { + description: 'Returns a list of profiles', + schema: { + $ref: '#/definitions/profilesWithEnvelope', }, - 400: { - description: 'Bad request', - schema: { - $ref: '#/definitions/badRequest', - }, + }, + 400: { + description: 'Bad request', + schema: { + $ref: '#/definitions/badRequest', }, }, }, + summary: 'Requests profiles data', + tags: [ + 'Profiles', + ], }, - '/transactions/dryrun': { - post: { - tags: [ - 'Transactions', - ], - summary: 'Dry run transactions.', - description: 'Dry run transactions.\n RPC => post.transactions.dryrun', - parameters: [ - { - $ref: '#/parameters/dryrunTransaction', - }, - ], - responses: { - 200: { - description: "Dry run transactions. 'errorMessage' is available only when 'result: -1'.", - schema: { - $ref: '#/definitions/dryTransactionWithEnvelope', - }, - }, - 400: { - description: 'Bad request', - schema: { - $ref: '#/definitions/badRequest', - }, + }, + '/schemas': { + get: { + tags: [ + 'Schemas', + ], + summary: 'Requests schemas.', + description: 'Returns schemas.\n RPC => get.schemas', + responses: { + 200: { + description: 'Returns a list of schemas.', + schema: { + $ref: '#/definitions/SchemaWithEnvelope', }, - 500: { - description: 'Internal server error', - schema: { - $ref: '#/definitions/serverErrorEnvelope', - }, + }, + 400: { + description: 'Bad request', + schema: { + $ref: '#/definitions/badRequest', }, }, }, }, - '/transactions/statistics': { - get: { - tags: [ - 'Transactions', - ], - summary: 'Requests transaction statistics', - description: 'Returns transaction statistics\n RPC => get.transactions.statistics', - parameters: [ - { - name: 'interval', - in: 'query', - description: 'interval to query statistics', - required: true, - type: 'string', - enum: [ - 'day', - 'month', - ], + }, + '/transactions/dryrun': { + post: { + tags: [ + 'Transactions', + ], + summary: 'Dry run transactions.', + description: 'Dry run transactions.\n RPC => post.transactions.dryrun', + parameters: [ + { + $ref: '#/parameters/dryrunTransaction', + }, + ], + responses: { + 200: { + description: "Dry run transactions. 'errorMessage' is available only when 'result: -1'.", + schema: { + $ref: '#/definitions/dryTransactionWithEnvelope', }, - { - $ref: '#/parameters/limit', + }, + 400: { + description: 'Bad request', + schema: { + $ref: '#/definitions/badRequest', }, - { - $ref: '#/parameters/offset', + }, + 500: { + description: 'Internal server error', + schema: { + $ref: '#/definitions/serverErrorEnvelope', }, - ], - responses: { - 200: { - description: 'Returns a list of transactions statistics by date or month', - schema: { - $ref: '#/definitions/TransactionsStatisticsWithEnvelope', - }, + }, + }, + }, + }, + '/transactions/statistics': { + get: { + tags: [ + 'Transactions', + ], + summary: 'Requests transaction statistics', + description: 'Returns transaction statistics\n RPC => get.transactions.statistics', + parameters: [ + { + name: 'interval', + in: 'query', + description: 'interval to query statistics', + required: true, + type: 'string', + enum: [ + 'day', + 'month', + ], + }, + { + $ref: '#/parameters/limit', + }, + { + $ref: '#/parameters/offset', + }, + ], + responses: { + 200: { + description: 'Returns a list of transactions statistics by date or month', + schema: { + $ref: '#/definitions/TransactionsStatisticsWithEnvelope', }, - 400: { - description: 'Bad request', - schema: { - $ref: '#/definitions/badRequest', - }, + }, + 400: { + description: 'Bad request', + schema: { + $ref: '#/definitions/badRequest', }, - 503: { - description: 'Service Unavailable', - schema: { - $ref: '#/definitions/serviceUnavailable', - }, + }, + 503: { + description: 'Service Unavailable', + schema: { + $ref: '#/definitions/serviceUnavailable', }, }, }, }, - '/auth': { - get: { - tags: [ - 'Auth', - ], - summary: 'Requests auth details by address', - description: 'Returns auth details by address\n RPC => get.auth', - parameters: [ - { - $ref: '#/parameters/address', - }, - ], - responses: { - 200: { - description: 'Auth details', - schema: { - $ref: '#/definitions/authWithEnvelope', - }, + }, + '/auth': { + get: { + tags: [ + 'Auth', + ], + summary: 'Requests auth details by address', + description: 'Returns auth details by address\n RPC => get.auth', + parameters: [ + { + $ref: '#/parameters/address', + }, + ], + responses: { + 200: { + description: 'Auth details', + schema: { + $ref: '#/definitions/authWithEnvelope', }, - 400: { - description: 'Bad request', - schema: { - $ref: '#/definitions/badRequest', - }, + }, + 400: { + description: 'Bad request', + schema: { + $ref: '#/definitions/badRequest', }, }, }, }, - '/validator': { - get: { - tags: [ - 'Validator', - ], - summary: 'Requests validator information', - description: 'Returns validator information\n RPC => get.validator', - parameters: [ - { - $ref: '#/parameters/address', - }, - ], - responses: { - 200: { - description: 'Returns validator information by address', - schema: { - $ref: '#/definitions/validatorWithEnvelope', - }, + }, + '/validator': { + get: { + tags: [ + 'Validator', + ], + summary: 'Requests validator information', + description: 'Returns validator information\n RPC => get.validator', + parameters: [ + { + $ref: '#/parameters/address', + }, + ], + responses: { + 200: { + description: 'Returns validator information by address', + schema: { + $ref: '#/definitions/validatorWithEnvelope', }, - 400: { - description: 'Bad request', - schema: { - $ref: '#/definitions/badRequest', - }, + }, + 400: { + description: 'Bad request', + schema: { + $ref: '#/definitions/badRequest', }, }, }, }, - '/validator/validate-bls-key': { - post: { - tags: [ - 'Validator', - ], - summary: 'Validates a BLS key against its corresponding Proof of Possession.', - description: 'Validates a BLS key against its corresponding Proof of Possession.\n RPC => post.validator.validate-bls-key', - parameters: [ - { - $ref: '#/parameters/validateBLSKeyParams', - }, - ], - responses: { - 200: { - description: 'Returns a boolean representing the validity of the supplied BLS key and Proof of Possession.', - schema: { - $ref: '#/definitions/blsKeyValidationWithEnvelope', - }, + }, + '/validator/validate-bls-key': { + post: { + tags: [ + 'Validator', + ], + summary: 'Validates a BLS key against its corresponding Proof of Possession.', + description: 'Validates a BLS key against its corresponding Proof of Possession.\n RPC => post.validator.validate-bls-key', + parameters: [ + { + $ref: '#/parameters/validateBLSKeyParams', + }, + ], + responses: { + 200: { + description: 'Returns a boolean representing the validity of the supplied BLS key and Proof of Possession.', + schema: { + $ref: '#/definitions/blsKeyValidationWithEnvelope', }, - 400: { - description: 'Bad request', - schema: { - $ref: '#/definitions/badRequest', - }, + }, + 400: { + description: 'Bad request', + schema: { + $ref: '#/definitions/badRequest', }, }, }, diff --git a/services/gateway/tests/constants/registerApi.js b/services/gateway/tests/constants/registerApi.js index ba6cbabdb..c11d29b83 100644 --- a/services/gateway/tests/constants/registerApi.js +++ b/services/gateway/tests/constants/registerApi.js @@ -26,7 +26,6 @@ const expectedResponseForRegisterHttpApi = { 'app-registry.blockchain.apps.meta.tokens.supported', 'indexer.blocks', 'indexer.collections', - 'indexer.profiles', 'indexer.events', 'fees.estimates', 'indexer.generators', @@ -37,6 +36,7 @@ const expectedResponseForRegisterHttpApi = { 'indexer.network.statistics', 'indexer.network.status', 'indexer.transactions.post', + 'indexer.profiles', 'indexer.schemas', 'gateway.spec', 'indexer.subscriptions', @@ -122,7 +122,6 @@ const expectedResponseForRegisterRpcApi = { 'app-registry.blockchain.apps.meta.tokens.supported', 'indexer.blocks', 'indexer.collections', - 'indexer.profiles', 'indexer.events', 'fees.estimates', 'indexer.generators', @@ -133,6 +132,7 @@ const expectedResponseForRegisterRpcApi = { 'indexer.network.statistics', 'indexer.network.status', 'indexer.transactions.post', + 'indexer.profiles', 'indexer.schemas', 'indexer.subscriptions', 'indexer.transactions', @@ -157,7 +157,6 @@ const expectedResponseForRegisterRpcApi = { aliases: { 'get.blocks.assets': 'indexer.blocks.assets', 'get.collections': 'indexer.collections', - 'get.profiles': 'indexer.profiles', 'get.audios': 'indexer.audios', 'get.blockchain.apps': 'indexer.blockchain.apps', 'get.blockchain.apps.meta.list': 'app-registry.blockchain.apps.meta.list', @@ -175,6 +174,7 @@ const expectedResponseForRegisterRpcApi = { 'get.network.peers': 'indexer.network.peers', 'get.network.statistics': 'indexer.network.statistics', 'get.network.status': 'indexer.network.status', + 'get.profiles': 'indexer.profiles', 'post.transactions': 'indexer.transactions.post', 'get.schemas': 'indexer.schemas', 'get.subscriptions': 'indexer.subscriptions',