Skip to content

Commit ce4a96b

Browse files
authored
Merge pull request #1632 from RoboSats/filter-deepth-chart-by-host
Filter deepth chart by host
2 parents a600e70 + c7c7f0b commit ce4a96b

28 files changed

+70
-36
lines changed

.pre-commit-config.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ repos:
3838
files: ^frontend/
3939
types_or: [javascript, jsx, ts, tsx, css, markdown, json] # uses https://github.com/pre-commit/identify
4040
entry: bash -c 'cd frontend && npm run format'
41+
- id: lintern-frontend
42+
name: lintern-frontend
43+
stages:
44+
- commit
45+
- merge-commit
46+
language: system
47+
files: ^frontend/
48+
types_or: [javascript, jsx, ts, tsx, css, markdown, json] # uses https://github.com/pre-commit/identify
49+
entry: bash -c 'cd frontend && npm run lint'
4150
- id: prettier-mobile
4251
name: prettier-mobile
4352
stages:
@@ -47,6 +56,15 @@ repos:
4756
files: ^mobile/
4857
types_or: [javascript, jsx, ts, tsx, css, markdown, json] # uses https://github.com/pre-commit/identify
4958
entry: bash -c 'cd mobile && npm run format'
59+
- id: lintern-mobile
60+
name: lintern-mobile
61+
stages:
62+
- commit
63+
- merge-commit
64+
language: system
65+
files: ^mobile/
66+
types_or: [javascript, jsx, ts, tsx, css, markdown, json] # uses https://github.com/pre-commit/identify
67+
entry: bash -c 'cd mobile && npm run lint'
5068
- repo: https://github.com/astral-sh/ruff-pre-commit
5169
rev: v0.1.13
5270
hooks:

frontend/src/basic/MakerPage/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { NoRobotDialog } from '../../components/Dialogs';
1212
import { FederationContext, type UseFederationStoreType } from '../../contexts/FederationContext';
1313
import { GarageContext, type UseGarageStoreType } from '../../contexts/GarageContext';
1414
import VisitThirdParty from '../../components/Dialogs/VisitThirdParty';
15-
import { PublicOrder } from '../../models';
15+
import { type PublicOrder } from '../../models';
1616

1717
const MakerPage = (): JSX.Element => {
1818
const { fav, windowSize, navbarHeight } = useContext<UseAppStoreType>(AppContext);

frontend/src/components/BookTable/BookControl.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ 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';
2625
import RoboSatsNoText from '../Icons/RoboSatsNoText';
2726

2827
interface BookControlProps {

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

+21-6
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,17 @@ const DepthChart: React.FC<DepthChartProps> = ({
5656
const [xRange, setXRange] = useState<number>(8);
5757
const [xType, setXType] = useState<string>('premium');
5858
const [currencyCode, setCurrencyCode] = useState<number>(0);
59+
const [coordinatorFilter, setCoordinatorFilter] = useState<string>('all');
5960
const [center, setCenter] = useState<number>();
6061

6162
const height = maxHeight < 10 ? 10 : maxHeight;
6263
const width = maxWidth < 10 ? 10 : maxWidth > 72.8 ? 72.8 : maxWidth;
6364

6465
useEffect(() => {
65-
setCurrencyCode(fav.currency); // as selected in BookControl
66-
}, [fav.currency]);
66+
setCurrencyCode(fav.currency); // as selected in BookControl
67+
setCoordinatorFilter(fav.coordinator);
68+
console.log(fav.coordinator);
69+
}, [fav.currency, fav.coordinator]);
6770

6871
useEffect(() => {
6972
if (Object.values(federation.book).length > 0) {
@@ -89,7 +92,7 @@ const DepthChart: React.FC<DepthChartProps> = ({
8992
});
9093
setEnrichedOrders(enriched);
9194
}
92-
}, [federationUpdatedAt, currencyCode]);
95+
}, [federationUpdatedAt, currencyCode, coordinatorFilter]);
9396

9497
useEffect(() => {
9598
if (enrichedOrders.length > 0) {
@@ -119,22 +122,34 @@ const DepthChart: React.FC<DepthChartProps> = ({
119122
setXRange(8);
120123
setRangeSteps(0.5);
121124
}
122-
}, [enrichedOrders, xType, federationUpdatedAt, currencyCode]);
125+
}, [enrichedOrders, xType, federationUpdatedAt, currencyCode, coordinatorFilter]);
123126

124127
const generateSeries: () => void = () => {
125128
const sortedOrders: PublicOrder[] =
126129
xType === 'base_price'
127130
? enrichedOrders
128131
.filter(
129-
(order: PublicOrder | null) => currencyCode === 0 || order?.currency == currencyCode,
132+
(order: PublicOrder | null) => currencyCode === 0 || order?.currency === currencyCode,
133+
)
134+
.filter(
135+
(order: PublicOrder | null) =>
136+
coordinatorFilter === 'any' ||
137+
(coordinatorFilter === 'robosats' && order?.federated) ||
138+
order?.coordinatorShortAlias === coordinatorFilter,
130139
)
131140
.sort(
132141
(order1: PublicOrder | null, order2: PublicOrder | null) =>
133142
(order1?.base_price ?? 0) - (order2?.base_price ?? 0),
134143
)
135144
: enrichedOrders
136145
.filter(
137-
(order: PublicOrder | null) => currencyCode === 0 || order?.currency == currencyCode,
146+
(order: PublicOrder | null) => currencyCode === 0 || order?.currency === currencyCode,
147+
)
148+
.filter(
149+
(order: PublicOrder | null) =>
150+
coordinatorFilter === 'any' ||
151+
(coordinatorFilter === 'robosats' && order?.federated) ||
152+
order?.coordinatorShortAlias === coordinatorFilter,
138153
)
139154
.sort(
140155
(order1: PublicOrder | null, order2: PublicOrder | null) =>

frontend/src/components/Dialogs/Exchange.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,14 @@ const ExchangeDialog = ({ open = false, onClose }: Props): JSX.Element => {
3838
const [loadingInfo, setLoadingInfo] = useState<boolean>(true);
3939

4040
useEffect(() => {
41-
if (open) federation.loadInfo();
41+
if (open) {
42+
federation
43+
.loadInfo()
44+
.then(() => {})
45+
.catch((error) => {
46+
console.error('Error loading info:', error);
47+
});
48+
}
4249
}, [open]);
4350

4451
useEffect(() => {

frontend/src/components/MakerForm/MakerForm.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,12 @@ const MakerForm = ({
8787
const amountSafeThresholds = [1.03, 0.98];
8888

8989
useEffect(() => {
90-
federation.loadInfo();
90+
federation
91+
.loadInfo()
92+
.then(() => {})
93+
.catch((error) => {
94+
console.error('Error loading info:', error);
95+
});
9196
}, []);
9297

9398
useEffect(() => {

frontend/src/components/MakerForm/SelectCoordinator.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
CircularProgress,
1111
Stack,
1212
} from '@mui/material';
13-
import { Bolt, Link, Info } from '@mui/icons-material';
13+
import { Link } from '@mui/icons-material';
1414
import RobotAvatar from '../RobotAvatar';
1515
import { AppContext, type UseAppStoreType } from '../../contexts/AppContext';
1616
import { useTheme } from '@emotion/react';

frontend/src/models/Book.model.ts

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export interface PublicOrder {
2525
maker_status?: 'Active' | 'Seen recently' | 'Inactive';
2626
coordinatorShortAlias?: string;
2727
link?: string;
28+
federated?: boolean;
2829
}
2930

3031
export interface Book {

frontend/src/utils/filterOrders.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type PublicOrder, type Favorites, type Federation, Coordinator } from '../models';
1+
import { type PublicOrder, type Favorites, type Federation } from '../models';
22
import thirdParties from '../../static/thirdparties.json';
33

44
interface AmountFilter {
@@ -35,7 +35,7 @@ const filterByHost = function (
3535
): boolean {
3636
if (shortAlias === 'any') {
3737
return true;
38-
} else if (shortAlias == 'robosats') {
38+
} else if (shortAlias === 'robosats') {
3939
const coordinator = federation.getCoordinator(order.coordinatorShortAlias ?? '');
4040
return coordinator?.federated ?? false;
4141
} else {
@@ -84,7 +84,7 @@ const filterOrders = function ({
8484
const coordinatorCheck = [...enabledCoordinators, ...Object.keys(thirdParties)].includes(
8585
order.coordinatorShortAlias ?? '',
8686
);
87-
const typeChecks = order.type === baseFilter.type || baseFilter.type == null;
87+
const typeChecks = order.type === baseFilter.type || baseFilter.type === null;
8888
const modeChecks = baseFilter.mode === 'fiat' ? !(order.currency === 1000) : true;
8989
const premiumChecks = premium !== null ? filterByPremium(order, premium) : true;
9090
const currencyChecks = order.currency === baseFilter.currency || baseFilter.currency === 0;

frontend/src/utils/nostr.ts

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const eventToPublicOrder = (event: Event): { dTag: string; publicOrder: PublicOr
4141
if (!coordinator || statusTag[1] !== 'pending') return { dTag: dTag[1], publicOrder: null };
4242

4343
publicOrder.coordinatorShortAlias = coordinator?.shortAlias;
44+
publicOrder.federated = coordinator?.federated ?? false;
4445

4546
event.tags.forEach((tag) => {
4647
switch (tag[0]) {

frontend/static/federation.json

+10-5
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
"i2p": ""
4848
},
4949
"mainnetNodesPubkeys": ["0226f31c5f3a8b48bbbb7aaa97a10effcfb445b5972a676955d5c095383d35a428"],
50-
"testnetNodesPubkeys": ["028e7a019180a664b84edf77ba656e96f2eb84f67f56d93020341caf4109e0dbc7"]
50+
"testnetNodesPubkeys": ["028e7a019180a664b84edf77ba656e96f2eb84f67f56d93020341caf4109e0dbc7"],
51+
"federated": true
5152
},
5253
"lake": {
5354
"longAlias": "TheBigLake",
@@ -94,7 +95,8 @@
9495
"i2p": ""
9596
},
9697
"mainnetNodesPubkeys": ["0385262f7e9e2eeeba1e7d6182a0efec98e79d01154b76189f3e0b88bcee279dd0"],
97-
"testnetNodesPubkeys": ["0355f8604df9ec4bee20a284f045f94e26cdd1fc5e15dee0716a5a5dfc7cd33b7c"]
98+
"testnetNodesPubkeys": ["0355f8604df9ec4bee20a284f045f94e26cdd1fc5e15dee0716a5a5dfc7cd33b7c"],
99+
"federated": true
98100
},
99101
"veneto": {
100102
"longAlias": "BitcoinVeneto",
@@ -140,7 +142,8 @@
140142
"i2p": ""
141143
},
142144
"mainnetNodesPubkeys": ["02c5b5972b05fba2cd2c2d9269a47bc478f73fae0f248a85cb1e5af60a07c1919d"],
143-
"testnetNodesPubkeys": ["032b698c8143f293d138c0926594f11d119194ddedb513f63a944d14c094d0e54a"]
145+
"testnetNodesPubkeys": ["032b698c8143f293d138c0926594f11d119194ddedb513f63a944d14c094d0e54a"],
146+
"federated": true
144147
},
145148
"moon": {
146149
"longAlias": "Over the moon",
@@ -186,7 +189,8 @@
186189
"i2p": ""
187190
},
188191
"mainnetNodesPubkeys": ["023924542082a5d16bce188ec4c29a45f00dd439a3f5992034d82e3353232a0345"],
189-
"testnetNodesPubkeys": ["02f0ddc838b35fe54daa13baa4abab84475c7b9f2670ff4b53c1724792843ef62a"]
192+
"testnetNodesPubkeys": ["02f0ddc838b35fe54daa13baa4abab84475c7b9f2670ff4b53c1724792843ef62a"],
193+
"federated": true
190194
},
191195
"local": {
192196
"longAlias": "Local Dev",
@@ -209,6 +213,7 @@
209213
"Development Policy": "Don't look around, just buidl"
210214
},
211215
"mainnetNodesPubkeys": ["..."],
212-
"testnetNodesPubkeys": ["..."]
216+
"testnetNodesPubkeys": ["..."],
217+
"federated": true
213218
}
214219
}

frontend/static/locales/ca.json

-1
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,6 @@
416416
"Maker": "Creador",
417417
"Onchain payouts enabled": "Onchain payouts enabled",
418418
"Taker": "Prenedor",
419-
"Order Host": "Amfitrió de l'ordre",
420419
"The provider the lightning and communication infrastructure. The host will be in charge of providing support and solving disputes. The trade fees are set by the host. Make sure to only select order hosts that you trust!": "El proveïdor de la infraestructura LN i comunicacions. L'amfitrió serà l'encarregat de donar suport i resoldre disputes. LEs comissions de les transaccions són fixades per l'amfitrió. Assegureu-vos de seleccionar només els amfitrions en què confieu!",
421420
"#41": "Phrases in components/Notifications/index.tsx",
422421
"Lightning routing failed": "L'enrutament Lightning ha fallat",

frontend/static/locales/cs.json

-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@
412412
"You send approx {{swapSats}} LN Sats (fees might vary)": "You send approx {{swapSats}} LN Sats (fees might vary)",
413413
"Your order fixed exchange rate": "Pevný směnný kurz tvé nabídky",
414414
"#40": "Phrases in components/MakerForm/SelectCoordinator.tsx",
415-
"Order Host": "Order Host",
416415
"Disabled": "Disabled",
417416
"Maker": "Tvůrce",
418417
"Onchain payouts enabled": "Onchain payouts enabled",

frontend/static/locales/de.json

-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@
412412
"You send approx {{swapSats}} LN Sats (fees might vary)": "You send approx {{swapSats}} LN Sats (fees might vary)",
413413
"Your order fixed exchange rate": "Dein fixierter Order-Kurs",
414414
"#40": "Phrases in components/MakerForm/SelectCoordinator.tsx",
415-
"Order Host": "Order Host",
416415
"Disabled": "Disabled",
417416
"Maker": "Maker",
418417
"Onchain payouts enabled": "Onchain payouts enabled",

frontend/static/locales/en.json

-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@
412412
"You send approx {{swapSats}} LN Sats (fees might vary)": "You send approx {{swapSats}} LN Sats (fees might vary)",
413413
"Your order fixed exchange rate": "Your order fixed exchange rate",
414414
"#40": "Phrases in components/MakerForm/SelectCoordinator.tsx",
415-
"Order Host": "Order Host",
416415
"Disabled": "Disabled",
417416
"Maker": "Maker",
418417
"Onchain payouts enabled": "Onchain payouts enabled",

frontend/static/locales/es.json

-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@
412412
"You send approx {{swapSats}} LN Sats (fees might vary)": "Envías aproximadamente {{swapSats}} LN Sats (la comisión puede variar)",
413413
"Your order fixed exchange rate": "La tasa de cambio fija de tu orden",
414414
"#40": "Phrases in components/MakerForm/SelectCoordinator.tsx",
415-
"Order Host": "Order Host",
416415
"Disabled": "Disabled",
417416
"Maker": "Creador",
418417
"Onchain payouts enabled": "Onchain payouts enabled",

frontend/static/locales/eu.json

-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@
412412
"You send approx {{swapSats}} LN Sats (fees might vary)": "You send approx {{swapSats}} LN Sats (fees might vary)",
413413
"Your order fixed exchange rate": "Zure eskaeraren kanbio-tasa finkoa",
414414
"#40": "Phrases in components/MakerForm/SelectCoordinator.tsx",
415-
"Order Host": "Order Host",
416415
"Disabled": "Disabled",
417416
"Maker": "Egile",
418417
"Onchain payouts enabled": "Onchain payouts enabled",

frontend/static/locales/fr.json

-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@
412412
"You send approx {{swapSats}} LN Sats (fees might vary)": "Vous envoyez environ {{swapSats}} LN Sats (les frais peuvent varier)",
413413
"Your order fixed exchange rate": "Taux de change fixe de votre commande",
414414
"#40": "Phrases in components/MakerForm/SelectCoordinator.tsx",
415-
"Order Host": "Order Host",
416415
"Disabled": "Disabled",
417416
"Maker": "Auteur",
418417
"Onchain payouts enabled": "Onchain payouts enabled",

frontend/static/locales/it.json

-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@
412412
"You send approx {{swapSats}} LN Sats (fees might vary)": "Invierai circa {{swapSats}} LN Sats (le commissioni possono variare)",
413413
"Your order fixed exchange rate": "Il tasso di cambio fisso del tuo ordine",
414414
"#40": "Phrases in components/MakerForm/SelectCoordinator.tsx",
415-
"Order Host": "Order Host",
416415
"Disabled": "Disabled",
417416
"Maker": "Maker",
418417
"Onchain payouts enabled": "Onchain payouts enabled",

frontend/static/locales/ja.json

-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@
412412
"You send approx {{swapSats}} LN Sats (fees might vary)": "約{{swapSats}} ライトニングSatsを送信します(手数料は異なる場合があります)",
413413
"Your order fixed exchange rate": "注文の固定為替レート",
414414
"#40": "Phrases in components/MakerForm/SelectCoordinator.tsx",
415-
"Order Host": "Order Host",
416415
"Disabled": "Disabled",
417416
"Maker": "メーカー",
418417
"Onchain payouts enabled": "Onchain payouts enabled",

frontend/static/locales/pl.json

-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@
412412
"You send approx {{swapSats}} LN Sats (fees might vary)": "You send approx {{swapSats}} LN Sats (fees might vary)",
413413
"Your order fixed exchange rate": "Your order fixed exchange rate",
414414
"#40": "Phrases in components/MakerForm/SelectCoordinator.tsx",
415-
"Order Host": "Order Host",
416415
"Disabled": "Disabled",
417416
"Maker": "Maker",
418417
"Onchain payouts enabled": "Onchain payouts enabled",

frontend/static/locales/pt.json

-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@
412412
"You send approx {{swapSats}} LN Sats (fees might vary)": "Você envia aprox {{swapSats}} LN Sats (as taxas podem variar)",
413413
"Your order fixed exchange rate": "Taxa de câmbio fixa do seu pedido",
414414
"#40": "Phrases in components/MakerForm/SelectCoordinator.tsx",
415-
"Order Host": "Order Host",
416415
"Disabled": "Disabled",
417416
"Maker": "Maker",
418417
"Onchain payouts enabled": "Onchain payouts enabled",

frontend/static/locales/ru.json

-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@
412412
"You send approx {{swapSats}} LN Sats (fees might vary)": "Вы отправляете примерно {{swapSats}} спутников LN (комиссия может различаться)",
413413
"Your order fixed exchange rate": "Фиксированный курс обмена Вашего ордера",
414414
"#40": "Phrases in components/MakerForm/SelectCoordinator.tsx",
415-
"Order Host": "Order Host",
416415
"Disabled": "Disabled",
417416
"Maker": "Мейкер",
418417
"Onchain payouts enabled": "Onchain payouts enabled",

frontend/static/locales/sv.json

-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@
412412
"You send approx {{swapSats}} LN Sats (fees might vary)": "You send approx {{swapSats}} LN Sats (fees might vary)",
413413
"Your order fixed exchange rate": "Din orders fasta växelkurs",
414414
"#40": "Phrases in components/MakerForm/SelectCoordinator.tsx",
415-
"Order Host": "Order Host",
416415
"Disabled": "Disabled",
417416
"Maker": "Maker",
418417
"Onchain payouts enabled": "Onchain payouts enabled",

frontend/static/locales/sw.json

-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@
412412
"You send approx {{swapSats}} LN Sats (fees might vary)": "Unatuma takribani {{swapSats}} LN Sats (ada inaweza kutofautiana)",
413413
"Your order fixed exchange rate": "Kiwango chako cha kubadilisha cha amri",
414414
"#40": "Phrases in components/MakerForm/SelectCoordinator.tsx",
415-
"Order Host": "Order Host",
416415
"Disabled": "Disabled",
417416
"Maker": "Muumba",
418417
"Onchain payouts enabled": "Onchain payouts enabled",

frontend/static/locales/th.json

-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@
412412
"You send approx {{swapSats}} LN Sats (fees might vary)": "You send approx {{swapSats}} LN Sats (fees might vary)",
413413
"Your order fixed exchange rate": "คุณกำหนดอัตราแลกเปลี่ยนคงที่",
414414
"#40": "Phrases in components/MakerForm/SelectCoordinator.tsx",
415-
"Order Host": "Order Host",
416415
"Disabled": "Disabled",
417416
"Maker": "Maker",
418417
"Onchain payouts enabled": "Onchain payouts enabled",

frontend/static/locales/zh-SI.json

-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@
412412
"You send approx {{swapSats}} LN Sats (fees might vary)": "你将发送大约{{swapSats}}闪电聪(费用会造成有所差异)",
413413
"Your order fixed exchange rate": "你的订单的固定汇率",
414414
"#40": "Phrases in components/MakerForm/SelectCoordinator.tsx",
415-
"Order Host": "Order Host",
416415
"Disabled": "Disabled",
417416
"Maker": "挂单方",
418417
"Onchain payouts enabled": "Onchain payouts enabled",

frontend/static/locales/zh-TR.json

-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@
412412
"You send approx {{swapSats}} LN Sats (fees might vary)": "你將發送大約{{swapSats}}閃電聰(費用會造成有所差異)",
413413
"Your order fixed exchange rate": "你的訂單的固定匯率",
414414
"#40": "Phrases in components/MakerForm/SelectCoordinator.tsx",
415-
"Order Host": "Order Host",
416415
"Disabled": "Disabled",
417416
"Maker": "掛單方",
418417
"Onchain payouts enabled": "Onchain payouts enabled",

0 commit comments

Comments
 (0)