mirror of
https://github.com/RoboSats/robosats.git
synced 2024-12-14 11:26:24 +00:00
Add penalty live countdown. Fix unilateral cancellation after escrow
This commit is contained in:
parent
d2dbc0d249
commit
2263ec7153
@ -1,4 +1,4 @@
|
|||||||
## RoboSats - Buy and sell Satoshis Privately.
|
## RoboSats - Buy and sell Satoshis Privately
|
||||||
[![release](https://img.shields.io/badge/release-v0.1.0%20MVP-orange)](https://github.com/Reckless-Satoshi/robosats/releases)
|
[![release](https://img.shields.io/badge/release-v0.1.0%20MVP-orange)](https://github.com/Reckless-Satoshi/robosats/releases)
|
||||||
[![AGPL-3.0 license](https://img.shields.io/badge/license-AGPL--3.0-blue)](https://github.com/Reckless-Satoshi/robosats/blob/main/LICENSE)
|
[![AGPL-3.0 license](https://img.shields.io/badge/license-AGPL--3.0-blue)](https://github.com/Reckless-Satoshi/robosats/blob/main/LICENSE)
|
||||||
[![Telegram](https://img.shields.io/badge/chat-telegram-brightgreen)](https://t.me/robosats)
|
[![Telegram](https://img.shields.io/badge/chat-telegram-brightgreen)](https://t.me/robosats)
|
||||||
@ -15,7 +15,7 @@ RoboSats is a simple and private way to exchange bitcoin for national currencies
|
|||||||
**Bitcoin testnet:**
|
**Bitcoin testnet:**
|
||||||
- Tor: robotestagw3dcxmd66r4rgksb4nmmr43fh77bzn2ia2eucduyeafnyd.onion (Active - On Dev Node)
|
- Tor: robotestagw3dcxmd66r4rgksb4nmmr43fh77bzn2ia2eucduyeafnyd.onion (Active - On Dev Node)
|
||||||
- Url: testnet.robosats.com (Coming soon)
|
- Url: testnet.robosats.com (Coming soon)
|
||||||
- Commit height: Latest commit.
|
- Latest commit.
|
||||||
|
|
||||||
*Always use [Tor Browser](https://www.torproject.org/download/) and .onion for best anonymity.*
|
*Always use [Tor Browser](https://www.torproject.org/download/) and .onion for best anonymity.*
|
||||||
|
|
||||||
|
@ -409,7 +409,7 @@ class Logics():
|
|||||||
|
|
||||||
# 4.a) When maker cancel after bond (before escrow)
|
# 4.a) When maker cancel after bond (before escrow)
|
||||||
'''The order into cancelled status if maker cancels.'''
|
'''The order into cancelled status if maker cancels.'''
|
||||||
elif order.status > Order.Status.PUB and order.status < Order.Status.CHA and order.maker == user:
|
elif order.status in [Order.Status.PUB, Order.Status.TAK, Order.Status.WF2, Order.Status.WFE] and order.maker == user:
|
||||||
#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:
|
||||||
|
@ -226,7 +226,7 @@ class Profile(models.Model):
|
|||||||
avatar = models.ImageField(default="static/assets/misc/unknown_avatar.png", verbose_name='Avatar', blank=True)
|
avatar = models.ImageField(default="static/assets/misc/unknown_avatar.png", verbose_name='Avatar', blank=True)
|
||||||
|
|
||||||
# Penalty expiration (only used then taking/cancelling repeatedly orders in the book before comitting bond)
|
# Penalty expiration (only used then taking/cancelling repeatedly orders in the book before comitting bond)
|
||||||
penalty_expiration = models.DateTimeField(null=True)
|
penalty_expiration = models.DateTimeField(null=True,default=None, blank=True)
|
||||||
|
|
||||||
@receiver(post_save, sender=User)
|
@receiver(post_save, sender=User)
|
||||||
def create_user_profile(sender, instance, created, **kwargs):
|
def create_user_profile(sender, instance, created, **kwargs):
|
||||||
|
@ -108,7 +108,7 @@ class OrderView(viewsets.ViewSet):
|
|||||||
# if user is under a limit (penalty), inform him.
|
# if user is under a limit (penalty), inform him.
|
||||||
is_penalized, time_out = Logics.is_penalized(request.user)
|
is_penalized, time_out = Logics.is_penalized(request.user)
|
||||||
if is_penalized:
|
if is_penalized:
|
||||||
data['penalty'] = time_out
|
data['penalty'] = request.user.profile.penalty_expiration
|
||||||
|
|
||||||
# Add booleans if user is maker, taker, partipant, buyer or seller
|
# Add booleans if user is maker, taker, partipant, buyer or seller
|
||||||
data['is_maker'] = order.maker == request.user
|
data['is_maker'] = order.maker == request.user
|
||||||
|
@ -143,6 +143,19 @@ export default class OrderPage extends Component {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Countdown Renderer callback with condition
|
||||||
|
countdownPenaltyRenderer = ({ minutes, seconds, completed }) => {
|
||||||
|
if (completed) {
|
||||||
|
// Render a completed state
|
||||||
|
return (<span> nothing. Good to go!</span>);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<span>{zeroPad(minutes)}m {zeroPad(seconds)}s </span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
LinearDeterminate =()=> {
|
LinearDeterminate =()=> {
|
||||||
const [progress, setProgress] = React.useState(0);
|
const [progress, setProgress] = React.useState(0);
|
||||||
|
|
||||||
@ -432,7 +445,7 @@ export default class OrderPage extends Component {
|
|||||||
<Divider />
|
<Divider />
|
||||||
<Grid item xs={12} align="center">
|
<Grid item xs={12} align="center">
|
||||||
<Alert severity="warning" sx={{maxWidth:360}}>
|
<Alert severity="warning" sx={{maxWidth:360}}>
|
||||||
You cannot take an order yet! Wait {this.state.penalty} seconds
|
You cannot take an order yet! Wait <Countdown date={new Date(this.state.penalty)} renderer={this.countdownPenaltyRenderer} />
|
||||||
</Alert>
|
</Alert>
|
||||||
</Grid>
|
</Grid>
|
||||||
</>
|
</>
|
||||||
|
Loading…
Reference in New Issue
Block a user