Improve Order Expired behaviour

This commit is contained in:
Reckless_Satoshi 2022-01-18 07:45:04 -08:00
parent c58070f437
commit ad6ee9d4de
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
3 changed files with 22 additions and 26 deletions

View File

@ -125,16 +125,12 @@ class Logics():
elif order.status == Order.Status.WFB:
order.status = Order.Status.EXP
cls.cancel_bond(order.maker_bond)
order.maker = None # TODO with the new validate_already_maker_taker there is no need to kick out participants on expired orders.
order.taker = None
order.save()
return True
elif order.status == Order.Status.PUB:
cls.return_bond(order.maker_bond)
order.status = Order.Status.EXP
order.maker = None
order.taker = None
order.save()
return True
@ -153,8 +149,6 @@ class Logics():
cls.settle_bond(order.taker_bond)
cls.cancel_escrow(order)
order.status = Order.Status.EXP
order.maker = None
order.taker = None
order.save()
return True
@ -166,8 +160,6 @@ class Logics():
cls.return_bond(order.taker_bond)
cls.cancel_escrow(order)
order.status = Order.Status.EXP
order.maker = None
order.taker = None
order.save()
return True
@ -192,8 +184,6 @@ class Logics():
cls.return_bond(order.taker_bond)
cls.return_escrow(order)
order.status = Order.Status.EXP
order.maker = None
order.taker = None
order.save()
return True
@ -369,7 +359,6 @@ class Logics():
'''The order never shows up on the book and order
status becomes "cancelled". That's it.'''
if order.status == Order.Status.WFB and order.maker == user:
order.maker = None
order.status = Order.Status.UCA
order.save()
return True, None
@ -380,7 +369,6 @@ class Logics():
elif order.status == Order.Status.PUB and order.maker == user:
#Settle the maker bond (Maker loses the bond for cancelling public order)
if cls.settle_bond(order.maker_bond):
order.maker = None
order.status = Order.Status.UCA
order.save()
return True, None
@ -405,7 +393,6 @@ class Logics():
#Settle the maker bond (Maker loses the bond for canceling an ongoing trade)
valid = cls.settle_bond(order.maker_bond)
if valid:
order.maker = None
order.status = Order.Status.UCA
order.save()
return True, None

View File

@ -95,10 +95,6 @@ class OrderView(viewsets.ViewSet):
# This is our order.
order = order[0]
# 1) If order has expired
if order.status == Order.Status.EXP:
return Response({'bad_request':'This order has expired'},status.HTTP_400_BAD_REQUEST)
# 2) If order has been cancelled
if order.status == Order.Status.UCA:
return Response({'bad_request':'This order has been cancelled by the maker'},status.HTTP_400_BAD_REQUEST)
@ -166,14 +162,14 @@ class OrderView(viewsets.ViewSet):
data['escrow_locked'] = False
# If both bonds are locked, participants can see the final trade amount in sats.
# if order.taker_bond:
# if order.maker_bond.status == order.taker_bond.status == LNPayment.Status.LOCKED:
# # Seller sees the amount he sends
# if data['is_seller']:
# data['trade_satoshis'] = order.last_satoshis
# # Buyer sees the amount he receives
# elif data['is_buyer']:
# data['trade_satoshis'] = Logics.buyer_invoice_amount(order, request.user)[1]['invoice_amount']
if order.taker_bond:
if order.maker_bond.status == order.taker_bond.status == LNPayment.Status.LOCKED:
# Seller sees the amount he sends
if data['is_seller']:
data['trade_satoshis'] = order.last_satoshis
# Buyer sees the amount he receives
elif data['is_buyer']:
data['trade_satoshis'] = Logics.buyer_invoice_amount(order, request.user)[1]['invoice_amount']
# 5) If status is 'waiting for maker bond' and user is MAKER, reply with a MAKER hold invoice.
if order.status == Order.Status.WFB and data['is_maker']:

View File

@ -513,6 +513,18 @@ handleRatingChange=(e)=>{
)
}
showOrderExpired(){
return(
<Grid container spacing={1}>
<Grid item xs={12} align="center">
<Typography component="subtitle1" variant="subtitle1">
<b>The order has expired</b>
</Typography>
</Grid>
</Grid>
)
}
showChat(sendFiatButton, receivedFiatButton, openDisputeButton){
return(
<Grid container spacing={1}>
@ -610,7 +622,8 @@ handleRatingChange=(e)=>{
{/* Trade Finished - TODO Needs more planning */}
{this.props.data.statusCode == 11 ? this.showInDisputeStatement() : ""}
{/* Order has expired */}
{this.props.data.statusCode == 5 ? this.showOrderExpired() : ""}
{/* TODO */}
{/* */}
{/* */}