-
Notifications
You must be signed in to change notification settings - Fork 91
Expand file tree
/
Copy pathindex.js
More file actions
737 lines (687 loc) · 24.8 KB
/
Copy pathindex.js
File metadata and controls
737 lines (687 loc) · 24.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
/*****
License
--------------
Copyright © 2017 Bill & Melinda Gates Foundation
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
http://www.apache.org/licenses/LICENSE-2.0
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.
Contributors
--------------
This is the official list of the Mojaloop project contributors for this file.
Names of the original copyright holders (individuals or organizations)
should be listed with a '*' in the first column. People who have
contributed from an organization can be listed under the organization
that actually holds the copyright for their contributions (see the
Gates Foundation organization for an example). Those individuals should have
their names indented and be marked with a '-'. Email address can be added
optionally within square brackets <email>.
* Gates Foundation
- Name Surname <name.surname@gatesfoundation.com>
* Georgi Georgiev <georgi.georgiev@modusbox.com>
--------------
******/
'use strict'
/**
* @module src/domain/participant/
*/
const ParticipantModel = require('../../models/participant/participant')
const ParticipantCurrencyModel = require('../../models/participant/participantCurrency')
const ParticipantPositionModel = require('../../models/participant/participantPosition')
const ParticipantPositionChangeModel = require('../../models/participant/participantPositionChange')
const ParticipantLimitModel = require('../../models/participant/participantLimit')
const LedgerAccountTypeModel = require('../../models/ledgerAccountType/ledgerAccountType')
const ParticipantFacade = require('../../models/participant/facade')
const PositionFacade = require('../../models/position/facade')
const Config = require('../../lib/config')
const Utility = require('../../handlers/lib/utility')
const Uuid = require('uuid4')
const Enum = require('../../lib/enum')
const TransferEventType = Enum.transferEventType
const TransferEventAction = Enum.transferEventAction
const create = async (payload) => {
try {
const participant = await ParticipantModel.create({ name: payload.name })
if (!participant) throw new Error('Something went wrong. Participant cannot be created')
return participant
} catch (err) {
throw err
}
}
const getAll = async () => {
try {
let all = await ParticipantModel.getAll()
await Promise.all(all.map(async (participant) => {
participant.currencyList = await ParticipantCurrencyModel.getByParticipantId(participant.participantId)
}))
return all
} catch (err) {
throw new Error(err.message)
}
}
const getById = async (id) => {
let participant = await ParticipantModel.getById(id)
if (participant) {
participant.currencyList = await ParticipantCurrencyModel.getByParticipantId(participant.participantId)
}
return participant
}
const getByName = async (name) => {
let participant = await ParticipantModel.getByName(name)
if (participant) {
participant.currencyList = await ParticipantCurrencyModel.getByParticipantId(participant.participantId)
}
return participant
}
const participantExists = (participant) => {
if (participant) {
return participant
}
throw new Error('Participant does not exist')
}
const update = async (name, payload) => {
try {
const participant = await ParticipantModel.getByName(name)
participantExists(participant)
await ParticipantModel.update(participant, payload.isActive)
participant.isActive = +payload.isActive
participant.currencyList = await ParticipantCurrencyModel.getByParticipantId(participant.participantId)
return participant
} catch (err) {
throw err
}
}
const createParticipantCurrency = async (participantId, currencyId, ledgerAccountTypeId, isActive = true) => {
try {
const participantCurrency = await ParticipantCurrencyModel.create(participantId, currencyId, ledgerAccountTypeId, isActive)
return participantCurrency
} catch (err) {
throw err
}
}
const createHubAccount = async (participantId, currencyId, ledgerAccountTypeId) => {
try {
const participantCurrency = await ParticipantFacade.addHubAccountAndInitPosition(participantId, currencyId, ledgerAccountTypeId)
return participantCurrency
} catch (err) {
throw err
}
}
const getParticipantCurrencyById = async (participantCurrencyId) => {
try {
return await ParticipantCurrencyModel.getById(participantCurrencyId)
} catch (err) {
throw err
}
}
const destroyByName = async (name) => {
try {
let participant = await ParticipantModel.getByName(name)
await ParticipantLimitModel.destroyByParticipantId(participant.participantId)
await ParticipantPositionModel.destroyByParticipantId(participant.participantId)
await ParticipantCurrencyModel.destroyByParticipantId(participant.participantId)
return await ParticipantModel.destroyByName(name)
} catch (err) {
throw new Error(err.message)
}
}
/**
* @function AddEndpoint
*
* @async
* @description This adds the endpoint details for a participant
*
* ParticipantModel.getByName called to get the participant details from the participant name
* ParticipantFacade.addEndpoint called to add the participant endpoint details
*
* @param {string} name - the name of the participant. Example 'dfsp1'
* @param {object} payload - the payload containing 'type' and 'value' of the endpoint.
* Example: {
* "type": "FSPIOP_CALLBACK_URL_TRANSFER_POST",
* "value": "http://localhost:3001/participants/dfsp1/notification12"
* }
* @returns {integer} - Returns number of database rows affected if successful, or throws an error if failed
*/
const addEndpoint = async (name, payload) => {
try {
const participant = await ParticipantModel.getByName(name)
participantExists(participant)
return ParticipantFacade.addEndpoint(participant.participantId, payload)
} catch (err) {
throw err
}
}
/**
* @function GetEndpoint
*
* @async
* @description This retuns the active endpoint value for a give participant and type of endpoint
*
* ParticipantModel.getByName called to get the participant details from the participant name
* ParticipantFacade.getEndpoint called to get the participant endpoint details
*
* @param {string} name - the name of the participant. Example 'dfsp1'
* @param {string} type - the type of the endpoint. Example 'FSPIOP_CALLBACK_URL_TRANSFER_POST'
*
* @returns {array} - Returns participantEndpoint array containing the details of active endpoint for the participant if successful, or throws an error if failed
*/
const getEndpoint = async (name, type) => {
try {
const participant = await ParticipantModel.getByName(name)
participantExists(participant)
const participantEndpoint = await ParticipantFacade.getEndpoint(participant.participantId, type)
return participantEndpoint
} catch (err) {
throw err
}
}
/**
* @function GetAllEndpoints
*
* @async
* @description This retuns all the active endpoints for a give participant
*
* ParticipantModel.getByName called to get the participant details from the participant name
* ParticipantFacade.getAllEndpoints called to get the participant endpoint details
*
* @param {string} name - the name of the participant. Example 'dfsp1'
*
* @returns {array} - Returns participantEndpoint array containing the list of all active endpoints for the participant if successful, or throws an error if failed
*/
const getAllEndpoints = async (name) => {
try {
const participant = await ParticipantModel.getByName(name)
participantExists(participant)
const participantEndpoints = await ParticipantFacade.getAllEndpoints(participant.participantId)
return participantEndpoints
} catch (err) {
throw err
}
}
/**
* @function DestroyPariticpantEndpointByName
*
* @async
* @description This functions deletes the existing endpoints for a given participant name
* else, it will throw and error
*
* @param {string} name - participant name
*
* @returns {integer} - Returns the number of rows deleted if successful, or throws an error if failed
*/
const destroyPariticpantEndpointByName = async (name) => {
try {
const participant = await ParticipantModel.getByName(name)
participantExists(participant)
return ParticipantModel.destroyPariticpantEndpointByParticipantId(participant.participantId)
} catch (err) {
throw err
}
}
/**
* @function addLimitAndInitialPosition
*
* @async
* @description This creates the initial position and limits for a participant
*
* ParticipantFacade.getByNameAndCurrency called to get the participant and currency details from the participant name
* ParticipantFacade.addLimitAndInitialPosition called to add the participant initial postion and limits
*
* @param {string} name - the name of the participant. Example 'dfsp1'
* @param {object} limitAndInitialPositionObj - the payload containing the currency, limit and initial postion values
* Example: {
* "currency": "USD",
* "limit": {
* "type": "NET_DEBIT_CAP",
* "value": 10000000
* },
* "initialPosition": 0
* }
*
* @returns {integer} - Returns number of database rows affected if successful, or throws an error if failed
*/
const addLimitAndInitialPosition = async (participantName, limitAndInitialPositionObj) => {
try {
const participant = await ParticipantFacade.getByNameAndCurrency(participantName, limitAndInitialPositionObj.currency, Enum.LedgerAccountType.POSITION, false)
participantExists(participant)
const settlementAccount = await ParticipantFacade.getByNameAndCurrency(participantName, limitAndInitialPositionObj.currency, Enum.LedgerAccountType.SETTLEMENT, false)
const existingLimit = await ParticipantLimitModel.getByParticipantCurrencyId(participant.participantCurrencyId)
const existingPosition = await ParticipantPositionModel.getByParticipantCurrencyId(participant.participantCurrencyId)
const existingSettlementPosition = await ParticipantPositionModel.getByParticipantCurrencyId(settlementAccount.participantCurrencyId)
if (existingLimit || existingPosition || existingSettlementPosition) {
throw new Error('Participant Limit or Initial Position already set')
}
let limitAndInitialPosition = limitAndInitialPositionObj
if (limitAndInitialPosition.initialPosition == null) {
limitAndInitialPosition.initialPosition = Config.PARTICIPANT_INITIAL_POSTITION
}
return ParticipantFacade.addLimitAndInitialPosition(participant.participantCurrencyId, settlementAccount.participantCurrencyId, limitAndInitialPosition, true)
} catch (err) {
throw err
}
}
/**
* @function getPositionByParticipantCurrencyId
*
* @async
* @description This returns the participant position corresponding to the participantCurrencyId
*
*
* @param {integer} participantCurrencyId - the participant currency id. Example: 1
*
* @returns {object} - Returns the row from participantPosition table if successful, or throws an error if failed
*/
const getPositionByParticipantCurrencyId = async (participantCurrencyId) => {
try {
return ParticipantPositionModel.getByParticipantCurrencyId(participantCurrencyId)
} catch (err) {
throw err
}
}
/**
* @function getPositionChangeByParticipantPositionId
*
* @async
* @description This returns the last participant position change for given participantPositionId
*
*
* @param {integer} participantPositionId - the participant position id. Example: 1
*
* @returns {object} - Returns the row from participantPositionChange table if successful, or throws an error if failed
*/
const getPositionChangeByParticipantPositionId = async (participantPositionId) => {
try {
return ParticipantPositionChangeModel.getByParticipantPositionId(participantPositionId)
} catch (err) {
throw err
}
}
/**
* @function DestroyParticipantPositionByNameAndCurrency
*
* @async
* @description This functions deletes the existing position for a given participant name
* else, it will throw and error
*
* @param {string} name - participant name
*
* @returns {integer} - Returns the number of rows deleted if successful, or throws an error if failed
*/
const destroyParticipantPositionByNameAndCurrency = async (name, currencyId) => {
try {
const participant = await ParticipantFacade.getByNameAndCurrency(name, currencyId, Enum.LedgerAccountType.POSITION)
participantExists(participant)
return ParticipantPositionModel.destroyByParticipantCurrencyId(participant.participantCurrencyId)
} catch (err) {
throw err
}
}
/**
* @function DestroyParticipantLimitByNameAndCurrency
*
* @async
* @description This functions deletes the existing limits for a given participant name
* else, it will throw and error
*
* @param {string} name - participant name
* @param {string} currencyId - participant currency
*
* @returns {integer} - Returns the number of rows deleted if successful, or throws an error if failed
*/
const destroyParticipantLimitByNameAndCurrency = async (name, currencyId) => {
try {
const participant = await ParticipantFacade.getByNameAndCurrency(name, currencyId, Enum.LedgerAccountType.POSITION)
participantExists(participant)
return ParticipantLimitModel.destroyByParticipantCurrencyId(participant.participantCurrencyId)
} catch (err) {
throw err
}
}
/**
* @function GetLimits
*
* @async
* @description This retuns the active endpoint value for a give participant and type of endpoint
*
* ParticipantFacade.getByNameAndCurrency called to get the participant and currency details from the participant name
* ParticipantModel.getByName called to get the participant details from the participant name
* ParticipantFacade.getParticipantLimitsByCurrencyId called to get the participant limit details from participant currency id
* ParticipantFacade.getParticipantLimitsByParticipantId called to get the participant limit details from participant id
*
* @param {string} name - the name of the participant. Example 'dfsp1'
* @param {string} type - the type of the endpoint. Example 'FSPIOP_CALLBACK_URL_TRANSFER_POST'
*
* @returns {array} - Returns participantEndpoint array containing the details of active endpoint for the participant if successful, or throws an error if failed
*/
const getLimits = async (name, { currency = null, type = null }) => {
try {
let participant
if (currency != null) {
participant = await ParticipantFacade.getByNameAndCurrency(name, currency, Enum.LedgerAccountType.POSITION)
participantExists(participant)
return ParticipantFacade.getParticipantLimitsByCurrencyId(participant.participantCurrencyId, type)
} else {
participant = await ParticipantModel.getByName(name)
participantExists(participant)
return ParticipantFacade.getParticipantLimitsByParticipantId(participant.participantId, type, Enum.LedgerAccountType.POSITION)
}
} catch (err) {
throw err
}
}
/**
* @function GetLimitsForAllParticipants
*
* @async
* @description This retuns the active limits value for all the participants for the currency and type combinations
*
* ParticipantFacade.getLimitsForAllParticipants called to get the participant limit details from participant id
*
* @param {string} currency - the currency id. Example USD
* @param {string} type - the type of the limit. Example 'NET_DEBIT_CAP'
*
* @returns {array} - Returns an array containing the details of active limits for all the participants if successful, or throws an error if failed
*/
const getLimitsForAllParticipants = async ({ currency = null, type = null }) => {
try {
return ParticipantFacade.getLimitsForAllParticipants(currency, type, Enum.LedgerAccountType.POSITION)
} catch (err) {
throw err
}
}
/**
* @function AdjustLimits
*
* @async
* @description This adds/updates limits for a participant
*
* ParticipantFacade.getByNameAndCurrency called to get the participant details from the participant name
* ParticipantFacade.adjustLimits called to add/update the participant limits
*
* @param {string} name - the name of the participant. Example 'dfsp1'
* @param {object} payload - the payload containing the currency and limit values
* Example: {
* "currency": "USD",
* "limit": {
* "type": "NET_DEBIT_CAP",
* "value": 10000000
* }
* }
*
* @returns {integer} - Returns number of database rows affected if successful, or throws an error if failed
*/
// {
// "currency": "USD",
// "limit": {
// "type": "NET_DEBIT_CAP",
// "value": 1500,
// "thresholdAlarmPercentage": 10
// }
// }
const adjustLimits = async (name, payload) => {
try {
let { limit, currency } = payload
payload.name = name
const participant = await ParticipantFacade.getByNameAndCurrency(name, currency, Enum.LedgerAccountType.POSITION)
participantExists(participant)
let result = await ParticipantFacade.adjustLimits(participant.participantCurrencyId, limit)
await Utility.produceGeneralMessage(TransferEventType.NOTIFICATION, TransferEventAction.EVENT, createLimitAdjustmentMessageProtocol(payload), Utility.ENUMS.STATE.SUCCESS)
return result
} catch (err) {
throw err
}
}
const createLimitAdjustmentMessageProtocol = (payload, action = 'limitAdjustment', state = '', pp = '') => {
return {
id: Uuid(),
from: payload.name,
to: 'SYSTEM',
type: 'application/json',
content: {
header: {},
payload
},
metadata: {
event: {
id: Uuid(),
responseTo: '',
type: 'notification',
action,
createdAt: new Date(),
state
}
},
pp
}
}
/**
* @function GetPositions
*
* @async
* @description This return the current position value for a participant/currency
*
* PositionFacade.getByNameAndCurrency called to get the participant position value from the participant name and currency if passed
*
* @param {string} name - the name of the participant. Example 'dfsp1'
* @param {object} query -Optional query object containing the currency value
* Example: {
* "currency": "USD"
* }
*
* @returns {object/array} - This returns and object or array depending on the following conditions
* 1. If the currency is passed as a param, Returns and object containing the current, value and updatedTime of the position, if found, if not found it returns an empty object {}
* e.g
* ```
* {
"currency": "USD",
"value": 0,
"updatedTime": "2018-08-14T04:01:55.000Z"
}
```
* 2. if the currency object is not passed, then it return an array containig the above mentioned objects for all the currencies defined for that participant.
* If no position is found then an empty array is returned.
* e.g.
* ```
[
{
"currency": "USD",
"value": 0,
"updatedTime": "2018-08-14T04:01:55.000Z"
},
{
"currency": "EUR",
"value": 200,
"updatedTime": "2018-08-14T15:15:44.000Z"
},
]
```
*/
const getPositions = async (name, query) => {
try {
if (query.currency) {
const participant = await ParticipantFacade.getByNameAndCurrency(name, query.currency, Enum.LedgerAccountType.POSITION)
participantExists(participant)
const result = await PositionFacade.getByNameAndCurrency(name, Enum.LedgerAccountType.POSITION, query.currency, Enum.LedgerAccountType.POSITION)
let position = {}
if (Array.isArray(result) && result.length > 0) {
position = {
currency: result[0].currencyId,
value: result[0].value,
changedDate: result[0].changedDate
}
}
return position
} else {
const participant = await ParticipantModel.getByName(name)
participantExists(participant)
const result = await await PositionFacade.getByNameAndCurrency(name, Enum.LedgerAccountType.POSITION)
let positions = []
if (Array.isArray(result) && result.length > 0) {
result.forEach(item => {
positions.push({
currency: item.currencyId,
value: item.value,
changedDate: item.changedDate
})
})
}
return positions
}
} catch (err) {
throw err
}
}
const getAccounts = async (name, query) => {
try {
const participant = await ParticipantModel.getByName(name)
participantExists(participant)
const result = await PositionFacade.getAllByNameAndCurrency(name, query.currency)
let positions = []
if (Array.isArray(result) && result.length > 0) {
result.forEach(item => {
positions.push({
id: item.participantCurrencyId,
ledgerAccountType: item.ledgerAccountType,
currency: item.currencyId,
isActive: item.isActive,
value: item.value,
reservedValue: item.reservedValue,
changedDate: item.changedDate
})
})
}
return positions
} catch (err) {
throw err
}
}
const updateAccount = async (payload, params, enums) => {
try {
let { name, id } = params
const participant = await ParticipantModel.getByName(name)
participantExists(participant)
const account = await ParticipantCurrencyModel.getById(id)
if (!account) {
throw new Error('Account not found')
} else if (account.participantId !== participant.participantId) {
throw new Error('Participant/account mismatch')
} else if (account.ledgerAccountTypeId !== enums.ledgerAccountType.POSITION) {
throw new Error('Only position account update is permitted')
}
return await ParticipantCurrencyModel.update(id, payload.isActive)
} catch (err) {
throw err
}
}
const getLedgerAccountTypeName = async (name) => {
try {
return await LedgerAccountTypeModel.getLedgerAccountByName(name)
} catch (err) {
throw err
}
}
const getParticipantAccount = async (accountParams) => {
try {
return await ParticipantCurrencyModel.getByName(accountParams)
} catch (err) {
throw err
}
}
const createRecordFundsMessageProtocol = (payload, action = '', state = '', pp = '') => {
return {
id: payload.transferId,
from: payload.payerFsp,
to: payload.payeeFsp,
type: 'application/json',
content: {
header: {},
payload
},
metadata: {
event: {
id: Uuid(),
responseTo: '',
type: 'transfer',
action,
createdAt: new Date(),
state
}
},
pp
}
}
const setPayerPayeeFundsInOut = (fspName, payload, enums) => {
let { action } = payload
const actions = {
'recordFundsIn': {
payer: fspName,
payee: enums.hubParticipant.name
},
'recordFundsOutPrepareReserve': {
payer: enums.hubParticipant.name,
payee: fspName
},
'recordFundsOutCommit': {
payer: enums.hubParticipant.name,
payee: fspName
},
'recordFundsOutAbort': {
payer: enums.hubParticipant.name,
payee: fspName
}
}
if (!actions[action]) throw new Error('The action is not supported')
return Object.assign(payload, actions[action])
}
const recordFundsInOut = async (payload, params, enums) => {
try {
let { name, id, transferId } = params
const participant = await ParticipantModel.getByName(name)
const currency = payload.amount && payload.amount.currency
participantExists(participant)
const accounts = await ParticipantFacade.getAllAccountsByNameAndCurrency(name, currency || null)
let accountMatched = accounts[accounts.map(account => account.participantCurrencyId).findIndex(i => i === id)]
if (!(accountMatched && accountMatched.ledgerAccountTypeId === enums.ledgerAccountType.SETTLEMENT)) {
throw new Error('Account id is not SETTLEMENT type or currency of the account does not match the currency requested')
}
transferId && (payload.transferId = transferId)
let messageProtocol = createRecordFundsMessageProtocol(setPayerPayeeFundsInOut(name, payload, enums))
messageProtocol.metadata.request = {
params: params,
enums: enums
}
return await Utility.produceGeneralMessage(TransferEventType.ADMIN, TransferEventAction.TRANSFER, messageProtocol, Utility.ENUMS.STATE.SUCCESS)
} catch (err) {
throw err
}
}
module.exports = {
create,
getAll,
getById,
getByName,
getLedgerAccountTypeName,
update,
createParticipantCurrency,
createHubAccount,
getParticipantCurrencyById,
destroyByName,
addEndpoint,
getEndpoint,
getAllEndpoints,
destroyPariticpantEndpointByName,
addLimitAndInitialPosition,
getPositionByParticipantCurrencyId,
getPositionChangeByParticipantPositionId,
destroyParticipantPositionByNameAndCurrency,
destroyParticipantLimitByNameAndCurrency,
getLimits,
adjustLimits,
getPositions,
getAccounts,
updateAccount,
getParticipantAccount,
recordFundsInOut,
getAccountByNameAndCurrency: ParticipantFacade.getByNameAndCurrency,
hubAccountExists: ParticipantCurrencyModel.hubAccountExists,
getLimitsForAllParticipants
}