@mojaloop/central-ledger 19.14.0 → 20.1.0
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/.grype.yaml +3 -0
- package/.license-scanner.json +16 -0
- package/.ncurc.yaml +19 -13
- package/.nvmrc +1 -1
- package/.nycrc.yml +14 -2
- package/CHANGELOG.md +51 -0
- package/Dockerfile +13 -10
- package/README.md +39 -89
- package/audit-ci.jsonc +1 -1
- package/config/default.json +60 -3
- package/config/deprecated.default-settlement.json +160 -0
- package/docker/ml-api-adapter/default.json +28 -0
- package/docker-compose.yml +6 -0
- package/nodemon.json +6 -0
- package/package.json +128 -64
- package/{sbom-v19.13.2.csv → sbom-v20.0.0.csv} +886 -736
- package/scripts/_wait4_all.js +5 -5
- package/scripts/transferSettlementTemp/interchangeFeeCalculation.js +51 -0
- package/src/api/index.ts +30 -0
- package/src/api/interface/swagger.json +2249 -2054
- package/src/api/participants/routes.js +1 -1
- package/src/api/root/handler.int.ts +55 -0
- package/src/api/routes.js +7 -6
- package/src/api/server.ts +27 -0
- package/src/api/server.unit.ts +16 -0
- package/src/api/settlementModels/routes.js +4 -4
- package/src/domain/participant/index.d.ts +47 -0
- package/src/domain/participant/index.int.ts +724 -0
- package/src/domain/participant/index.js +4 -5
- package/src/domain/position/fx-prepare.js +1 -1
- package/src/domain/position/fx-timeout-reserved.js +6 -0
- package/src/domain/position/prepare.js +1 -1
- package/src/handlers/admin/handler.js +1 -1
- package/src/handlers/index.js +30 -0
- package/src/handlers/positions/handler.js +0 -2
- package/src/handlers/positions/handlerBatch.js +5 -5
- package/src/handlers/register.js +44 -29
- package/src/handlers/timeouts/handler.js +1 -4
- package/src/handlers/transfers/fx-abort.int.ts +209 -0
- package/src/handlers/transfers/fx-handlers.int.ts +275 -0
- package/src/handlers/transfers/fx-timeout.int.ts +284 -0
- package/src/handlers/transfers/handler.js +1 -3
- package/src/handlers/transfers/handlers.int.ts +538 -0
- package/src/handlers/transfers/prepare.int.ts +1283 -0
- package/src/handlers/transfers/prepare.js +2 -2
- package/src/knexfile.js +19 -0
- package/src/lib/cache.js +1 -1
- package/src/lib/config/index.ts +60 -0
- package/src/lib/config/resolver.ts +231 -0
- package/src/lib/config/resolver.unit.ts +72 -0
- package/src/lib/config/types.ts +372 -0
- package/src/lib/config/util.ts +523 -0
- package/src/lib/config/util.unit.ts +825 -0
- package/src/lib/migrator.js +3 -3
- package/src/lib/proxyCache.js +3 -3
- package/{migrations → src/migrations}/100100_event.js +1 -1
- package/{migrations → src/migrations}/110100_contactType.js +1 -1
- package/{migrations → src/migrations}/110200_currency.js +1 -1
- package/{migrations → src/migrations}/110201_currency-scale.js +1 -1
- package/{migrations → src/migrations}/110300_endpointType.js +1 -1
- package/{migrations → src/migrations}/110400_ledgerEntryType.js +1 -1
- package/{migrations → src/migrations}/110450_ledgerAccountType.js +1 -1
- package/{migrations → src/migrations}/110500_participantLimitType.js +1 -1
- package/{migrations → src/migrations}/110600_transferParticipantRoleType.js +1 -1
- package/{migrations → src/migrations}/110700_transferState.js +1 -1
- package/{migrations → src/migrations}/110900_settlementState.js +1 -1
- package/{migrations → src/migrations}/112000_bulkTransferState.js +1 -1
- package/{migrations → src/migrations}/112100_bulkProcessingState.js +1 -1
- package/{migrations → src/migrations}/200100_participant.js +1 -1
- package/{migrations → src/migrations}/200200_participantContact.js +1 -1
- package/{migrations → src/migrations}/200300_participantEndpoint.js +1 -1
- package/{migrations → src/migrations}/200400_participantParty.js +1 -1
- package/{migrations → src/migrations}/200600_token.js +1 -1
- package/{migrations → src/migrations}/200601_token-indexes.js +1 -1
- package/{migrations → src/migrations}/300100_transferDuplicateCheck.js +2 -2
- package/{migrations → src/migrations}/300150_bulkTransferDuplicateCheck.js +2 -2
- package/{migrations → src/migrations}/300200_transfer.js +2 -2
- package/{migrations → src/migrations}/300202_transfer-decimal184.js +1 -1
- package/{migrations → src/migrations}/300250_bulkTransfer.js +2 -3
- package/{migrations → src/migrations}/300275_bulkTransferAssociation.js +2 -3
- package/{migrations → src/migrations}/300300_ilpPacket.js +1 -1
- package/{migrations → src/migrations}/300400_transferStateChange.js +1 -1
- package/{migrations → src/migrations}/300450_bulkTransferStateChange.js +1 -1
- package/{migrations → src/migrations}/300500_segment.js +1 -1
- package/{migrations → src/migrations}/310100_participantCurrency.js +1 -1
- package/{migrations → src/migrations}/310200_transferParticipant.js +1 -1
- package/{migrations → src/migrations}/310202_transferParticipant-decimal184.js +1 -1
- package/{migrations → src/migrations}/310204_transferParticipant-participantId.js +2 -2
- package/{migrations → src/migrations}/310300_participantPosition.js +1 -1
- package/{migrations → src/migrations}/310302_participantPosition-decimal184.js +1 -1
- package/{migrations → src/migrations}/310400_participantPositionChange.js +1 -1
- package/{migrations → src/migrations}/310402_participantPositionChange-decimal184.js +1 -1
- package/{migrations → src/migrations}/310403_participantPositionChange-participantCurrencyId.js +2 -2
- package/{migrations → src/migrations}/310404_participantPositionChange-change.js +2 -2
- package/{migrations → src/migrations}/310500_participantLimit.js +1 -1
- package/{migrations → src/migrations}/310502_participantLimit-decimal184.js +1 -1
- package/{migrations → src/migrations}/400100_settlementWindow.js +1 -1
- package/{migrations → src/migrations}/400200_settlement.js +1 -1
- package/{migrations → src/migrations}/400300_settlementSettlementWindow.js +1 -1
- package/{migrations → src/migrations}/400301_settlementSettlementWindow-indexes.js +0 -1
- package/{migrations → src/migrations}/400400_settlementWindowStateChange.js +1 -1
- package/{migrations → src/migrations}/400500_settlementTransferParticipant.js +1 -1
- package/{migrations → src/migrations}/400502_settlementTransferParticipant-decimal184.js +1 -1
- package/{migrations → src/migrations}/400600_settlementParticipantCurrency.js +1 -1
- package/{migrations → src/migrations}/400602_settlementParticipantCurrency-decimal184.js +1 -1
- package/{migrations → src/migrations}/400700_settlementParticipantCurrencyStateChange.js +1 -1
- package/{migrations → src/migrations}/400800_settlementStateChange.js +1 -1
- package/{migrations → src/migrations}/400900_settlementWindowContent.js +1 -1
- package/{migrations → src/migrations}/401000_settlementWindowContentStateChange.js +1 -1
- package/{migrations → src/migrations}/401001_settlementWindowContentStateChange-indexes.js +6 -6
- package/{migrations → src/migrations}/401200_settlementContentAggregation.js +1 -1
- package/{migrations → src/migrations}/401300_settlementModel.js +1 -1
- package/{migrations → src/migrations}/410100_transferFulfilmentDuplicateCheck.js +1 -1
- package/{migrations → src/migrations}/410102_transferFulfilmentDuplicateCheck-dropForeignTransferId.js +1 -1
- package/{migrations → src/migrations}/410103_transferFulfilmentDuplicateCheck-hashNullable.js +1 -1
- package/{migrations → src/migrations}/410200_transferFulfilment.js +1 -1
- package/{migrations → src/migrations}/410202_transferFulfilment-ilpFulfilment.js +1 -1
- package/{migrations → src/migrations}/410203_transferFulfilment-foreignTransferFulfilmentId.js +1 -1
- package/{migrations → src/migrations}/410240_bulkTransferFulfilmentDuplicateCheck.js +1 -1
- package/{migrations → src/migrations}/410250_bulkTransferFulfilment.js +1 -1
- package/{migrations → src/migrations}/410300_transferExtension.js +1 -1
- package/{migrations → src/migrations}/410302_transferExtension-transferErrorId.js +1 -1
- package/{migrations → src/migrations}/410350_bulkTransferExtension.js +1 -1
- package/{migrations → src/migrations}/410400_transferTimeout.js +1 -1
- package/{migrations → src/migrations}/410450_transferErrorDuplicateCheck.js +1 -1
- package/{migrations → src/migrations}/410500_transferError.js +1 -1
- package/{migrations → src/migrations}/410502_transferError-foreignTransferErrorDuplicateCheckId.js +1 -1
- package/{migrations → src/migrations}/410550_bulkTransferError.js +1 -1
- package/{migrations → src/migrations}/410600_expiringTransfer.js +1 -1
- package/{migrations → src/migrations}/500401_quote-hotfix-2719.js +8 -8
- package/{migrations → src/migrations}/500501_feature-fixSubIdRef.js +12 -12
- package/{migrations → src/migrations}/500601_party-2480.js +3 -3
- package/{migrations → src/migrations}/501001_quoteExtension-quote-service-174.js +1 -2
- package/{migrations → src/migrations}/501002_quoteExtension-2522.js +3 -3
- package/{migrations → src/migrations}/600010_fxTransferType.js +1 -1
- package/{migrations → src/migrations}/600012_fxParticipantCurrencyType.js +1 -1
- package/{migrations → src/migrations}/600100_fxTransferDuplicateCheck.js +2 -2
- package/{migrations → src/migrations}/600110_fxTransferErrorDuplicateCheck.js.js +1 -1
- package/{migrations → src/migrations}/600200_fxTransfer.js +2 -2
- package/{migrations → src/migrations}/600400_fxTransferStateChange.js +1 -1
- package/{migrations → src/migrations}/600501_fxWatchList.js +2 -2
- package/{migrations → src/migrations}/600600_fxTransferFulfilmentDuplicateCheck.js +1 -1
- package/{migrations → src/migrations}/600700_fxTransferFulfilment.js +1 -1
- package/{migrations → src/migrations}/600800_fxTransferExtension.js +1 -1
- package/{migrations → src/migrations}/601400_fxTransferTimeout.js +1 -1
- package/{migrations → src/migrations}/601500_fxTransferError.js +1 -1
- package/{migrations → src/migrations}/610200_fxTransferParticipant.js +1 -1
- package/{migrations → src/migrations}/610202_fxTransferParticipant-participantId.js +2 -2
- package/{migrations → src/migrations}/610403_participantPositionChange-fxTransfer.js +1 -1
- package/{migrations → src/migrations}/800100_quotePartyView.js +1 -1
- package/{migrations → src/migrations}/800101_feature-fixSubIdRef.js +1 -1
- package/{migrations → src/migrations}/800200_quoteView.js +1 -1
- package/{migrations → src/migrations}/800300_quoteResponseView.js +1 -1
- package/{migrations → src/migrations}/900100_foreign-keys.js +18 -18
- package/{migrations → src/migrations}/900101_foreign-keys.js +6 -6
- package/{migrations → src/migrations}/910100_feature904DDL.js +7 -7
- package/{migrations → src/migrations}/910101_feature904DataMigration.js +1 -1
- package/{migrations → src/migrations}/910102_feature949DataMigration.js +1 -1
- package/{migrations → src/migrations}/910103_feature1093SettlementByCurrency.js +3 -3
- package/{migrations → src/migrations}/940101_quotePartyIdInfoExtension-2522.js +25 -25
- package/{migrations → src/migrations}/950101_transferParticipantStateChange.js +2 -2
- package/{migrations → src/migrations}/950102_settlementModel-adjustPosition.js +2 -2
- package/{migrations → src/migrations}/950103_dropTransferParticipantStateChange.js +3 -3
- package/{migrations → src/migrations}/950104_settlementModel-settlementAccountTypeId.js +3 -3
- package/src/migrations/950107_settlementWindowContent_foreign_settlementModel.js +63 -0
- package/{migrations → src/migrations}/950108_participantProxy.js +1 -2
- package/{migrations → src/migrations}/950120_fxQuoteConversionTerms_sourceAmount_nullable.js +1 -1
- package/{migrations → src/migrations}/960100_create_externalParticipant.js +2 -2
- package/{migrations → src/migrations}/960110_alter_transferParticipant__addFiled_externalParticipantId.js +2 -2
- package/{migrations → src/migrations}/961001_transferForwarded.js +1 -1
- package/{migrations → src/migrations}/961002_fxTransferForwarded.js +1 -1
- package/src/models/participant/externalParticipant.int.ts +85 -0
- package/src/models/participant/facade.js +4 -2
- package/src/models/participant/participantCurrencyCached.js +1 -1
- package/src/models/position/facade.js +8 -2
- package/src/models/transfer/facade.int.ts +139 -0
- package/src/models/transfer/facade.js +8 -3
- package/src/models/transfer/transferDuplicateCheck.js +2 -2
- package/src/models/transfer/transferError.int.ts +112 -0
- package/src/models/transfer/transferExtension.int.ts +137 -0
- package/src/models/transfer/transferStateChange.int.ts +117 -0
- package/{seeds → src/seeds}/participant.js +1 -1
- package/{seeds → src/seeds}/settlementInterchange.js +1 -0
- package/src/settlement/api/handlerRoutes.js +71 -0
- package/src/settlement/api/handlers/health.js +10 -0
- package/src/settlement/api/handlers/index.js +57 -0
- package/src/settlement/api/handlers/settlementWindows/{id}.js +103 -0
- package/src/settlement/api/handlers/settlementWindows.js +77 -0
- package/src/settlement/api/handlers/settlements/{id}.js +133 -0
- package/src/settlement/api/handlers/settlements/{sid}/participants/{pid}/accounts/{aid}.js +127 -0
- package/src/settlement/api/handlers/settlements/{sid}/participants/{pid}.js +127 -0
- package/src/settlement/api/handlers/settlements.js +114 -0
- package/src/settlement/api/openapiRouting.js +87 -0
- package/src/settlement/api/routes.js +176 -0
- package/src/settlement/domain/rules/index.js +46 -0
- package/src/settlement/domain/settlement/index.js +405 -0
- package/src/settlement/domain/settlementWindow/index.js +117 -0
- package/src/settlement/domain/transactions/index.js +83 -0
- package/src/settlement/domain/transferSettlement/index.js +57 -0
- package/src/settlement/handlers/deferredSettlement/handler.js +180 -0
- package/src/settlement/handlers/grossSettlement/handler.js +180 -0
- package/src/settlement/handlers/index.js +101 -0
- package/src/settlement/handlers/register.js +92 -0
- package/src/settlement/handlers/rules/handler.js +164 -0
- package/src/settlement/interface/swagger-handler.json +34 -0
- package/src/settlement/interface/swagger.json +1560 -0
- package/src/settlement/lib/db.js +32 -0
- package/src/settlement/lib/kafka/index.js +41 -0
- package/src/settlement/lib/kafka/producer.js +142 -0
- package/src/settlement/lib/scriptEngine.js +99 -0
- package/src/settlement/lib/scriptsLoader.js +175 -0
- package/src/settlement/lib/utility.js +243 -0
- package/src/settlement/models/ilpPackets/ilpPacket.js +42 -0
- package/src/settlement/models/lib/enums.js +192 -0
- package/src/settlement/models/misc/migrationLock.js +53 -0
- package/src/settlement/models/settlement/facade.js +1652 -0
- package/src/settlement/models/settlement/index.js +55 -0
- package/src/settlement/models/settlement/participantCurrency.js +48 -0
- package/src/settlement/models/settlement/settlement.js +49 -0
- package/src/settlement/models/settlement/settlementModel.js +44 -0
- package/src/settlement/models/settlement/settlementParticipantCurrency.js +61 -0
- package/src/settlement/models/settlement/settlementStateChange.js +44 -0
- package/src/settlement/models/settlement/settlementTransferParticipant.js +46 -0
- package/src/settlement/models/settlementWindow/facade.js +345 -0
- package/src/settlement/models/settlementWindow/index.js +47 -0
- package/src/settlement/models/settlementWindow/settlementWindowStateChange.js +55 -0
- package/src/settlement/models/settlementWindowContent/facade.js +79 -0
- package/src/settlement/models/settlementWindowContent/index.js +40 -0
- package/src/settlement/models/settlementWindowContent/settlementWindowContentStateChange.js +53 -0
- package/src/settlement/models/transferSettlement/facade.js +363 -0
- package/src/settlement/models/transferSettlement/index.js +42 -0
- package/src/settlement/shared/logger/index.js +7 -0
- package/src/settlement/shared/plugins.js +88 -0
- package/src/settlement/shared/setup.js +224 -0
- package/src/settlement/utils/truthyProperty.js +37 -0
- package/src/shared/legacyUtilShim.js +20 -0
- package/src/shared/plugins.js +3 -3
- package/src/shared/results.ts +22 -0
- package/src/shared/results.unit.ts +38 -0
- package/src/shared/setup.js +14 -1
- package/src/testing/api-helpers.ts +1222 -0
- package/src/testing/exec-async.ts +67 -0
- package/src/testing/harness.snapshot.sql +3895 -0
- package/src/testing/harness.test.ts +15 -0
- package/src/testing/harness.ts +1160 -0
- package/src/testing/kafka.ts +221 -0
- package/src/testing/prng.ts +82 -0
- package/src/testing/rdkafka.test.ts +263 -0
- package/src/testing/run.ts +559 -0
- package/src/testing/snapshot.test.ts +92 -0
- package/src/testing/snapshot.ts +549 -0
- package/src/testing/tap-stream.ts +164 -0
- package/src/testing/types.ts +95 -0
- package/src/testing/util.ts +333 -0
- package/src/types/central-services-error-handling.d.ts +72 -0
- package/src/types/central-services-stream.d.ts +148 -0
- package/test-integration.Dockerfile +0 -2
- package/test.Dockerfile +0 -2
- package/tsconfig.json +40 -0
- package/config/knexfile.js +0 -19
- package/migrations/950107_settlementWindowContent_foreign_settlementModel.js +0 -63
- package/src/api/index.js +0 -16
- package/src/lib/config.js +0 -81
- /package/{migrations → src/migrations}/110101_contactType-indexes.js +0 -0
- /package/{migrations → src/migrations}/110301_endpointType-indexes.js +0 -0
- /package/{migrations → src/migrations}/110401_ledgerEntryType-indexes.js +0 -0
- /package/{migrations → src/migrations}/110451_ledgerAccountType-indexes.js +0 -0
- /package/{migrations → src/migrations}/110501_participantLimitType-indexes.js +0 -0
- /package/{migrations → src/migrations}/110601_transferParticipantRoleType-indexes.js +0 -0
- /package/{migrations → src/migrations}/110800_settlementWindowState.js +0 -0
- /package/{migrations → src/migrations}/111000_amountType.js +0 -0
- /package/{migrations → src/migrations}/111001_amountType-indexes.js +0 -0
- /package/{migrations → src/migrations}/111100_balanceOfPayments.js +0 -0
- /package/{migrations → src/migrations}/111101_balanceOfPayments-indexes.js +0 -0
- /package/{migrations → src/migrations}/111200_partyIdentifierType.js +0 -0
- /package/{migrations → src/migrations}/111201_partyIdentifierType-indexes.js +0 -0
- /package/{migrations → src/migrations}/111300_partyType.js +0 -0
- /package/{migrations → src/migrations}/111301_partyType-indexes.js +0 -0
- /package/{migrations → src/migrations}/111400_quoteDuplicateCheck.js +0 -0
- /package/{migrations → src/migrations}/111500_transactionInitiator.js +0 -0
- /package/{migrations → src/migrations}/111501_transactionInitiator-indexes.js +0 -0
- /package/{migrations → src/migrations}/111600_transactionInitiatorType.js +0 -0
- /package/{migrations → src/migrations}/111601_transactionInitiatorType-indexes.js +0 -0
- /package/{migrations → src/migrations}/111700_settlementDelay.js +0 -0
- /package/{migrations → src/migrations}/111701_settlementDelay-indexes.js +0 -0
- /package/{migrations → src/migrations}/111800_settlementInterchange.js +0 -0
- /package/{migrations → src/migrations}/111801_settlementInterchange-indexes.js +0 -0
- /package/{migrations → src/migrations}/111900_settlementGranularity.js +0 -0
- /package/{migrations → src/migrations}/111901_settlementGranularity-indexes.js +0 -0
- /package/{migrations → src/migrations}/112101_bulkProcessingState-indexes.js +0 -0
- /package/{migrations → src/migrations}/200101_participant-indexes.js +0 -0
- /package/{migrations → src/migrations}/200201_participantContact-indexes.js +0 -0
- /package/{migrations → src/migrations}/200301_participantEndpoint-indexes.js +0 -0
- /package/{migrations → src/migrations}/200401_participantParty-indexes.js +0 -0
- /package/{migrations → src/migrations}/300201_transfer-indexes.js +0 -0
- /package/{migrations → src/migrations}/300251_bulkTransfer-indexes.js +0 -0
- /package/{migrations → src/migrations}/300276_bulkTransferAssociation-indexes.js +0 -0
- /package/{migrations → src/migrations}/300401_transferStateChange-indexes.js +0 -0
- /package/{migrations → src/migrations}/300451_bulkTransferStateChange-indexes.js +0 -0
- /package/{migrations → src/migrations}/300501_segment-indexes.js +0 -0
- /package/{migrations → src/migrations}/310101_participantCurrency-indexes.js +0 -0
- /package/{migrations → src/migrations}/310201_transferParticipant-indexes.js +0 -0
- /package/{migrations → src/migrations}/310203_transferParticipant-indexes.js +0 -0
- /package/{migrations → src/migrations}/310301_participantPosition-indexes.js +0 -0
- /package/{migrations → src/migrations}/310401_participantPositionChange-indexes.js +0 -0
- /package/{migrations → src/migrations}/310405_participantPositionChange-positionChange.js +0 -0
- /package/{migrations → src/migrations}/310406_participantPositionChange-positionChange-revert.js +0 -0
- /package/{migrations → src/migrations}/310501_participantLimit-indexes.js +0 -0
- /package/{migrations → src/migrations}/310503_participantLimit-indexes-composite.js +0 -0
- /package/{migrations → src/migrations}/400401_settlmentWindowStateChange-indexes.js +0 -0
- /package/{migrations → src/migrations}/400501_settlementTransferParticipant-indexes.js +0 -0
- /package/{migrations → src/migrations}/400601_settlementParticipantCurrency-indexes.js +0 -0
- /package/{migrations → src/migrations}/400701_settlementParticipantCurrencyStateChange-indexes.js +0 -0
- /package/{migrations → src/migrations}/400801_settlementStateChange-indexes.js +0 -0
- /package/{migrations → src/migrations}/401002_settlementWindowContent-indexes.js +0 -0
- /package/{migrations → src/migrations}/401201_settlementContentAggregation-indexes.js +0 -0
- /package/{migrations → src/migrations}/401301_settlementModel-indexes.js +0 -0
- /package/{migrations → src/migrations}/410101_transferFulfilmentDuplicateCheck-indexes.js +0 -0
- /package/{migrations → src/migrations}/410201_transferFulfilment-indexes.js +0 -0
- /package/{migrations → src/migrations}/410301_transferExtension-indexes.js +0 -0
- /package/{migrations → src/migrations}/410351_bulkTransferExtension-indexes.js +0 -0
- /package/{migrations → src/migrations}/410401_transferTimeout-indexes.js +0 -0
- /package/{migrations → src/migrations}/410501_transferError-indexes.js +0 -0
- /package/{migrations → src/migrations}/410551_bulkTransferError-indexes.js +0 -0
- /package/{migrations → src/migrations}/410601_expiringTransfer-indexes.js +0 -0
- /package/{migrations → src/migrations}/500100_transactionReference.js +0 -0
- /package/{migrations → src/migrations}/500101_transactionReference-indexes.js +0 -0
- /package/{migrations → src/migrations}/500200_transactionScenario.js +0 -0
- /package/{migrations → src/migrations}/500201_transactionScenario-indexes.js +0 -0
- /package/{migrations → src/migrations}/500300_transactionSubScenario.js +0 -0
- /package/{migrations → src/migrations}/500400_quote.js +0 -0
- /package/{migrations → src/migrations}/500500_quoteParty.js +0 -0
- /package/{migrations → src/migrations}/500600_party.js +0 -0
- /package/{migrations → src/migrations}/500700_quoteResponse.js +0 -0
- /package/{migrations → src/migrations}/500800_quoteResponseIlpPacket.js +0 -0
- /package/{migrations → src/migrations}/500900_geoCode.js +0 -0
- /package/{migrations → src/migrations}/501000_quoteExtension.js +0 -0
- /package/{migrations → src/migrations}/501100_quoteResponseDuplicateCheck.js +0 -0
- /package/{migrations → src/migrations}/501200_quoteError.js +0 -0
- /package/{migrations → src/migrations}/501300_transferRules.js +0 -0
- /package/{migrations → src/migrations}/600011_fxTransferType-indexes.js +0 -0
- /package/{migrations → src/migrations}/600013_fxParticipantCurrencyType-indexes.js +0 -0
- /package/{migrations → src/migrations}/600201_fxTransfer-indexes.js +0 -0
- /package/{migrations → src/migrations}/600401_fxTransferStateChange-indexes.js +0 -0
- /package/{migrations → src/migrations}/600502_fxWatchList-indexes.js +0 -0
- /package/{migrations → src/migrations}/600601_fxTransferFulfilmentDuplicateCheck-indexes.js +0 -0
- /package/{migrations → src/migrations}/600701_fxTransferFulfilment-indexes.js +0 -0
- /package/{migrations → src/migrations}/601401_fxTransferTimeout-indexes.js +0 -0
- /package/{migrations → src/migrations}/601501_fxTransferError-indexes.js +0 -0
- /package/{migrations → src/migrations}/610201_fxTransferParticipant-indexes.js +0 -0
- /package/{migrations → src/migrations}/910102_hotfix954.js +0 -0
- /package/{migrations → src/migrations}/940100_quotePartyIdInfoExtension.js +0 -0
- /package/{migrations → src/migrations}/950100_settlementContentAggregation-decimal184.js +0 -0
- /package/{migrations → src/migrations}/950106_unique_settlement_model_ledger_account_currency.js +0 -0
- /package/{migrations → src/migrations}/950109_fxQuote.js +0 -0
- /package/{migrations → src/migrations}/950110_fxQuoteResponse.js +0 -0
- /package/{migrations → src/migrations}/950111_fxQuoteError.js +0 -0
- /package/{migrations → src/migrations}/950113_fxQuoteDuplicateCheck.js +0 -0
- /package/{migrations → src/migrations}/950114_fxQuoteResponseDuplicateCheck.js +0 -0
- /package/{migrations → src/migrations}/950115_fxQuoteConversionTerms.js +0 -0
- /package/{migrations → src/migrations}/950116_fxQuoteConversionTermsExtension.js +0 -0
- /package/{migrations → src/migrations}/950117_fxQuoteResponseConversionTerms.js +0 -0
- /package/{migrations → src/migrations}/950118_fxQuoteResponseConversionTermsExtension.js +0 -0
- /package/{migrations → src/migrations}/950119_fxCharge.js +0 -0
- /package/{migrations → src/migrations}/960111_alter_fxTransferParticipant__addFiled_externalParticipantId.js +0 -0
- /package/{migrations → src/migrations}/960112_fxTransfer-indexes2.js +0 -0
- /package/{migrations → src/migrations}/960113_fxTransferExtension-indexes.js +0 -0
- /package/{migrations → src/migrations}/960114_fxTransferTimeout-indexes2.js +0 -0
- /package/{migrations → src/migrations}/961000_participantEndpoint_unique.js +0 -0
- /package/{migrations → src/migrations}/migration.template +0 -0
- /package/{seeds → src/seeds}/amountType.js +0 -0
- /package/{seeds → src/seeds}/balanceOfPayments.js +0 -0
- /package/{seeds → src/seeds}/bulkProcessingState.js +0 -0
- /package/{seeds → src/seeds}/bulkTransferState.js +0 -0
- /package/{seeds → src/seeds}/currency.js +0 -0
- /package/{seeds → src/seeds}/endpointType.js +0 -0
- /package/{seeds → src/seeds}/fxParticipantCurrencyType.js +0 -0
- /package/{seeds → src/seeds}/fxTransferType.js +0 -0
- /package/{seeds → src/seeds}/ledgerAccountType.js +0 -0
- /package/{seeds → src/seeds}/ledgerEntryType.js +0 -0
- /package/{seeds → src/seeds}/participantLimitType.js +0 -0
- /package/{seeds → src/seeds}/partyIdentifierType.js +0 -0
- /package/{seeds → src/seeds}/partyType.js +0 -0
- /package/{seeds → src/seeds}/settlementDelay.js +0 -0
- /package/{seeds → src/seeds}/settlementGranularity.js +0 -0
- /package/{seeds → src/seeds}/settlementState.js +0 -0
- /package/{seeds → src/seeds}/settlementWindow1State.js +0 -0
- /package/{seeds → src/seeds}/settlementWindow2Open.js +0 -0
- /package/{seeds → src/seeds}/transactionInitiator.js +0 -0
- /package/{seeds → src/seeds}/transactionInitiatorType.js +0 -0
- /package/{seeds → src/seeds}/transactionScenario.js +0 -0
- /package/{seeds → src/seeds}/transferParticipantRoleType.js +0 -0
- /package/{seeds → src/seeds}/transferState.js +0 -0
- /package/{seeds → src/seeds}/z1000_settlementModel-deprecated.js- +0 -0
|
@@ -0,0 +1,724 @@
|
|
|
1
|
+
import assert from "node:assert"
|
|
2
|
+
import { after, before, describe, it } from "node:test"
|
|
3
|
+
import Harness from '../../testing/harness'
|
|
4
|
+
import { Enum, LedgerAccountTypeEnum } from '@mojaloop/central-services-shared'
|
|
5
|
+
import ParticipantService from './index'
|
|
6
|
+
import { ApplicationConfig } from "../../lib/config/types"
|
|
7
|
+
import { Snapshot } from "../../testing/snapshot"
|
|
8
|
+
import { createDfsp } from "../../testing/api-helpers"
|
|
9
|
+
|
|
10
|
+
const harness = Harness.getInstance()
|
|
11
|
+
|
|
12
|
+
// Test data:
|
|
13
|
+
const dfsps = ['dfspa', 'dfspb', 'dfspc', 'dfspd']
|
|
14
|
+
const proxyStatus = [false, false, false, true]
|
|
15
|
+
const currencies = ['USD', 'KES']
|
|
16
|
+
const accountTypes: Array<LedgerAccountTypeEnum> = [
|
|
17
|
+
Enum.Accounts.LedgerAccountType.POSITION,
|
|
18
|
+
Enum.Accounts.LedgerAccountType.SETTLEMENT
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
describe('domain/participant/index', () => {
|
|
22
|
+
let config: ApplicationConfig
|
|
23
|
+
|
|
24
|
+
before(async () => {
|
|
25
|
+
await harness.up()
|
|
26
|
+
await harness.setupGlobals()
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
after(async () => {
|
|
30
|
+
await harness.teardownGlobals()
|
|
31
|
+
await harness.down()
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('creates the hub accounts', async () => {
|
|
35
|
+
let exists = await ParticipantService.hubAccountExists(
|
|
36
|
+
'USD',
|
|
37
|
+
Enum.Accounts.LedgerAccountType.HUB_RECONCILIATION
|
|
38
|
+
)
|
|
39
|
+
assert.equal(exists, false)
|
|
40
|
+
|
|
41
|
+
let newAccount = await ParticipantService.createHubAccount(
|
|
42
|
+
harness.config.HUB_ID, 'USD', Enum.Accounts.LedgerAccountType.HUB_RECONCILIATION
|
|
43
|
+
)
|
|
44
|
+
assert(newAccount.participantCurrency)
|
|
45
|
+
assert(newAccount.participantPosition)
|
|
46
|
+
|
|
47
|
+
exists = await ParticipantService.hubAccountExists(
|
|
48
|
+
'USD',
|
|
49
|
+
Enum.Accounts.LedgerAccountType.HUB_MULTILATERAL_SETTLEMENT
|
|
50
|
+
)
|
|
51
|
+
assert.equal(exists, false)
|
|
52
|
+
newAccount = await ParticipantService.createHubAccount(
|
|
53
|
+
harness.config.HUB_ID, 'USD', Enum.Accounts.LedgerAccountType.HUB_MULTILATERAL_SETTLEMENT
|
|
54
|
+
)
|
|
55
|
+
assert(newAccount.participantCurrency)
|
|
56
|
+
assert(newAccount.participantPosition)
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it('creates the participants', async (test) => {
|
|
60
|
+
assert(dfsps.length === proxyStatus.length)
|
|
61
|
+
|
|
62
|
+
for (const [idx, dfsp] of dfsps.entries()) {
|
|
63
|
+
const isProxy = proxyStatus[idx]
|
|
64
|
+
const resultGetByName = await ParticipantService.getByName(dfsp)
|
|
65
|
+
assert.equal(resultGetByName, undefined)
|
|
66
|
+
|
|
67
|
+
const participantId = await ParticipantService.create({
|
|
68
|
+
name: dfsp, isProxy,
|
|
69
|
+
})
|
|
70
|
+
for (const currency of currencies) {
|
|
71
|
+
for (const accountType of accountTypes) {
|
|
72
|
+
await ParticipantService.createParticipantCurrency(
|
|
73
|
+
participantId,
|
|
74
|
+
currency,
|
|
75
|
+
accountType,
|
|
76
|
+
false
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const created = await ParticipantService.getById(participantId)
|
|
82
|
+
Snapshot.from(`{
|
|
83
|
+
"participantId": ${participantId},
|
|
84
|
+
"name": "${dfsp}",
|
|
85
|
+
"description": null,
|
|
86
|
+
"isActive": 1,
|
|
87
|
+
"createdDate": :ignore
|
|
88
|
+
"createdBy": "unknown",
|
|
89
|
+
"isProxy": ${isProxy ? '1' : '0'},
|
|
90
|
+
"currencyList": [
|
|
91
|
+
{
|
|
92
|
+
"participantCurrencyId": :int,
|
|
93
|
+
"participantId": ${participantId},
|
|
94
|
+
"currencyId": "USD",
|
|
95
|
+
"ledgerAccountTypeId": 1,
|
|
96
|
+
"isActive": 0,
|
|
97
|
+
"createdDate": :ignore
|
|
98
|
+
"createdBy": "unknown"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"participantCurrencyId": :int,
|
|
102
|
+
"participantId": ${participantId},
|
|
103
|
+
"currencyId": "USD",
|
|
104
|
+
"ledgerAccountTypeId": 2,
|
|
105
|
+
"isActive": 0,
|
|
106
|
+
"createdDate": :ignore
|
|
107
|
+
"createdBy": "unknown"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"participantCurrencyId": :int,
|
|
111
|
+
"participantId": ${participantId},
|
|
112
|
+
"currencyId": "KES",
|
|
113
|
+
"ledgerAccountTypeId": 1,
|
|
114
|
+
"isActive": 0,
|
|
115
|
+
"createdDate": :ignore
|
|
116
|
+
"createdBy": "unknown"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"participantCurrencyId": :int,
|
|
120
|
+
"participantId": ${participantId},
|
|
121
|
+
"currencyId": "KES",
|
|
122
|
+
"ledgerAccountTypeId": 2,
|
|
123
|
+
"isActive": 0,
|
|
124
|
+
"createdDate": :ignore
|
|
125
|
+
"createdBy": "unknown"
|
|
126
|
+
}
|
|
127
|
+
]
|
|
128
|
+
}`).checkStringUnwrap(JSON.stringify(created, null, 2))
|
|
129
|
+
}
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
it('getAll()', async () => {
|
|
133
|
+
const result = await ParticipantService.getAll()
|
|
134
|
+
Snapshot.from(`[
|
|
135
|
+
{
|
|
136
|
+
"participantId": 2,
|
|
137
|
+
"name": "dfspa",
|
|
138
|
+
"description": null,
|
|
139
|
+
"isActive": 1,
|
|
140
|
+
"createdDate": ":ignore",
|
|
141
|
+
"createdBy": "unknown",
|
|
142
|
+
"isProxy": 0,
|
|
143
|
+
"currencyList": [
|
|
144
|
+
{
|
|
145
|
+
"participantCurrencyId": 3,
|
|
146
|
+
"participantId": 2,
|
|
147
|
+
"currencyId": "USD",
|
|
148
|
+
"ledgerAccountTypeId": 1,
|
|
149
|
+
"isActive": 0,
|
|
150
|
+
"createdDate": ":ignore",
|
|
151
|
+
"createdBy": "unknown"
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"participantCurrencyId": 4,
|
|
155
|
+
"participantId": 2,
|
|
156
|
+
"currencyId": "USD",
|
|
157
|
+
"ledgerAccountTypeId": 2,
|
|
158
|
+
"isActive": 0,
|
|
159
|
+
"createdDate": ":ignore",
|
|
160
|
+
"createdBy": "unknown"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"participantCurrencyId": 5,
|
|
164
|
+
"participantId": 2,
|
|
165
|
+
"currencyId": "KES",
|
|
166
|
+
"ledgerAccountTypeId": 1,
|
|
167
|
+
"isActive": 0,
|
|
168
|
+
"createdDate": ":ignore",
|
|
169
|
+
"createdBy": "unknown"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"participantCurrencyId": 6,
|
|
173
|
+
"participantId": 2,
|
|
174
|
+
"currencyId": "KES",
|
|
175
|
+
"ledgerAccountTypeId": 2,
|
|
176
|
+
"isActive": 0,
|
|
177
|
+
"createdDate": ":ignore",
|
|
178
|
+
"createdBy": "unknown"
|
|
179
|
+
}
|
|
180
|
+
]
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"participantId": 3,
|
|
184
|
+
"name": "dfspb",
|
|
185
|
+
"description": null,
|
|
186
|
+
"isActive": 1,
|
|
187
|
+
"createdDate": ":ignore",
|
|
188
|
+
"createdBy": "unknown",
|
|
189
|
+
"isProxy": 0,
|
|
190
|
+
"currencyList": [
|
|
191
|
+
{
|
|
192
|
+
"participantCurrencyId": 7,
|
|
193
|
+
"participantId": 3,
|
|
194
|
+
"currencyId": "USD",
|
|
195
|
+
"ledgerAccountTypeId": 1,
|
|
196
|
+
"isActive": 0,
|
|
197
|
+
"createdDate": ":ignore",
|
|
198
|
+
"createdBy": "unknown"
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
"participantCurrencyId": 8,
|
|
202
|
+
"participantId": 3,
|
|
203
|
+
"currencyId": "USD",
|
|
204
|
+
"ledgerAccountTypeId": 2,
|
|
205
|
+
"isActive": 0,
|
|
206
|
+
"createdDate": ":ignore",
|
|
207
|
+
"createdBy": "unknown"
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"participantCurrencyId": 9,
|
|
211
|
+
"participantId": 3,
|
|
212
|
+
"currencyId": "KES",
|
|
213
|
+
"ledgerAccountTypeId": 1,
|
|
214
|
+
"isActive": 0,
|
|
215
|
+
"createdDate": ":ignore",
|
|
216
|
+
"createdBy": "unknown"
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
"participantCurrencyId": 10,
|
|
220
|
+
"participantId": 3,
|
|
221
|
+
"currencyId": "KES",
|
|
222
|
+
"ledgerAccountTypeId": 2,
|
|
223
|
+
"isActive": 0,
|
|
224
|
+
"createdDate": ":ignore",
|
|
225
|
+
"createdBy": "unknown"
|
|
226
|
+
}
|
|
227
|
+
]
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
"participantId": 4,
|
|
231
|
+
"name": "dfspc",
|
|
232
|
+
"description": null,
|
|
233
|
+
"isActive": 1,
|
|
234
|
+
"createdDate": ":ignore",
|
|
235
|
+
"createdBy": "unknown",
|
|
236
|
+
"isProxy": 0,
|
|
237
|
+
"currencyList": [
|
|
238
|
+
{
|
|
239
|
+
"participantCurrencyId": 11,
|
|
240
|
+
"participantId": 4,
|
|
241
|
+
"currencyId": "USD",
|
|
242
|
+
"ledgerAccountTypeId": 1,
|
|
243
|
+
"isActive": 0,
|
|
244
|
+
"createdDate": ":ignore",
|
|
245
|
+
"createdBy": "unknown"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"participantCurrencyId": 12,
|
|
249
|
+
"participantId": 4,
|
|
250
|
+
"currencyId": "USD",
|
|
251
|
+
"ledgerAccountTypeId": 2,
|
|
252
|
+
"isActive": 0,
|
|
253
|
+
"createdDate": ":ignore",
|
|
254
|
+
"createdBy": "unknown"
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
"participantCurrencyId": 13,
|
|
258
|
+
"participantId": 4,
|
|
259
|
+
"currencyId": "KES",
|
|
260
|
+
"ledgerAccountTypeId": 1,
|
|
261
|
+
"isActive": 0,
|
|
262
|
+
"createdDate": ":ignore",
|
|
263
|
+
"createdBy": "unknown"
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
"participantCurrencyId": 14,
|
|
267
|
+
"participantId": 4,
|
|
268
|
+
"currencyId": "KES",
|
|
269
|
+
"ledgerAccountTypeId": 2,
|
|
270
|
+
"isActive": 0,
|
|
271
|
+
"createdDate": ":ignore",
|
|
272
|
+
"createdBy": "unknown"
|
|
273
|
+
}
|
|
274
|
+
]
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
"participantId": 5,
|
|
278
|
+
"name": "dfspd",
|
|
279
|
+
"description": null,
|
|
280
|
+
"isActive": 1,
|
|
281
|
+
"createdDate": ":ignore",
|
|
282
|
+
"createdBy": "unknown",
|
|
283
|
+
"isProxy": 1,
|
|
284
|
+
"currencyList": [
|
|
285
|
+
{
|
|
286
|
+
"participantCurrencyId": 15,
|
|
287
|
+
"participantId": 5,
|
|
288
|
+
"currencyId": "USD",
|
|
289
|
+
"ledgerAccountTypeId": 1,
|
|
290
|
+
"isActive": 0,
|
|
291
|
+
"createdDate": ":ignore",
|
|
292
|
+
"createdBy": "unknown"
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
"participantCurrencyId": 16,
|
|
296
|
+
"participantId": 5,
|
|
297
|
+
"currencyId": "USD",
|
|
298
|
+
"ledgerAccountTypeId": 2,
|
|
299
|
+
"isActive": 0,
|
|
300
|
+
"createdDate": ":ignore",
|
|
301
|
+
"createdBy": "unknown"
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
"participantCurrencyId": 17,
|
|
305
|
+
"participantId": 5,
|
|
306
|
+
"currencyId": "KES",
|
|
307
|
+
"ledgerAccountTypeId": 1,
|
|
308
|
+
"isActive": 0,
|
|
309
|
+
"createdDate": ":ignore",
|
|
310
|
+
"createdBy": "unknown"
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
"participantCurrencyId": 18,
|
|
314
|
+
"participantId": 5,
|
|
315
|
+
"currencyId": "KES",
|
|
316
|
+
"ledgerAccountTypeId": 2,
|
|
317
|
+
"isActive": 0,
|
|
318
|
+
"createdDate": ":ignore",
|
|
319
|
+
"createdBy": "unknown"
|
|
320
|
+
}
|
|
321
|
+
]
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
"participantId": 1,
|
|
325
|
+
"name": "Hub",
|
|
326
|
+
"description": "Hub Operator",
|
|
327
|
+
"isActive": 1,
|
|
328
|
+
"createdDate": ":ignore",
|
|
329
|
+
"createdBy": "seeds",
|
|
330
|
+
"isProxy": 0,
|
|
331
|
+
"currencyList": [
|
|
332
|
+
{
|
|
333
|
+
"participantCurrencyId": 1,
|
|
334
|
+
"participantId": 1,
|
|
335
|
+
"currencyId": "USD",
|
|
336
|
+
"ledgerAccountTypeId": 3,
|
|
337
|
+
"isActive": 1,
|
|
338
|
+
"createdDate": ":ignore",
|
|
339
|
+
"createdBy": "unknown"
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
"participantCurrencyId": 2,
|
|
343
|
+
"participantId": 1,
|
|
344
|
+
"currencyId": "USD",
|
|
345
|
+
"ledgerAccountTypeId": 4,
|
|
346
|
+
"isActive": 1,
|
|
347
|
+
"createdDate": ":ignore",
|
|
348
|
+
"createdBy": "unknown"
|
|
349
|
+
}
|
|
350
|
+
]
|
|
351
|
+
}
|
|
352
|
+
]`).checkUnwrap(result)
|
|
353
|
+
})
|
|
354
|
+
|
|
355
|
+
it('getById()', async () => {
|
|
356
|
+
// Just look for a single participantId.
|
|
357
|
+
const result = await ParticipantService.getById(3)
|
|
358
|
+
Snapshot.from(`{
|
|
359
|
+
"participantId": 3,
|
|
360
|
+
"name": "dfspb",
|
|
361
|
+
"description": null,
|
|
362
|
+
"isActive": 1,
|
|
363
|
+
"createdDate": ":ignore",
|
|
364
|
+
"createdBy": "unknown",
|
|
365
|
+
"isProxy": 0,
|
|
366
|
+
"currencyList": [
|
|
367
|
+
{
|
|
368
|
+
"participantCurrencyId": 7,
|
|
369
|
+
"participantId": 3,
|
|
370
|
+
"currencyId": "USD",
|
|
371
|
+
"ledgerAccountTypeId": 1,
|
|
372
|
+
"isActive": 0,
|
|
373
|
+
"createdDate": ":ignore",
|
|
374
|
+
"createdBy": "unknown"
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
"participantCurrencyId": 8,
|
|
378
|
+
"participantId": 3,
|
|
379
|
+
"currencyId": "USD",
|
|
380
|
+
"ledgerAccountTypeId": 2,
|
|
381
|
+
"isActive": 0,
|
|
382
|
+
"createdDate": ":ignore",
|
|
383
|
+
"createdBy": "unknown"
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
"participantCurrencyId": 9,
|
|
387
|
+
"participantId": 3,
|
|
388
|
+
"currencyId": "KES",
|
|
389
|
+
"ledgerAccountTypeId": 1,
|
|
390
|
+
"isActive": 0,
|
|
391
|
+
"createdDate": ":ignore",
|
|
392
|
+
"createdBy": "unknown"
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
"participantCurrencyId": 10,
|
|
396
|
+
"participantId": 3,
|
|
397
|
+
"currencyId": "KES",
|
|
398
|
+
"ledgerAccountTypeId": 2,
|
|
399
|
+
"isActive": 0,
|
|
400
|
+
"createdDate": ":ignore",
|
|
401
|
+
"createdBy": "unknown"
|
|
402
|
+
}
|
|
403
|
+
]
|
|
404
|
+
}`).checkUnwrap(result)
|
|
405
|
+
})
|
|
406
|
+
|
|
407
|
+
it('addEndpoint() and getAllEndpoints()', async () => {
|
|
408
|
+
for (const dfsp of dfsps) {
|
|
409
|
+
await ParticipantService.addEndpoint(dfsp, {
|
|
410
|
+
type: Enum.EndPoints.FspEndpointTypes.FSPIOP_CALLBACK_URL_TRANSFER_POST,
|
|
411
|
+
value: `http://localhost:1080/transfers`
|
|
412
|
+
})
|
|
413
|
+
await ParticipantService.addEndpoint(dfsp, {
|
|
414
|
+
type: Enum.EndPoints.FspEndpointTypes.FSPIOP_CALLBACK_URL_TRANSFER_PUT,
|
|
415
|
+
value: `http://localhost:1080/transfers/{{transferId}}`
|
|
416
|
+
})
|
|
417
|
+
await ParticipantService.addEndpoint(dfsp, {
|
|
418
|
+
type: Enum.EndPoints.FspEndpointTypes.FSPIOP_CALLBACK_URL_TRANSFER_ERROR,
|
|
419
|
+
value: `http://localhost:1080/transfers/{{transferId}}/error`
|
|
420
|
+
})
|
|
421
|
+
await ParticipantService.addEndpoint(dfsp, {
|
|
422
|
+
type: Enum.EndPoints.FspEndpointTypes.FSPIOP_CALLBACK_URL_BULK_TRANSFER_POST,
|
|
423
|
+
value: `http://localhost:1080/bulkTransfers`
|
|
424
|
+
})
|
|
425
|
+
await ParticipantService.addEndpoint(dfsp, {
|
|
426
|
+
type: Enum.EndPoints.FspEndpointTypes.FSPIOP_CALLBACK_URL_BULK_TRANSFER_PUT,
|
|
427
|
+
value: `http://localhost:1080/bulkTransfers/{{id}}`
|
|
428
|
+
})
|
|
429
|
+
await ParticipantService.addEndpoint(dfsp, {
|
|
430
|
+
type: Enum.EndPoints.FspEndpointTypes.FSPIOP_CALLBACK_URL_BULK_TRANSFER_ERROR,
|
|
431
|
+
value: `http://localhost:1080//bulkTransfers/{{id}}/error`
|
|
432
|
+
})
|
|
433
|
+
await ParticipantService.addEndpoint(dfsp, {
|
|
434
|
+
type: Enum.EndPoints.FspEndpointTypes.FSPIOP_CALLBACK_URL_QUOTES,
|
|
435
|
+
value: `http://localhost:1080`
|
|
436
|
+
})
|
|
437
|
+
await ParticipantService.addEndpoint(dfsp, {
|
|
438
|
+
type: Enum.EndPoints.FspEndpointTypes.FSPIOP_CALLBACK_URL_AUTHORIZATIONS,
|
|
439
|
+
value: `http://localhost:1080`
|
|
440
|
+
})
|
|
441
|
+
await ParticipantService.addEndpoint(dfsp, {
|
|
442
|
+
type: Enum.EndPoints.FspEndpointTypes.FSPIOP_CALLBACK_URL_TRX_REQ_SERVICE,
|
|
443
|
+
value: `http://localhost:1080`
|
|
444
|
+
})
|
|
445
|
+
|
|
446
|
+
const endpoints = await ParticipantService.getAllEndpoints(dfsp)
|
|
447
|
+
assert.equal(endpoints.length, 9)
|
|
448
|
+
}
|
|
449
|
+
})
|
|
450
|
+
|
|
451
|
+
it('getEndpoint()', async () => {
|
|
452
|
+
// Spot check a a single endpoint for a single participant.
|
|
453
|
+
const result = await ParticipantService.getEndpoint(
|
|
454
|
+
'dfspd', Enum.EndPoints.FspEndpointTypes.FSPIOP_CALLBACK_URL_TRANSFER_PUT
|
|
455
|
+
)
|
|
456
|
+
Snapshot.from(`[
|
|
457
|
+
{
|
|
458
|
+
"participantEndpointId": 29,
|
|
459
|
+
"participantId": 5,
|
|
460
|
+
"endpointTypeId": 4,
|
|
461
|
+
"value": "http://localhost:1080/transfers/{{transferId}}",
|
|
462
|
+
"isActive": 1,
|
|
463
|
+
"createdDate": ":ignore",
|
|
464
|
+
"createdBy": "unknown",
|
|
465
|
+
"name": "FSPIOP_CALLBACK_URL_TRANSFER_PUT"
|
|
466
|
+
}
|
|
467
|
+
]`).checkUnwrap(result)
|
|
468
|
+
})
|
|
469
|
+
|
|
470
|
+
it('Gets no endpoint when the endpoint doesn\'t exist',
|
|
471
|
+
{ expectFailure: /participant not found/ },
|
|
472
|
+
async () => {
|
|
473
|
+
await ParticipantService.getEndpoint(
|
|
474
|
+
'dfsp_nope', Enum.EndPoints.FspEndpointTypes.FSPIOP_CALLBACK_URL_QUOTES
|
|
475
|
+
)
|
|
476
|
+
})
|
|
477
|
+
|
|
478
|
+
it('destroyParticipantEndpointByName() deletes an existing endpoint', async () => {
|
|
479
|
+
const name = 'tmp_dfsp_1'
|
|
480
|
+
// Create a new DFSP we can ignore in other tests
|
|
481
|
+
await createDfsp(harness, {
|
|
482
|
+
name,
|
|
483
|
+
currencies: ['USD'],
|
|
484
|
+
isProxy: false,
|
|
485
|
+
initialPostionsAndLimits: [{ initialPosition: 0, value: 100000 }],
|
|
486
|
+
deposits: [10000]
|
|
487
|
+
})
|
|
488
|
+
await ParticipantService.addEndpoint(name, {
|
|
489
|
+
type: Enum.EndPoints.FspEndpointTypes.FSPIOP_CALLBACK_URL_QUOTES,
|
|
490
|
+
value: `http://localhost:1080`
|
|
491
|
+
})
|
|
492
|
+
let result = await ParticipantService.getEndpoint(
|
|
493
|
+
name, Enum.EndPoints.FspEndpointTypes.FSPIOP_CALLBACK_URL_QUOTES
|
|
494
|
+
)
|
|
495
|
+
assert(result, 'Expected endpoint to exist')
|
|
496
|
+
assert.equal(result.length, 1, 'Expected dfsp to have exactly 1 endpoint.')
|
|
497
|
+
|
|
498
|
+
// Destroy endpoints.
|
|
499
|
+
result = await ParticipantService.destroyParticipantEndpointByName(name)
|
|
500
|
+
assert.equal(result, 1, 'Expected 1 endpoint to be deleted.')
|
|
501
|
+
|
|
502
|
+
// Check if it exists still.
|
|
503
|
+
result = await ParticipantService.getEndpoint(
|
|
504
|
+
name, Enum.EndPoints.FspEndpointTypes.FSPIOP_CALLBACK_URL_QUOTES
|
|
505
|
+
)
|
|
506
|
+
assert(Array.isArray(result), 'Expected result to be an array.')
|
|
507
|
+
assert.equal(result.length, 0, 'Expected dfsp to have exactly 0 endpoints.')
|
|
508
|
+
|
|
509
|
+
// Try and delete again!
|
|
510
|
+
result = await ParticipantService.destroyParticipantEndpointByName(name)
|
|
511
|
+
assert.equal(result, 0, 'Expected 0 endpoints to be deleted.')
|
|
512
|
+
})
|
|
513
|
+
|
|
514
|
+
// TODO: This fails with an SQL error. We should fix this in the next pass (after rewriting the
|
|
515
|
+
// integration tests).
|
|
516
|
+
it.skip('addLimitAndInitialPosition() when the dfsp does not exist', async () => {
|
|
517
|
+
const payload = {}
|
|
518
|
+
await ParticipantService.addLimitAndInitialPosition('nope_dsp', payload)
|
|
519
|
+
})
|
|
520
|
+
|
|
521
|
+
it('addLimitAndInitialPosition() for each dfsp', async () => {
|
|
522
|
+
for (const dfsp of dfsps) {
|
|
523
|
+
for (const currency of currencies) {
|
|
524
|
+
const payload = {
|
|
525
|
+
currency,
|
|
526
|
+
limit: {
|
|
527
|
+
type: 'NET_DEBIT_CAP',
|
|
528
|
+
value: 10000000
|
|
529
|
+
},
|
|
530
|
+
initialPosition: 0
|
|
531
|
+
}
|
|
532
|
+
const result = await ParticipantService.addLimitAndInitialPosition(dfsp, payload)
|
|
533
|
+
assert.equal(result, true)
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
// Now check the positions and limits for each dfsp (ignoring tmp_dfsp from other tests).
|
|
538
|
+
const positions = (await ParticipantService.getLimitsForAllParticipants({
|
|
539
|
+
currency: 'USD', type: 'NET_DEBIT_CAP'
|
|
540
|
+
})).filter((dfsp: any) => dfsp.name.match(/^dfsp.*/))
|
|
541
|
+
Snapshot.from(`[
|
|
542
|
+
{
|
|
543
|
+
"participantId": 2,
|
|
544
|
+
"name": "dfspa",
|
|
545
|
+
"description": null,
|
|
546
|
+
"isActive": 1,
|
|
547
|
+
"createdDate": ":ignore",
|
|
548
|
+
"createdBy": "unknown",
|
|
549
|
+
"isProxy": 0,
|
|
550
|
+
"participantCurrencyId": :ignore
|
|
551
|
+
"currencyId": "USD",
|
|
552
|
+
"ledgerAccountTypeId": 1,
|
|
553
|
+
"participantLimitId": :ignore
|
|
554
|
+
"participantLimitTypeId": 1,
|
|
555
|
+
"value": "10000000.0000",
|
|
556
|
+
"thresholdAlarmPercentage": "10.00",
|
|
557
|
+
"startAfterParticipantPositionChangeId": null,
|
|
558
|
+
"limitType": "NET_DEBIT_CAP"
|
|
559
|
+
},
|
|
560
|
+
{
|
|
561
|
+
"participantId": 3,
|
|
562
|
+
"name": "dfspb",
|
|
563
|
+
"description": null,
|
|
564
|
+
"isActive": 1,
|
|
565
|
+
"createdDate": ":ignore",
|
|
566
|
+
"createdBy": "unknown",
|
|
567
|
+
"isProxy": 0,
|
|
568
|
+
"participantCurrencyId": :ignore
|
|
569
|
+
"currencyId": "USD",
|
|
570
|
+
"ledgerAccountTypeId": 1,
|
|
571
|
+
"participantLimitId": :ignore
|
|
572
|
+
"participantLimitTypeId": 1,
|
|
573
|
+
"value": "10000000.0000",
|
|
574
|
+
"thresholdAlarmPercentage": "10.00",
|
|
575
|
+
"startAfterParticipantPositionChangeId": null,
|
|
576
|
+
"limitType": "NET_DEBIT_CAP"
|
|
577
|
+
},
|
|
578
|
+
{
|
|
579
|
+
"participantId": 4,
|
|
580
|
+
"name": "dfspc",
|
|
581
|
+
"description": null,
|
|
582
|
+
"isActive": 1,
|
|
583
|
+
"createdDate": ":ignore",
|
|
584
|
+
"createdBy": "unknown",
|
|
585
|
+
"isProxy": 0,
|
|
586
|
+
"participantCurrencyId": :ignore
|
|
587
|
+
"currencyId": "USD",
|
|
588
|
+
"ledgerAccountTypeId": 1,
|
|
589
|
+
"participantLimitId": :ignore
|
|
590
|
+
"participantLimitTypeId": 1,
|
|
591
|
+
"value": "10000000.0000",
|
|
592
|
+
"thresholdAlarmPercentage": "10.00",
|
|
593
|
+
"startAfterParticipantPositionChangeId": null,
|
|
594
|
+
"limitType": "NET_DEBIT_CAP"
|
|
595
|
+
},
|
|
596
|
+
{
|
|
597
|
+
"participantId": 5,
|
|
598
|
+
"name": "dfspd",
|
|
599
|
+
"description": null,
|
|
600
|
+
"isActive": 1,
|
|
601
|
+
"createdDate": ":ignore",
|
|
602
|
+
"createdBy": "unknown",
|
|
603
|
+
"isProxy": 1,
|
|
604
|
+
"participantCurrencyId": :ignore
|
|
605
|
+
"currencyId": "USD",
|
|
606
|
+
"ledgerAccountTypeId": 1,
|
|
607
|
+
"participantLimitId": :ignore
|
|
608
|
+
"participantLimitTypeId": 1,
|
|
609
|
+
"value": "10000000.0000",
|
|
610
|
+
"thresholdAlarmPercentage": "10.00",
|
|
611
|
+
"startAfterParticipantPositionChangeId": null,
|
|
612
|
+
"limitType": "NET_DEBIT_CAP"
|
|
613
|
+
}
|
|
614
|
+
]`).checkUnwrap(positions);
|
|
615
|
+
})
|
|
616
|
+
|
|
617
|
+
// TODO: This fails with an SQL error. We should fix this in the next pass (after rewriting the
|
|
618
|
+
// integration tests).
|
|
619
|
+
it.skip('addLimitAndInitialPosition() tries to set the position to negative',
|
|
620
|
+
{ expectFailure: /position must be >= 0/ },
|
|
621
|
+
async () => {
|
|
622
|
+
const name = 'dfsp_tmp_2'
|
|
623
|
+
// Create a new DFSP we can ignore in other tests
|
|
624
|
+
await createDfsp(harness, {
|
|
625
|
+
name,
|
|
626
|
+
currencies: ['USD'],
|
|
627
|
+
isProxy: false,
|
|
628
|
+
initialPostionsAndLimits: [{ initialPosition: 0, value: 100000 }],
|
|
629
|
+
deposits: [10000]
|
|
630
|
+
})
|
|
631
|
+
const payload = {
|
|
632
|
+
currency: 'USD',
|
|
633
|
+
limit: {
|
|
634
|
+
type: 'NET_DEBIT_CAP',
|
|
635
|
+
value: 10000000
|
|
636
|
+
},
|
|
637
|
+
initialPosition: -100
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
const result = await ParticipantService.addLimitAndInitialPosition(name, payload)
|
|
641
|
+
console.log(result);
|
|
642
|
+
})
|
|
643
|
+
|
|
644
|
+
it('adjustLimit() changes the limit', async () => {
|
|
645
|
+
const name = 'tmp_dfsp_3'
|
|
646
|
+
await createDfsp(harness, {
|
|
647
|
+
name,
|
|
648
|
+
currencies: ['USD'],
|
|
649
|
+
isProxy: false,
|
|
650
|
+
initialPostionsAndLimits: [{ initialPosition: 0, value: 100000 }],
|
|
651
|
+
deposits: [10000]
|
|
652
|
+
})
|
|
653
|
+
|
|
654
|
+
const result = await ParticipantService.adjustLimits(name, {
|
|
655
|
+
currency: 'USD',
|
|
656
|
+
limit: { type: 'NET_DEBIT_CAP', value: 9999 }
|
|
657
|
+
})
|
|
658
|
+
Snapshot.from(`{
|
|
659
|
+
"participantLimit": {
|
|
660
|
+
"participantCurrencyId": :ignore,
|
|
661
|
+
"participantLimitTypeId": 1,
|
|
662
|
+
"value": 9999,
|
|
663
|
+
"isActive": 1,
|
|
664
|
+
"createdBy": "unknown",
|
|
665
|
+
"participantLimitId": :ignore
|
|
666
|
+
}
|
|
667
|
+
}`).checkUnwrap(result);
|
|
668
|
+
|
|
669
|
+
// Get limit by currency.
|
|
670
|
+
const resultByCurrency = await ParticipantService.getLimits(name, { currency: 'USD' })
|
|
671
|
+
|
|
672
|
+
Snapshot.from(`[
|
|
673
|
+
{
|
|
674
|
+
"participantLimitId": :ignore,
|
|
675
|
+
"participantCurrencyId": 21,
|
|
676
|
+
"participantLimitTypeId": 1,
|
|
677
|
+
"value": "9999.0000",
|
|
678
|
+
"thresholdAlarmPercentage": "10.00",
|
|
679
|
+
"startAfterParticipantPositionChangeId": null,
|
|
680
|
+
"isActive": 1,
|
|
681
|
+
"createdDate": ":ignore",
|
|
682
|
+
"createdBy": "unknown",
|
|
683
|
+
"name": "NET_DEBIT_CAP"
|
|
684
|
+
}
|
|
685
|
+
]`).checkUnwrap(resultByCurrency);
|
|
686
|
+
|
|
687
|
+
// Get limit by type.
|
|
688
|
+
const resultByType = await ParticipantService.getLimits(name, { type: 'NET_DEBIT_CAP' })
|
|
689
|
+
Snapshot.from(`[
|
|
690
|
+
{
|
|
691
|
+
"participantLimitId": :ignore,
|
|
692
|
+
"participantCurrencyId": 21,
|
|
693
|
+
"participantLimitTypeId": 1,
|
|
694
|
+
"value": "9999.0000",
|
|
695
|
+
"thresholdAlarmPercentage": "10.00",
|
|
696
|
+
"startAfterParticipantPositionChangeId": null,
|
|
697
|
+
"isActive": 1,
|
|
698
|
+
"createdDate": ":ignore",
|
|
699
|
+
"createdBy": "unknown",
|
|
700
|
+
"name": "NET_DEBIT_CAP",
|
|
701
|
+
"currencyId": "USD"
|
|
702
|
+
}
|
|
703
|
+
]`).checkUnwrap(resultByType);
|
|
704
|
+
})
|
|
705
|
+
|
|
706
|
+
it('getPositions() ', async () => {
|
|
707
|
+
const name = 'tmp_dfsp_4'
|
|
708
|
+
await createDfsp(harness, {
|
|
709
|
+
name,
|
|
710
|
+
currencies: ['USD'],
|
|
711
|
+
isProxy: false,
|
|
712
|
+
initialPostionsAndLimits: [{ initialPosition: 0, value: 100000 }],
|
|
713
|
+
deposits: [10000]
|
|
714
|
+
})
|
|
715
|
+
const response = await ParticipantService.getPositions(name, {
|
|
716
|
+
currency: 'USD'
|
|
717
|
+
})
|
|
718
|
+
Snapshot.from(`{
|
|
719
|
+
"currency": "USD",
|
|
720
|
+
"value": "0.0000",
|
|
721
|
+
"changedDate": ":ignore"
|
|
722
|
+
}`).checkUnwrap(response)
|
|
723
|
+
})
|
|
724
|
+
})
|