@mojaloop/central-ledger 16.3.2 → 16.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [16.3.3](https://github.com/mojaloop/central-ledger/compare/v16.3.2...v16.3.3) (2022-12-12)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **mojaloop/#2644:** missing error-code for the transfer in the central-ledger db ([#929](https://github.com/mojaloop/central-ledger/issues/929)) ([7e49456](https://github.com/mojaloop/central-ledger/commit/7e4945614224f4887cb0abd956faf51b804e3873)), closes [mojaloop/#2644](https://github.com/mojaloop/project/issues/2644)
11
+
5
12
  ### [16.3.2](https://github.com/mojaloop/central-ledger/compare/v16.3.1...v16.3.2) (2022-11-24)
6
13
 
7
14
 
@@ -166,6 +166,27 @@ services:
166
166
  start_period: 40s
167
167
  interval: 30s
168
168
 
169
+ init-kafka:
170
+ container_name: cl_init_kafka
171
+ networks:
172
+ - cl-mojaloop-net
173
+ image: docker.io/bitnami/kafka:3.2
174
+ depends_on:
175
+ - kafka
176
+ entrypoint: [ '/bin/sh', '-c' ]
177
+ command: |
178
+ "
179
+ # blocks until kafka is reachable
180
+ kafka-topics.sh --bootstrap-server kafka:29092 --list
181
+ echo -e 'Creating kafka topics'
182
+ kafka-topics.sh --bootstrap-server kafka:29092 --create --if-not-exists --topic topic-transfer-prepare --replication-factor 1 --partitions 1
183
+ kafka-topics.sh --bootstrap-server kafka:29092 --create --if-not-exists --topic topic-transfer-position --replication-factor 1 --partitions 1
184
+ kafka-topics.sh --bootstrap-server kafka:29092 --create --if-not-exists --topic topic-transfer-fulfil --replication-factor 1 --partitions 1
185
+ kafka-topics.sh --bootstrap-server kafka:29092 --create --if-not-exists --topic topic-notification-event --replication-factor 1 --partitions 1
186
+ echo -e 'Successfully created the following topics:'
187
+ kafka-topics.sh --bootstrap-server kafka:29092 --list
188
+ "
189
+
169
190
  objstore:
170
191
  image: mongo:latest
171
192
  container_name: cl_objstore
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mojaloop/central-ledger",
3
- "version": "16.3.2",
3
+ "version": "16.3.3",
4
4
  "description": "Central ledger hosted by a scheme to record and settle transfers",
5
5
  "license": "Apache-2.0",
6
6
  "author": "ModusBox",
@@ -48,7 +48,7 @@
48
48
  "test:xunit": "npx tape 'test/unit/**/**.test.js' | tap-xunit > ./test/results/xunit.xml",
49
49
  "test:coverage": "npx nyc --reporter=lcov --reporter=text-summary tapes -- 'test/unit/**/**.test.js'",
50
50
  "test:coverage-check": "npm run test:coverage && nyc check-coverage",
51
- "test:int": "npm run migrate && npx tape 'test/integration/**/*.test.js' | tap-spec",
51
+ "test:int": "npm run migrate && TST_RETRY_COUNT=20 TST_RETRY_TIMEOUT=3 UV_THREADPOOL_SIZE=12 npx tape 'test/integration/**/*.test.js' | tap-spec",
52
52
  "migrate": "npm run migrate:latest && npm run seed:run",
53
53
  "migrate:latest": "npx knex $npm_package_config_knex migrate:latest",
54
54
  "migrate:create": "npx knex migrate:make $npm_package_config_knex",
@@ -60,6 +60,7 @@
60
60
  "docker:build:api": "docker build --no-cache -f Dockerfile -t $npm_package_config_images_api:latest .",
61
61
  "docker:up": "docker-compose -f docker-compose.yml up",
62
62
  "docker:up:backend": "docker-compose up -d ml-api-adapter mysql mockserver kafka kowl temp_curl",
63
+ "docker:up:int": "docker compose up -d kafka init-kafka objstore mysql",
63
64
  "docker:script:populateTestData": "sh ./test/util/scripts/populateTestData.sh",
64
65
  "docker:stop": "docker-compose -f docker-compose.yml stop",
65
66
  "docker:rm": "docker-compose -f docker-compose.yml rm -f -v",
@@ -76,7 +77,7 @@
76
77
  },
77
78
  "dependencies": {
78
79
  "@hapi/good": "9.0.1",
79
- "@hapi/hapi": "21.0.0",
80
+ "@hapi/hapi": "21.1.0",
80
81
  "@hapi/inert": "7.0.0",
81
82
  "@hapi/joi": "17.1.1",
82
83
  "@hapi/vision": "7.0.0",
@@ -98,7 +99,7 @@
98
99
  "catbox-memory": "4.0.1",
99
100
  "commander": "9.4.1",
100
101
  "cron": "2.1.0",
101
- "decimal.js": "10.4.2",
102
+ "decimal.js": "10.4.3",
102
103
  "docdash": "2.0.0",
103
104
  "event-stream": "4.0.1",
104
105
  "five-bells-condition": "5.0.1",
@@ -119,17 +120,17 @@
119
120
  },
120
121
  "devDependencies": {
121
122
  "async-retry": "1.3.3",
122
- "audit-ci": "^6.3.0",
123
+ "audit-ci": "^6.4.0",
123
124
  "get-port": "5.1.1",
124
125
  "jsdoc": "4.0.0",
125
126
  "jsonpath": "1.1.1",
126
127
  "nodemon": "2.0.20",
127
- "npm-check-updates": "16.4.3",
128
+ "npm-check-updates": "16.5.6",
128
129
  "nyc": "15.1.0",
129
130
  "pre-commit": "1.2.2",
130
131
  "proxyquire": "2.1.3",
131
132
  "replace": "^1.2.2",
132
- "sinon": "14.0.2",
133
+ "sinon": "15.0.0",
133
134
  "standard": "17.0.0",
134
135
  "standard-version": "^9.5.0",
135
136
  "tap-spec": "^5.0.0",
@@ -598,6 +598,7 @@ const timeoutExpireReserved = async (segmentId, intervalMin, intervalMax) => {
598
598
  const knex = await Db.getKnex()
599
599
  await knex.transaction(async (trx) => {
600
600
  try {
601
+ // Insert `transferTimeout` records for transfers found between the interval intervalMin <= intervalMax
601
602
  await knex.from(knex.raw('transferTimeout (transferId, expirationDate)')).transacting(trx)
602
603
  .insert(function () {
603
604
  this.from('transfer AS t')
@@ -613,9 +614,10 @@ const timeoutExpireReserved = async (segmentId, intervalMin, intervalMax) => {
613
614
  .whereNull('tt.transferId')
614
615
  .whereIn('tsc.transferStateId', [`${Enum.Transfers.TransferInternalState.RECEIVED_PREPARE}`, `${Enum.Transfers.TransferState.RESERVED}`])
615
616
  .select('t.transferId', 't.expirationDate')
616
- })// .toSQL().sql
617
- // console.log('SQL: ' + q)
617
+ }) // .toSQL().sql
618
+ // console.log('SQL: ' + q1)
618
619
 
620
+ // Insert `transferStateChange` records for RECEIVED_PREPARE
619
621
  await knex.from(knex.raw('transferStateChange (transferId, transferStateId, reason)')).transacting(trx)
620
622
  .insert(function () {
621
623
  this.from('transferTimeout AS tt')
@@ -629,9 +631,10 @@ const timeoutExpireReserved = async (segmentId, intervalMin, intervalMax) => {
629
631
  .where('tt.expirationDate', '<', transactionTimestamp)
630
632
  .andWhere('tsc.transferStateId', `${Enum.Transfers.TransferInternalState.RECEIVED_PREPARE}`)
631
633
  .select('tt.transferId', knex.raw('?', Enum.Transfers.TransferInternalState.EXPIRED_PREPARED), knex.raw('?', 'Aborted by Timeout Handler'))
632
- })// .toSQL().sql
633
- // console.log('SQL: ' + q)
634
+ }) // .toSQL().sql
635
+ // console.log('SQL: ' + q2)
634
636
 
637
+ // Insert `transferStateChange` records for RESERVED
635
638
  await knex.from(knex.raw('transferStateChange (transferId, transferStateId, reason)')).transacting(trx)
636
639
  .insert(function () {
637
640
  this.from('transferTimeout AS tt')
@@ -645,8 +648,25 @@ const timeoutExpireReserved = async (segmentId, intervalMin, intervalMax) => {
645
648
  .where('tt.expirationDate', '<', transactionTimestamp)
646
649
  .andWhere('tsc.transferStateId', `${Enum.Transfers.TransferState.RESERVED}`)
647
650
  .select('tt.transferId', knex.raw('?', Enum.Transfers.TransferInternalState.RESERVED_TIMEOUT), knex.raw('?', 'Marked for expiration by Timeout Handler'))
648
- })// .toSQL().sql
649
- // console.log('SQL: ' + q)
651
+ }) // .toSQL().sql
652
+ // console.log('SQL: ' + q3)
653
+
654
+ // Insert `transferError` records
655
+ await knex.from(knex.raw('transferError (transferId, transferStateChangeId, errorCode, errorDescription)')).transacting(trx)
656
+ .insert(function () {
657
+ this.from('transferTimeout AS tt')
658
+ .innerJoin(knex('transferStateChange AS tsc1')
659
+ .select('tsc1.transferId')
660
+ .max('tsc1.transferStateChangeId AS maxTransferStateChangeId')
661
+ .innerJoin('transferTimeout AS tt1', 'tt1.transferId', 'tsc1.transferId')
662
+ .groupBy('tsc1.transferId').as('ts'), 'ts.transferId', 'tt.transferId'
663
+ )
664
+ .innerJoin('transferStateChange AS tsc', 'tsc.transferStateChangeId', 'ts.maxTransferStateChangeId')
665
+ .where('tt.expirationDate', '<', transactionTimestamp)
666
+ .andWhere('tsc.transferStateId', `${Enum.Transfers.TransferInternalState.RESERVED_TIMEOUT}`)
667
+ .select('tt.transferId', 'tsc.transferStateChangeId', knex.raw('?', ErrorHandler.Enums.FSPIOPErrorCodes.TRANSFER_EXPIRED.code), knex.raw('?', ErrorHandler.Enums.FSPIOPErrorCodes.TRANSFER_EXPIRED.message))
668
+ }) // .toSQL().sql
669
+ // console.log('SQL: ' + q4)
650
670
 
651
671
  if (segmentId === 0) {
652
672
  const segment = {