mirror of
https://github.com/RoboSats/robosats.git
synced 2025-07-22 02:33:17 +00:00
Improve Order Expired behaviour
This commit is contained in:
@ -125,16 +125,12 @@ class Logics():
|
|||||||
elif order.status == Order.Status.WFB:
|
elif order.status == Order.Status.WFB:
|
||||||
order.status = Order.Status.EXP
|
order.status = Order.Status.EXP
|
||||||
cls.cancel_bond(order.maker_bond)
|
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()
|
order.save()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
elif order.status == Order.Status.PUB:
|
elif order.status == Order.Status.PUB:
|
||||||
cls.return_bond(order.maker_bond)
|
cls.return_bond(order.maker_bond)
|
||||||
order.status = Order.Status.EXP
|
order.status = Order.Status.EXP
|
||||||
order.maker = None
|
|
||||||
order.taker = None
|
|
||||||
order.save()
|
order.save()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -153,8 +149,6 @@ class Logics():
|
|||||||
cls.settle_bond(order.taker_bond)
|
cls.settle_bond(order.taker_bond)
|
||||||
cls.cancel_escrow(order)
|
cls.cancel_escrow(order)
|
||||||
order.status = Order.Status.EXP
|
order.status = Order.Status.EXP
|
||||||
order.maker = None
|
|
||||||
order.taker = None
|
|
||||||
order.save()
|
order.save()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -166,8 +160,6 @@ class Logics():
|
|||||||
cls.return_bond(order.taker_bond)
|
cls.return_bond(order.taker_bond)
|
||||||
cls.cancel_escrow(order)
|
cls.cancel_escrow(order)
|
||||||
order.status = Order.Status.EXP
|
order.status = Order.Status.EXP
|
||||||
order.maker = None
|
|
||||||
order.taker = None
|
|
||||||
order.save()
|
order.save()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -192,8 +184,6 @@ class Logics():
|
|||||||
cls.return_bond(order.taker_bond)
|
cls.return_bond(order.taker_bond)
|
||||||
cls.return_escrow(order)
|
cls.return_escrow(order)
|
||||||
order.status = Order.Status.EXP
|
order.status = Order.Status.EXP
|
||||||
order.maker = None
|
|
||||||
order.taker = None
|
|
||||||
order.save()
|
order.save()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -369,7 +359,6 @@ class Logics():
|
|||||||
'''The order never shows up on the book and order
|
'''The order never shows up on the book and order
|
||||||
status becomes "cancelled". That's it.'''
|
status becomes "cancelled". That's it.'''
|
||||||
if order.status == Order.Status.WFB and order.maker == user:
|
if order.status == Order.Status.WFB and order.maker == user:
|
||||||
order.maker = None
|
|
||||||
order.status = Order.Status.UCA
|
order.status = Order.Status.UCA
|
||||||
order.save()
|
order.save()
|
||||||
return True, None
|
return True, None
|
||||||
@ -380,7 +369,6 @@ class Logics():
|
|||||||
elif order.status == Order.Status.PUB and order.maker == user:
|
elif order.status == Order.Status.PUB and order.maker == user:
|
||||||
#Settle the maker bond (Maker loses the bond for cancelling public order)
|
#Settle the maker bond (Maker loses the bond for cancelling public order)
|
||||||
if cls.settle_bond(order.maker_bond):
|
if cls.settle_bond(order.maker_bond):
|
||||||
order.maker = None
|
|
||||||
order.status = Order.Status.UCA
|
order.status = Order.Status.UCA
|
||||||
order.save()
|
order.save()
|
||||||
return True, None
|
return True, None
|
||||||
@ -405,7 +393,6 @@ class Logics():
|
|||||||
#Settle the maker bond (Maker loses the bond for canceling an ongoing trade)
|
#Settle the maker bond (Maker loses the bond for canceling an ongoing trade)
|
||||||
valid = cls.settle_bond(order.maker_bond)
|
valid = cls.settle_bond(order.maker_bond)
|
||||||
if valid:
|
if valid:
|
||||||
order.maker = None
|
|
||||||
order.status = Order.Status.UCA
|
order.status = Order.Status.UCA
|
||||||
order.save()
|
order.save()
|
||||||
return True, None
|
return True, None
|
||||||
|
20
api/views.py
20
api/views.py
@ -95,10 +95,6 @@ class OrderView(viewsets.ViewSet):
|
|||||||
# This is our order.
|
# This is our order.
|
||||||
order = order[0]
|
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
|
# 2) If order has been cancelled
|
||||||
if order.status == Order.Status.UCA:
|
if order.status == Order.Status.UCA:
|
||||||
return Response({'bad_request':'This order has been cancelled by the maker'},status.HTTP_400_BAD_REQUEST)
|
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
|
data['escrow_locked'] = False
|
||||||
|
|
||||||
# If both bonds are locked, participants can see the final trade amount in sats.
|
# If both bonds are locked, participants can see the final trade amount in sats.
|
||||||
# if order.taker_bond:
|
if order.taker_bond:
|
||||||
# if order.maker_bond.status == order.taker_bond.status == LNPayment.Status.LOCKED:
|
if order.maker_bond.status == order.taker_bond.status == LNPayment.Status.LOCKED:
|
||||||
# # Seller sees the amount he sends
|
# Seller sees the amount he sends
|
||||||
# if data['is_seller']:
|
if data['is_seller']:
|
||||||
# data['trade_satoshis'] = order.last_satoshis
|
data['trade_satoshis'] = order.last_satoshis
|
||||||
# # Buyer sees the amount he receives
|
# Buyer sees the amount he receives
|
||||||
# elif data['is_buyer']:
|
elif data['is_buyer']:
|
||||||
# data['trade_satoshis'] = Logics.buyer_invoice_amount(order, request.user)[1]['invoice_amount']
|
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.
|
# 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']:
|
if order.status == Order.Status.WFB and data['is_maker']:
|
||||||
|
@ -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){
|
showChat(sendFiatButton, receivedFiatButton, openDisputeButton){
|
||||||
return(
|
return(
|
||||||
<Grid container spacing={1}>
|
<Grid container spacing={1}>
|
||||||
@ -610,7 +622,8 @@ handleRatingChange=(e)=>{
|
|||||||
{/* Trade Finished - TODO Needs more planning */}
|
{/* Trade Finished - TODO Needs more planning */}
|
||||||
{this.props.data.statusCode == 11 ? this.showInDisputeStatement() : ""}
|
{this.props.data.statusCode == 11 ? this.showInDisputeStatement() : ""}
|
||||||
|
|
||||||
|
{/* Order has expired */}
|
||||||
|
{this.props.data.statusCode == 5 ? this.showOrderExpired() : ""}
|
||||||
{/* TODO */}
|
{/* TODO */}
|
||||||
{/* */}
|
{/* */}
|
||||||
{/* */}
|
{/* */}
|
||||||
|
Reference in New Issue
Block a user