remove withdrawal event listeners

This commit is contained in:
keyan 2021-08-19 14:53:38 -05:00
parent 099a578a1b
commit 81d5647cd9
1 changed files with 8 additions and 2 deletions

View File

@ -123,8 +123,11 @@ export default {
}) })
// if it's confirmed, update confirmed returning extra fees to user // if it's confirmed, update confirmed returning extra fees to user
sub.on('confirmed', async e => { sub.once('confirmed', async e => {
console.log(e) console.log(e)
sub.removeAllListeners()
// mtokens also contains the fee // mtokens also contains the fee
const fee = Number(e.fee_mtokens) const fee = Number(e.fee_mtokens)
const paid = Number(e.mtokens) - fee const paid = Number(e.mtokens) - fee
@ -135,8 +138,11 @@ export default {
// if the payment fails, we need to // if the payment fails, we need to
// 1. return the funds to the user // 1. return the funds to the user
// 2. update the widthdrawl as failed // 2. update the widthdrawl as failed
sub.on('failed', async e => { sub.once('failed', async e => {
console.log(e) console.log(e)
sub.removeAllListeners()
let status = 'UNKNOWN_FAILURE' let status = 'UNKNOWN_FAILURE'
if (e.is_insufficient_balance) { if (e.is_insufficient_balance) {
status = 'INSUFFICIENT_BALANCE' status = 'INSUFFICIENT_BALANCE'