@mojaloop/central-ledger 17.7.8 → 17.8.0-orb.1

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.
Files changed (147) hide show
  1. package/.ncurc.yaml +3 -1
  2. package/.nvmrc +1 -1
  3. package/.nycrc.yml +16 -1
  4. package/Dockerfile +9 -10
  5. package/README.md +39 -9
  6. package/audit-ci.jsonc +15 -2
  7. package/config/default.json +17 -1
  8. package/docker/central-ledger/default.json +9 -0
  9. package/docker/config-modifier/configs/central-ledger.js +25 -0
  10. package/docker/env.sh +15 -0
  11. package/docker/kafka/scripts/provision.sh +4 -1
  12. package/docker/ml-api-adapter/default.json +4 -1
  13. package/docker-compose.yml +90 -2
  14. package/documentation/db/erd-transfer-timeout.png +0 -0
  15. package/documentation/db/erd-transfer-timeout.txt +81 -0
  16. package/documentation/fx-implementation/README.md +48 -0
  17. package/documentation/fx-implementation/assets/fx-position-movements.drawio.svg +4 -0
  18. package/documentation/fx-implementation/assets/test-scenario.drawio.svg +4 -0
  19. package/documentation/sequence-diagrams/Handler - FX timeout.plantuml +123 -0
  20. package/documentation/sequence-diagrams/Handler - FX timeout.png +0 -0
  21. package/documentation/sequence-diagrams/Handler - timeout.plantuml +81 -0
  22. package/documentation/sequence-diagrams/Handler - timeout.png +0 -0
  23. package/documentation/state-diagrams/transfer-ML-spec-states-diagram.png +0 -0
  24. package/documentation/state-diagrams/transfer-internal-states-diagram.png +0 -0
  25. package/documentation/state-diagrams/transfer-internal-states.plantuml +75 -0
  26. package/documentation/state-diagrams/transfer-states.plantuml +13 -0
  27. package/migrations/310204_transferParticipant-participantId.js +52 -0
  28. package/migrations/310403_participantPositionChange-participantCurrencyId.js +47 -0
  29. package/migrations/310404_participantPositionChange-change.js +46 -0
  30. package/migrations/600010_fxTransferType.js +43 -0
  31. package/migrations/600011_fxTransferType-indexes.js +38 -0
  32. package/migrations/600012_fxParticipantCurrencyType.js +43 -0
  33. package/migrations/600013_fxParticipantCurrencyType-indexes.js +38 -0
  34. package/migrations/600100_fxTransferDuplicateCheck.js +42 -0
  35. package/migrations/600110_fxTransferErrorDuplicateCheck.js.js +17 -0
  36. package/migrations/600200_fxTransfer.js +51 -0
  37. package/migrations/600201_fxTransfer-indexes.js +40 -0
  38. package/migrations/600400_fxTransferStateChange.js +46 -0
  39. package/migrations/600401_fxTransferStateChange-indexes.js +40 -0
  40. package/migrations/600501_fxWatchList.js +46 -0
  41. package/migrations/600502_fxWatchList-indexes.js +40 -0
  42. package/migrations/600600_fxTransferFulfilmentDuplicateCheck.js +43 -0
  43. package/migrations/600601_fxTransferFulfilmentDuplicateCheck-indexes.js +38 -0
  44. package/migrations/600700_fxTransferFulfilment.js +47 -0
  45. package/migrations/600701_fxTransferFulfilment-indexes.js +43 -0
  46. package/migrations/600800_fxTransferExtension.js +47 -0
  47. package/migrations/601400_fxTransferTimeout.js +43 -0
  48. package/migrations/601401_fxTransferTimeout-indexes.js +37 -0
  49. package/migrations/601500_fxTransferError.js +44 -0
  50. package/migrations/601501_fxTransferError-indexes.js +37 -0
  51. package/migrations/610200_fxTransferParticipant.js +52 -0
  52. package/migrations/610201_fxTransferParticipant-indexes.js +44 -0
  53. package/migrations/610202_fxTransferParticipant-participantId.js +52 -0
  54. package/migrations/610403_participantPositionChange-fxTransfer.js +46 -0
  55. package/migrations/910101_feature904DataMigration.js +46 -52
  56. package/migrations/910102_feature949DataMigration.js +219 -225
  57. package/migrations/950104_settlementModel-settlementAccountTypeId.js +15 -20
  58. package/migrations/950108_participantProxy.js +18 -0
  59. package/migrations/950109_fxQuote.js +19 -0
  60. package/migrations/950110_fxQuoteResponse.js +25 -0
  61. package/migrations/950111_fxQuoteError.js +23 -0
  62. package/migrations/950113_fxQuoteDuplicateCheck.js +18 -0
  63. package/migrations/950114_fxQuoteResponseDuplicateCheck.js +21 -0
  64. package/migrations/950115_fxQuoteConversionTerms.js +36 -0
  65. package/migrations/950116_fxQuoteConversionTermsExtension.js +21 -0
  66. package/migrations/950117_fxQuoteResponseConversionTerms.js +39 -0
  67. package/migrations/950118_fxQuoteResponseConversionTermsExtension.js +21 -0
  68. package/migrations/950119_fxCharge.js +27 -0
  69. package/migrations/960100_create_externalParticipant.js +47 -0
  70. package/migrations/960110_alter_transferParticipant__addFiled_externalParticipantId.js +50 -0
  71. package/migrations/960111_alter_fxTransferParticipant__addFiled_externalParticipantId.js +50 -0
  72. package/package.json +27 -20
  73. package/seeds/endpointType.js +18 -0
  74. package/seeds/fxParticipantCurrencyType.js +45 -0
  75. package/seeds/fxTransferType.js +45 -0
  76. package/seeds/participant.js +2 -1
  77. package/seeds/transferParticipantRoleType.js +9 -0
  78. package/seeds/transferState.js +10 -0
  79. package/src/api/interface/swagger.json +23 -30
  80. package/src/api/participants/handler.js +6 -2
  81. package/src/api/participants/routes.js +8 -7
  82. package/src/api/root/handler.js +15 -5
  83. package/src/domain/fx/cyril.js +466 -0
  84. package/src/domain/fx/index.js +107 -0
  85. package/src/domain/participant/index.js +108 -1
  86. package/src/domain/position/abort.js +215 -0
  87. package/src/domain/position/binProcessor.js +361 -99
  88. package/src/domain/position/fulfil.js +252 -111
  89. package/src/domain/position/fx-fulfil.js +138 -0
  90. package/src/domain/position/fx-prepare.js +280 -0
  91. package/src/domain/position/fx-timeout-reserved.js +159 -0
  92. package/src/domain/position/index.js +1 -0
  93. package/src/domain/position/prepare.js +69 -49
  94. package/src/domain/position/timeout-reserved.js +162 -0
  95. package/src/domain/timeout/index.js +26 -2
  96. package/src/domain/transfer/index.js +22 -5
  97. package/src/domain/transfer/transform.js +19 -6
  98. package/src/handlers/admin/handler.js +0 -2
  99. package/src/handlers/bulk/fulfil/handler.js +5 -5
  100. package/src/handlers/bulk/get/handler.js +5 -5
  101. package/src/handlers/bulk/prepare/handler.js +9 -9
  102. package/src/handlers/bulk/processing/handler.js +8 -7
  103. package/src/handlers/bulk/shared/validator.js +1 -1
  104. package/src/handlers/positions/handler.js +23 -10
  105. package/src/handlers/positions/handlerBatch.js +54 -26
  106. package/src/handlers/register.js +2 -1
  107. package/src/handlers/timeouts/handler.js +212 -68
  108. package/src/handlers/transfers/FxFulfilService.js +387 -0
  109. package/src/handlers/transfers/createRemittanceEntity.js +106 -0
  110. package/src/handlers/transfers/dto.js +53 -0
  111. package/src/handlers/transfers/handler.js +609 -571
  112. package/src/handlers/transfers/prepare.js +572 -0
  113. package/src/handlers/transfers/validator.js +75 -14
  114. package/src/lib/cache.js +1 -1
  115. package/src/lib/config.js +6 -3
  116. package/src/lib/healthCheck/subServiceHealth.js +12 -2
  117. package/src/lib/proxyCache.js +131 -0
  118. package/src/models/bulkTransfer/facade.js +58 -82
  119. package/src/models/fxTransfer/duplicateCheck.js +153 -0
  120. package/src/models/fxTransfer/fxTransfer.js +578 -0
  121. package/src/models/fxTransfer/fxTransferError.js +53 -0
  122. package/src/models/fxTransfer/fxTransferExtension.js +41 -0
  123. package/src/models/fxTransfer/fxTransferTimeout.js +68 -0
  124. package/src/models/fxTransfer/index.js +15 -0
  125. package/src/models/fxTransfer/stateChange.js +47 -0
  126. package/src/models/fxTransfer/watchList.js +49 -0
  127. package/src/models/ledgerAccountType/ledgerAccountType.js +8 -32
  128. package/src/models/misc/segment.js +0 -1
  129. package/src/models/participant/externalParticipant.js +96 -0
  130. package/src/models/participant/externalParticipantCached.js +148 -0
  131. package/src/models/participant/facade.js +192 -123
  132. package/src/models/participant/participant.js +2 -1
  133. package/src/models/participant/participantCurrency.js +1 -1
  134. package/src/models/participant/participantPosition.js +2 -8
  135. package/src/models/position/batch.js +90 -1
  136. package/src/models/position/facade.js +5 -5
  137. package/src/models/position/participantPositionChanges.js +68 -0
  138. package/src/models/settlement/settlementModel.js +5 -23
  139. package/src/models/transfer/facade.js +806 -447
  140. package/src/shared/constants.js +52 -0
  141. package/src/shared/fspiopErrorFactory.js +131 -0
  142. package/src/shared/logger/index.js +8 -0
  143. package/src/shared/loggingPlugin.js +43 -0
  144. package/src/shared/plugins.js +6 -0
  145. package/src/shared/setup.js +10 -0
  146. package/test-integration.Dockerfile +1 -1
  147. package/test.Dockerfile +1 -1
@@ -0,0 +1,25 @@
1
+ 'use strict'
2
+
3
+ exports.up = (knex) => {
4
+ return knex.schema.hasTable('fxQuoteResponse').then((exists) => {
5
+ if (!exists) {
6
+ return knex.schema.createTable('fxQuoteResponse', (t) => {
7
+ t.bigIncrements('fxQuoteResponseId').primary().notNullable()
8
+
9
+ // reference to the original fxQuote
10
+ t.string('conversionRequestId', 36).notNullable()
11
+ t.foreign('conversionRequestId').references('conversionRequestId').inTable('fxQuote')
12
+
13
+ // ilpCondition sent in FXP response
14
+ t.string('ilpCondition', 256).notNullable()
15
+
16
+ // time keeping
17
+ t.dateTime('createdDate').defaultTo(knex.fn.now()).notNullable().comment('System dateTime stamp pertaining to the inserted record')
18
+ })
19
+ }
20
+ })
21
+ }
22
+
23
+ exports.down = (knex) => {
24
+ return knex.schema.dropTableIfExists('fxQuoteResponse')
25
+ }
@@ -0,0 +1,23 @@
1
+ // Notes: these changes are required for the quoting-service and are not used by central-ledger
2
+ 'use strict'
3
+
4
+ exports.up = (knex) => {
5
+ return knex.schema.hasTable('fxQuoteError').then((exists) => {
6
+ if (!exists) {
7
+ return knex.schema.createTable('fxQuoteError', (t) => {
8
+ t.bigIncrements('fxQuoteErrorId').primary().notNullable()
9
+ t.string('conversionRequestId', 36).notNullable()
10
+ t.foreign('conversionRequestId').references('conversionRequestId').inTable('fxQuote')
11
+ t.bigInteger('fxQuoteResponseId').unsigned().defaultTo(null).nullable().comment('The response to the initial fxQuote')
12
+ t.foreign('fxQuoteResponseId').references('fxQuoteResponseId').inTable('fxQuoteResponse')
13
+ t.integer('errorCode').unsigned().notNullable()
14
+ t.string('errorDescription', 128).notNullable()
15
+ t.dateTime('createdDate').defaultTo(knex.fn.now()).notNullable()
16
+ })
17
+ }
18
+ })
19
+ }
20
+
21
+ exports.down = (knex) => {
22
+ return knex.schema.dropTableIfExists('quoteError')
23
+ }
@@ -0,0 +1,18 @@
1
+ // Notes: these changes are required for the quoting-service and are not used by central-ledger
2
+ 'use strict'
3
+
4
+ exports.up = (knex) => {
5
+ return knex.schema.hasTable('fxQuoteDuplicateCheck').then((exists) => {
6
+ if (!exists) {
7
+ return knex.schema.createTable('fxQuoteDuplicateCheck', (t) => {
8
+ t.string('conversionRequestId', 36).primary().notNullable()
9
+ t.string('hash', 1024).defaultTo(null).nullable().comment('hash value received for the quote request')
10
+ t.dateTime('createdDate').defaultTo(knex.fn.now()).notNullable().comment('System dateTime stamp pertaining to the inserted record')
11
+ })
12
+ }
13
+ })
14
+ }
15
+
16
+ exports.down = (knex) => {
17
+ return knex.schema.dropTableIfExists('fxQuoteDuplicateCheck')
18
+ }
@@ -0,0 +1,21 @@
1
+ // Notes: these changes are required for the quoting-service and are not used by central-ledger
2
+ 'use strict'
3
+
4
+ exports.up = (knex) => {
5
+ return knex.schema.hasTable('fxQuoteResponseDuplicateCheck').then((exists) => {
6
+ if (!exists) {
7
+ return knex.schema.createTable('fxQuoteResponseDuplicateCheck', (t) => {
8
+ t.bigIncrements('fxQuoteResponseId').primary().unsigned().comment('The response to the initial quote')
9
+ t.foreign('fxQuoteResponseId').references('fxQuoteResponseId').inTable('fxQuoteResponse')
10
+ t.string('conversionRequestId', 36).notNullable()
11
+ t.foreign('conversionRequestId').references('conversionRequestId').inTable('fxQuote')
12
+ t.string('hash', 255).defaultTo(null).nullable().comment('hash value received for the quote response')
13
+ t.dateTime('createdDate').defaultTo(knex.fn.now()).notNullable().comment('System dateTime stamp pertaining to the inserted record')
14
+ })
15
+ }
16
+ })
17
+ }
18
+
19
+ exports.down = (knex) => {
20
+ return knex.schema.dropTableIfExists('fxQuoteResponseDuplicateCheck')
21
+ }
@@ -0,0 +1,36 @@
1
+ 'use strict'
2
+
3
+ exports.up = (knex) => {
4
+ return knex.schema.hasTable('fxQuoteConversionTerms').then((exists) => {
5
+ if (!exists) {
6
+ return knex.schema.createTable('fxQuoteConversionTerms', (t) => {
7
+ t.string('conversionId').primary().notNullable()
8
+ t.string('determiningTransferId', 36).defaultTo(null).nullable()
9
+
10
+ // reference to the original fxQuote
11
+ t.string('conversionRequestId', 36).notNullable()
12
+ t.foreign('conversionRequestId').references('conversionRequestId').inTable('fxQuote')
13
+
14
+ t.integer('amountTypeId').unsigned().notNullable().comment('This is part of the transaction type that contains valid elements for - Amount Type')
15
+ t.foreign('amountTypeId').references('amountTypeId').inTable('amountType')
16
+ t.string('initiatingFsp', 255)
17
+ t.string('counterPartyFsp', 255)
18
+ t.decimal('sourceAmount', 18, 4).notNullable()
19
+ t.string('sourceCurrency', 3).notNullable()
20
+ t.foreign('sourceCurrency').references('currencyId').inTable('currency')
21
+ // Should only be nullable in POST /fxQuote request
22
+ t.decimal('targetAmount', 18, 4).defaultTo(null).nullable()
23
+ t.string('targetCurrency', 3).notNullable()
24
+ t.foreign('targetCurrency').references('currencyId').inTable('currency')
25
+
26
+ // time keeping
27
+ t.dateTime('expirationDate').notNullable()
28
+ t.dateTime('createdDate').defaultTo(knex.fn.now()).notNullable().comment('System dateTime stamp pertaining to the inserted record')
29
+ })
30
+ }
31
+ })
32
+ }
33
+
34
+ exports.down = (knex) => {
35
+ return knex.schema.dropTableIfExists('fxQuoteConversionTerms')
36
+ }
@@ -0,0 +1,21 @@
1
+ // Notes: these changes are required for the quoting-service and are not used by central-ledger
2
+ 'use strict'
3
+
4
+ exports.up = (knex) => {
5
+ return knex.schema.hasTable('fxQuoteConversionTermsExtension').then((exists) => {
6
+ if (!exists) {
7
+ return knex.schema.createTable('fxQuoteConversionTermsExtension', (t) => {
8
+ t.bigIncrements('fxQuoteConversionTermExtension').primary().notNullable()
9
+ t.string('conversionId', 36).notNullable()
10
+ t.foreign('conversionId').references('conversionId').inTable('fxQuoteConversionTerms')
11
+ t.string('key', 128).notNullable()
12
+ t.text('value').notNullable()
13
+ t.dateTime('createdDate').defaultTo(knex.fn.now()).notNullable().comment('System dateTime stamp pertaining to the inserted record')
14
+ })
15
+ }
16
+ })
17
+ }
18
+
19
+ exports.down = (knex) => {
20
+ return knex.schema.dropTableIfExists('fxQuoteConversionTermsExtension')
21
+ }
@@ -0,0 +1,39 @@
1
+ 'use strict'
2
+
3
+ exports.up = (knex) => {
4
+ return knex.schema.hasTable('fxQuoteResponseConversionTerms').then((exists) => {
5
+ if (!exists) {
6
+ return knex.schema.createTable('fxQuoteResponseConversionTerms', (t) => {
7
+ t.string('conversionId').primary().notNullable()
8
+ t.string('determiningTransferId', 36).defaultTo(null).nullable()
9
+
10
+ // reference to the original fxQuote
11
+ t.string('conversionRequestId', 36).notNullable()
12
+ t.foreign('conversionRequestId').references('conversionRequestId').inTable('fxQuote')
13
+
14
+ // reference to the original fxQuoteResponse
15
+ t.bigIncrements('fxQuoteResponseId', 36).notNullable()
16
+ t.foreign('fxQuoteResponseId').references('fxQuoteResponseId').inTable('fxQuoteResponse')
17
+
18
+ t.integer('amountTypeId').unsigned().notNullable().comment('This is part of the transaction type that contains valid elements for - Amount Type')
19
+ t.foreign('amountTypeId').references('amountTypeId').inTable('amountType')
20
+ t.string('initiatingFsp', 255)
21
+ t.string('counterPartyFsp', 255)
22
+ t.decimal('sourceAmount', 18, 4).notNullable()
23
+ t.string('sourceCurrency', 3).notNullable()
24
+ t.foreign('sourceCurrency').references('currencyId').inTable('currency')
25
+ t.decimal('targetAmount', 18, 4).notNullable()
26
+ t.string('targetCurrency', 3).notNullable()
27
+ t.foreign('targetCurrency').references('currencyId').inTable('currency')
28
+
29
+ // time keeping
30
+ t.dateTime('expirationDate').notNullable()
31
+ t.dateTime('createdDate').defaultTo(knex.fn.now()).notNullable().comment('System dateTime stamp pertaining to the inserted record')
32
+ })
33
+ }
34
+ })
35
+ }
36
+
37
+ exports.down = (knex) => {
38
+ return knex.schema.dropTableIfExists('fxQuoteResponseConversionTerms')
39
+ }
@@ -0,0 +1,21 @@
1
+ // Notes: these changes are required for the quoting-service and are not used by central-ledger
2
+ 'use strict'
3
+
4
+ exports.up = (knex) => {
5
+ return knex.schema.hasTable('fxQuoteResponseConversionTermsExtension').then((exists) => {
6
+ if (!exists) {
7
+ return knex.schema.createTable('fxQuoteResponseConversionTermsExtension', (t) => {
8
+ t.bigIncrements('fxQuoteResponseConversionTermsExtension').primary().notNullable()
9
+ t.string('conversionId', 36).notNullable()
10
+ t.foreign('conversionId').references('conversionId').inTable('fxQuoteResponseConversionTerms')
11
+ t.string('key', 128).notNullable()
12
+ t.text('value').notNullable()
13
+ t.dateTime('createdDate').defaultTo(knex.fn.now()).notNullable().comment('System dateTime stamp pertaining to the inserted record')
14
+ })
15
+ }
16
+ })
17
+ }
18
+
19
+ exports.down = (knex) => {
20
+ return knex.schema.dropTableIfExists('fxQuoteResponseConversionTermsExtension')
21
+ }
@@ -0,0 +1,27 @@
1
+ 'use strict'
2
+
3
+ exports.up = (knex) => {
4
+ return knex.schema.hasTable('fxCharge').then((exists) => {
5
+ if (!exists) {
6
+ return knex.schema.createTable('fxCharge', (t) => {
7
+ t.bigIncrements('fxChargeId').primary().notNullable()
8
+ t.string('chargeType', 32).notNullable().comment('A description of the charge which is being levied.')
9
+
10
+ // fxCharge should only be sent back in the response to an fxQuote
11
+ // so reference the terms in fxQuoteResponse `conversionTerms`
12
+ t.string('conversionId', 36).notNullable()
13
+ t.foreign('conversionId').references('conversionId').inTable('fxQuoteResponseConversionTerms')
14
+
15
+ t.decimal('sourceAmount', 18, 4).nullable().comment('The amount of the charge which is being levied, expressed in the source currency.')
16
+ t.string('sourceCurrency', 3).nullable().comment('The currency in which the source amount charge is being levied.')
17
+
18
+ t.decimal('targetAmount', 18, 4).nullable().comment('The amount of the charge which is being levied, expressed in the target currency.')
19
+ t.string('targetCurrency', 3).nullable().comment('The currency in which the target amount charge is being levied.')
20
+ })
21
+ }
22
+ })
23
+ }
24
+
25
+ exports.down = (knex) => {
26
+ return knex.schema.dropTableIfExists('fxCharge')
27
+ }
@@ -0,0 +1,47 @@
1
+ /*****
2
+ License
3
+ --------------
4
+ Copyright © 2017 Bill & Melinda Gates Foundation
5
+ The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+ Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
8
+
9
+ Contributors
10
+ --------------
11
+ This is the official list of the Mojaloop project contributors for this file.
12
+ Names of the original copyright holders (individuals or organizations)
13
+ should be listed with a '*' in the first column. People who have
14
+ contributed from an organization can be listed under the organization
15
+ that actually holds the copyright for their contributions (see the
16
+ Gates Foundation organization for an example). Those individuals should have
17
+ their names indented and be marked with a '-'. Email address can be added
18
+ optionally within square brackets <email>.
19
+ * Gates Foundation
20
+ - Name Surname <name.surname@gatesfoundation.com>
21
+
22
+ * Eugen Klymniuk <eugen.klymniuk@infitx.com>
23
+ --------------
24
+ **********/
25
+
26
+ exports.up = async (knex) => {
27
+ return knex.schema.hasTable('externalParticipant').then(function(exists) {
28
+ if (!exists) {
29
+ return knex.schema.createTable('externalParticipant', (t) => {
30
+ t.bigIncrements('externalParticipantId').primary().notNullable()
31
+ t.string('name', 30).notNullable()
32
+ t.unique('name')
33
+ t.dateTime('createdDate').defaultTo(knex.fn.now()).notNullable()
34
+ t.integer('proxyId').unsigned().notNullable()
35
+ t.foreign('proxyId').references('participantId').inTable('participant')
36
+ })
37
+ }
38
+ })
39
+ }
40
+
41
+ exports.down = function (knex) {
42
+ return knex.schema.hasTable('externalParticipant').then(function(exists) {
43
+ if (!exists) {
44
+ return knex.schema.dropTableIfExists('externalParticipant')
45
+ }
46
+ })
47
+ }
@@ -0,0 +1,50 @@
1
+ /*****
2
+ License
3
+ --------------
4
+ Copyright © 2017 Bill & Melinda Gates Foundation
5
+ The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+ Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
8
+
9
+ Contributors
10
+ --------------
11
+ This is the official list of the Mojaloop project contributors for this file.
12
+ Names of the original copyright holders (individuals or organizations)
13
+ should be listed with a '*' in the first column. People who have
14
+ contributed from an organization can be listed under the organization
15
+ that actually holds the copyright for their contributions (see the
16
+ Gates Foundation organization for an example). Those individuals should have
17
+ their names indented and be marked with a '-'. Email address can be added
18
+ optionally within square brackets <email>.
19
+ * Gates Foundation
20
+ - Name Surname <name.surname@gatesfoundation.com>
21
+
22
+ * Eugen Klymniuk <eugen.klymniuk@infitx.com>
23
+ --------------
24
+ **********/
25
+
26
+ const EP_ID_FIELD = 'externalParticipantId'
27
+
28
+ exports.up = async (knex) => {
29
+ return knex.schema.hasTable('transferParticipant').then(function(exists) {
30
+ if (exists) {
31
+ return knex.schema.alterTable('transferParticipant', (t) => {
32
+ t.bigint(EP_ID_FIELD).unsigned().nullable()
33
+ t.foreign(EP_ID_FIELD).references(EP_ID_FIELD).inTable('externalParticipant')
34
+ t.index(EP_ID_FIELD)
35
+ })
36
+ }
37
+ })
38
+ }
39
+
40
+ exports.down = async (knex) => {
41
+ return knex.schema.hasTable('transferParticipant').then(function(exists) {
42
+ if (exists) {
43
+ return knex.schema.alterTable('transferParticipant', (t) => {
44
+ t.dropIndex(EP_ID_FIELD)
45
+ t.dropForeign(EP_ID_FIELD)
46
+ t.dropColumn(EP_ID_FIELD)
47
+ })
48
+ }
49
+ })
50
+ }
@@ -0,0 +1,50 @@
1
+ /*****
2
+ License
3
+ --------------
4
+ Copyright © 2017 Bill & Melinda Gates Foundation
5
+ The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+ Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
8
+
9
+ Contributors
10
+ --------------
11
+ This is the official list of the Mojaloop project contributors for this file.
12
+ Names of the original copyright holders (individuals or organizations)
13
+ should be listed with a '*' in the first column. People who have
14
+ contributed from an organization can be listed under the organization
15
+ that actually holds the copyright for their contributions (see the
16
+ Gates Foundation organization for an example). Those individuals should have
17
+ their names indented and be marked with a '-'. Email address can be added
18
+ optionally within square brackets <email>.
19
+ * Gates Foundation
20
+ - Name Surname <name.surname@gatesfoundation.com>
21
+
22
+ * Eugen Klymniuk <eugen.klymniuk@infitx.com>
23
+ --------------
24
+ **********/
25
+
26
+ const EP_ID_FIELD = 'externalParticipantId'
27
+
28
+ exports.up = async (knex) => {
29
+ return knex.schema.hasTable('fxTransferParticipant').then((exists) => {
30
+ if (exists) {
31
+ return knex.schema.alterTable('fxTransferParticipant', (t) => {
32
+ t.bigint(EP_ID_FIELD).unsigned().nullable()
33
+ t.foreign(EP_ID_FIELD).references(EP_ID_FIELD).inTable('externalParticipant')
34
+ t.index(EP_ID_FIELD)
35
+ })
36
+ }
37
+ })
38
+ }
39
+
40
+ exports.down = async (knex) => {
41
+ return knex.schema.hasTable('fxTransferParticipant').then((exists) => {
42
+ if (exists) {
43
+ return knex.schema.alterTable('fxTransferParticipant', (t) => {
44
+ t.dropIndex(EP_ID_FIELD)
45
+ t.dropForeign(EP_ID_FIELD)
46
+ t.dropColumn(EP_ID_FIELD)
47
+ })
48
+ }
49
+ })
50
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mojaloop/central-ledger",
3
- "version": "17.7.8",
3
+ "version": "17.8.0-orb.1",
4
4
  "description": "Central ledger hosted by a scheme to record and settle transfers",
5
5
  "license": "Apache-2.0",
6
6
  "author": "ModusBox",
@@ -31,13 +31,15 @@
31
31
  "pre-commit": [
32
32
  "lint",
33
33
  "dep:check",
34
+ "audit:check",
34
35
  "test"
35
36
  ],
36
37
  "scripts": {
37
38
  "start": "npm run start:api",
38
39
  "start:api": "node src/api/index.js",
39
- "watch:api": "npx nodemon src/api/index.js",
40
40
  "start:handlers": "node src/handlers/index.js",
41
+ "start:debug": "npm start --node-options --inspect=0.0.0.0",
42
+ "watch:api": "npx nodemon src/api/index.js",
41
43
  "dev": "npm run docker:stop && docker-compose -f docker-compose.yml -f docker-compose.dev.yml up --build -d",
42
44
  "lint": "npx standard",
43
45
  "lint:fix": "npx standard --fix",
@@ -50,10 +52,10 @@
50
52
  "test:int": "npx tape 'test/integration/**/*.test.js' ",
51
53
  "test:int-override": "npx tape 'test/integration-override/**/*.test.js'",
52
54
  "test:int:spec": "npm run test:int | npx tap-spec",
53
- "test:xint": "npm run test:int | tap-xunit > ./test/results/xunit-integration.xml",
54
- "test:xint-override": "npm run test:int-override | tap-xunit > ./test/results/xunit-integration-override.xml",
55
- "test:integration": "sh ./test/scripts/test-integration.sh",
56
- "test:functional": "sh ./test/scripts/test-functional.sh",
55
+ "test:xint": "npm run test:int | tee /dev/tty | tap-xunit > ./test/results/xunit-integration.xml",
56
+ "test:xint-override": "npm run test:int-override | tee /dev/tty | tap-xunit > ./test/results/xunit-integration-override.xml",
57
+ "test:integration": "./test/scripts/test-integration.sh",
58
+ "test:functional": "./test/scripts/test-functional.sh",
57
59
  "migrate": "npm run migrate:latest && npm run seed:run",
58
60
  "migrate:latest": "npx knex $npm_package_config_knex migrate:latest",
59
61
  "migrate:create": "npx knex migrate:make $npm_package_config_knex",
@@ -61,7 +63,7 @@
61
63
  "migrate:current": "npx knex migrate:currentVersion $npm_package_config_knex",
62
64
  "seed:run": "npx knex seed:run $npm_package_config_knex",
63
65
  "docker:build": "docker build --build-arg NODE_VERSION=\"$(cat .nvmrc)-alpine\" -t mojaloop/central-ledger:local .",
64
- "docker:up": "docker-compose -f docker-compose.yml up",
66
+ "docker:up": ". ./docker/env.sh && docker-compose -f docker-compose.yml up -d",
65
67
  "docker:up:backend": "docker-compose up -d ml-api-adapter mysql mockserver kafka kowl temp_curl",
66
68
  "docker:up:int": "docker compose up -d kafka init-kafka objstore mysql",
67
69
  "docker:script:populateTestData": "sh ./test/util/scripts/populateTestData.sh",
@@ -79,25 +81,26 @@
79
81
  "wait-4-docker": "node ./scripts/_wait4_all.js"
80
82
  },
81
83
  "dependencies": {
84
+ "@hapi/basic": "7.0.2",
85
+ "@hapi/catbox-memory": "6.0.2",
82
86
  "@hapi/good": "9.0.1",
83
87
  "@hapi/hapi": "21.3.10",
84
- "@hapi/basic": "7.0.2",
85
88
  "@hapi/inert": "7.1.0",
86
89
  "@hapi/joi": "17.1.1",
87
90
  "@hapi/vision": "7.0.3",
88
- "@hapi/catbox-memory": "6.0.2",
89
- "@mojaloop/database-lib": "11.0.5",
90
91
  "@mojaloop/central-services-error-handling": "13.0.1",
91
92
  "@mojaloop/central-services-health": "15.0.0",
92
- "@mojaloop/central-services-logger": "11.3.1",
93
+ "@mojaloop/central-services-logger": "11.5.1",
93
94
  "@mojaloop/central-services-metrics": "12.0.8",
94
- "@mojaloop/central-services-shared": "18.3.8",
95
+ "@mojaloop/central-services-shared": "18.9.0",
95
96
  "@mojaloop/central-services-stream": "11.3.1",
97
+ "@mojaloop/database-lib": "11.0.6",
96
98
  "@mojaloop/event-sdk": "14.1.1",
99
+ "@mojaloop/inter-scheme-proxy-cache-lib": "2.3.0",
97
100
  "@mojaloop/ml-number": "11.2.4",
98
101
  "@mojaloop/object-store-lib": "12.0.3",
99
102
  "@now-ims/hapi-now-auth": "2.1.0",
100
- "ajv": "8.16.0",
103
+ "ajv": "8.17.1",
101
104
  "ajv-keywords": "5.1.0",
102
105
  "base64url": "3.0.1",
103
106
  "blipp": "4.0.2",
@@ -107,14 +110,16 @@
107
110
  "docdash": "2.0.2",
108
111
  "event-stream": "4.0.1",
109
112
  "five-bells-condition": "5.0.1",
110
- "glob": "10.4.1",
113
+ "glob": "10.4.3",
114
+ "hapi-auth-basic": "5.0.0",
111
115
  "hapi-auth-bearer-token": "8.0.0",
112
- "hapi-swagger": "17.2.1",
116
+ "hapi-swagger": "17.3.0",
113
117
  "ilp-packet": "2.2.0",
114
118
  "knex": "3.1.0",
115
119
  "lodash": "4.17.21",
116
120
  "moment": "2.30.1",
117
121
  "mongo-uri-builder": "^4.0.0",
122
+ "parse-strings-in-object": "2.0.0",
118
123
  "rc": "1.2.8",
119
124
  "require-glob": "^4.1.0"
120
125
  },
@@ -122,19 +127,21 @@
122
127
  "mysql": "2.18.1"
123
128
  },
124
129
  "devDependencies": {
130
+ "@types/mock-knex": "0.4.8",
125
131
  "async-retry": "1.3.3",
126
- "audit-ci": "^7.0.1",
132
+ "audit-ci": "^7.1.0",
127
133
  "get-port": "5.1.1",
128
134
  "jsdoc": "4.0.3",
129
135
  "jsonpath": "1.1.1",
130
- "nodemon": "3.1.3",
131
- "npm-check-updates": "16.14.20",
132
- "nyc": "17.0.0",
136
+ "mock-knex": "0.4.13",
137
+ "nodemon": "3.1.7",
138
+ "npm-check-updates": "17.1.3",
139
+ "nyc": "17.1.0",
133
140
  "pre-commit": "1.2.2",
134
141
  "proxyquire": "2.1.3",
135
142
  "replace": "^1.2.2",
136
143
  "sinon": "17.0.0",
137
- "standard": "17.1.0",
144
+ "standard": "17.1.2",
138
145
  "standard-version": "^9.5.0",
139
146
  "tap-spec": "^5.0.0",
140
147
  "tap-xunit": "2.4.1",
@@ -25,6 +25,8 @@
25
25
 
26
26
  'use strict'
27
27
 
28
+ const { FspEndpointTypes } = require('@mojaloop/central-services-shared').Enum.EndPoints
29
+
28
30
  const endpointTypes = [
29
31
  {
30
32
  name: 'ALARM_NOTIFICATION_URL',
@@ -46,6 +48,22 @@ const endpointTypes = [
46
48
  name: 'FSPIOP_CALLBACK_URL_TRANSFER_ERROR',
47
49
  description: 'Participant callback URL to which transfer error notifications can be sent'
48
50
  },
51
+ {
52
+ name: FspEndpointTypes.FSPIOP_CALLBACK_URL_FX_QUOTES,
53
+ description: 'Participant callback URL to which FX quote requests can be sent'
54
+ },
55
+ {
56
+ name: FspEndpointTypes.FSPIOP_CALLBACK_URL_FX_TRANSFER_POST,
57
+ description: 'Participant callback URL to which FX transfer post can be sent'
58
+ },
59
+ {
60
+ name: FspEndpointTypes.FSPIOP_CALLBACK_URL_FX_TRANSFER_PUT,
61
+ description: 'Participant callback URL to which FX transfer put can be sent'
62
+ },
63
+ {
64
+ name: FspEndpointTypes.FSPIOP_CALLBACK_URL_FX_TRANSFER_ERROR,
65
+ description: 'Participant callback URL to which FX transfer error notifications can be sent'
66
+ },
49
67
  {
50
68
  name: 'NET_DEBIT_CAP_THRESHOLD_BREACH_EMAIL',
51
69
  description: 'Participant/Hub operator email address to which the net debit cap breach e-mail notification can be sent'
@@ -0,0 +1,45 @@
1
+ /*****
2
+ License
3
+ --------------
4
+ Copyright © 2017 Bill & Melinda Gates Foundation
5
+ The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+ Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
8
+ Contributors
9
+ --------------
10
+ This is the official list of the Mojaloop project contributors for this file.
11
+ Names of the original copyright holders (individuals or organizations)
12
+ should be listed with a '*' in the first column. People who have
13
+ contributed from an organization can be listed under the organization
14
+ that actually holds the copyright for their contributions (see the
15
+ Gates Foundation organization for an example). Those individuals should have
16
+ their names indented and be marked with a '-'. Email address can be added
17
+ optionally within square brackets <email>.
18
+ * Gates Foundation
19
+ - Name Surname <name.surname@gatesfoundation.com>
20
+
21
+ * Vijay Kumar Guthi <vijaya.guthi@infitx.com>
22
+ --------------
23
+ ******/
24
+
25
+ 'use strict'
26
+
27
+ const fxParticipantCurrencyTypes = [
28
+ {
29
+ name: 'SOURCE',
30
+ description: 'The participant currency is the source of the currency conversion'
31
+ },
32
+ {
33
+ name: 'TARGET',
34
+ description: 'The participant currency is the target of the currency conversion'
35
+ }
36
+ ]
37
+
38
+ exports.seed = async function (knex) {
39
+ try {
40
+ return await knex('fxParticipantCurrencyType').insert(fxParticipantCurrencyTypes).onConflict('name').ignore()
41
+ } catch (err) {
42
+ console.log(`Uploading seeds for fxParticipantCurrencyType has failed with the following error: ${err}`)
43
+ return -1000
44
+ }
45
+ }
@@ -0,0 +1,45 @@
1
+ /*****
2
+ License
3
+ --------------
4
+ Copyright © 2017 Bill & Melinda Gates Foundation
5
+ The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+ Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
8
+ Contributors
9
+ --------------
10
+ This is the official list of the Mojaloop project contributors for this file.
11
+ Names of the original copyright holders (individuals or organizations)
12
+ should be listed with a '*' in the first column. People who have
13
+ contributed from an organization can be listed under the organization
14
+ that actually holds the copyright for their contributions (see the
15
+ Gates Foundation organization for an example). Those individuals should have
16
+ their names indented and be marked with a '-'. Email address can be added
17
+ optionally within square brackets <email>.
18
+ * Gates Foundation
19
+ - Name Surname <name.surname@gatesfoundation.com>
20
+
21
+ * Vijay Kumar Guthi <vijaya.guthi@infitx.com>
22
+ --------------
23
+ ******/
24
+
25
+ 'use strict'
26
+
27
+ const fxTransferTypes = [
28
+ {
29
+ name: 'PAYER_CONVERSION',
30
+ description: 'Payer side currency conversion'
31
+ },
32
+ {
33
+ name: 'PAYEE_CONVERSION',
34
+ description: 'Payee side currency conversion'
35
+ }
36
+ ]
37
+
38
+ exports.seed = async function (knex) {
39
+ try {
40
+ return await knex('fxTransferType').insert(fxTransferTypes).onConflict('name').ignore()
41
+ } catch (err) {
42
+ console.log(`Uploading seeds for fxTransferType has failed with the following error: ${err}`)
43
+ return -1000
44
+ }
45
+ }