Skip to content

Commit 673037c

Browse files
Websockets on Tor android (#1615)
* Websockets on Tor android * Show turtle mode on android * Display lnp2pbot orders (#1617) * P2PBOT working * Display LNP2POrders * Filter by robosats orders * Robosats hosts filter by default and better browse text --------- Co-authored-by: Reckless_Satoshi <[email protected]>
1 parent be80cc1 commit 673037c

File tree

61 files changed

+1865
-1026
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1865
-1026
lines changed

docs/_sass/minimal-mistakes/skins/_robosats.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/* Colors */
66
$background-color: #ffffff !default;
77
$text-color: #2c2c2c !default;
8-
$muted-text-color: #393e46 !default;
8+
$muted-text-color: hsl(217, 10%, 25%) !default;
99
$primary-color: #1976d2 !default;
1010
$primary-light-color: #42a5f5 !default;
1111
$primary-dark-color: #1565c0 !default;

frontend/src/basic/BookPage/index.tsx

+26-1
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,38 @@ import BookTable from '../../components/BookTable';
99
import { BarChart, FormatListBulleted, Map } from '@mui/icons-material';
1010
import { AppContext, type UseAppStoreType } from '../../contexts/AppContext';
1111
import MapChart from '../../components/Charts/MapChart';
12+
import thirdParties from '../../../static/thirdparties.json';
13+
import { FederationContext, type UseFederationStoreType } from '../../contexts/FederationContext';
14+
import VisitThirdParty from '../../components/Dialogs/VisitThirdParty';
15+
import { type PublicOrder } from '../../models';
1216

1317
const BookPage = (): JSX.Element => {
1418
const { windowSize } = useContext<UseAppStoreType>(AppContext);
19+
const { federation } = useContext<UseFederationStoreType>(FederationContext);
1520
const { t } = useTranslation();
1621
const navigate = useNavigate();
1722
const [view, setView] = useState<'list' | 'depth' | 'map'>('list');
23+
const [openVisitThirdParty, setOpenVisitThirdParty] = useState<boolean>(false);
24+
const [thirdPartyOrder, setThirdPartyOrder] = useState<PublicOrder>();
1825

1926
const doubleView = windowSize.width > 115;
2027
const width = windowSize.width * 0.9;
2128
const maxBookTableWidth = 85;
2229
const chartWidthEm = width - maxBookTableWidth;
2330

2431
const onOrderClicked = function (id: number, shortAlias: string): void {
25-
navigate(`/order/${shortAlias}/${id}`);
32+
const thirdParty = thirdParties[shortAlias];
33+
if (thirdParty) {
34+
const thirdPartyOrder = Object.values(federation.book).find(
35+
(o) => o?.id === id && o?.coordinatorShortAlias === shortAlias,
36+
);
37+
if (thirdPartyOrder) {
38+
setThirdPartyOrder(thirdPartyOrder);
39+
setOpenVisitThirdParty(true);
40+
}
41+
} else {
42+
navigate(`/order/${shortAlias}/${id}`);
43+
}
2644
};
2745

2846
const NavButtons = function (): JSX.Element {
@@ -69,6 +87,13 @@ const BookPage = (): JSX.Element => {
6987

7088
return (
7189
<Grid container direction='column' alignItems='center' spacing={1} sx={{ minWidth: 400 }}>
90+
<VisitThirdParty
91+
open={openVisitThirdParty}
92+
onClose={() => {
93+
setOpenVisitThirdParty(false);
94+
}}
95+
thirdPartyOrder={thirdPartyOrder}
96+
/>
7297
<Grid item xs={12}>
7398
{doubleView ? (
7499
<Grid

frontend/src/basic/MainDialogs/index.tsx

+9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
} from '../../components/Dialogs';
1212
import { AppContext, type UseAppStoreType, closeAll } from '../../contexts/AppContext';
1313
import { FederationContext, type UseFederationStoreType } from '../../contexts/FederationContext';
14+
import ThirdPartyDialog from '../../components/Dialogs/ThirdParty';
1415

1516
export interface OpenDialogs {
1617
more: boolean;
@@ -24,6 +25,7 @@ export interface OpenDialogs {
2425
update: boolean;
2526
profile: boolean;
2627
recovery: boolean;
28+
thirdParty: string;
2729
}
2830

2931
const MainDialogs = (): JSX.Element => {
@@ -95,6 +97,13 @@ const MainDialogs = (): JSX.Element => {
9597
}}
9698
shortAlias={open.coordinator}
9799
/>
100+
<ThirdPartyDialog
101+
open={Boolean(open.thirdParty)}
102+
onClose={() => {
103+
setOpen(closeAll);
104+
}}
105+
shortAlias={open.thirdParty}
106+
/>
98107
</>
99108
);
100109
};

frontend/src/basic/MakerPage/index.tsx

+27-5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import { AppContext, type UseAppStoreType } from '../../contexts/AppContext';
1111
import { NoRobotDialog } from '../../components/Dialogs';
1212
import { FederationContext, type UseFederationStoreType } from '../../contexts/FederationContext';
1313
import { GarageContext, type UseGarageStoreType } from '../../contexts/GarageContext';
14+
import VisitThirdParty from '../../components/Dialogs/VisitThirdParty';
15+
import { PublicOrder } from '../../models';
1416

1517
const MakerPage = (): JSX.Element => {
1618
const { fav, windowSize, navbarHeight } = useContext<UseAppStoreType>(AppContext);
@@ -23,6 +25,8 @@ const MakerPage = (): JSX.Element => {
2325
const [showMatches, setShowMatches] = useState<boolean>(false);
2426
const [openNoRobot, setOpenNoRobot] = useState<boolean>(false);
2527
const [clickedOrder, setClickedOrder] = useState<{ id: number; shortAlias: string }>();
28+
const [openVisitThirdParty, setOpenVisitThirdParty] = useState<boolean>(false);
29+
const [thirdPartyOrder, setThirdPartyOrder] = useState<PublicOrder>();
2630

2731
const matches = useMemo(() => {
2832
return filterOrders({
@@ -31,7 +35,7 @@ const MakerPage = (): JSX.Element => {
3135
currency: fav.currency === 0 ? 1 : fav.currency,
3236
type: fav.type,
3337
mode: fav.mode,
34-
coordinator: 'any',
38+
coordinator: 'robosats',
3539
},
3640
premium: Number(maker.premium) ?? null,
3741
paymentMethods: maker.paymentMethods,
@@ -53,16 +57,34 @@ const MakerPage = (): JSX.Element => {
5357
]);
5458

5559
const onOrderClicked = function (id: number, shortAlias: string): void {
56-
if (garage.getSlot()?.hashId) {
57-
navigate(`/order/${shortAlias}/${id}`);
60+
const thirdParty = thirdParties[shortAlias];
61+
if (thirdParty) {
62+
const thirdPartyOrder = Object.values(federation.book).find(
63+
(o) => o?.id === id && o?.coordinatorShortAlias === shortAlias,
64+
);
65+
if (thirdPartyOrder) {
66+
setThirdPartyOrder(thirdPartyOrder);
67+
setOpenVisitThirdParty(true);
68+
}
5869
} else {
59-
setClickedOrder({ id, shortAlias });
60-
setOpenNoRobot(true);
70+
if (garage.getSlot()?.hashId) {
71+
navigate(`/order/${shortAlias}/${id}`);
72+
} else {
73+
setClickedOrder({ id, shortAlias });
74+
setOpenNoRobot(true);
75+
}
6176
}
6277
};
6378

6479
return (
6580
<Grid container direction='column' alignItems='center' spacing={1}>
81+
<VisitThirdParty
82+
open={openVisitThirdParty}
83+
onClose={() => {
84+
setOpenVisitThirdParty(false);
85+
}}
86+
thirdPartyOrder={thirdPartyOrder}
87+
/>
6688
<NoRobotDialog
6789
open={openNoRobot}
6890
onClose={() => {

frontend/src/basic/SettingsPage/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const SettingsPage = (): JSX.Element => {
1919
const onionUrlPattern = /^((http|https):\/\/)?[a-zA-Z2-7]{16,56}\.onion$/;
2020

2121
const addCoordinator: () => void = () => {
22-
if (federation.coordinators[newAlias]) {
22+
if (federation.getCoordinator(newAlias)) {
2323
setError(t('Alias already exists'));
2424
} else {
2525
if (onionUrlPattern.test(newUrl)) {

frontend/src/components/BookTable/BookControl.tsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import CheckBoxOutlineBlankIcon from '@mui/icons-material/CheckBoxOutlineBlank';
2222
import SwapCalls from '@mui/icons-material/SwapCalls';
2323
import { FederationContext, type UseFederationStoreType } from '../../contexts/FederationContext';
2424
import RobotAvatar from '../RobotAvatar';
25+
import RoboSats from '../Icons/RoboSats';
26+
import RoboSatsNoText from '../Icons/RoboSatsNoText';
2527

2628
interface BookControlProps {
2729
width: number;
@@ -350,7 +352,13 @@ const BookControl = ({
350352
<FlagWithProps code='ANY' />
351353
</div>
352354
</MenuItem>
353-
{Object.values(federation.coordinators)
355+
<MenuItem value='robosats'>
356+
<div style={{ display: 'flex', alignItems: 'center', flexWrap: 'wrap' }}>
357+
<RoboSatsNoText sx={{ color: '#1976d2' }} />
358+
</div>
359+
</MenuItem>
360+
{federation
361+
.getCoordinators()
354362
.filter((coord) => coord.enabled)
355363
.map((coordinator) => (
356364
<MenuItem

frontend/src/components/BookTable/index.tsx

+56-22
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { Fullscreen, FullscreenExit, Refresh } from '@mui/icons-material';
4040
import { AppContext, type UseAppStoreType } from '../../contexts/AppContext';
4141
import { FederationContext, type UseFederationStoreType } from '../../contexts/FederationContext';
4242
import headerStyleFix from '../DataGrid/HeaderFix';
43+
import thirdParties from '../../../static/thirdparties.json';
4344

4445
const ClickThroughDataGrid = styled(DataGrid)({
4546
'& .MuiDataGrid-overlayWrapperInner': {
@@ -183,6 +184,7 @@ const BookTable = ({
183184
headerName: t('Robot'),
184185
width: width * fontSize,
185186
renderCell: (params: any) => {
187+
const thirdParty = thirdParties[params.row.coordinatorShortAlias];
186188
return (
187189
<ListItemButton
188190
style={{ cursor: 'pointer' }}
@@ -203,7 +205,7 @@ const BookTable = ({
203205
/>
204206
</ListItemAvatar>
205207
<ListItemText
206-
primary={params.row.maker_nick}
208+
primary={params.row.maker_nick ?? thirdParty.longAlias}
207209
sx={{ position: 'relative', left: '-1.3em', bottom: '0.6em' }}
208210
/>
209211
</ListItemButton>
@@ -218,9 +220,11 @@ const BookTable = ({
218220
headerName: t('Robot'),
219221
width: width * fontSize,
220222
renderCell: (params: any) => {
223+
const coordinator = federation.getCoordinator(params.row.coordinatorShortAlias);
224+
const thirdParty = thirdParties[params.row.coordinatorShortAlias];
221225
return (
222226
<div
223-
style={{ position: 'relative', left: '-0.34em', cursor: 'pointer', bottom: '0.2em' }}
227+
style={{ position: 'relative', cursor: 'pointer', bottom: '0.2em' }}
224228
onClick={() => {
225229
onOrderClicked(params.row.id, params.row.coordinatorShortAlias);
226230
}}
@@ -233,6 +237,10 @@ const BookTable = ({
233237
orderType={params.row.type}
234238
statusColor={statusBadgeColor(params.row.maker_status)}
235239
tooltip={t(params.row.maker_status)}
240+
coordinatorShortAlias={
241+
thirdParty?.shortAlias ??
242+
(coordinator?.federated ? params.row.coordinatorShortAlias : undefined)
243+
}
236244
/>
237245
</div>
238246
);
@@ -242,7 +250,12 @@ const BookTable = ({
242250

243251
const onClickCoordinator = function (shortAlias: string): void {
244252
setOpen((open) => {
245-
return { ...open, coordinator: shortAlias };
253+
const thirdParty = thirdParties[shortAlias];
254+
if (thirdParty) {
255+
return { ...open, thirdParty: shortAlias };
256+
} else {
257+
return { ...open, coordinator: shortAlias };
258+
}
246259
});
247260
};
248261

@@ -252,7 +265,8 @@ const BookTable = ({
252265
headerName: t('Host'),
253266
width: width * fontSize,
254267
renderCell: (params: any) => {
255-
const coordinator = federation.coordinators[params.row.coordinatorShortAlias];
268+
const coordinator = federation.getCoordinator(params.row.coordinatorShortAlias);
269+
const thirdParty = thirdParties[params.row.coordinatorShortAlias];
256270
return (
257271
<ListItemButton
258272
style={{ cursor: 'pointer' }}
@@ -262,8 +276,11 @@ const BookTable = ({
262276
>
263277
<ListItemAvatar sx={{ position: 'relative', left: '-1.54em', bottom: '0.4em' }}>
264278
<RobotAvatar
265-
shortAlias={coordinator.federated ? params.row.coordinatorShortAlias : undefined}
266-
hashId={coordinator.federated ? undefined : coordinator.mainnet.onion}
279+
shortAlias={
280+
thirdParty?.shortAlias ??
281+
(coordinator?.federated ? params.row.coordinatorShortAlias : undefined)
282+
}
283+
hashId={coordinator?.federated ? undefined : coordinator?.shortAlias}
267284
style={{ width: '3.215em', height: '3.215em' }}
268285
smooth={true}
269286
small={true}
@@ -426,7 +443,9 @@ const BookTable = ({
426443
width: width * fontSize,
427444
renderCell: (params: any) => {
428445
const currencyCode = String(currencyDict[params.row.currency.toString()]);
429-
const coordinator = federation.getCoordinator(params.row.coordinatorShortAlias);
446+
const coordinator =
447+
federation.getCoordinator(params.row.coordinatorShortAlias) ??
448+
federation.getCoordinators()[0];
430449
const premium = parseFloat(params.row.premium);
431450
const limitPrice = coordinator.limits[params.row.currency.toString()]?.price;
432451
const price = (limitPrice ?? 1) * (1 + premium / 100);
@@ -523,7 +542,7 @@ const BookTable = ({
523542
onOrderClicked(params.row.id, params.row.coordinatorShortAlias);
524543
}}
525544
>
526-
{hours > 0 ? `${hours}h` : `${minutes}m`}
545+
{hours > 0 ? `${hours}h` : minutes ? `${minutes}m` : '-'}
527546
</div>
528547
);
529548
},
@@ -585,7 +604,9 @@ const BookTable = ({
585604
type: 'number',
586605
width: width * fontSize,
587606
renderCell: (params: any) => {
588-
const coordinator = federation.getCoordinator(params.row.coordinatorShortAlias);
607+
const coordinator =
608+
federation.getCoordinator(params.row.coordinatorShortAlias) ??
609+
federation.getCoordinators()[0];
589610
const amount =
590611
params.row.has_range === true
591612
? parseFloat(params.row.max_amount)
@@ -646,7 +667,9 @@ const BookTable = ({
646667
onClick={() => {
647668
onOrderClicked(params.row.id, params.row.coordinatorShortAlias);
648669
}}
649-
>{`${Number(params.row.bond_size)}%`}</div>
670+
>
671+
{params.row.bond_size ? `${Number(params.row.bond_size)}%` : '-'}
672+
</div>
650673
);
651674
},
652675
};
@@ -698,18 +721,10 @@ const BookTable = ({
698721
object: robotObj,
699722
},
700723
small: {
701-
width: 4.1,
724+
width: 5.1,
702725
object: robotSmallObj,
703726
},
704727
},
705-
coordinatorShortAlias: {
706-
priority: 5,
707-
order: 3,
708-
normal: {
709-
width: 4.1,
710-
object: coordinatorObj,
711-
},
712-
},
713728
price: {
714729
priority: 6,
715730
order: 11,
@@ -742,24 +757,43 @@ const BookTable = ({
742757
object: satoshisObj,
743758
},
744759
},
745-
type: {
760+
coordinatorShortAlias: {
746761
priority: 10,
762+
order: 3,
763+
normal: {
764+
width: 4.1,
765+
object: coordinatorObj,
766+
},
767+
small: {
768+
width: 5.1,
769+
object: () => {
770+
return {
771+
field: 'coordinatorShortAlias',
772+
headerName: '',
773+
width: 0,
774+
renderCell: () => <></>,
775+
};
776+
},
777+
},
778+
},
779+
type: {
780+
priority: 11,
747781
order: 2,
748782
normal: {
749783
width: fav.mode === 'swap' ? 7 : 4.3,
750784
object: typeObj,
751785
},
752786
},
753787
bond_size: {
754-
priority: 11,
788+
priority: 12,
755789
order: 11,
756790
normal: {
757791
width: 4.2,
758792
object: bondObj,
759793
},
760794
},
761795
id: {
762-
priority: 12,
796+
priority: 13,
763797
order: 13,
764798
normal: {
765799
width: 4.8,

frontend/src/components/Charts/DepthChart/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ const DepthChart: React.FC<DepthChartProps> = ({
6868
useEffect(() => {
6969
if (Object.values(federation.book).length > 0) {
7070
const enriched = Object.values(federation.book).map((order) => {
71-
if (order?.coordinatorShortAlias && order?.currency) {
72-
const limits = federation.getCoordinator(order.coordinatorShortAlias)?.limits;
71+
if (order?.currency) {
72+
const limits = federation.getCoordinators()[0]?.limits;
7373

7474
const originalPrice =
7575
(limits[order.currency]?.price ?? 0) * (1 + parseFloat(order.premium) / 100);

0 commit comments

Comments
 (0)