2019-05-08 16:12:02 +03:00
|
|
|
require('dotenv').config()
|
|
|
|
const eventsInfo = require('./utils/events')
|
2019-10-29 22:22:02 +03:00
|
|
|
const { processedMsgNotDelivered, deliveredMsgNotProcessed, eventWithoutReference } = require('./utils/message')
|
2019-09-18 22:45:13 +03:00
|
|
|
const { BRIDGE_MODES } = require('../commons')
|
2019-05-08 16:12:02 +03:00
|
|
|
|
|
|
|
async function main() {
|
2019-09-18 22:45:13 +03:00
|
|
|
const {
|
|
|
|
homeToForeignRequests,
|
|
|
|
homeToForeignConfirmations,
|
|
|
|
foreignToHomeConfirmations,
|
|
|
|
foreignToHomeRequests,
|
|
|
|
bridgeMode
|
|
|
|
} = await eventsInfo()
|
2019-05-08 16:12:02 +03:00
|
|
|
|
2019-09-18 22:45:13 +03:00
|
|
|
if (bridgeMode === BRIDGE_MODES.ARBITRARY_MESSAGE) {
|
|
|
|
return {
|
|
|
|
home: {
|
|
|
|
deliveredMsgNotProcessedInForeign: homeToForeignRequests.filter(
|
|
|
|
deliveredMsgNotProcessed(homeToForeignConfirmations)
|
|
|
|
),
|
|
|
|
processedMsgNotDeliveredInForeign: foreignToHomeConfirmations.filter(
|
|
|
|
processedMsgNotDelivered(foreignToHomeRequests)
|
|
|
|
)
|
|
|
|
},
|
|
|
|
foreign: {
|
|
|
|
deliveredMsgNotProcessedInHome: foreignToHomeRequests.filter(
|
|
|
|
deliveredMsgNotProcessed(foreignToHomeConfirmations)
|
|
|
|
),
|
|
|
|
processedMsgNotDeliveredInHome: homeToForeignConfirmations.filter(
|
|
|
|
processedMsgNotDelivered(homeToForeignRequests)
|
|
|
|
)
|
|
|
|
},
|
|
|
|
lastChecked: Math.floor(Date.now() / 1000)
|
|
|
|
}
|
|
|
|
} else {
|
2019-10-29 22:22:02 +03:00
|
|
|
const onlyInHomeDeposits = homeToForeignRequests.filter(eventWithoutReference(homeToForeignConfirmations))
|
|
|
|
const onlyInForeignDeposits = homeToForeignConfirmations.filter(eventWithoutReference(homeToForeignRequests))
|
2019-05-08 16:12:02 +03:00
|
|
|
|
2019-10-29 22:22:02 +03:00
|
|
|
const onlyInHomeWithdrawals = foreignToHomeConfirmations.filter(eventWithoutReference(foreignToHomeRequests))
|
|
|
|
const onlyInForeignWithdrawals = foreignToHomeRequests.filter(eventWithoutReference(foreignToHomeConfirmations))
|
2019-05-08 16:12:02 +03:00
|
|
|
|
2019-09-18 22:45:13 +03:00
|
|
|
return {
|
|
|
|
onlyInHomeDeposits,
|
|
|
|
onlyInForeignDeposits,
|
|
|
|
onlyInHomeWithdrawals,
|
|
|
|
onlyInForeignWithdrawals,
|
|
|
|
lastChecked: Math.floor(Date.now() / 1000)
|
|
|
|
}
|
2019-05-08 16:12:02 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = main
|