Skip to content

Commit

Permalink
feat(mojaloop/#2801): add fulfil timestamp validation and more error …
Browse files Browse the repository at this point in the history
…handling (#916)

* feat: add fulfil timestamp validation and more error handling

* chore: space

* chore(snapshot): 15.3.0-snapshot.0

* chore: change

* chore(snapshot): 15.3.0-snapshot.1

* chore: add error

* chore(snapshot): 15.3.0-snapshot.2

* chore: use enumeration for INVALID bulk transfers

* chore: dep

* chore: add case to handle payer callback

* chore: update

* chore: changes

* chore: revert

* chore: diff

* chore: todo

* chore: changes

* chore: update

* chore: dep

* chore: address comments and dep

* chore: lock

* chore: validator tests

* chore: enum
  • Loading branch information
kleyow authored Aug 15, 2022
1 parent e244b7b commit 336a0a2
Show file tree
Hide file tree
Showing 16 changed files with 427 additions and 111 deletions.
1 change: 1 addition & 0 deletions config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"CREATE_RETRY_INTERVAL_MILLIS": 200,
"DEBUG": false
},
"MAX_FULFIL_TIMEOUT_DURATION_SECONDS": 300,
"MIGRATIONS": {
"DISABLED": false,
"RUN_DATA_MIGRATIONS": true
Expand Down
68 changes: 14 additions & 54 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"@mojaloop/central-services-health": "14.0.1",
"@mojaloop/central-services-logger": "11.0.1",
"@mojaloop/central-services-metrics": "12.0.5",
"@mojaloop/central-services-shared": "17.2.0",
"@mojaloop/central-services-shared": "17.3.0",
"@mojaloop/central-services-stream": "11.0.0",
"@mojaloop/event-sdk": "11.0.2",
"@mojaloop/ml-number": "11.2.1",
Expand All @@ -98,7 +98,7 @@
"catbox-memory": "4.0.1",
"commander": "9.4.0",
"cron": "2.1.0",
"decimal.js": "10.3.1",
"decimal.js": "10.4.0",
"docdash": "1.2.0",
"event-stream": "4.0.1",
"five-bells-condition": "5.0.1",
Expand Down
15 changes: 15 additions & 0 deletions seeds/bulkProcessingState.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,44 +27,59 @@

const bulkProcessingStates = [
{
bulkProcessingStateId: 1,
name: 'RECEIVED',
description: 'The switch has received the individual transfer ids part of the bulk transfer'
},
{
bulkProcessingStateId: 2,
name: 'RECEIVED_DUPLICATE',
description: 'The switch has matched individual transfer as duplicate'
},
{
bulkProcessingStateId: 3,
name: 'RECEIVED_INVALID',
description: 'The switch has matched individual transfer as invalid within Prepare or Position Handler'
},
{
bulkProcessingStateId: 4,
name: 'ACCEPTED',
description: 'The switch has reserved the funds for the transfers in the bulk'
},
{
bulkProcessingStateId: 5,
name: 'PROCESSING',
description: 'Fulfilment request has been received for the individual transfer'
},
{
bulkProcessingStateId: 6,
name: 'FULFIL_DUPLICATE',
description: 'The switch has matched individual transfer fulfil as duplicate'
},
{
bulkProcessingStateId: 7,
name: 'FULFIL_INVALID',
description: 'The switch has matched individual transfer fulfilment as invalid within Fulfil or Position Handler'
},
{
bulkProcessingStateId: 8,
name: 'COMPLETED',
description: 'The switch has marked the individual transfer as committed'
},
{
bulkProcessingStateId: 9,
name: 'REJECTED',
description: 'The switch has marked the individual transfer as rejected'
},
{
bulkProcessingStateId: 10,
name: 'EXPIRED',
description: 'The switch has marked the individual transfer as timed out'
},
{
bulkProcessingStateId: 11,
name: 'ABORTING',
description: 'The switch has marked the individual transfer as aborting due to failed validation'
}
]

Expand Down
5 changes: 5 additions & 0 deletions seeds/bulkTransferState.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ const bulkTransferStates = [
bulkTransferStateId: 'INVALID',
enumeration: 'REJECTED',
description: 'Final state when the switch has completed processing of pending invalid bulk transfer'
},
{
bulkTransferStateId: 'ABORTING',
enumeration: 'PROCESSING',
description: 'The switch is attempting to abort all individual transfers'
}
]

Expand Down
13 changes: 12 additions & 1 deletion src/domain/bulkTransfer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ const getBulkTransferById = async (id) => {
expiration: bulkTransfer.expirationDate,
completedDate: bulkTransfer.completedTimestamp,
payerBulkTransfer,
payeeBulkTransfer
payeeBulkTransfer,
bulkTransferStateEnumeration: bulkTransfer.bulkTransferStateEnumeration
}
} catch (err) {
Logger.isErrorEnabled && Logger.error(err)
Expand Down Expand Up @@ -162,9 +163,19 @@ const getBulkTransferExtensionListById = async (id, completedTimestamp) => {
}
}

const bulkFulfilTransitionToAborting = async (bulkFulfilPayload, stateReason = null) => {
try {
BulkTransferFacade.saveBulkTransferAborting(bulkFulfilPayload, stateReason)
} catch (err) {
Logger.isErrorEnabled && Logger.error(err)
throw err
}
}

const BulkTransferService = {
getBulkTransferById,
getBulkTransferExtensionListById,
bulkFulfilTransitionToAborting,
getBulkTransferByTransferId: BulkTransferModel.getByTransferId,
getParticipantsById: BulkTransferModel.getParticipantsById,
bulkPrepare: BulkTransferFacade.saveBulkTransferReceived,
Expand Down
Loading

0 comments on commit 336a0a2

Please sign in to comment.