@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.
- package/.ncurc.yaml +3 -1
- package/.nvmrc +1 -1
- package/.nycrc.yml +16 -1
- package/Dockerfile +9 -10
- package/README.md +39 -9
- package/audit-ci.jsonc +15 -2
- package/config/default.json +17 -1
- package/docker/central-ledger/default.json +9 -0
- package/docker/config-modifier/configs/central-ledger.js +25 -0
- package/docker/env.sh +15 -0
- package/docker/kafka/scripts/provision.sh +4 -1
- package/docker/ml-api-adapter/default.json +4 -1
- package/docker-compose.yml +90 -2
- package/documentation/db/erd-transfer-timeout.png +0 -0
- package/documentation/db/erd-transfer-timeout.txt +81 -0
- package/documentation/fx-implementation/README.md +48 -0
- package/documentation/fx-implementation/assets/fx-position-movements.drawio.svg +4 -0
- package/documentation/fx-implementation/assets/test-scenario.drawio.svg +4 -0
- package/documentation/sequence-diagrams/Handler - FX timeout.plantuml +123 -0
- package/documentation/sequence-diagrams/Handler - FX timeout.png +0 -0
- package/documentation/sequence-diagrams/Handler - timeout.plantuml +81 -0
- package/documentation/sequence-diagrams/Handler - timeout.png +0 -0
- package/documentation/state-diagrams/transfer-ML-spec-states-diagram.png +0 -0
- package/documentation/state-diagrams/transfer-internal-states-diagram.png +0 -0
- package/documentation/state-diagrams/transfer-internal-states.plantuml +75 -0
- package/documentation/state-diagrams/transfer-states.plantuml +13 -0
- package/migrations/310204_transferParticipant-participantId.js +52 -0
- package/migrations/310403_participantPositionChange-participantCurrencyId.js +47 -0
- package/migrations/310404_participantPositionChange-change.js +46 -0
- package/migrations/600010_fxTransferType.js +43 -0
- package/migrations/600011_fxTransferType-indexes.js +38 -0
- package/migrations/600012_fxParticipantCurrencyType.js +43 -0
- package/migrations/600013_fxParticipantCurrencyType-indexes.js +38 -0
- package/migrations/600100_fxTransferDuplicateCheck.js +42 -0
- package/migrations/600110_fxTransferErrorDuplicateCheck.js.js +17 -0
- package/migrations/600200_fxTransfer.js +51 -0
- package/migrations/600201_fxTransfer-indexes.js +40 -0
- package/migrations/600400_fxTransferStateChange.js +46 -0
- package/migrations/600401_fxTransferStateChange-indexes.js +40 -0
- package/migrations/600501_fxWatchList.js +46 -0
- package/migrations/600502_fxWatchList-indexes.js +40 -0
- package/migrations/600600_fxTransferFulfilmentDuplicateCheck.js +43 -0
- package/migrations/600601_fxTransferFulfilmentDuplicateCheck-indexes.js +38 -0
- package/migrations/600700_fxTransferFulfilment.js +47 -0
- package/migrations/600701_fxTransferFulfilment-indexes.js +43 -0
- package/migrations/600800_fxTransferExtension.js +47 -0
- package/migrations/601400_fxTransferTimeout.js +43 -0
- package/migrations/601401_fxTransferTimeout-indexes.js +37 -0
- package/migrations/601500_fxTransferError.js +44 -0
- package/migrations/601501_fxTransferError-indexes.js +37 -0
- package/migrations/610200_fxTransferParticipant.js +52 -0
- package/migrations/610201_fxTransferParticipant-indexes.js +44 -0
- package/migrations/610202_fxTransferParticipant-participantId.js +52 -0
- package/migrations/610403_participantPositionChange-fxTransfer.js +46 -0
- package/migrations/910101_feature904DataMigration.js +46 -52
- package/migrations/910102_feature949DataMigration.js +219 -225
- package/migrations/950104_settlementModel-settlementAccountTypeId.js +15 -20
- package/migrations/950108_participantProxy.js +18 -0
- package/migrations/950109_fxQuote.js +19 -0
- package/migrations/950110_fxQuoteResponse.js +25 -0
- package/migrations/950111_fxQuoteError.js +23 -0
- package/migrations/950113_fxQuoteDuplicateCheck.js +18 -0
- package/migrations/950114_fxQuoteResponseDuplicateCheck.js +21 -0
- package/migrations/950115_fxQuoteConversionTerms.js +36 -0
- package/migrations/950116_fxQuoteConversionTermsExtension.js +21 -0
- package/migrations/950117_fxQuoteResponseConversionTerms.js +39 -0
- package/migrations/950118_fxQuoteResponseConversionTermsExtension.js +21 -0
- package/migrations/950119_fxCharge.js +27 -0
- package/migrations/960100_create_externalParticipant.js +47 -0
- package/migrations/960110_alter_transferParticipant__addFiled_externalParticipantId.js +50 -0
- package/migrations/960111_alter_fxTransferParticipant__addFiled_externalParticipantId.js +50 -0
- package/package.json +27 -20
- package/seeds/endpointType.js +18 -0
- package/seeds/fxParticipantCurrencyType.js +45 -0
- package/seeds/fxTransferType.js +45 -0
- package/seeds/participant.js +2 -1
- package/seeds/transferParticipantRoleType.js +9 -0
- package/seeds/transferState.js +10 -0
- package/src/api/interface/swagger.json +23 -30
- package/src/api/participants/handler.js +6 -2
- package/src/api/participants/routes.js +8 -7
- package/src/api/root/handler.js +15 -5
- package/src/domain/fx/cyril.js +466 -0
- package/src/domain/fx/index.js +107 -0
- package/src/domain/participant/index.js +108 -1
- package/src/domain/position/abort.js +215 -0
- package/src/domain/position/binProcessor.js +361 -99
- package/src/domain/position/fulfil.js +252 -111
- package/src/domain/position/fx-fulfil.js +138 -0
- package/src/domain/position/fx-prepare.js +280 -0
- package/src/domain/position/fx-timeout-reserved.js +159 -0
- package/src/domain/position/index.js +1 -0
- package/src/domain/position/prepare.js +69 -49
- package/src/domain/position/timeout-reserved.js +162 -0
- package/src/domain/timeout/index.js +26 -2
- package/src/domain/transfer/index.js +22 -5
- package/src/domain/transfer/transform.js +19 -6
- package/src/handlers/admin/handler.js +0 -2
- package/src/handlers/bulk/fulfil/handler.js +5 -5
- package/src/handlers/bulk/get/handler.js +5 -5
- package/src/handlers/bulk/prepare/handler.js +9 -9
- package/src/handlers/bulk/processing/handler.js +8 -7
- package/src/handlers/bulk/shared/validator.js +1 -1
- package/src/handlers/positions/handler.js +23 -10
- package/src/handlers/positions/handlerBatch.js +54 -26
- package/src/handlers/register.js +2 -1
- package/src/handlers/timeouts/handler.js +212 -68
- package/src/handlers/transfers/FxFulfilService.js +387 -0
- package/src/handlers/transfers/createRemittanceEntity.js +106 -0
- package/src/handlers/transfers/dto.js +53 -0
- package/src/handlers/transfers/handler.js +609 -571
- package/src/handlers/transfers/prepare.js +572 -0
- package/src/handlers/transfers/validator.js +75 -14
- package/src/lib/cache.js +1 -1
- package/src/lib/config.js +6 -3
- package/src/lib/healthCheck/subServiceHealth.js +12 -2
- package/src/lib/proxyCache.js +131 -0
- package/src/models/bulkTransfer/facade.js +58 -82
- package/src/models/fxTransfer/duplicateCheck.js +153 -0
- package/src/models/fxTransfer/fxTransfer.js +578 -0
- package/src/models/fxTransfer/fxTransferError.js +53 -0
- package/src/models/fxTransfer/fxTransferExtension.js +41 -0
- package/src/models/fxTransfer/fxTransferTimeout.js +68 -0
- package/src/models/fxTransfer/index.js +15 -0
- package/src/models/fxTransfer/stateChange.js +47 -0
- package/src/models/fxTransfer/watchList.js +49 -0
- package/src/models/ledgerAccountType/ledgerAccountType.js +8 -32
- package/src/models/misc/segment.js +0 -1
- package/src/models/participant/externalParticipant.js +96 -0
- package/src/models/participant/externalParticipantCached.js +148 -0
- package/src/models/participant/facade.js +192 -123
- package/src/models/participant/participant.js +2 -1
- package/src/models/participant/participantCurrency.js +1 -1
- package/src/models/participant/participantPosition.js +2 -8
- package/src/models/position/batch.js +90 -1
- package/src/models/position/facade.js +5 -5
- package/src/models/position/participantPositionChanges.js +68 -0
- package/src/models/settlement/settlementModel.js +5 -23
- package/src/models/transfer/facade.js +806 -447
- package/src/shared/constants.js +52 -0
- package/src/shared/fspiopErrorFactory.js +131 -0
- package/src/shared/logger/index.js +8 -0
- package/src/shared/loggingPlugin.js +43 -0
- package/src/shared/plugins.js +6 -0
- package/src/shared/setup.js +10 -0
- package/test-integration.Dockerfile +1 -1
- package/test.Dockerfile +1 -1
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
* ModusBox
|
|
22
|
+
- Vijay Kumar Guthi <vijaya.guthi@infitx.com>
|
|
23
|
+
--------------
|
|
24
|
+
******/
|
|
25
|
+
|
|
26
|
+
'use strict'
|
|
27
|
+
|
|
28
|
+
exports.up = function (knex) {
|
|
29
|
+
return knex.schema.table('fxTransferFulfilment', (t) => {
|
|
30
|
+
t.index('commitRequestId')
|
|
31
|
+
t.index('settlementWindowId')
|
|
32
|
+
// TODO: Need to check if this is required
|
|
33
|
+
t.unique(['commitRequestId', 'ilpFulfilment'])
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
exports.down = function (knex) {
|
|
38
|
+
return knex.schema.table('fxTransferFulfilment', (t) => {
|
|
39
|
+
t.dropIndex('transferId')
|
|
40
|
+
t.dropIndex('settlementWindowId')
|
|
41
|
+
t.unique(['transferId', 'ilpFulfilment'])
|
|
42
|
+
})
|
|
43
|
+
}
|
|
@@ -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
|
+
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
|
+
* Infitx
|
|
22
|
+
- Kalin Krustev <kalin.krustev@infitx.com>
|
|
23
|
+
--------------
|
|
24
|
+
******/
|
|
25
|
+
|
|
26
|
+
'use strict'
|
|
27
|
+
|
|
28
|
+
exports.up = async (knex) => {
|
|
29
|
+
return await knex.schema.hasTable('fxTransferExtension').then(function(exists) {
|
|
30
|
+
if (!exists) {
|
|
31
|
+
return knex.schema.createTable('fxTransferExtension', (t) => {
|
|
32
|
+
t.bigIncrements('fxTransferExtensionId').primary().notNullable()
|
|
33
|
+
t.string('commitRequestId', 36).notNullable()
|
|
34
|
+
t.foreign('commitRequestId').references('commitRequestId').inTable('fxTransfer')
|
|
35
|
+
t.boolean('isFulfilment').defaultTo(false).notNullable()
|
|
36
|
+
t.boolean('isError').defaultTo(false).notNullable()
|
|
37
|
+
t.string('key', 128).notNullable()
|
|
38
|
+
t.text('value').notNullable()
|
|
39
|
+
t.dateTime('createdDate').defaultTo(knex.fn.now()).notNullable()
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
exports.down = function (knex) {
|
|
46
|
+
return knex.schema.dropTableIfExists('fxTransferExtension')
|
|
47
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
- Eugen Klymniuk <eugen.klymniuk@infitx.com>
|
|
22
|
+
--------------
|
|
23
|
+
******/
|
|
24
|
+
|
|
25
|
+
'use strict'
|
|
26
|
+
|
|
27
|
+
exports.up = async (knex) => {
|
|
28
|
+
return await knex.schema.hasTable('fxTransferTimeout').then(function(exists) {
|
|
29
|
+
if (!exists) {
|
|
30
|
+
return knex.schema.createTable('fxTransferTimeout', (t) => {
|
|
31
|
+
t.bigIncrements('fxTransferTimeoutId').primary().notNullable()
|
|
32
|
+
t.string('commitRequestId', 36).notNullable()
|
|
33
|
+
t.foreign('commitRequestId').references('commitRequestId').inTable('fxTransfer')
|
|
34
|
+
t.dateTime('expirationDate').notNullable()
|
|
35
|
+
t.dateTime('createdDate').defaultTo(knex.fn.now()).notNullable()
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
exports.down = function (knex) {
|
|
42
|
+
return knex.schema.dropTableIfExists('fxTransferTimeout')
|
|
43
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
- Eugen Klymniuk <eugen.klymniuk@infitx.com>
|
|
22
|
+
--------------
|
|
23
|
+
******/
|
|
24
|
+
|
|
25
|
+
'use strict'
|
|
26
|
+
|
|
27
|
+
exports.up = function (knex) {
|
|
28
|
+
return knex.schema.table('fxTransferTimeout', (t) => {
|
|
29
|
+
t.unique('commitRequestId')
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
exports.down = function (knex) {
|
|
34
|
+
return knex.schema.table('fxTransferTimeout', (t) => {
|
|
35
|
+
t.dropUnique('commitRequestId')
|
|
36
|
+
})
|
|
37
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
- Eugen Klymniuk <eugen.klymniuk@infitx.com>
|
|
22
|
+
--------------
|
|
23
|
+
******/
|
|
24
|
+
|
|
25
|
+
'use strict'
|
|
26
|
+
|
|
27
|
+
exports.up = async (knex) => {
|
|
28
|
+
return await knex.schema.hasTable('fxTransferError').then(function(exists) {
|
|
29
|
+
if (!exists) {
|
|
30
|
+
return knex.schema.createTable('fxTransferError', (t) => {
|
|
31
|
+
t.string('commitRequestId', 36).primary().notNullable()
|
|
32
|
+
t.bigInteger('fxTransferStateChangeId').unsigned().notNullable()
|
|
33
|
+
t.foreign('fxTransferStateChangeId').references('fxTransferStateChangeId').inTable('fxTransferStateChange')
|
|
34
|
+
t.integer('errorCode').unsigned().notNullable()
|
|
35
|
+
t.string('errorDescription', 128).notNullable()
|
|
36
|
+
t.dateTime('createdDate').defaultTo(knex.fn.now()).notNullable()
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
exports.down = function (knex) {
|
|
43
|
+
return knex.schema.dropTableIfExists('fxTransferError')
|
|
44
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
- Eugen Klymniuk <eugen.klymniuk@infitx.com>
|
|
22
|
+
--------------
|
|
23
|
+
******/
|
|
24
|
+
|
|
25
|
+
'use strict'
|
|
26
|
+
|
|
27
|
+
exports.up = function (knex) {
|
|
28
|
+
return knex.schema.table('fxTransferError', (t) => {
|
|
29
|
+
t.index('fxTransferStateChangeId')
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
exports.down = function (knex) {
|
|
34
|
+
return knex.schema.table('fxTransferError', (t) => {
|
|
35
|
+
t.dropIndex('fxTransferStateChangeId')
|
|
36
|
+
})
|
|
37
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
* INFITX
|
|
22
|
+
- Vijay Kumar Guthi <vijaya.guthi@infitx.com>
|
|
23
|
+
--------------
|
|
24
|
+
******/
|
|
25
|
+
|
|
26
|
+
'use strict'
|
|
27
|
+
|
|
28
|
+
exports.up = async (knex) => {
|
|
29
|
+
return await knex.schema.hasTable('fxTransferParticipant').then(function(exists) {
|
|
30
|
+
if (!exists) {
|
|
31
|
+
return knex.schema.createTable('fxTransferParticipant', (t) => {
|
|
32
|
+
t.bigIncrements('fxTransferParticipantId').primary().notNullable()
|
|
33
|
+
t.string('commitRequestId', 36).notNullable()
|
|
34
|
+
t.foreign('commitRequestId').references('commitRequestId').inTable('fxTransfer')
|
|
35
|
+
t.integer('participantCurrencyId').unsigned().notNullable()
|
|
36
|
+
t.foreign('participantCurrencyId').references('participantCurrencyId').inTable('participantCurrency')
|
|
37
|
+
t.integer('transferParticipantRoleTypeId').unsigned().notNullable()
|
|
38
|
+
t.foreign('transferParticipantRoleTypeId').references('transferParticipantRoleTypeId').inTable('transferParticipantRoleType')
|
|
39
|
+
t.integer('ledgerEntryTypeId').unsigned().notNullable()
|
|
40
|
+
t.foreign('ledgerEntryTypeId').references('ledgerEntryTypeId').inTable('ledgerEntryType')
|
|
41
|
+
t.integer('fxParticipantCurrencyTypeId').unsigned()
|
|
42
|
+
t.foreign('fxParticipantCurrencyTypeId').references('fxParticipantCurrencyTypeId').inTable('fxParticipantCurrencyType')
|
|
43
|
+
t.decimal('amount', 18, 4).notNullable()
|
|
44
|
+
t.dateTime('createdDate').defaultTo(knex.fn.now()).notNullable()
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
exports.down = function (knex) {
|
|
51
|
+
return knex.schema.dropTableIfExists('fxTransferParticipant')
|
|
52
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
* INFITX
|
|
22
|
+
- Vijay Kumar Guthi <vijaya.guthi@infitx.com>
|
|
23
|
+
--------------
|
|
24
|
+
******/
|
|
25
|
+
|
|
26
|
+
'use strict'
|
|
27
|
+
|
|
28
|
+
exports.up = function (knex) {
|
|
29
|
+
return knex.schema.table('fxTransferParticipant', (t) => {
|
|
30
|
+
t.index('commitRequestId')
|
|
31
|
+
t.index('participantCurrencyId')
|
|
32
|
+
t.index('transferParticipantRoleTypeId')
|
|
33
|
+
t.index('ledgerEntryTypeId')
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
exports.down = function (knex) {
|
|
38
|
+
return knex.schema.table('fxTransferParticipant', (t) => {
|
|
39
|
+
t.dropIndex('commitRequestId')
|
|
40
|
+
t.dropIndex('participantCurrencyId')
|
|
41
|
+
t.dropIndex('transferParticipantRoleTypeId')
|
|
42
|
+
t.dropIndex('ledgerEntryTypeId')
|
|
43
|
+
})
|
|
44
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
* INFITX
|
|
22
|
+
- Vijay Kumar Guthi <vijaya.guthi@infitx.com>
|
|
23
|
+
--------------
|
|
24
|
+
******/
|
|
25
|
+
|
|
26
|
+
'use strict'
|
|
27
|
+
|
|
28
|
+
exports.up = async (knex) => {
|
|
29
|
+
return await knex.schema.hasTable('fxTransferParticipant').then(function(exists) {
|
|
30
|
+
if (exists) {
|
|
31
|
+
return knex.schema.alterTable('fxTransferParticipant', (t) => {
|
|
32
|
+
t.integer('participantId').unsigned().notNullable()
|
|
33
|
+
// Disabling this as its throwing error while running the migration with existing data in the table
|
|
34
|
+
// t.foreign('participantId').references('participantId').inTable('participant')
|
|
35
|
+
t.index('participantId')
|
|
36
|
+
t.integer('participantCurrencyId').unsigned().nullable().alter()
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
exports.down = async (knex) => {
|
|
43
|
+
return await knex.schema.hasTable('fxTransferParticipant').then(function(exists) {
|
|
44
|
+
if (exists) {
|
|
45
|
+
return knex.schema.alterTable('fxTransferParticipant', (t) => {
|
|
46
|
+
t.dropIndex('participantId')
|
|
47
|
+
t.dropColumn('participantId')
|
|
48
|
+
t.integer('participantCurrencyId').unsigned().notNullable().alter()
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
* INFITX
|
|
22
|
+
- Vijay Kumar Guthi <vijaya.guthi@infitx.com>
|
|
23
|
+
--------------
|
|
24
|
+
******/
|
|
25
|
+
|
|
26
|
+
'use strict'
|
|
27
|
+
|
|
28
|
+
exports.up = async (knex) => {
|
|
29
|
+
return await knex.schema.hasTable('participantPositionChange').then(function(exists) {
|
|
30
|
+
if (exists) {
|
|
31
|
+
return knex.schema.alterTable('participantPositionChange', (t) => {
|
|
32
|
+
t.bigInteger('transferStateChangeId').unsigned().defaultTo(null).alter()
|
|
33
|
+
t.bigInteger('fxTransferStateChangeId').unsigned().defaultTo(null)
|
|
34
|
+
t.foreign('fxTransferStateChangeId').references('fxTransferStateChangeId').inTable('fxTransferStateChange')
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
exports.down = function (knex) {
|
|
41
|
+
return knex.schema.alterTable('participantPositionChange', (t) => {
|
|
42
|
+
t.dropForeign('fxTransferStateChangeId')
|
|
43
|
+
t.dropColumn('fxTransferStateChangeId')
|
|
44
|
+
t.bigInteger('transferStateChangeId').unsigned().notNullable().alter()
|
|
45
|
+
})
|
|
46
|
+
}
|
|
@@ -44,62 +44,56 @@ const tableNameSuffix = Time.getYMDString(new Date())
|
|
|
44
44
|
*/
|
|
45
45
|
const migrateData = async (knex) => {
|
|
46
46
|
return knex.transaction(async trx => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
select transferFulfilmentId
|
|
67
|
-
from (
|
|
68
|
-
select transferFulfilmentId, transferId, ilpFulfilment, completedDate, isValid, settlementWindowId, createdDate,
|
|
69
|
-
row_number() over(partition by transferId order by isValid desc, createdDate) rowNumber
|
|
70
|
-
from transferFulfilment${tableNameSuffix}) t
|
|
71
|
-
where t.rowNumber = 1)`)
|
|
72
|
-
}
|
|
73
|
-
exists = await knex.schema.hasTable(`transferFulfilment${tableNameSuffix}`)
|
|
74
|
-
if (exists) {
|
|
75
|
-
await knex.transacting(trx).raw(`
|
|
76
|
-
insert into transferFulfilment (transferId, ilpFulfilment, completedDate, isValid, settlementWindowId, createdDate)
|
|
77
|
-
select t.transferId, t.ilpFulfilment, t.completedDate, t.isValid, t.settlementWindowId, t.createdDate
|
|
47
|
+
let exists = false
|
|
48
|
+
exists = await knex.schema.hasTable(`transferExtension${tableNameSuffix}`)
|
|
49
|
+
if (exists) {
|
|
50
|
+
await knex.transacting(trx).raw(`
|
|
51
|
+
insert into transferExtension (transferExtensionId, transferId, \`key\`, \`value\`, isFulfilment, isError, createdDate)
|
|
52
|
+
select te.transferExtensionId, te.transferId, te.\`key\`, te.\`value\`,
|
|
53
|
+
case when te.transferFulfilmentId is null then 0 else 1 end,
|
|
54
|
+
case when te.transferErrorId is null then 0 else 1 end,
|
|
55
|
+
te.createdDate
|
|
56
|
+
from transferExtension${tableNameSuffix} as te`)
|
|
57
|
+
}
|
|
58
|
+
exists = await knex.schema.hasTable(`transferFulfilmentDuplicateCheck${tableNameSuffix}`) &&
|
|
59
|
+
await knex.schema.hasTable(`transferFulfilment${tableNameSuffix}`)
|
|
60
|
+
if (exists) {
|
|
61
|
+
await knex.transacting(trx).raw(`
|
|
62
|
+
insert into transferFulfilmentDuplicateCheck (transferId, \`hash\`, createdDate)
|
|
63
|
+
select transferId, \`hash\`, createdDate from transferFulfilmentDuplicateCheck${tableNameSuffix}
|
|
64
|
+
where transferFulfilmentId in(
|
|
65
|
+
select transferFulfilmentId
|
|
78
66
|
from (
|
|
79
67
|
select transferFulfilmentId, transferId, ilpFulfilment, completedDate, isValid, settlementWindowId, createdDate,
|
|
80
68
|
row_number() over(partition by transferId order by isValid desc, createdDate) rowNumber
|
|
81
69
|
from transferFulfilment${tableNameSuffix}) t
|
|
82
|
-
where t.rowNumber = 1`)
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
70
|
+
where t.rowNumber = 1)`)
|
|
71
|
+
}
|
|
72
|
+
exists = await knex.schema.hasTable(`transferFulfilment${tableNameSuffix}`)
|
|
73
|
+
if (exists) {
|
|
74
|
+
await knex.transacting(trx).raw(`
|
|
75
|
+
insert into transferFulfilment (transferId, ilpFulfilment, completedDate, isValid, settlementWindowId, createdDate)
|
|
76
|
+
select t.transferId, t.ilpFulfilment, t.completedDate, t.isValid, t.settlementWindowId, t.createdDate
|
|
77
|
+
from (
|
|
78
|
+
select transferFulfilmentId, transferId, ilpFulfilment, completedDate, isValid, settlementWindowId, createdDate,
|
|
79
|
+
row_number() over(partition by transferId order by isValid desc, createdDate) rowNumber
|
|
80
|
+
from transferFulfilment${tableNameSuffix}) t
|
|
81
|
+
where t.rowNumber = 1`)
|
|
82
|
+
}
|
|
83
|
+
exists = await knex.schema.hasTable(`transferErrorDuplicateCheck${tableNameSuffix}`)
|
|
84
|
+
if (exists) {
|
|
85
|
+
await knex.transacting(trx).raw(`
|
|
86
|
+
insert into transferErrorDuplicateCheck (transferId, \`hash\`, createdDate)
|
|
87
|
+
select transferId, \`hash\`, createdDate
|
|
88
|
+
from transferErrorDuplicateCheck${tableNameSuffix}`)
|
|
89
|
+
}
|
|
90
|
+
exists = await knex.schema.hasTable(`transferError${tableNameSuffix}`)
|
|
91
|
+
if (exists) {
|
|
92
|
+
await knex.transacting(trx).raw(`
|
|
93
|
+
insert into transferError (transferId, transferStateChangeId, errorCode, errorDescription, createdDate)
|
|
94
|
+
select tsc.transferId, te.transferStateChangeId, te.errorCode, te.errorDescription, te.createdDate
|
|
95
|
+
from transferError${tableNameSuffix} te
|
|
96
|
+
join transferStateChange tsc on tsc.transferStateChangeId = te.transferStateChangeId`)
|
|
103
97
|
}
|
|
104
98
|
})
|
|
105
99
|
}
|