mirror of
https://github.com/RoboSats/robosats.git
synced 2025-02-07 05:49:04 +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() '''
|
LNPayment "order.taker_bond" is deleted() '''
|
||||||
elif order.status == Order.Status.TAK and order.taker == user:
|
elif order.status == Order.Status.TAK and order.taker == user:
|
||||||
# adds a timeout penalty
|
# adds a timeout penalty
|
||||||
user.profile.penalty_expiration = timezone.now() + timedelta(seconds=PENALTY_TIMEOUT)
|
cls.kick_taker(order)
|
||||||
user.profile.save()
|
|
||||||
|
|
||||||
order.taker = None
|
|
||||||
order.status = Order.Status.PUB
|
|
||||||
order.save()
|
|
||||||
|
|
||||||
return True, None
|
return True, None
|
||||||
|
|
||||||
# 4) When taker or maker cancel after bond (before escrow)
|
# 4) When taker or maker cancel after bond (before escrow)
|
||||||
@ -395,6 +389,7 @@ class Logics():
|
|||||||
created_at = hold_payment['created_at'],
|
created_at = hold_payment['created_at'],
|
||||||
expires_at = hold_payment['expires_at'])
|
expires_at = hold_payment['expires_at'])
|
||||||
|
|
||||||
|
order.expires_at = timezone.now() + timedelta(seconds=EXP_TAKER_BOND_INVOICE)
|
||||||
order.save()
|
order.save()
|
||||||
return True, {'bond_invoice': hold_payment['invoice'], 'bond_satoshis': bond_satoshis}
|
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:
|
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)
|
return Response({'bad_request':'You are not allowed to see this order'},status.HTTP_403_FORBIDDEN)
|
||||||
|
|
||||||
# 3.b If public
|
# 3.b If order is between public and WF2
|
||||||
if order.status == Order.Status.PUB:
|
if order.status >= Order.Status.PUB and order.status > Order.Status.WFB:
|
||||||
data['price_now'], data['premium_now'] = Logics.price_and_premium_now(order)
|
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.
|
# 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['robots_in_book'] = None # TODO
|
||||||
data['premium_percentile'] = None # TODO
|
data['premium_percentile'] = None # TODO
|
||||||
data['num_similar_orders'] = len(Order.objects.filter(currency=order.currency, status=Order.Status.PUB))
|
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:
|
if order.status == Order.Status.PUB:
|
||||||
valid, context = Logics.validate_already_maker_or_taker(request.user)
|
valid, context = Logics.validate_already_maker_or_taker(request.user)
|
||||||
if not valid: return Response(context, status=status.HTTP_409_CONFLICT)
|
if not valid: return Response(context, status=status.HTTP_409_CONFLICT)
|
||||||
|
|
||||||
valid, context = Logics.take(order, request.user)
|
valid, context = Logics.take(order, request.user)
|
||||||
if not valid: return Response(context, status=status.HTTP_403_FORBIDDEN)
|
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)
|
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
|
# 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
|
delay: 60000, // Refresh every 60 seconds by default
|
||||||
currencies_dict: {"1":"USD"},
|
currencies_dict: {"1":"USD"},
|
||||||
total_secs_expiry: 300,
|
total_secs_expiry: 300,
|
||||||
|
loading: true,
|
||||||
};
|
};
|
||||||
this.orderId = this.props.match.params.orderId;
|
this.orderId = this.props.match.params.orderId;
|
||||||
this.getCurrencyDict();
|
this.getCurrencyDict();
|
||||||
@ -53,6 +54,7 @@ export default class OrderPage extends Component {
|
|||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data) => {console.log(data) &
|
.then((data) => {console.log(data) &
|
||||||
this.setState({
|
this.setState({
|
||||||
|
loading: false,
|
||||||
id: data.id,
|
id: data.id,
|
||||||
statusCode: data.status,
|
statusCode: data.status,
|
||||||
statusText: data.status_message,
|
statusText: data.status_message,
|
||||||
@ -294,7 +296,7 @@ export default class OrderPage extends Component {
|
|||||||
<AccessTimeIcon/>
|
<AccessTimeIcon/>
|
||||||
</ListItemIcon>
|
</ListItemIcon>
|
||||||
<ListItemText secondary="Expires in">
|
<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>
|
</ListItemText>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
<this.LinearDeterminate />
|
<this.LinearDeterminate />
|
||||||
@ -380,7 +382,7 @@ export default class OrderPage extends Component {
|
|||||||
render (){
|
render (){
|
||||||
return (
|
return (
|
||||||
// Only so nothing shows while requesting the first batch of data
|
// 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">
|
<Grid item xs={12} align="center">
|
||||||
<TextField
|
<TextField
|
||||||
hiddenLabel
|
hiddenLabel
|
||||||
variant="filled"
|
variant="standard"
|
||||||
size="small"
|
size="small"
|
||||||
defaultValue={this.props.data.bondInvoice}
|
defaultValue={this.props.data.bondInvoice}
|
||||||
disabled="true"
|
disabled="true"
|
||||||
helperText="This is a hold invoice. It will simply freeze in your wallet.
|
helperText="This is a hold invoice. It will be charged only if you cancel or lose a dispute."
|
||||||
It will be charged only if you cancel the order or lose a dispute."
|
|
||||||
color = "secondary"
|
color = "secondary"
|
||||||
onClick = {this.copyCodeToClipboard}
|
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
@ -85,16 +83,9 @@ export default class TradeBox extends Component {
|
|||||||
showBondIsLocked=()=>{
|
showBondIsLocked=()=>{
|
||||||
return (
|
return (
|
||||||
<Grid item xs={12} align="center">
|
<Grid item xs={12} align="center">
|
||||||
<ListItem>
|
<Typography color="primary" component="subtitle1" variant="subtitle1" align="center">
|
||||||
<ListItemIcon>
|
🔒 Your {this.props.data.isMaker ? 'maker' : 'taker'} bond is locked
|
||||||
<LockIcon/>
|
</Typography>
|
||||||
</ListItemIcon>
|
|
||||||
<ListItemText>
|
|
||||||
<Typography color="primary" component="subtitle1" variant="subtitle1" align="center">
|
|
||||||
Your {this.props.data.isMaker ? 'maker' : 'taker'} bond is locked
|
|
||||||
</Typography>
|
|
||||||
</ListItemText>
|
|
||||||
</ListItem>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -118,7 +109,7 @@ export default class TradeBox extends Component {
|
|||||||
size="small"
|
size="small"
|
||||||
defaultValue={this.props.data.escrowInvoice}
|
defaultValue={this.props.data.escrowInvoice}
|
||||||
disabled="true"
|
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"
|
color = "secondary"
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
Loading…
Reference in New Issue
Block a user