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/#2574): sdk-scheme-adapter is not returning party sub-id #120

Merged
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
[![Docker pulls](https://img.shields.io/docker/pulls/mojaloop/mojaloop-simulator.svg?style=flat)](https://hub.docker.com/r/mojaloop/mojaloop-simulator)
[![CircleCI](https://circleci.com/gh/mojaloop/mojaloop-simulator.svg?style=svg)](https://circleci.com/gh/mojaloop/mojaloop-simulator)


The code in this repo, along with the [Mojaloop SDK Example Scheme Adapter](http://www.github.com/modusbox/mojaloop-sdk-example-scheme-adapter), intends to simulate an exemplary FSP. It is a generic simulator, an implementation of the FSPIOP spec. It is intended to be used both locally, by prospective scheme participants to validate their FSPIOP implementations, and hosted in a cloud to validate a switch implementation. The objective of these use cases is to ease DFSP backend development and integration with the Mojaloop switch.

It is also intended to be used by the Scheme implementing Mojaloop itself to validate prospective participants' implementations before inclusion in the scheme. To these ends, it intends to behave as a stand-alone implementation of the Mojaloop switch, or as a participant in a Mojaloop scheme.
Expand Down Expand Up @@ -166,4 +165,4 @@ docker-compose up -d

# wait until mojaloop-simulator is up and running
npm run test:integration
```
```
6 changes: 6 additions & 0 deletions src/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ const config = {
after: 'always',
},
],
'no-await-in-loop': [
'off',
],
'no-restricted-syntax': [
'off',
],
},
};

Expand Down
6 changes: 6 additions & 0 deletions src/.ncurc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"reject": [
"eslint",
"node-fetch"
]
}
135 changes: 66 additions & 69 deletions src/audit-resolve.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,19 +231,16 @@
"expiresAt": 1636008277840
},
"1002401|sqlite3>node-gyp>npmlog>gauge>wide-align>string-width>strip-ansi>ansi-regex": {
"decision": "ignore",
"madeAt": 1633657747209,
"expiresAt": 1636249735221
"decision": "fix",
"madeAt": 1636557192974
},
"1002401|00unidentified>sqlite3>node-gyp>npmlog>gauge>wide-align>string-width>strip-ansi>ansi-regex": {
"decision": "ignore",
"madeAt": 1633657747209,
"expiresAt": 1636249735221
"decision": "fix",
"madeAt": 1636557192974
},
"1002401|00unidentified>00unidentified>sqlite3>node-gyp>npmlog>gauge>wide-align>string-width>strip-ansi>ansi-regex": {
"decision": "ignore",
"madeAt": 1633657747209,
"expiresAt": 1636249735221
"decision": "fix",
"madeAt": 1636557192974
},
"1002401|sqlite3>node-pre-gyp>npmlog>gauge>wide-align>string-width>strip-ansi>ansi-regex": {
"decision": "ignore",
Expand All @@ -262,153 +259,153 @@
},
"1002503|sqlite3>node-gyp>tar": {
"decision": "ignore",
"madeAt": 1633657753346,
"expiresAt": 1636249735221
"madeAt": 1636557209047,
"expiresAt": 1637161961051
},
"1002503|00unidentified>sqlite3>node-gyp>tar": {
"decision": "ignore",
"madeAt": 1633657753347,
"expiresAt": 1636249735221
"madeAt": 1636557209047,
"expiresAt": 1637161961051
},
"1002503|00unidentified>00unidentified>sqlite3>node-gyp>tar": {
"decision": "ignore",
"madeAt": 1633657753347,
"expiresAt": 1636249735221
"madeAt": 1636557209047,
"expiresAt": 1637161961051
},
"1002503|sqlite3>node-pre-gyp>tar": {
"decision": "ignore",
"madeAt": 1633657753347,
"expiresAt": 1636249735221
"madeAt": 1636557209047,
"expiresAt": 1637161961051
},
"1002503|00unidentified>sqlite3>node-pre-gyp>tar": {
"decision": "ignore",
"madeAt": 1633657753347,
"expiresAt": 1636249735221
"madeAt": 1636557209047,
"expiresAt": 1637161961051
},
"1002503|00unidentified>00unidentified>sqlite3>node-pre-gyp>tar": {
"decision": "ignore",
"madeAt": 1633657753347,
"expiresAt": 1636249735221
"madeAt": 1636557209047,
"expiresAt": 1637161961051
},
"1002506|sqlite3>node-gyp>tar": {
"decision": "ignore",
"madeAt": 1633657753347,
"expiresAt": 1636249735221
"madeAt": 1636557209047,
"expiresAt": 1637161961051
},
"1002506|00unidentified>sqlite3>node-gyp>tar": {
"decision": "ignore",
"madeAt": 1633657753347,
"expiresAt": 1636249735221
"madeAt": 1636557209047,
"expiresAt": 1637161961051
},
"1002506|00unidentified>00unidentified>sqlite3>node-gyp>tar": {
"decision": "ignore",
"madeAt": 1633657753347,
"expiresAt": 1636249735221
"madeAt": 1636557209047,
"expiresAt": 1637161961051
},
"1002506|sqlite3>node-pre-gyp>tar": {
"decision": "ignore",
"madeAt": 1633657753347,
"expiresAt": 1636249735221
"madeAt": 1636557209047,
"expiresAt": 1637161961051
},
"1002506|00unidentified>sqlite3>node-pre-gyp>tar": {
"decision": "ignore",
"madeAt": 1633657753347,
"expiresAt": 1636249735221
"madeAt": 1636557209047,
"expiresAt": 1637161961051
},
"1002506|00unidentified>00unidentified>sqlite3>node-pre-gyp>tar": {
"decision": "ignore",
"madeAt": 1633657753347,
"expiresAt": 1636249735221
"madeAt": 1636557209047,
"expiresAt": 1637161961051
},
"1002509|sqlite3>node-gyp>tar": {
"decision": "ignore",
"madeAt": 1633657753347,
"expiresAt": 1636249735221
"madeAt": 1636557209047,
"expiresAt": 1637161961051
},
"1002509|00unidentified>sqlite3>node-gyp>tar": {
"decision": "ignore",
"madeAt": 1633657753347,
"expiresAt": 1636249735221
"madeAt": 1636557209047,
"expiresAt": 1637161961051
},
"1002509|00unidentified>00unidentified>sqlite3>node-gyp>tar": {
"decision": "ignore",
"madeAt": 1633657753347,
"expiresAt": 1636249735221
"madeAt": 1636557209047,
"expiresAt": 1637161961051
},
"1002509|sqlite3>node-pre-gyp>tar": {
"decision": "ignore",
"madeAt": 1633657753347,
"expiresAt": 1636249735221
"madeAt": 1636557209047,
"expiresAt": 1637161961051
},
"1002509|00unidentified>sqlite3>node-pre-gyp>tar": {
"decision": "ignore",
"madeAt": 1633657753347,
"expiresAt": 1636249735221
"madeAt": 1636557209047,
"expiresAt": 1637161961051
},
"1002509|00unidentified>00unidentified>sqlite3>node-pre-gyp>tar": {
"decision": "ignore",
"madeAt": 1633657753347,
"expiresAt": 1636249735221
"madeAt": 1636557209047,
"expiresAt": 1637161961051
},
"1002541|sqlite3>node-pre-gyp>tar": {
"decision": "ignore",
"madeAt": 1633657753347,
"expiresAt": 1636249735221
"madeAt": 1636557209047,
"expiresAt": 1637161961051
},
"1002541|00unidentified>sqlite3>node-pre-gyp>tar": {
"decision": "ignore",
"madeAt": 1633657753347,
"expiresAt": 1636249735221
"madeAt": 1636557209047,
"expiresAt": 1637161961051
},
"1002541|00unidentified>00unidentified>sqlite3>node-pre-gyp>tar": {
"decision": "ignore",
"madeAt": 1633657753347,
"expiresAt": 1636249735221
"madeAt": 1636557209047,
"expiresAt": 1637161961051
},
"1002542|sqlite3>node-gyp>tar": {
"decision": "ignore",
"madeAt": 1633657753347,
"expiresAt": 1636249735221
"madeAt": 1636557209047,
"expiresAt": 1637161961051
},
"1002542|00unidentified>sqlite3>node-gyp>tar": {
"decision": "ignore",
"madeAt": 1633657753347,
"expiresAt": 1636249735221
"madeAt": 1636557209047,
"expiresAt": 1637161961051
},
"1002542|00unidentified>00unidentified>sqlite3>node-gyp>tar": {
"decision": "ignore",
"madeAt": 1633657753347,
"expiresAt": 1636249735221
"madeAt": 1636557209047,
"expiresAt": 1637161961051
},
"1002545|sqlite3>node-pre-gyp>tar": {
"decision": "ignore",
"madeAt": 1633657753347,
"expiresAt": 1636249735221
"madeAt": 1636557209047,
"expiresAt": 1637161961051
},
"1002545|00unidentified>sqlite3>node-pre-gyp>tar": {
"decision": "ignore",
"madeAt": 1633657753347,
"expiresAt": 1636249735221
"madeAt": 1636557209048,
"expiresAt": 1637161961051
},
"1002545|00unidentified>00unidentified>sqlite3>node-pre-gyp>tar": {
"decision": "ignore",
"madeAt": 1633657753347,
"expiresAt": 1636249735221
"madeAt": 1636557209048,
"expiresAt": 1637161961051
},
"1002546|sqlite3>node-gyp>tar": {
"decision": "ignore",
"madeAt": 1633657753347,
"expiresAt": 1636249735221
"madeAt": 1636557209048,
"expiresAt": 1637161961051
},
"1002546|00unidentified>sqlite3>node-gyp>tar": {
"decision": "ignore",
"madeAt": 1633657753347,
"expiresAt": 1636249735221
"madeAt": 1636557209048,
"expiresAt": 1637161961051
},
"1002546|00unidentified>00unidentified>sqlite3>node-gyp>tar": {
"decision": "ignore",
"madeAt": 1633657753347,
"expiresAt": 1636249735221
"madeAt": 1636557209048,
"expiresAt": 1637161961051
}
},
"rules": {},
Expand Down
8 changes: 4 additions & 4 deletions src/lib/validate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"author": "Matt Kingston, ModusBox Inc.",
"license": "Apache-2.0",
"devDependencies": {
"eslint": "7.28.0"
"eslint": "8.2.0"
},
"dependencies": {
"ajv": "8.6.0",
"json-schema-ref-parser": "9.0.7",
"openapi-jsonschema-parameters": "9.0.3"
"ajv": "8.7.1",
"json-schema-ref-parser": "9.0.9",
"openapi-jsonschema-parameters": "9.3.0"
}
}
6 changes: 4 additions & 2 deletions src/models/bulkQuote.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@ module.exports = class BulkQuote {
const resStr = JSON.stringify(response);
const created = new Date().toISOString().slice(0, 19);

await this.db.get(`INSERT INTO ${bulkQuoteTable} (id, request, response, created) VALUES (?, ?, ?, ?)`,
[bulkQuoteId, reqStr, resStr, created]);
await this.db.get(
`INSERT INTO ${bulkQuoteTable} (id, request, response, created) VALUES (?, ?, ?, ?)`,
[bulkQuoteId, reqStr, resStr, created],
);

return response;
}
Expand Down
14 changes: 13 additions & 1 deletion src/models/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,18 @@ CREATE TABLE IF NOT EXISTS ${partyAccountsTable} (
address TEXT NOT NULL PRIMARY KEY,
currency TEXT NOT NULL,
description TEXT NOT NULL,
idValue TEXT NOT NULL
idValue TEXT NOT NULL,
subIdValue TEXT
)
`;

// below index is a workaround to avoid the duplicates since sqlite treats every null as a unique value
// thus allowing to insert multiple records for same the idValue/key having subIdValue as NULL
const createAccountTableUniqueIndex = `
CREATE UNIQUE INDEX IF NOT EXISTS idx_party_account_unique ON ${partyAccountsTable} (
idValue,
IFNULL(subIdValue, ''),
address
)
`;

Expand All @@ -149,4 +160,5 @@ module.exports = {
createPartyExtensionTableUniqueIndex,
partyAccountsTable,
createAccountTable,
createAccountTableUniqueIndex,
};
4 changes: 3 additions & 1 deletion src/models/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const {
createPartyExtensionTable,
createPartyExtensionTableUniqueIndex,
createAccountTable,
createAccountTableUniqueIndex,
} = require('./constants');

/**
Expand Down Expand Up @@ -88,7 +89,7 @@ module.exports = class Model {
* @param [{Object}] parties Array of party objects to create after db initialisation
* @throws {Error}
*/
async init({ databaseFilepath, parties }) {
async init({ databaseFilepath, parties = null }) {
if (this.db) {
throw new Error('Attempted to initialise database twice');
}
Expand All @@ -108,6 +109,7 @@ module.exports = class Model {
await this.db.run(createBulkQuoteTable);
await this.db.run(createBulkTransferTable);
await this.db.run(createAccountTable);
await this.db.run(createAccountTableUniqueIndex);

this.party = new Party(this.db);
this.quote = new Quote(this.db);
Expand Down
Loading