mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-31 02:21:35 +00:00
Add taker bond lock expiry
This commit is contained in:
parent
806c469b64
commit
032d3a1369
@ -238,13 +238,7 @@ class Logics():
|
||||
LNPayment "order.taker_bond" is deleted() '''
|
||||
elif order.status == Order.Status.TAK and order.taker == user:
|
||||
# adds a timeout penalty
|
||||
user.profile.penalty_expiration = timezone.now() + timedelta(seconds=PENALTY_TIMEOUT)
|
||||
user.profile.save()
|
||||
|
||||
order.taker = None
|
||||
order.status = Order.Status.PUB
|
||||
order.save()
|
||||
|
||||
cls.kick_taker(order)
|
||||
return True, None
|
||||
|
||||
# 4) When taker or maker cancel after bond (before escrow)
|
||||
@ -395,6 +389,7 @@ class Logics():
|
||||
created_at = hold_payment['created_at'],
|
||||
expires_at = hold_payment['expires_at'])
|
||||
|
||||
order.expires_at = timezone.now() + timedelta(seconds=EXP_TAKER_BOND_INVOICE)
|
||||
order.save()
|
||||
return True, {'bond_invoice': hold_payment['invoice'], 'bond_satoshis': bond_satoshis}
|
||||
|
||||
|
@ -122,12 +122,12 @@ class OrderView(viewsets.ViewSet):
|
||||
if not data['is_participant'] and order.status != Order.Status.PUB:
|
||||
return Response({'bad_request':'You are not allowed to see this order'},status.HTTP_403_FORBIDDEN)
|
||||
|
||||
# 3.b If public
|
||||
if order.status == Order.Status.PUB:
|
||||
# 3.b If order is between public and WF2
|
||||
if order.status >= Order.Status.PUB and order.status > Order.Status.WFB:
|
||||
data['price_now'], data['premium_now'] = Logics.price_and_premium_now(order)
|
||||
|
||||
# 3. c) If maker and Public, add num robots in book, premium percentile and num similar orders.
|
||||
if data['is_maker']:
|
||||
if data['is_maker'] and order.status == Order.Status.PUB:
|
||||
data['robots_in_book'] = None # TODO
|
||||
data['premium_percentile'] = None # TODO
|
||||
data['num_similar_orders'] = len(Order.objects.filter(currency=order.currency, status=Order.Status.PUB))
|
||||
@ -227,10 +227,11 @@ class OrderView(viewsets.ViewSet):
|
||||
if order.status == Order.Status.PUB:
|
||||
valid, context = Logics.validate_already_maker_or_taker(request.user)
|
||||
if not valid: return Response(context, status=status.HTTP_409_CONFLICT)
|
||||
|
||||
valid, context = Logics.take(order, request.user)
|
||||
if not valid: return Response(context, status=status.HTTP_403_FORBIDDEN)
|
||||
|
||||
return self.get(request)
|
||||
|
||||
else: Response({'bad_request':'This order is not public anymore.'}, status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
# Any other action is only allowed if the user is a participant
|
||||
|
@ -41,6 +41,7 @@ export default class OrderPage extends Component {
|
||||
delay: 60000, // Refresh every 60 seconds by default
|
||||
currencies_dict: {"1":"USD"},
|
||||
total_secs_expiry: 300,
|
||||
loading: true,
|
||||
};
|
||||
this.orderId = this.props.match.params.orderId;
|
||||
this.getCurrencyDict();
|
||||
@ -53,6 +54,7 @@ export default class OrderPage extends Component {
|
||||
.then((response) => response.json())
|
||||
.then((data) => {console.log(data) &
|
||||
this.setState({
|
||||
loading: false,
|
||||
id: data.id,
|
||||
statusCode: data.status,
|
||||
statusText: data.status_message,
|
||||
@ -294,7 +296,7 @@ export default class OrderPage extends Component {
|
||||
<AccessTimeIcon/>
|
||||
</ListItemIcon>
|
||||
<ListItemText secondary="Expires in">
|
||||
<Countdown onTick={console.log(this.seconds)} date={new Date(this.state.expiresAt)} renderer={this.countdownRenderer} />
|
||||
<Countdown date={new Date(this.state.expiresAt)} renderer={this.countdownRenderer} />
|
||||
</ListItemText>
|
||||
</ListItem>
|
||||
<this.LinearDeterminate />
|
||||
@ -380,7 +382,7 @@ export default class OrderPage extends Component {
|
||||
render (){
|
||||
return (
|
||||
// Only so nothing shows while requesting the first batch of data
|
||||
(this.state.statusCode == null & this.state.badRequest == null) ? <CircularProgress /> : this.orderDetailsPage()
|
||||
this.state.loading ? <CircularProgress /> : this.orderDetailsPage()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -68,14 +68,12 @@ export default class TradeBox extends Component {
|
||||
<Grid item xs={12} align="center">
|
||||
<TextField
|
||||
hiddenLabel
|
||||
variant="filled"
|
||||
variant="standard"
|
||||
size="small"
|
||||
defaultValue={this.props.data.bondInvoice}
|
||||
disabled="true"
|
||||
helperText="This is a hold invoice. It will simply freeze in your wallet.
|
||||
It will be charged only if you cancel the order or lose a dispute."
|
||||
helperText="This is a hold invoice. It will be charged only if you cancel or lose a dispute."
|
||||
color = "secondary"
|
||||
onClick = {this.copyCodeToClipboard}
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
@ -85,16 +83,9 @@ export default class TradeBox extends Component {
|
||||
showBondIsLocked=()=>{
|
||||
return (
|
||||
<Grid item xs={12} align="center">
|
||||
<ListItem>
|
||||
<ListItemIcon>
|
||||
<LockIcon/>
|
||||
</ListItemIcon>
|
||||
<ListItemText>
|
||||
<Typography color="primary" component="subtitle1" variant="subtitle1" align="center">
|
||||
Your {this.props.data.isMaker ? 'maker' : 'taker'} bond is locked
|
||||
</Typography>
|
||||
</ListItemText>
|
||||
</ListItem>
|
||||
<Typography color="primary" component="subtitle1" variant="subtitle1" align="center">
|
||||
🔒 Your {this.props.data.isMaker ? 'maker' : 'taker'} bond is locked
|
||||
</Typography>
|
||||
</Grid>
|
||||
);
|
||||
}
|
||||
@ -118,7 +109,7 @@ export default class TradeBox extends Component {
|
||||
size="small"
|
||||
defaultValue={this.props.data.escrowInvoice}
|
||||
disabled="true"
|
||||
helperText="This is a hold invoice. It will simply freeze in your wallet. It will be charged once the buyer confirms he sent the fiat."
|
||||
helperText="This is a hold invoice. It will be charged once the buyer confirms he sent the fiat."
|
||||
color = "secondary"
|
||||
/>
|
||||
</Grid>
|
||||
|
Loading…
Reference in New Issue
Block a user