Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mojaloop/#2993): change external bulk prepare to internal function #408

Merged
merged 8 commits into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions modules/api-svc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mojaloop/sdk-scheme-adapter-api-svc",
"version": "19.0.0-snapshot.25",
"version": "19.0.0-snapshot.27",
"description": "An adapter for connecting to Mojaloop API enabled switches.",
"main": "src/index.js",
"types": "src/index.d.ts",
Expand Down Expand Up @@ -79,7 +79,7 @@
"js-yaml": "^4.1.0",
"json-schema-ref-parser": "^9.0.9",
"koa": "^2.13.4",
"koa-body": "^5.0.0",
"koa-body": "^6.0.1",
"lodash": "^4.17.21",
"module-alias": "^2.2.2",
"oauth2-server": "^4.0.0-dev.2",
Expand All @@ -89,28 +89,28 @@
"random-word-slugs": "^0.1.6",
"redis": "^4.3.1",
"uuidv4": "^6.2.13",
"ws": "^8.9.0"
"ws": "^8.10.0"
},
"devDependencies": {
"@babel/core": "^7.19.6",
"@babel/preset-env": "^7.19.4",
"@redocly/openapi-cli": "^1.0.0-beta.94",
"@types/jest": "^29.2.0",
"babel-jest": "^29.2.1",
"eslint": "^8.25.0",
"babel-jest": "^29.2.2",
"eslint": "^8.26.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^27.1.3",
"jest": "^29.2.1",
"jest": "^29.2.2",
"jest-junit": "^14.0.1",
"nock": "^13.2.9",
"npm-check-updates": "^16.3.14",
"npm-check-updates": "^16.3.16",
"openapi-response-validator": "^12.0.2",
"openapi-typescript": "^5.4.1",
"redis-mock": "^0.56.3",
"replace": "^1.2.1",
"replace": "^1.2.2",
"standard-version": "^9.5.0",
"supertest": "^6.3.0",
"supertest": "^6.3.1",
"swagger-cli": "^4.0.4"
},
"standard-version": {
Expand Down
2 changes: 1 addition & 1 deletion modules/api-svc/src/OutboundServer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
const http = require('http');

const Koa = require('koa');
const koaBody = require('koa-body');
const koaBody = require('koa-body').default;
const yaml = require('js-yaml');
const fs = require('fs');
const path = require('path');
Expand Down
2 changes: 1 addition & 1 deletion modules/api-svc/src/lib/metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

const http = require('http');
const Koa = require('koa');
const koaBody = require('koa-body');
const koaBody = require('koa-body').default;
const PrometheusClient = require('prom-client');


Expand Down
36 changes: 21 additions & 15 deletions modules/api-svc/src/lib/model/lib/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -571,19 +571,22 @@ const internalBulkTransfersResponseToMojaloop = (internal, fulfilments) => {
const mojaloopBulkPrepareToInternalBulkTransfer = (external, bulkQuotes, ilp) => {
let internal = null;
if (bulkQuotes) {
// create a map of internal individual quotes payees indexed by quotedId, for faster lookup
const internalQuotesPayeesByQuoteId = {};
// In order to pass on information not contained in an FSPIOP `IndividualTransfer` to
// FSP backend, we create mappings that can resolve an internal quote from
// the transfer id.

// create a map of internal individual quotes indexed by quotedId, for faster lookup
const internalQuotesByQuoteId = {};
for (const quote of bulkQuotes.internalRequest.individualQuotes) {
internalQuotesPayeesByQuoteId[quote.quoteId] = quote.to;
internalQuotesByQuoteId[quote.quoteId] = quote;
}

// create a map of external individual transfers indexed by quotedId, for faster lookup
const externalTransferIdsByQuoteId = {};
// create a map of quoted ids indexed by individual transfers id, for faster lookup
const externalQuoteIdByTransferIds = {};

for (const transfer of external.individualTransfers) {
const transactionObject = ilp.getTransactionObject(transfer.ilpPacket);
externalTransferIdsByQuoteId[transactionObject.quoteId] = transfer.transferId;
externalQuoteIdByTransferIds[transfer.transferId] = transactionObject.quoteId;
}

internal = {
Expand All @@ -592,15 +595,18 @@ const mojaloopBulkPrepareToInternalBulkTransfer = (external, bulkQuotes, ilp) =>
from: bulkQuotes.internalRequest.from,
};

internal.individualTransfers = bulkQuotes.request.individualQuotes.map((quote) => ({
transferId: externalTransferIdsByQuoteId[quote.quoteId],
to: internalQuotesPayeesByQuoteId[quote.quoteId],
amountType: quote.amountType,
currency: quote.amount.currency,
amount: quote.amount.amount,
transactionType: quote.transactionType.scenario,
note: quote.note
}));
internal.individualTransfers = external.individualTransfers.map((transfer) => {
const internalQuote = internalQuotesByQuoteId[externalQuoteIdByTransferIds[transfer.transferId]];
return {
transferId: transfer.transferId,
currency: transfer.transferAmount.currency,
amount: transfer.transferAmount.amount,
to: internalQuote.to,
amountType: internalQuote.amountType,
transactionType: internalQuote.transactionType,
note: internalQuote.note
};
});
} else {
internal = {
bulkTransferId: external.bulkTransferId,
Expand Down
16 changes: 8 additions & 8 deletions modules/outbound-command-event-handler/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mojaloop/sdk-scheme-adapter-outbound-command-event-handler",
"version": "0.1.0-snapshot.0",
"version": "0.1.0-snapshot.1",
"description": "mojaloop sdk scheme adapter command event handler",
"license": "Apache-2.0",
"homepage": "https://github.com/mojaloop/sdk-scheme-adapter/",
Expand Down Expand Up @@ -56,19 +56,19 @@
"@types/convict": "^6.1.1",
"@types/express": "^4.17.14",
"@types/jest": "^29.2.0",
"@types/node": "^18.11.3",
"@types/node": "^18.11.8",
"@types/node-cache": "^4.2.5",
"@types/supertest": "^2.0.12",
"@types/swagger-ui-express": "^4.1.3",
"@types/yamljs": "^0.2.31",
"@typescript-eslint/eslint-plugin": "^5.40.1",
"@typescript-eslint/parser": "^5.40.1",
"@typescript-eslint/eslint-plugin": "^5.41.0",
"@typescript-eslint/parser": "^5.41.0",
"copyfiles": "^2.4.1",
"eslint": "^8.25.0",
"jest": "^29.2.1",
"eslint": "^8.26.0",
"jest": "^29.2.2",
"nodemon": "^2.0.20",
"npm-check-updates": "^16.3.14",
"replace": "^1.2.1",
"npm-check-updates": "^16.3.16",
"replace": "^1.2.2",
"standard-version": "^9.5.0",
"ts-jest": "^29.0.3",
"ts-node": "^10.9.1",
Expand Down
16 changes: 8 additions & 8 deletions modules/outbound-domain-event-handler/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mojaloop/sdk-scheme-adapter-outbound-domain-event-handler",
"version": "0.1.0-snapshot.0",
"version": "0.1.0-snapshot.1",
"description": "mojaloop sdk scheme adapter outbound domain event handler",
"license": "Apache-2.0",
"homepage": "https://github.com/mojaloop/sdk-scheme-adapter/",
Expand Down Expand Up @@ -54,19 +54,19 @@
"@types/convict": "^6.1.1",
"@types/express": "^4.17.14",
"@types/jest": "^29.2.0",
"@types/node": "^18.11.3",
"@types/node": "^18.11.8",
"@types/node-cache": "^4.2.5",
"@types/supertest": "^2.0.12",
"@types/swagger-ui-express": "^4.1.3",
"@types/yamljs": "^0.2.31",
"@typescript-eslint/eslint-plugin": "^5.40.1",
"@typescript-eslint/parser": "^5.40.1",
"@typescript-eslint/eslint-plugin": "^5.41.0",
"@typescript-eslint/parser": "^5.41.0",
"copyfiles": "^2.4.1",
"eslint": "^8.25.0",
"jest": "^29.2.1",
"eslint": "^8.26.0",
"jest": "^29.2.2",
"nodemon": "^2.0.20",
"npm-check-updates": "^16.3.14",
"replace": "^1.2.1",
"npm-check-updates": "^16.3.16",
"replace": "^1.2.2",
"standard-version": "^9.5.0",
"ts-jest": "^29.0.3",
"ts-node": "^10.9.1",
Expand Down
12 changes: 6 additions & 6 deletions modules/private-shared-lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mojaloop/sdk-scheme-adapter-private-shared-lib",
"version": "0.2.0-snapshot.0",
"version": "0.2.0-snapshot.1",
"description": "SDK Scheme Adapter private shared library.",
"license": "Apache-2.0",
"homepage": "https://github.com/mojaloop/accounts-and-balances-bc/tree/main/modules/private-types",
Expand Down Expand Up @@ -37,11 +37,11 @@
"uuid": "^9.0.0"
},
"devDependencies": {
"@types/node": "^18.11.3",
"eslint": "^8.25.0",
"jest": "^29.2.1",
"npm-check-updates": "^16.3.14",
"replace": "^1.2.1",
"@types/node": "^18.11.8",
"eslint": "^8.26.0",
"jest": "^29.2.2",
"npm-check-updates": "^16.3.16",
"replace": "^1.2.2",
"standard-version": "^9.5.0",
"ts-jest": "^29.0.3",
"typescript": "^4.8.4"
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mojaloop/sdk-scheme-adapter",
"version": "20.0.0-snapshot.22",
"version": "20.0.0-snapshot.24",
"description": "mojaloop sdk-scheme-adapter",
"license": "Apache-2.0",
"homepage": "https://github.com/mojaloop/sdk-scheme-adapter",
Expand Down Expand Up @@ -67,24 +67,24 @@
"wait-4-docker": "node ./scripts/_wait4_all.js"
},
"dependencies": {
"nx": "15.0.0",
"nx": "15.0.4",
"tslib": "^2.4.0"
},
"devDependencies": {
"@types/jest": "^29.2.0",
"@types/node": "^18.11.3",
"@types/node": "^18.11.8",
"@types/node-cache": "^4.2.5",
"@typescript-eslint/eslint-plugin": "^5.40.1",
"@typescript-eslint/parser": "^5.40.1",
"@typescript-eslint/eslint-plugin": "^5.41.0",
"@typescript-eslint/parser": "^5.41.0",
"audit-ci": "^6.3.0",
"eslint": "^8.25.0",
"eslint": "^8.26.0",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-plugin-import": "latest",
"husky": "^8.0.1",
"jest": "^29.2.1",
"jest": "^29.2.2",
"nodemon": "^2.0.20",
"npm-check-updates": "^16.3.14",
"replace": "^1.2.1",
"npm-check-updates": "^16.3.16",
"replace": "^1.2.2",
"standard-version": "^9.5.0",
"ts-jest": "^29.0.3",
"ts-node": "^10.9.1",
Expand Down
Loading