From a995a4e2eadde81afcddb412a9169c5c9a206542 Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Fri, 14 Jan 2022 16:28:19 -0800 Subject: [PATCH] Add Info and Stats for nerds popups --- api/utils.py | 3 +- frontend/src/components/BottomBar.js | 55 +++++++- frontend/src/components/HomePage.js | 2 +- frontend/src/components/InfoDialog.js | 126 ++++++++++++++++++ .../components/{InfoPage.js => InfoPageMd.js} | 3 - frontend/src/components/UserGenPage.js | 36 +++-- 6 files changed, 207 insertions(+), 18 deletions(-) create mode 100644 frontend/src/components/InfoDialog.js rename frontend/src/components/{InfoPage.js => InfoPageMd.js} (88%) diff --git a/api/utils.py b/api/utils.py index f97cb569..645d8084 100644 --- a/api/utils.py +++ b/api/utils.py @@ -10,12 +10,11 @@ def get_exchange_rate(currency): Checks for exchange rates in several public APIs. Returns the median price. ''' - + APIS = config('MARKET_PRICE_APIS', cast=lambda v: [s.strip() for s in v.split(',')]) exchange_rates = [] for api_url in APIS: - print(api_url) try: if 'blockchain.info' in api_url: blockchain_prices = requests.get(api_url).json() diff --git a/frontend/src/components/BottomBar.js b/frontend/src/components/BottomBar.js index eb30284c..7b1d7c0f 100644 --- a/frontend/src/components/BottomBar.js +++ b/frontend/src/components/BottomBar.js @@ -1,5 +1,5 @@ import React, { Component } from 'react' -import {Paper, Grid, IconButton, Select, MenuItem, List, ListItemText, ListItem, ListItemIcon} from "@mui/material"; +import {Paper, Grid, IconButton, Typography, Select, MenuItem, List, ListItemText, ListItem, ListItemIcon, Divider, Dialog, DialogContent} from "@mui/material"; // Icons import SettingsIcon from '@mui/icons-material/Settings'; @@ -9,11 +9,15 @@ import SellIcon from '@mui/icons-material/Sell'; import SmartToyIcon from '@mui/icons-material/SmartToy'; import PercentIcon from '@mui/icons-material/Percent'; import PriceChangeIcon from '@mui/icons-material/PriceChange'; +import BoltIcon from '@mui/icons-material/Bolt'; +import GitHubIcon from '@mui/icons-material/GitHub'; +import EqualizerIcon from '@mui/icons-material/Equalizer'; export default class BottomBar extends Component { constructor(props) { super(props); this.state = { + openStatsForNerds: false, num_public_buy_orders: null, num_active_robotsats: null, num_public_sell_orders: null, @@ -37,13 +41,60 @@ export default class BottomBar extends Component { }); } + handleClickOpenStatsForNerds = () => { + this.setState({openStatsForNerds: true}); + }; + + handleClickCloseStatsForNerds = () => { + this.setState({openStatsForNerds: false}); + }; + + StatsDialog =() =>{ + return( + + + Stats For Nerds + + + + + + + + + + + {this.state.robosats_running_commit_hash} + + + + + + + + + + + + ) + } + render() { return ( + - + diff --git a/frontend/src/components/HomePage.js b/frontend/src/components/HomePage.js index f3413355..e47a17e8 100644 --- a/frontend/src/components/HomePage.js +++ b/frontend/src/components/HomePage.js @@ -5,7 +5,7 @@ import UserGenPage from "./UserGenPage"; import MakerPage from "./MakerPage"; import BookPage from "./BookPage"; import OrderPage from "./OrderPage"; -import InfoPage from "./InfoPage"; +import InfoPage from "./InfoPageMd"; export default class HomePage extends Component { constructor(props) { diff --git a/frontend/src/components/InfoDialog.js b/frontend/src/components/InfoDialog.js new file mode 100644 index 00000000..3490e6bb --- /dev/null +++ b/frontend/src/components/InfoDialog.js @@ -0,0 +1,126 @@ + +import {Typography, DialogTitle, DialogContent, DialogContentText, Button } from "@mui/material" +import React, { Component } from 'react' + +export default class InfoDialog extends Component { + render() { + return ( +
+ + What is RoboSats? + +

It is a BTC/FIAT peer-to-peer exchange over lightning. It simplifies + matchmaking and minimizes the trust needed to trade with a peer.

+ +

RoboSats is an open source project (GitHub). +

+
+ + How does it work? + +

AdequateAlice01 wants to sell bitcoin, so she posts a sell order. + BafflingBob02 wants to buy bitcoin and he takes Alice's order. + Both have to post a small bond using lightning to prove they are real + robots. Then, Alice posts the trade collateral also using a lightning + hold invoice. RobotSats locks the invoice until Bob confirms he sent + the fiat to Alice. Once Alice confirms she received the fiat, she + tells RoboSats to release the satoshis to Bob. Enjoy your satoshis, + Bob!

+ +

At no point, AdequateAlice01 and BafflingBob02 have to trust the + bitcoin to each other. In case they have a conflict, RoboSats staff + will help resolving the dispute.

+
+ + What payment methods are accepted? + +

Basically all of them. You can write down your preferred payment + method(s). You will have to match with a peer who also accepts + that method. Lightning is fast, so we highly recommend using instant + fiat payment rails.

+
+ + Are there trade limits? + +

Maximum single trade size is 500,000 Satoshis to minimize lightninh + routing failures. This limit will be raised as the Lightning Network + matures. There is no limits to the number of trades per day + or number of simultaneous Robots you can use.

+
+ + Is RoboSats private? + +

RoboSats will never ask you for your name, country or ID. For + best anonymity use Tor Browser and access the .onion hidden service.

+ +

Your trading peer is the only one who can potentially guess + anything about you. Keep your chat short and concise. Avoid + providing non-essential information other than strictly necessary + for the fiat payment.

+
+ + What are the risks? + +

This is an experimental application, things could go wrong. + Trade small amounts!

+ +

The seller faces the same chargeback risk as with any + other peer-to-peer service. Paypal or credit cards are + not adviced.

+
+ + What is the trust model? + +

The buyer and the seller never have to trust each other. + Some trust on RoboSats staff is needed since linking + the seller's hold invoice and buyer payment is not atomic. + In addition, disputes are solved by the RoboSats staff. +

+ +

While trust requirements are minimized, RoboSats could + run away with your satoshis. It could be argued that it is not + worth it, as it would instantly destroy RoboSats reputation. + However, you should hesitate and only trade small quantities at a + time. For large amounts use an onchain escrow service such as Bisq +

+ +

You can build more trust on RoboSats by + inspecting the source code

+
+ + What happens if RoboSats suddently disapears? + +

Your sats will most likely return to you. Any hold invoice that is not + settled would be automatically returned even if RoboSats goes down + forever. This is true for both, locked bonds and trading escrows. However, + in the window between the buyer confirms FIAT SENT and the moment the moment + the seller releases the satoshis, the fund could be lost. +

+
+ + It RoboSats legal in my country? + +

In many countries using RoboSats is no different than using Ebay + or Craiglist. Your regulation may vary. It is your responsibility + to comply. +

+
+ + Disclaimer + +

This lightning application is provided as is. It is in active + development: trade with the utmost caution. There is no private + support. Support is only offered via public channels + (Telegram). RoboSats will never contact you. + RoboSats will definitely never ask for your user token. +

+
+ + +
+ +
+ ) + } +} \ No newline at end of file diff --git a/frontend/src/components/InfoPage.js b/frontend/src/components/InfoPageMd.js similarity index 88% rename from frontend/src/components/InfoPage.js rename to frontend/src/components/InfoPageMd.js index 9146d8f5..bde547b5 100644 --- a/frontend/src/components/InfoPage.js +++ b/frontend/src/components/InfoPageMd.js @@ -28,9 +28,6 @@ export default class InfoPage extends Component {
- ) diff --git a/frontend/src/components/UserGenPage.js b/frontend/src/components/UserGenPage.js index 06491bb6..5ed55d18 100644 --- a/frontend/src/components/UserGenPage.js +++ b/frontend/src/components/UserGenPage.js @@ -1,7 +1,8 @@ import React, { Component } from "react"; -import { Button , Grid, Typography, TextField, ButtonGroup} from "@mui/material" +import { Button , Dialog, Grid, Typography, TextField, ButtonGroup} from "@mui/material" import { Link } from 'react-router-dom' import Image from 'material-ui-image' +import InfoDialog from './InfoDialog' function getCookie(name) { let cookieValue = null; @@ -25,6 +26,7 @@ export default class UserGenPage extends Component { super(props); this.state = { token: this.genBase62Token(34), + openInfo: false, }; this.getGeneratedUser(this.state.token); } @@ -65,16 +67,11 @@ export default class UserGenPage extends Component { .then((data) => console.log(data)); } - // Fix next two handler functions so they work sequentially - // at the moment they make the request generate a new user in parallel - // to updating the token in the state. So the it works a bit weird. - handleAnotherButtonPressed=(e)=>{ this.delGeneratedUser() this.setState({ token: this.genBase62Token(34), }) - this.reload_for_csrf_to_work(); } handleChangeToken=(e)=>{ @@ -85,11 +82,29 @@ export default class UserGenPage extends Component { this.getGeneratedUser(e.target.value); } - // TO FIX CSRF TOKEN IS NOT UPDATED UNTIL WINDOW IS RELOADED - reload_for_csrf_to_work=()=>{ - window.location.reload() + handleClickOpenInfo = () => { + this.setState({openInfo: true}); + }; + + handleCloseInfo = () => { + this.setState({openInfo: false}); + }; + + InfoDialog =() =>{ + return( + + + + ) } + render() { return ( @@ -137,7 +152,8 @@ export default class UserGenPage extends Component { - + +