mirror of
https://github.com/RoboSats/robosats.git
synced 2024-12-13 02:46:28 +00:00
Add dynamic refresh rate to OrderPage based on order status
This commit is contained in:
parent
a03cfdc01d
commit
8e609b9e47
@ -1,4 +1,4 @@
|
||||
# RoboSats: Buy and sell non-KYC Satoshis.
|
||||
# RoboSats: Buy and sell Satoshis Privately.
|
||||
## What is RoboSats?
|
||||
|
||||
RoboSats is a simple and private way to exchange bitcoin for national currencies. Robosats aims to simplify the peer-to-peer experience and uses lightning hodl invoices to minimize the trust needed to trade. In addition, your Robotic Satoshi will help you stick to best privacy practices.
|
||||
@ -15,11 +15,11 @@ RoboSats is a simple and private way to exchange bitcoin for national currencies
|
||||
- Url: testnet.robosats.com (Registered - Not active)
|
||||
- Commit height: v0.0.0 Latest commit.
|
||||
|
||||
*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.*
|
||||
|
||||
## Contribute to the Robotic Satoshis Open Source Project
|
||||
See [CONTRIBUTING.md](CONTRIBUTING.md)
|
||||
|
||||
## License
|
||||
|
||||
RoboSats is released under the terms of the AGPL3.0 license. See [LICENSE](LICENSE) for more details.
|
||||
The Robotic Satoshis Open Source Project is released under the terms of the AGPL3.0 license. See [LICENSE](LICENSE) for more details.
|
||||
|
@ -369,7 +369,8 @@ class Logics():
|
||||
order.last_satoshis = cls.satoshis_now(order)
|
||||
bond_satoshis = int(order.last_satoshis * BOND_SIZE)
|
||||
pos_text = 'Buying' if cls.is_buyer(order, user) else 'Selling'
|
||||
description = f"RoboSats - Taking 'Order {order.id}' {pos_text} BTC for {order.amount} - This is a taker bond, it will freeze in your wallet temporarily and automatically return. It will be charged if you cheat or cancel."
|
||||
description = (f"RoboSats - Taking 'Order {order.id}' {pos_text} BTC for {float(order.amount) + Order.currency_dict[str(order.currency)]}"
|
||||
+ " - This is a taker bond, it will freeze in your wallet temporarily and automatically return. It will be charged if you cheat or cancel.")
|
||||
|
||||
# Gen hold Invoice
|
||||
hold_payment = LNNode.gen_hold_invoice(bond_satoshis, description, BOND_EXPIRY*3600)
|
||||
@ -482,8 +483,8 @@ class Logics():
|
||||
def pay_buyer_invoice(order):
|
||||
''' Pay buyer invoice'''
|
||||
# TODO ERROR HANDLING
|
||||
if LNNode.pay_invoice(order.buyer_invoice.invoice, order.buyer_invoice.num_satoshis):
|
||||
return True
|
||||
suceeded, context = LNNode.pay_invoice(order.buyer_invoice.invoice, order.buyer_invoice.num_satoshis)
|
||||
return suceeded, context
|
||||
|
||||
@classmethod
|
||||
def confirm_fiat(cls, order, user):
|
||||
|
@ -2,6 +2,7 @@
|
||||
import requests, ring, os
|
||||
from decouple import config
|
||||
from statistics import median
|
||||
|
||||
market_cache = {}
|
||||
|
||||
@ring.dict(market_cache, expire=30) #keeps in cache for 30 seconds
|
||||
|
@ -38,7 +38,7 @@ export default class OrderPage extends Component {
|
||||
super(props);
|
||||
this.state = {
|
||||
isExplicit: false,
|
||||
delay: 3000, // Refresh every 3 seconds by default
|
||||
delay: 60000, // Refresh every 60 seconds by default
|
||||
currencies_dict: {"1":"USD"},
|
||||
total_secs_expiry: 300,
|
||||
loading: true,
|
||||
@ -46,6 +46,28 @@ export default class OrderPage extends Component {
|
||||
this.orderId = this.props.match.params.orderId;
|
||||
this.getCurrencyDict();
|
||||
this.getOrderDetails();
|
||||
|
||||
// Change refresh delay according to Order status
|
||||
this.statusToDelay = {
|
||||
"0": 3000, //'Waiting for maker bond'
|
||||
"1": 30000, //'Public'
|
||||
"2": 999999, //'Deleted'
|
||||
"3": 3000, //'Waiting for taker bond'
|
||||
"4": 999999, //'Cancelled'
|
||||
"5": 999999, //'Expired'
|
||||
"6": 3000, //'Waiting for trade collateral and buyer invoice'
|
||||
"7": 3000, //'Waiting only for seller trade collateral'
|
||||
"8": 10000, //'Waiting only for buyer invoice'
|
||||
"9": 10000, //'Sending fiat - In chatroom'
|
||||
"10": 15000, //'Fiat sent - In chatroom'
|
||||
"11": 300000, //'In dispute'
|
||||
"12": 999999, //'Collaboratively cancelled'
|
||||
"13": 120000, //'Sending satoshis to buyer'
|
||||
"14": 999999, //'Sucessful trade'
|
||||
"15": 15000, //'Failed lightning network routing'
|
||||
"16": 999999, //'Maker lost dispute'
|
||||
"17": 999999, //'Taker lost dispute'
|
||||
}
|
||||
}
|
||||
|
||||
getOrderDetails() {
|
||||
@ -55,6 +77,7 @@ export default class OrderPage extends Component {
|
||||
.then((data) => {console.log(data) &
|
||||
this.setState({
|
||||
loading: false,
|
||||
delay: this.statusToDelay[data.status.toString()],
|
||||
id: data.id,
|
||||
statusCode: data.status,
|
||||
statusText: data.status_message,
|
||||
@ -99,12 +122,11 @@ export default class OrderPage extends Component {
|
||||
componentDidMount() {
|
||||
this.interval = setInterval(this.tick, this.state.delay);
|
||||
}
|
||||
componentDidUpdate(prevProps, prevState) {
|
||||
if (prevState.delay !== this.state.delay) {
|
||||
clearInterval(this.interval);
|
||||
componentDidUpdate() {
|
||||
clearInterval(this.interval);
|
||||
this.interval = setInterval(this.tick, this.state.delay);
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
clearInterval(this.interval);
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import QRCode from "react-qr-code";
|
||||
import Chat from "./Chat"
|
||||
|
||||
// Icons
|
||||
import LockIcon from '@mui/icons-material/Lock';
|
||||
import SmartToyIcon from '@mui/icons-material/SmartToy';
|
||||
import PercentIcon from '@mui/icons-material/Percent';
|
||||
import BookIcon from '@mui/icons-material/Book';
|
||||
@ -238,24 +237,24 @@ export default class TradeBox extends Component {
|
||||
valid invoice for {pn(this.props.data.invoiceAmount)} Satoshis.
|
||||
</Typography>
|
||||
</Grid>
|
||||
<form noValidate onSubmit={this.handleClickSubmitInvoiceButton}>
|
||||
<Grid item xs={12} align="center">
|
||||
<TextField
|
||||
error={this.state.badInvoice}
|
||||
helperText={this.state.badInvoice ? this.state.badInvoice : "" }
|
||||
label={"Payout Lightning Invoice"}
|
||||
required
|
||||
inputProps={{
|
||||
style: {textAlign:"center"}
|
||||
}}
|
||||
multiline
|
||||
onChange={this.handleInputInvoiceChanged}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} align="center">
|
||||
<Button variant='contained' color='primary'>Submit</Button>
|
||||
</Grid>
|
||||
</form>
|
||||
|
||||
<Grid item xs={12} align="center">
|
||||
<TextField
|
||||
error={this.state.badInvoice}
|
||||
helperText={this.state.badInvoice ? this.state.badInvoice : "" }
|
||||
label={"Payout Lightning Invoice"}
|
||||
required
|
||||
inputProps={{
|
||||
style: {textAlign:"center"}
|
||||
}}
|
||||
multiline
|
||||
onChange={this.handleInputInvoiceChanged}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} align="center">
|
||||
<Button onClick={this.handleClickSubmitInvoiceButton} variant='contained' color='primary'>Submit</Button>
|
||||
</Grid>
|
||||
|
||||
{this.showBondIsLocked()}
|
||||
</Grid>
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user