Skip to content

Commit

Permalink
feat(mojaloop/#3053): add support for subscenarios to backend, outbou…
Browse files Browse the repository at this point in the history
…d and ilp (#430)

* feat(mojaloop/#3053): add support for subscenarios to backend, outbound and ilp

* blop

* dep

* dep

* audit

* chore: change

* chore: cleanup

* chore: config

* chore: fix

* chore: version

* chore: bump ml tkk and add tests

* chore: bump

* change

* dep

* chore(snapshot): 21.6.0-snapshot.0

* chore: dep

* chore(snapshot): 21.6.0-snapshot.1

* chore: fix ci

* chore: audit

* chore(snapshot): 21.6.0-snapshot.2

* audit

* dep
  • Loading branch information
kleyow committed Jan 19, 2023
1 parent 933a6c3 commit f6c739a
Show file tree
Hide file tree
Showing 60 changed files with 9,675 additions and 14,495 deletions.
3 changes: 1 addition & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ defaults_configure_nvm: &defaults_configure_nvm
nvm use $(cat .nvmrc)
defaults_environment: &defaults_environment
## TODO: Update this to master/main once its merged into working branch
# env var for nx to set main branch
MAIN_BRANCH_NAME: mvp/bulk-sdk
MAIN_BRANCH_NAME: master

##
# Executors
Expand Down
11 changes: 10 additions & 1 deletion audit-ci.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
"GHSA-8qr4-xgw6-wmr3",
"GHSA-f772-66g8-q5h3",
"GHSA-cph5-m8f7-6c5x",
"GHSA-hrpp-h998-j3pp"
"GHSA-hrpp-h998-j3pp",
"GHSA-8cf7-32gw-wr33",
// Vulnerabilities for jsonwebtoken in
// sdk-standard-components
// central-services-error-handling
// central-services-shared
"GHSA-27h2-hvpr-p74q",
"GHSA-hjrf-2m68-5959",
"GHSA-qwph-4952-7xr6",
"GHSA-9c47-m6qq-7p4h"
]
}
28 changes: 14 additions & 14 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": "20.5.2",
"version": "20.6.0-snapshot.2",
"description": "An adapter for connecting to Mojaloop API enabled switches.",
"main": "src/index.js",
"types": "src/index.d.ts",
Expand Down Expand Up @@ -61,16 +61,16 @@
},
"dependencies": {
"@koa/cors": "^4.0.0",
"@mojaloop/api-snippets": "17.0.0",
"@mojaloop/api-snippets": "17.0.3",
"@mojaloop/central-services-error-handling": "^12.0.5",
"@mojaloop/central-services-logger": "^11.2.0",
"@mojaloop/central-services-metrics": "^12.0.5",
"@mojaloop/central-services-shared": "17.3.1",
"@mojaloop/central-services-shared": "17.5.0",
"@mojaloop/event-sdk": "^11.0.2",
"@mojaloop/sdk-scheme-adapter-private-shared-lib": "workspace:^",
"@mojaloop/sdk-standard-components": "^17.1.1",
"ajv": "8.11.2",
"axios": "^1.2.1",
"ajv": "8.12.0",
"axios": "^1.2.3",
"co-body": "^6.1.0",
"dotenv": "^16.0.3",
"env-var": "^7.3.0",
Expand All @@ -85,27 +85,27 @@
"module-alias": "^2.2.2",
"oauth2-server": "^4.0.0-dev.2",
"openapi-jsonschema-parameters": "^12.1.0",
"prom-client": "^14.1.0",
"prom-client": "^14.1.1",
"promise-timeout": "^1.3.0",
"random-word-slugs": "^0.1.6",
"redis": "^4.5.1",
"uuidv4": "^6.2.13",
"ws": "^8.11.0"
"ws": "^8.12.0"
},
"devDependencies": {
"@babel/core": "^7.20.5",
"@babel/core": "^7.20.12",
"@babel/preset-env": "^7.20.2",
"@redocly/openapi-cli": "^1.0.0-beta.94",
"@types/jest": "^29.2.4",
"@types/jest": "^29.2.5",
"babel-jest": "^29.3.1",
"eslint": "^8.29.0",
"eslint": "^8.32.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^27.1.7",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.2.1",
"jest": "^29.3.1",
"jest-junit": "^15.0.0",
"nock": "^13.2.9",
"npm-check-updates": "^16.6.0",
"nock": "^13.3.0",
"npm-check-updates": "^16.6.2",
"openapi-response-validator": "^12.1.0",
"openapi-typescript": "^6.1.0",
"redis-mock": "^0.56.3",
Expand Down
6 changes: 4 additions & 2 deletions modules/api-svc/src/lib/model/InboundTransfersModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ class InboundTransfersModel {

// make a call to the backend to ask for a quote response
const response = await this._backendRequests.postQuoteRequests(internalForm);

if(!response) {
// make an error callback to the source fsp
return 'No response from backend';
Expand Down Expand Up @@ -258,7 +257,7 @@ class InboundTransfersModel {
*/
async getQuoteRequest(quoteId, sourceFspId) {
try {
// Get the quoteRespnse data for the quoteId from the cache to be sent as a response to GET /quotes/{ID}
// Get the quoteResponse data for the quoteId from the cache to be sent as a response to GET /quotes/{ID}
const quoteResponse = await this._cache.get(`quoteResponse_${quoteId}`);

// If no quoteResponse is found in the cache, make an error callback to the source fsp
Expand Down Expand Up @@ -441,6 +440,7 @@ class InboundTransfersModel {
currency: response.currency,
amount: response.amount,
transactionType: response.transactionType,
subScenario: response.subScenario,
note: response.note,
};

Expand Down Expand Up @@ -513,6 +513,7 @@ class InboundTransfersModel {
payee: quote.payee,
payer: bulkQuoteRequest.payer,
transactionType: quote.transactionType,
subScenario: quote.subScenario,
};

const quoteResponse = {
Expand Down Expand Up @@ -718,6 +719,7 @@ class InboundTransfersModel {
currency: transfer.currency,
amount: transfer.amount,
transactionType: transfer.transactionType,
subScenario: transfer.subScenario,
note: transfer.note,
};
let fulfilment;
Expand Down
1 change: 1 addition & 0 deletions modules/api-svc/src/lib/model/OutboundBulkQuotesModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ class OutboundBulkQuotesModel {
},
transactionType: {
scenario: individualQuote.transactionType,
subScenario: individualQuote.subScenario,
// TODO: support payee initiated txns?
initiator: 'PAYER',
// TODO: defaulting to CONSUMER initiator type should
Expand Down
1 change: 1 addition & 0 deletions modules/api-svc/src/lib/model/OutboundRequestToPayModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ class OutboundRequestToPayModel {
},
transactionType: {
scenario: this.data.scenario,
subScenario: this.data.subScenario,
initiator: this.data.initiator,
initiatorType: this.data.initiatorType
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ class OutboundRequestToPayTransferModel {

quote.transactionType = {
scenario: this.data.scenario,
subScenario: this.data.subScenario,
initiator: this.data.initiator,
initiatorType: this.data.initiatorType
};
Expand Down
1 change: 1 addition & 0 deletions modules/api-svc/src/lib/model/OutboundTransfersModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ class OutboundTransfersModel {

quote.transactionType = {
scenario: this.data.transactionType,
subScenario: this.data.subScenario,
// TODO: support payee initiated txns?
initiator: 'PAYER',
// TODO: defaulting to CONSUMER initiator type should
Expand Down
5 changes: 5 additions & 0 deletions modules/api-svc/src/lib/model/lib/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ const mojaloopQuoteRequestToInternal = (external) => {
amount: external.amount.amount,
currency: external.amount.currency,
transactionType: external.transactionType.scenario,
subScenario: external.transactionType.subScenario,
initiator: external.transactionType.initiator,
initiatorType: external.transactionType.initiatorType
};
Expand Down Expand Up @@ -253,6 +254,7 @@ const mojaloopPrepareToInternalTransfer = (external, quote, ilp) => {
currency: quote.request.amount.currency,
amount: quote.request.amount.amount,
transactionType: quote.request.transactionType.scenario,
subScenario: quote.request.transactionType.subScenario,
ilpPacket: {
data: ilp.getTransactionObject(external.ilpPacket),
},
Expand Down Expand Up @@ -286,6 +288,7 @@ const mojaloopTransactionRequestToInternal = (external) => {
amount: external.amount.amount,
currency: external.amount.currency,
transactionType: external.transactionType.scenario,
subScenario: external.transactionType.subScenario,
initiator: external.transactionType.initiator,
initiatorType: external.transactionType.initiatorType
};
Expand Down Expand Up @@ -325,6 +328,7 @@ const mojaloopBulkQuotesRequestToInternal = (external) => {
amount: quote.amount.amount,
currency: quote.amount.currency,
transactionType: quote.transactionType.scenario,
subScenario: quote.transactionType.subScenario,
initiator: quote.transactionType.initiator,
initiatorType: quote.transactionType.initiatorType
};
Expand Down Expand Up @@ -600,6 +604,7 @@ const mojaloopBulkPrepareToInternalBulkTransfer = (external, bulkQuotes, ilp) =>
to: internalQuote.to,
amountType: internalQuote.amountType,
transactionType: internalQuote.transactionType,
subScenario: internalQuote.subScenario,
note: internalQuote.note
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"transactionType": {
"scenario": "TRANSFER",
"initiator": "PAYEE",
"initiatorType": "CONSUMER"
"initiatorType": "CONSUMER",
"subScenario": "SUBSCENARIO"
}
}
}
1 change: 1 addition & 0 deletions modules/api-svc/test/unit/FSPIOPEventHandler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ describe('FSPIOPEventHandler', () => {
currency: 'USD',
amount: '10',
transactionType: 'TRANSFER',
subScenario: 'SUBSCENARIO',
note: 'test'
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"transactionType": {
"initiator": "PAYER",
"initiatorType": "CONSUMER",
"scenario": "TRANSFER"
"scenario": "TRANSFER",
"subScenario": "SUBSCENARIO"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"currency": "USD",
"amount": "100",
"transactionType": "TRANSFER",
"subScenario": "SUBSCENARIO",
"note": "test payment",
"homeTransactionId": "123ABC"
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"idValue": "987654321"
},
"transactionType": "TRANSFER",
"subScenario": "SUBSCENARIO",
"transferId": "00000000-0000-1000-8000-000000000001",
"transferRequestExtensions": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"idValue": "987654321"
},
"transactionType": "TRANSFER",
"subScenario": "SUBSCENARIO",
"transferId": "00000000-0000-1000-8000-000000000001",
"transferRequestExtensions": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"currency": "USD",
"amount": "100",
"transactionType": "TRANSFER",
"subScenario": "SUBSCENARIO",
"note": "test payment",
"homeTransactionId": "123ABC",
"quoteRequestExtensions": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
"middleName": "Someone"
},
"transactionType": "TRANSFER",
"subScenario": "SUBSCENARIO",
"transferId": "00000000-0000-1000-8000-000000000001",
"transferRequestExtensions": [
{
Expand Down
3 changes: 2 additions & 1 deletion modules/api-svc/test/unit/data/postQuotesBody.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"transactionType": {
"initiator": "PAYER",
"initiatorType": "CONSUMER",
"scenario": "TRANSFER"
"scenario": "TRANSFER",
"subScenario": "SUBSCENARIO"
}
}
5 changes: 3 additions & 2 deletions modules/api-svc/test/unit/inboundApi/data/mockArguments.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
"transactionType": {
"scenario": "TRANSFER",
"initiator": "PAYER",
"initiatorType": "CONSUMER"
"initiatorType": "CONSUMER",
"subScenario": "SUBSCENARIO"
}
}
],
Expand Down Expand Up @@ -114,4 +115,4 @@
}
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"currency": "USD",
"amount": "100",
"transactionType": "TRANSFER",
"subScenario": "SUBSCENARIO",
"note": "test payment"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"currency": "USD",
"amount": "100",
"transactionType": "TRANSFER",
"subScenario": "SUBSCENARIO",
"note": "test payment"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"transactionType": {
"initiator": "PAYER",
"initiatorType": "CONSUMER",
"scenario": "TRANSFER"
"scenario": "TRANSFER",
"subScenario": "SUBSCENARIO"
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"transactionType": {
"initiator": "PAYER",
"initiatorType": "CONSUMER",
"scenario": "TRANSFER"
"scenario": "TRANSFER",
"subScenario": "SUBSCENARIO"
},
"transferState": "COMMITTED",
"timestamp": "2019-11-15T14:16:09.663"
Expand Down
5 changes: 4 additions & 1 deletion modules/api-svc/test/unit/lib/model/data/mockArguments.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
"transactionType": {
"scenario": "TRANSFER",
"initiator": "PAYER",
"initiatorType": "CONSUMER"
"initiatorType": "CONSUMER",
"subScenario": "SUBSCENARIO"
},
"extensionList": {
"extension": [{
Expand Down Expand Up @@ -84,6 +85,7 @@
"amount": 10,
"currency": "XOF",
"transactionType": "TRANSFER",
"subScenario": "SUBSCENARIO",
"initiator": "PAYER",
"initiatorType": "CONSUMER",
"expiration": "2019-06-04T04:02:10.378Z",
Expand Down Expand Up @@ -165,6 +167,7 @@
},
"transactionType": {
"scenario": "TRANSFER",
"subScenario": "SUBSCENARIO",
"initiator": "PAYER",
"initiatorType": "CONSUMER"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"transactionType": {
"scenario": "TRANSFER",
"initiator": "PAYER",
"initiatorType": "CONSUMER"
"initiatorType": "CONSUMER",
"subScenario": "SUBSCENARIO"
}
},
"internalTransactionRequestResponse": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"currency": "USD",
"amount": "100",
"transactionType": "TRANSFER",
"subScenario": "SUBSCENARIO",
"note": "test payment",
"homeTransactionId": "123ABC",
"quoteRequestExtensions": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"currency": "USD",
"amount": "100",
"transactionType": "TRANSFER",
"subScenario": "SUBSCENARIO",
"note": "test payment"
}
]
}
}

0 comments on commit f6c739a

Please sign in to comment.