From b5777610fae5a6339d65321c1f69b3ef23c87f06 Mon Sep 17 00:00:00 2001 From: Steven Oderayi Date: Tue, 22 Sep 2020 12:01:27 +0000 Subject: [PATCH] Fix error callback for expired transfers (#785) --- package-lock.json | 117 ++++++++++++++++-------------- package.json | 12 +-- src/handlers/transfers/handler.js | 7 ++ 3 files changed, 74 insertions(+), 62 deletions(-) diff --git a/package-lock.json b/package-lock.json index 09c414fee..c27c3af71 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@mojaloop/central-ledger", - "version": "11.2.0", + "version": "11.2.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -923,9 +923,9 @@ } }, "@mojaloop/central-services-shared": { - "version": "11.3.3", - "resolved": "https://registry.npmjs.org/@mojaloop/central-services-shared/-/central-services-shared-11.3.3.tgz", - "integrity": "sha512-2LuqxEiTSUsC0rh1I5xCZ+ZuspqEaUhoxAd9TMAmD5cz02/D2gNZl7DW0J0cUXgakmWrFqD1r958ayQFAa89qg==", + "version": "11.3.5", + "resolved": "https://registry.npmjs.org/@mojaloop/central-services-shared/-/central-services-shared-11.3.5.tgz", + "integrity": "sha512-jZvHMtd3hvatZ6ylEgDGgiXxHEbKZFSZIK0z3M9C96KEbl4C50xuIzj2cxnqkp6UuRn3T/2KsJZSCbdqlCUuuw==", "requires": { "@hapi/catbox": "11.1.1", "@hapi/catbox-memory": "5.0.0", @@ -933,7 +933,7 @@ "@mojaloop/central-services-logger": "10.6.0", "@mojaloop/central-services-metrics": "9.5.0", "@mojaloop/event-sdk": "10.6.0", - "ajv": "6.12.4", + "ajv": "6.12.5", "ajv-keywords": "3.5.2", "axios": "0.20.0", "base64url": "3.0.1", @@ -944,16 +944,16 @@ "immutable": "3.8.2", "lodash": "4.17.20", "mustache": "4.0.1", - "openapi-backend": "3.5.2", + "openapi-backend": "3.5.4", "raw-body": "2.4.1", "rc": "1.2.8", "uuid4": "2.0.2" }, "dependencies": { "ajv": { - "version": "6.12.4", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.4.tgz", - "integrity": "sha512-eienB2c9qVQs2KWexhkrdMLVDoIQCz5KSeLxwg9Lzk4DOfBtIK9PQwwufcsn1jjGuf9WZmqPMbGxOzfcuphJCQ==", + "version": "6.12.5", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.5.tgz", + "integrity": "sha512-lRF8RORchjpKG50/WFf8xmg7sgCLFiYNNnqdKflk63whMQcWR5ngGjiSXkL9bjxy6B2npOK2HSMN49jEBMSkag==", "requires": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", @@ -980,9 +980,9 @@ "integrity": "sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA==" }, "openapi-backend": { - "version": "3.5.2", - "resolved": "https://registry.npmjs.org/openapi-backend/-/openapi-backend-3.5.2.tgz", - "integrity": "sha512-B6VptLEvyDstDd2bY+7/Lk6IK1syEzHMyAZG7U4A+UiGLD+/NN39axVhFD+8ulBjo037AcrZ3OeQzoMV+nigPQ==", + "version": "3.5.4", + "resolved": "https://registry.npmjs.org/openapi-backend/-/openapi-backend-3.5.4.tgz", + "integrity": "sha512-gGuq69ai/oxR9/DFiLK+6DWL4mJjtO3xGI/tp2GYI8HTL/W6PpDMeIk+jEw5Ep1Yo7aepPpuSUsibsh0yIbyDQ==", "requires": { "ajv": "^6.10.0", "bath-es5": "^3.0.3", @@ -1037,6 +1037,11 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz", "integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==" }, + "moment": { + "version": "2.27.0", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.27.0.tgz", + "integrity": "sha512-al0MUK7cpIcglMv3YF13qSgdAIqxHTO7brRtaz3DlSULbqfazqkc5kEjNrLDOM7fsjshoFIihnU8snrP7zUvhQ==" + }, "sinon": { "version": "9.0.2", "resolved": "https://registry.npmjs.org/sinon/-/sinon-9.0.2.tgz", @@ -1437,12 +1442,12 @@ }, "dependencies": { "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", + "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } } } @@ -1459,12 +1464,12 @@ }, "dependencies": { "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", + "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } } } @@ -4846,12 +4851,12 @@ }, "dependencies": { "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", + "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } } } @@ -4883,12 +4888,12 @@ }, "dependencies": { "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", + "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } } } @@ -5629,9 +5634,9 @@ "dev": true }, "jsdoc": { - "version": "3.6.5", - "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.6.5.tgz", - "integrity": "sha512-SbY+i9ONuxSK35cgVHaI8O9senTE4CDYAmGSDJ5l3+sfe62Ff4gy96osy6OW84t4K4A8iGnMrlRrsSItSNp3RQ==", + "version": "3.6.6", + "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.6.6.tgz", + "integrity": "sha512-znR99e1BHeyEkSvgDDpX0sTiTu+8aQyDl9DawrkOGZTTW8hv0deIFXx87114zJ7gRaDZKVQD/4tr1ifmJp9xhQ==", "dev": true, "requires": { "@babel/parser": "^7.9.4", @@ -6588,9 +6593,9 @@ "dev": true }, "moment": { - "version": "2.27.0", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.27.0.tgz", - "integrity": "sha512-al0MUK7cpIcglMv3YF13qSgdAIqxHTO7brRtaz3DlSULbqfazqkc5kEjNrLDOM7fsjshoFIihnU8snrP7zUvhQ==" + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.0.tgz", + "integrity": "sha512-z6IJ5HXYiuxvFTI6eiQ9dm77uE0gyy1yXNApVHqTcnIKfY9tIwEjlzsZ6u1LQXvVgKeTnv9Xm7NDvJ7lso3MtA==" }, "moment-timezone": { "version": "0.5.31", @@ -6614,13 +6619,13 @@ } }, "mongoose": { - "version": "5.10.3", - "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.10.3.tgz", - "integrity": "sha512-FLemltuzcsCHlFpEZ3bYOiNhJfHful+GoS+3uRgdEWGlY0HKfOjm9xsISM/tql8vRvhjr7qveuRfoBBGO3xNtw==", + "version": "5.10.6", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.10.6.tgz", + "integrity": "sha512-p32oja2ydzFMS0K4P7G408Kagju6Qz/LmiAFAcP6BqnIi1McLTd6VZ3+ZQtQmaHM7w8iNupLLambCrsPKNJpYw==", "requires": { "bson": "^1.1.4", "kareem": "2.3.1", - "mongodb": "3.6.1", + "mongodb": "3.6.2", "mongoose-legacy-pluralize": "1.0.2", "mpath": "0.7.0", "mquery": "3.2.2", @@ -6632,11 +6637,11 @@ }, "dependencies": { "mongodb": { - "version": "3.6.1", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.6.1.tgz", - "integrity": "sha512-uH76Zzr5wPptnjEKJRQnwTsomtFOU/kQEU8a9hKHr2M7y9qVk7Q4Pkv0EQVp88742z9+RwvsdTw6dRjDZCNu1g==", + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.6.2.tgz", + "integrity": "sha512-sSZOb04w3HcnrrXC82NEh/YGCmBuRgR+C1hZgmmv4L6dBz4BkRse6Y8/q/neXer9i95fKUBbFi4KgeceXmbsOA==", "requires": { - "bl": "^2.2.0", + "bl": "^2.2.1", "bson": "^1.1.4", "denque": "^1.4.1", "require_optional": "^1.0.1", @@ -6947,9 +6952,9 @@ } }, "npm-check-updates": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/npm-check-updates/-/npm-check-updates-8.1.1.tgz", - "integrity": "sha512-8YxCG/ExD9HdcvflEfPrvEeonkAc+1OZCbZ9ExANkDRqMrolOMHC52eJyQlF4bsFMAAtT3nS1EOjkCRaDaOiHQ==", + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/npm-check-updates/-/npm-check-updates-9.0.1.tgz", + "integrity": "sha512-xSMyNEIvsrNPDh5r1N/VxDGE+5ZkiEx8BxBvoEBWc/rsaHHfwKCvsY3qJjAn064pULH4uTrT7+kJwroHYsY/Yw==", "dev": true, "requires": { "chalk": "^4.1.0", @@ -8408,12 +8413,12 @@ }, "dependencies": { "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", + "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } } } @@ -9159,9 +9164,9 @@ } }, "socks": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/socks/-/socks-2.4.2.tgz", - "integrity": "sha512-cE6P9R+/CET9XhIMvqhRgaNT1GXKIahioMjwwhgYOd+8UQWP50rrFm+faqG/4xkZsjTdVeBYr0Tb246BSC9/fg==", + "version": "2.4.4", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.4.4.tgz", + "integrity": "sha512-7LmHN4IHj1Vpd/k8D872VGCHJ6yIVyeFkfIBExRmGPYQ/kdUkpdg9eKh9oOzYYYKQhuxavayJHTnmBG+EzluUA==", "dev": true, "requires": { "ip": "^1.1.5", @@ -9180,12 +9185,12 @@ }, "dependencies": { "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", + "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } } } diff --git a/package.json b/package.json index 38a6ec864..e8bc5799d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mojaloop/central-ledger", - "version": "11.2.0", + "version": "11.2.1", "description": "Central ledger hosted by a scheme to record and settle transfers", "license": "Apache-2.0", "author": "ModusBox", @@ -86,7 +86,7 @@ "@mojaloop/central-services-health": "10.6.0", "@mojaloop/central-services-logger": "10.6.0", "@mojaloop/central-services-metrics": "9.5.0", - "@mojaloop/central-services-shared": "11.3.3", + "@mojaloop/central-services-shared": "11.3.5", "@mojaloop/central-services-stream": "10.6.0", "@mojaloop/event-sdk": "10.6.0", "@mojaloop/forensic-logging-client": "8.3.0", @@ -108,8 +108,8 @@ "ilp-packet": "2.2.0", "knex": "0.21.5", "lodash": "4.17.20", - "moment": "2.27.0", - "mongoose": "5.10.3", + "moment": "2.29.0", + "mongoose": "5.10.6", "npm-run-all": "4.1.5", "rc": "1.2.8", "require-glob": "3.2.0", @@ -122,11 +122,11 @@ "async-retry": "1.3.1", "faucet": "0.0.1", "get-port": "5.1.1", - "jsdoc": "3.6.5", + "jsdoc": "3.6.6", "jsonpath": "1.0.2", "nodemon": "2.0.4", "npm-audit-resolver": "2.2.1", - "npm-check-updates": "8.1.1", + "npm-check-updates": "9.0.1", "nyc": "15.1.0", "pre-commit": "1.2.2", "proxyquire": "2.1.3", diff --git a/src/handlers/transfers/handler.js b/src/handlers/transfers/handler.js index c350b2586..7f457d611 100644 --- a/src/handlers/transfers/handler.js +++ b/src/handlers/transfers/handler.js @@ -572,6 +572,13 @@ const getTransfer = async (error, messages) => { await Kafka.proceed(Config.KAFKA_CONFIG, params, { consumerCommit, fspiopError: fspiopError.toApiErrorObject(Config.ERROR_HANDLING), eventDetail, fromSwitch }) throw fspiopError } + if (transfer.transferState === Enum.Transfers.TransferInternalState.EXPIRED_RESERVED) { + Logger.isInfoEnabled && Logger.info(Util.breadcrumb(location, `callbackTransferExpired--${actionLetter}3`)) + const fspiopError = ErrorHandler.Factory.createFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.TRANSFER_EXPIRED) + await Kafka.proceed(Config.KAFKA_CONFIG, params, { consumerCommit, fspiopError: fspiopError.toApiErrorObject(Config.ERROR_HANDLING), eventDetail, fromSwitch }) + throw fspiopError + } + // ============================================================================================ Util.breadcrumb(location, { path: 'validationPassed' }) Logger.isInfoEnabled && Logger.info(Util.breadcrumb(location, `callbackMessage--${actionLetter}4`))