Skip to content

Commit

Permalink
Merge pull request #58 from Muzikie/feature/adapt-to-muzikie
Browse files Browse the repository at this point in the history
Merge Feature/adapt-to-muzikie into development
  • Loading branch information
reyraa authored Jul 13, 2023
2 parents 05c341b + 4aa637d commit c6d9741
Show file tree
Hide file tree
Showing 73 changed files with 3,225 additions and 16 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/branch-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,3 @@ jobs:
run: make build-local
- name: Check test coverage
run: npm run test:coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
files: coverage-final.json
name: codecov-umbrella
verbose: true
8 changes: 0 additions & 8 deletions .github/workflows/pr-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,3 @@ jobs:
run: make build-local
- name: Check test coverage
run: npm run test:coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
files: coverage-final.json
name: codecov-umbrella
verbose: true
32 changes: 32 additions & 0 deletions services/blockchain-connector/shared/sdk/constants/eventTopics.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,22 @@ const {
MODULE_NAME_LEGACY,
EVENT_NAME_ACCOUNT_RECLAIMED,
EVENT_NAME_KEYS_REGISTERED,

MODULE_NAME_SUBSCRIPTION,
EVENT_NAME_SUBSCRIPTION_CREATED,
EVENT_NAME_SUBSCRIPTION_PURCHASED,

MODULE_NAME_COLLECTION,
EVENT_NAME_COLLECTION_CREATED,
EVENT_NAME_COLLECTION_TRANSFERED,

MODULE_NAME_AUDIO,
EVENT_NAME_AUDIO_CREATED,
EVENT_NAME_AUDIO_STREAMED,
EVENT_NAME_AUDIO_INCOME_RECLAIMED,

MODULE_NAME_PROFILE,
EVENT_NAME_PROFILE_CREATED,
} = require('./names');

const COMMAND_EXECUTION_RESULT_TOPICS = ['transactionID'];
Expand Down Expand Up @@ -140,6 +156,22 @@ const EVENT_TOPIC_MAPPINGS_BY_MODULE = {
[EVENT_NAME_ACCOUNT_RECLAIMED]: ['transactionID', 'legacyAddress', 'newAddress'],
[EVENT_NAME_KEYS_REGISTERED]: ['transactionID', 'validatorAddress', 'generatorKey', 'blsKey'],
},
[MODULE_NAME_SUBSCRIPTION]: {
[EVENT_NAME_SUBSCRIPTION_CREATED]: ['transactionID', 'senderAddress'],
[EVENT_NAME_SUBSCRIPTION_PURCHASED]: ['transactionID', 'senderAddress'],
},
[MODULE_NAME_COLLECTION]: {
[EVENT_NAME_COLLECTION_CREATED]: ['transactionID', 'senderAddress'],
[EVENT_NAME_COLLECTION_TRANSFERED]: ['transactionID', 'senderAddress'],
},
[MODULE_NAME_AUDIO]: {
[EVENT_NAME_AUDIO_CREATED]: ['transactionID', 'senderAddress'],
[EVENT_NAME_AUDIO_STREAMED]: ['transactionID', 'senderAddress'],
[EVENT_NAME_AUDIO_INCOME_RECLAIMED]: ['transactionID', 'senderAddress'],
},
[MODULE_NAME_PROFILE]: {
[EVENT_NAME_PROFILE_CREATED]: ['transactionID', 'senderAddress'],
},
};

module.exports = {
Expand Down
36 changes: 36 additions & 0 deletions services/blockchain-connector/shared/sdk/constants/names.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,26 @@ const MODULE_NAME_LEGACY = 'legacy';
const EVENT_NAME_ACCOUNT_RECLAIMED = 'accountReclaimed';
const EVENT_NAME_KEYS_REGISTERED = 'keysRegistered';

// Subscription
const MODULE_NAME_SUBSCRIPTION = 'subscription';
const EVENT_NAME_SUBSCRIPTION_CREATED = 'subscriptionCreated';
const EVENT_NAME_SUBSCRIPTION_PURCHASED = 'subscriptionPurchased';

// Collection
const MODULE_NAME_COLLECTION = 'collection';
const EVENT_NAME_COLLECTION_CREATED = 'collectionCreated';
const EVENT_NAME_COLLECTION_TRANSFERED = 'collectionTransfered';

// Audios
const MODULE_NAME_AUDIO = 'audio';
const EVENT_NAME_AUDIO_CREATED = 'audioCreated';
const EVENT_NAME_AUDIO_STREAMED = 'audioStreamed';
const EVENT_NAME_AUDIO_INCOME_RECLAIMED = 'audioIncomeReclaimed';

// Profiles
const MODULE_NAME_PROFILE = 'profile';
const EVENT_NAME_PROFILE_CREATED = 'profileCreated';

module.exports = {
MODULE_NAME_AUTH,
EVENT_NAME_MULTISIGNATURE_REGISTERED,
Expand Down Expand Up @@ -146,4 +166,20 @@ module.exports = {
MODULE_NAME_LEGACY,
EVENT_NAME_ACCOUNT_RECLAIMED,
EVENT_NAME_KEYS_REGISTERED,

MODULE_NAME_SUBSCRIPTION,
EVENT_NAME_SUBSCRIPTION_CREATED,
EVENT_NAME_SUBSCRIPTION_PURCHASED,

MODULE_NAME_COLLECTION,
EVENT_NAME_COLLECTION_CREATED,
EVENT_NAME_COLLECTION_TRANSFERED,

MODULE_NAME_AUDIO,
EVENT_NAME_AUDIO_CREATED,
EVENT_NAME_AUDIO_STREAMED,
EVENT_NAME_AUDIO_INCOME_RECLAIMED,

MODULE_NAME_PROFILE,
EVENT_NAME_PROFILE_CREATED,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const {
HTTP: { StatusCodes: { BAD_REQUEST } },
Exceptions: { ValidationException, InvalidParamsException },
} = require('lisk-service-framework');

const dataService = require('../../../shared/dataService');

const getAudios = async params => {
const audios = {
data: [],
meta: {},
};

try {
const response = await dataService.getAudios(params);
if (response.data) audios.data = response.data;
if (response.meta) audios.meta = response.meta;

return audios;
} 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 = {
getAudios,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const {
HTTP: { StatusCodes: { BAD_REQUEST } },
Exceptions: { ValidationException, InvalidParamsException },
} = require('lisk-service-framework');

const dataService = require('../../../shared/dataService');

const getCollections = async params => {
const collections = {
data: [],
meta: {},
};

try {
const response = await dataService.getCollections(params);
if (response.data) collections.data = response.data;
if (response.meta) collections.meta = response.meta;

return collections;
} 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 = {
getCollections,
};
Original file line number Diff line number Diff line change
@@ -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,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const {
HTTP: { StatusCodes: { BAD_REQUEST } },
Exceptions: { ValidationException, InvalidParamsException },
} = require('lisk-service-framework');

const dataService = require('../../../shared/dataService');

const getSubscriptions = async params => {
const subscriptions = {
data: [],
meta: {},
};

try {
const response = await dataService.getSubscriptions(params);
if (response.data) subscriptions.data = response.data;
if (response.meta) subscriptions.meta = response.meta;

return subscriptions;
} 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 = {
getSubscriptions,
};
16 changes: 16 additions & 0 deletions services/blockchain-indexer/methods/dataService/modules/audio.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const {
getAudios,
} = require('../controllers/audios');

module.exports = [
{
name: 'audios',
controller: getAudios,
params: {
creatorAddress: { optional: true, type: 'string' },
audioID: { optional: true, type: 'string' },
limit: { optional: true, type: 'number' },
offset: { optional: true, type: 'number' },
},
},
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const {
getCollections,
} = require('../controllers/collections');

module.exports = [
{
name: 'collections',
controller: getCollections,
params: {
creatorAddress: { optional: true, type: 'string' },
collectionID: { optional: true, type: 'string' },
limit: { optional: true, type: 'number' },
offset: { optional: true, type: 'number' },
},
},
];
16 changes: 16 additions & 0 deletions services/blockchain-indexer/methods/dataService/modules/profile.js
Original file line number Diff line number Diff line change
@@ -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' },
},
},
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const {
getSubscriptions,
} = require('../controllers/subscriptions');

module.exports = [
{
name: 'subscriptions',
controller: getSubscriptions,
params: {
creatorAddress: { optional: true, type: 'string' },
subscriptionID: { optional: true, type: 'string' },
limit: { optional: true, type: 'number' },
offset: { optional: true, type: 'number' },
memberAddress: { optional: true, type: 'string' },
},
},
];
4 changes: 4 additions & 0 deletions services/blockchain-indexer/shared/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ const TRANSACTION_VERIFY_RESULT = {
OK: 1,
};

// @todo retrieve this from Core
const DEV_ADDRESS = 'lskh96jgzfftzff2fta2zvsmba9mvs5cnz9ahr3ke';

module.exports = {
updateFinalizedHeight,
getFinalizedHeight,
Expand All @@ -155,4 +158,5 @@ module.exports = {
KV_STORE_KEY,
TRANSACTION_STATUS,
TRANSACTION_VERIFY_RESULT,
DEV_ADDRESS,
};
22 changes: 22 additions & 0 deletions services/blockchain-indexer/shared/dataService/audios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const { Logger } = require('lisk-service-framework');
const util = require('util');

const logger = Logger();

const business = require('./business');

const getAudios = async params => {
// Store logs
if (params.audioID) logger.debug(`Retrieved audio with ID ${params.audioID} from Lisk Core`);
else if (params.creatorAddress) logger.debug(`Retrieved audio with creatorAddress: ${params.creatorAddress} from Lisk Core`);
else logger.debug(`Retrieved audios with custom search: ${util.inspect(params)} from Lisk Core`);

// Get data from server
const response = await business.getAudios(params);

return response;
};

module.exports = {
getAudios,
};
Loading

0 comments on commit c6d9741

Please sign in to comment.