From 449ee79ca4a44f5bf6120a639ed503e7c758477e Mon Sep 17 00:00:00 2001 From: koalasat Date: Mon, 25 Nov 2024 10:29:44 +0100 Subject: [PATCH] Filter depth chart by host --- .../components/Charts/DepthChart/index.tsx | 23 +++++++++++++++---- frontend/src/models/Book.model.ts | 1 + frontend/src/utils/nostr.ts | 1 + frontend/static/federation.json | 15 ++++++++---- frontend/static/locales/ca.json | 1 - frontend/static/locales/cs.json | 1 - frontend/static/locales/de.json | 1 - frontend/static/locales/en.json | 1 - frontend/static/locales/es.json | 1 - frontend/static/locales/eu.json | 1 - frontend/static/locales/fr.json | 1 - frontend/static/locales/it.json | 1 - frontend/static/locales/ja.json | 1 - frontend/static/locales/pl.json | 1 - frontend/static/locales/pt.json | 1 - frontend/static/locales/ru.json | 1 - frontend/static/locales/sv.json | 1 - frontend/static/locales/sw.json | 1 - frontend/static/locales/th.json | 1 - frontend/static/locales/zh-SI.json | 1 - frontend/static/locales/zh-TR.json | 1 - 21 files changed, 31 insertions(+), 26 deletions(-) diff --git a/frontend/src/components/Charts/DepthChart/index.tsx b/frontend/src/components/Charts/DepthChart/index.tsx index 475306fc..db5169e7 100644 --- a/frontend/src/components/Charts/DepthChart/index.tsx +++ b/frontend/src/components/Charts/DepthChart/index.tsx @@ -56,14 +56,17 @@ const DepthChart: React.FC = ({ const [xRange, setXRange] = useState(8); const [xType, setXType] = useState('premium'); const [currencyCode, setCurrencyCode] = useState(0); + const [coordinatorFilter, setCoordinatorFilter] = useState('all'); const [center, setCenter] = useState(); const height = maxHeight < 10 ? 10 : maxHeight; const width = maxWidth < 10 ? 10 : maxWidth > 72.8 ? 72.8 : maxWidth; useEffect(() => { - setCurrencyCode(fav.currency); // as selected in BookControl - }, [fav.currency]); + setCurrencyCode(fav.currency); // as selected in BookControl + setCoordinatorFilter(fav.coordinator); + console.log(fav.coordinator); + }, [fav.currency, fav.coordinator]); useEffect(() => { if (Object.values(federation.book).length > 0) { @@ -89,7 +92,7 @@ const DepthChart: React.FC = ({ }); setEnrichedOrders(enriched); } - }, [federationUpdatedAt, currencyCode]); + }, [federationUpdatedAt, currencyCode, coordinatorFilter]); useEffect(() => { if (enrichedOrders.length > 0) { @@ -119,7 +122,7 @@ const DepthChart: React.FC = ({ setXRange(8); setRangeSteps(0.5); } - }, [enrichedOrders, xType, federationUpdatedAt, currencyCode]); + }, [enrichedOrders, xType, federationUpdatedAt, currencyCode, coordinatorFilter]); const generateSeries: () => void = () => { const sortedOrders: PublicOrder[] = @@ -128,6 +131,12 @@ const DepthChart: React.FC = ({ .filter( (order: PublicOrder | null) => currencyCode === 0 || order?.currency == currencyCode, ) + .filter( + (order: PublicOrder | null) => + coordinatorFilter === 'any' || + (coordinatorFilter === 'robosats' && order?.federated) || + order?.coordinatorShortAlias == coordinatorFilter, + ) .sort( (order1: PublicOrder | null, order2: PublicOrder | null) => (order1?.base_price ?? 0) - (order2?.base_price ?? 0), @@ -136,6 +145,12 @@ const DepthChart: React.FC = ({ .filter( (order: PublicOrder | null) => currencyCode === 0 || order?.currency == currencyCode, ) + .filter( + (order: PublicOrder | null) => + coordinatorFilter === 'any' || + (coordinatorFilter === 'robosats' && order?.federated) || + order?.coordinatorShortAlias == coordinatorFilter, + ) .sort( (order1: PublicOrder | null, order2: PublicOrder | null) => order1?.premium - order2?.premium, diff --git a/frontend/src/models/Book.model.ts b/frontend/src/models/Book.model.ts index be15f83c..cf7023ed 100644 --- a/frontend/src/models/Book.model.ts +++ b/frontend/src/models/Book.model.ts @@ -25,6 +25,7 @@ export interface PublicOrder { maker_status?: 'Active' | 'Seen recently' | 'Inactive'; coordinatorShortAlias?: string; link?: string; + federated?: boolean; } export interface Book { diff --git a/frontend/src/utils/nostr.ts b/frontend/src/utils/nostr.ts index 5567e32b..fd28661b 100644 --- a/frontend/src/utils/nostr.ts +++ b/frontend/src/utils/nostr.ts @@ -41,6 +41,7 @@ const eventToPublicOrder = (event: Event): { dTag: string; publicOrder: PublicOr if (!coordinator || statusTag[1] !== 'pending') return { dTag: dTag[1], publicOrder: null }; publicOrder.coordinatorShortAlias = coordinator?.shortAlias; + publicOrder.federated = coordinator?.federated ?? false; event.tags.forEach((tag) => { switch (tag[0]) { diff --git a/frontend/static/federation.json b/frontend/static/federation.json index 6e32862d..1f13fa80 100644 --- a/frontend/static/federation.json +++ b/frontend/static/federation.json @@ -47,7 +47,8 @@ "i2p": "" }, "mainnetNodesPubkeys": ["0226f31c5f3a8b48bbbb7aaa97a10effcfb445b5972a676955d5c095383d35a428"], - "testnetNodesPubkeys": ["028e7a019180a664b84edf77ba656e96f2eb84f67f56d93020341caf4109e0dbc7"] + "testnetNodesPubkeys": ["028e7a019180a664b84edf77ba656e96f2eb84f67f56d93020341caf4109e0dbc7"], + "federated": true }, "lake": { "longAlias": "TheBigLake", @@ -94,7 +95,8 @@ "i2p": "" }, "mainnetNodesPubkeys": ["0385262f7e9e2eeeba1e7d6182a0efec98e79d01154b76189f3e0b88bcee279dd0"], - "testnetNodesPubkeys": ["0355f8604df9ec4bee20a284f045f94e26cdd1fc5e15dee0716a5a5dfc7cd33b7c"] + "testnetNodesPubkeys": ["0355f8604df9ec4bee20a284f045f94e26cdd1fc5e15dee0716a5a5dfc7cd33b7c"], + "federated": true }, "veneto": { "longAlias": "BitcoinVeneto", @@ -140,7 +142,8 @@ "i2p": "" }, "mainnetNodesPubkeys": ["02c5b5972b05fba2cd2c2d9269a47bc478f73fae0f248a85cb1e5af60a07c1919d"], - "testnetNodesPubkeys": ["032b698c8143f293d138c0926594f11d119194ddedb513f63a944d14c094d0e54a"] + "testnetNodesPubkeys": ["032b698c8143f293d138c0926594f11d119194ddedb513f63a944d14c094d0e54a"], + "federated": true }, "moon": { "longAlias": "Over the moon", @@ -186,7 +189,8 @@ "i2p": "" }, "mainnetNodesPubkeys": ["023924542082a5d16bce188ec4c29a45f00dd439a3f5992034d82e3353232a0345"], - "testnetNodesPubkeys": ["02f0ddc838b35fe54daa13baa4abab84475c7b9f2670ff4b53c1724792843ef62a"] + "testnetNodesPubkeys": ["02f0ddc838b35fe54daa13baa4abab84475c7b9f2670ff4b53c1724792843ef62a"], + "federated": true }, "local": { "longAlias": "Local Dev", @@ -209,6 +213,7 @@ "Development Policy": "Don't look around, just buidl" }, "mainnetNodesPubkeys": ["..."], - "testnetNodesPubkeys": ["..."] + "testnetNodesPubkeys": ["..."], + "federated": true } } diff --git a/frontend/static/locales/ca.json b/frontend/static/locales/ca.json index 04554b11..fe3e4816 100644 --- a/frontend/static/locales/ca.json +++ b/frontend/static/locales/ca.json @@ -416,7 +416,6 @@ "Maker": "Creador", "Onchain payouts enabled": "Onchain payouts enabled", "Taker": "Prenedor", - "Order Host": "Amfitrió de l'ordre", "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!", "#41": "Phrases in components/Notifications/index.tsx", "Lightning routing failed": "L'enrutament Lightning ha fallat", diff --git a/frontend/static/locales/cs.json b/frontend/static/locales/cs.json index ccc21430..64ffa9db 100644 --- a/frontend/static/locales/cs.json +++ b/frontend/static/locales/cs.json @@ -412,7 +412,6 @@ "You send approx {{swapSats}} LN Sats (fees might vary)": "You send approx {{swapSats}} LN Sats (fees might vary)", "Your order fixed exchange rate": "Pevný směnný kurz tvé nabídky", "#40": "Phrases in components/MakerForm/SelectCoordinator.tsx", - "Order Host": "Order Host", "Disabled": "Disabled", "Maker": "Tvůrce", "Onchain payouts enabled": "Onchain payouts enabled", diff --git a/frontend/static/locales/de.json b/frontend/static/locales/de.json index 5359bc6b..d0e9885b 100644 --- a/frontend/static/locales/de.json +++ b/frontend/static/locales/de.json @@ -412,7 +412,6 @@ "You send approx {{swapSats}} LN Sats (fees might vary)": "You send approx {{swapSats}} LN Sats (fees might vary)", "Your order fixed exchange rate": "Dein fixierter Order-Kurs", "#40": "Phrases in components/MakerForm/SelectCoordinator.tsx", - "Order Host": "Order Host", "Disabled": "Disabled", "Maker": "Maker", "Onchain payouts enabled": "Onchain payouts enabled", diff --git a/frontend/static/locales/en.json b/frontend/static/locales/en.json index 343abb72..48f45e96 100644 --- a/frontend/static/locales/en.json +++ b/frontend/static/locales/en.json @@ -412,7 +412,6 @@ "You send approx {{swapSats}} LN Sats (fees might vary)": "You send approx {{swapSats}} LN Sats (fees might vary)", "Your order fixed exchange rate": "Your order fixed exchange rate", "#40": "Phrases in components/MakerForm/SelectCoordinator.tsx", - "Order Host": "Order Host", "Disabled": "Disabled", "Maker": "Maker", "Onchain payouts enabled": "Onchain payouts enabled", diff --git a/frontend/static/locales/es.json b/frontend/static/locales/es.json index fbc5fcfe..7e895281 100644 --- a/frontend/static/locales/es.json +++ b/frontend/static/locales/es.json @@ -412,7 +412,6 @@ "You send approx {{swapSats}} LN Sats (fees might vary)": "Envías aproximadamente {{swapSats}} LN Sats (la comisión puede variar)", "Your order fixed exchange rate": "La tasa de cambio fija de tu orden", "#40": "Phrases in components/MakerForm/SelectCoordinator.tsx", - "Order Host": "Order Host", "Disabled": "Disabled", "Maker": "Creador", "Onchain payouts enabled": "Onchain payouts enabled", diff --git a/frontend/static/locales/eu.json b/frontend/static/locales/eu.json index 3629d45d..a62e4cc3 100644 --- a/frontend/static/locales/eu.json +++ b/frontend/static/locales/eu.json @@ -412,7 +412,6 @@ "You send approx {{swapSats}} LN Sats (fees might vary)": "You send approx {{swapSats}} LN Sats (fees might vary)", "Your order fixed exchange rate": "Zure eskaeraren kanbio-tasa finkoa", "#40": "Phrases in components/MakerForm/SelectCoordinator.tsx", - "Order Host": "Order Host", "Disabled": "Disabled", "Maker": "Egile", "Onchain payouts enabled": "Onchain payouts enabled", diff --git a/frontend/static/locales/fr.json b/frontend/static/locales/fr.json index 1b41a4b5..def2ac2e 100644 --- a/frontend/static/locales/fr.json +++ b/frontend/static/locales/fr.json @@ -412,7 +412,6 @@ "You send approx {{swapSats}} LN Sats (fees might vary)": "Vous envoyez environ {{swapSats}} LN Sats (les frais peuvent varier)", "Your order fixed exchange rate": "Taux de change fixe de votre commande", "#40": "Phrases in components/MakerForm/SelectCoordinator.tsx", - "Order Host": "Order Host", "Disabled": "Disabled", "Maker": "Auteur", "Onchain payouts enabled": "Onchain payouts enabled", diff --git a/frontend/static/locales/it.json b/frontend/static/locales/it.json index cba7b356..76d1017f 100644 --- a/frontend/static/locales/it.json +++ b/frontend/static/locales/it.json @@ -412,7 +412,6 @@ "You send approx {{swapSats}} LN Sats (fees might vary)": "Invierai circa {{swapSats}} LN Sats (le commissioni possono variare)", "Your order fixed exchange rate": "Il tasso di cambio fisso del tuo ordine", "#40": "Phrases in components/MakerForm/SelectCoordinator.tsx", - "Order Host": "Order Host", "Disabled": "Disabled", "Maker": "Maker", "Onchain payouts enabled": "Onchain payouts enabled", diff --git a/frontend/static/locales/ja.json b/frontend/static/locales/ja.json index fcd621b3..6f2e0082 100644 --- a/frontend/static/locales/ja.json +++ b/frontend/static/locales/ja.json @@ -412,7 +412,6 @@ "You send approx {{swapSats}} LN Sats (fees might vary)": "約{{swapSats}} ライトニングSatsを送信します(手数料は異なる場合があります)", "Your order fixed exchange rate": "注文の固定為替レート", "#40": "Phrases in components/MakerForm/SelectCoordinator.tsx", - "Order Host": "Order Host", "Disabled": "Disabled", "Maker": "メーカー", "Onchain payouts enabled": "Onchain payouts enabled", diff --git a/frontend/static/locales/pl.json b/frontend/static/locales/pl.json index b5bf7351..27eda701 100644 --- a/frontend/static/locales/pl.json +++ b/frontend/static/locales/pl.json @@ -412,7 +412,6 @@ "You send approx {{swapSats}} LN Sats (fees might vary)": "You send approx {{swapSats}} LN Sats (fees might vary)", "Your order fixed exchange rate": "Your order fixed exchange rate", "#40": "Phrases in components/MakerForm/SelectCoordinator.tsx", - "Order Host": "Order Host", "Disabled": "Disabled", "Maker": "Maker", "Onchain payouts enabled": "Onchain payouts enabled", diff --git a/frontend/static/locales/pt.json b/frontend/static/locales/pt.json index 132a612a..24288734 100644 --- a/frontend/static/locales/pt.json +++ b/frontend/static/locales/pt.json @@ -412,7 +412,6 @@ "You send approx {{swapSats}} LN Sats (fees might vary)": "Você envia aprox {{swapSats}} LN Sats (as taxas podem variar)", "Your order fixed exchange rate": "Taxa de câmbio fixa do seu pedido", "#40": "Phrases in components/MakerForm/SelectCoordinator.tsx", - "Order Host": "Order Host", "Disabled": "Disabled", "Maker": "Maker", "Onchain payouts enabled": "Onchain payouts enabled", diff --git a/frontend/static/locales/ru.json b/frontend/static/locales/ru.json index 0471375e..1c894a9f 100644 --- a/frontend/static/locales/ru.json +++ b/frontend/static/locales/ru.json @@ -412,7 +412,6 @@ "You send approx {{swapSats}} LN Sats (fees might vary)": "Вы отправляете примерно {{swapSats}} спутников LN (комиссия может различаться)", "Your order fixed exchange rate": "Фиксированный курс обмена Вашего ордера", "#40": "Phrases in components/MakerForm/SelectCoordinator.tsx", - "Order Host": "Order Host", "Disabled": "Disabled", "Maker": "Мейкер", "Onchain payouts enabled": "Onchain payouts enabled", diff --git a/frontend/static/locales/sv.json b/frontend/static/locales/sv.json index 8be59df0..9f06967f 100644 --- a/frontend/static/locales/sv.json +++ b/frontend/static/locales/sv.json @@ -412,7 +412,6 @@ "You send approx {{swapSats}} LN Sats (fees might vary)": "You send approx {{swapSats}} LN Sats (fees might vary)", "Your order fixed exchange rate": "Din orders fasta växelkurs", "#40": "Phrases in components/MakerForm/SelectCoordinator.tsx", - "Order Host": "Order Host", "Disabled": "Disabled", "Maker": "Maker", "Onchain payouts enabled": "Onchain payouts enabled", diff --git a/frontend/static/locales/sw.json b/frontend/static/locales/sw.json index be9a5c84..342ae84c 100644 --- a/frontend/static/locales/sw.json +++ b/frontend/static/locales/sw.json @@ -412,7 +412,6 @@ "You send approx {{swapSats}} LN Sats (fees might vary)": "Unatuma takribani {{swapSats}} LN Sats (ada inaweza kutofautiana)", "Your order fixed exchange rate": "Kiwango chako cha kubadilisha cha amri", "#40": "Phrases in components/MakerForm/SelectCoordinator.tsx", - "Order Host": "Order Host", "Disabled": "Disabled", "Maker": "Muumba", "Onchain payouts enabled": "Onchain payouts enabled", diff --git a/frontend/static/locales/th.json b/frontend/static/locales/th.json index ab2deea3..04d403b2 100644 --- a/frontend/static/locales/th.json +++ b/frontend/static/locales/th.json @@ -412,7 +412,6 @@ "You send approx {{swapSats}} LN Sats (fees might vary)": "You send approx {{swapSats}} LN Sats (fees might vary)", "Your order fixed exchange rate": "คุณกำหนดอัตราแลกเปลี่ยนคงที่", "#40": "Phrases in components/MakerForm/SelectCoordinator.tsx", - "Order Host": "Order Host", "Disabled": "Disabled", "Maker": "Maker", "Onchain payouts enabled": "Onchain payouts enabled", diff --git a/frontend/static/locales/zh-SI.json b/frontend/static/locales/zh-SI.json index db8c2c8f..8a22aec5 100644 --- a/frontend/static/locales/zh-SI.json +++ b/frontend/static/locales/zh-SI.json @@ -412,7 +412,6 @@ "You send approx {{swapSats}} LN Sats (fees might vary)": "你将发送大约{{swapSats}}闪电聪(费用会造成有所差异)", "Your order fixed exchange rate": "你的订单的固定汇率", "#40": "Phrases in components/MakerForm/SelectCoordinator.tsx", - "Order Host": "Order Host", "Disabled": "Disabled", "Maker": "挂单方", "Onchain payouts enabled": "Onchain payouts enabled", diff --git a/frontend/static/locales/zh-TR.json b/frontend/static/locales/zh-TR.json index 3244a56f..0ee1c4d7 100644 --- a/frontend/static/locales/zh-TR.json +++ b/frontend/static/locales/zh-TR.json @@ -412,7 +412,6 @@ "You send approx {{swapSats}} LN Sats (fees might vary)": "你將發送大約{{swapSats}}閃電聰(費用會造成有所差異)", "Your order fixed exchange rate": "你的訂單的固定匯率", "#40": "Phrases in components/MakerForm/SelectCoordinator.tsx", - "Order Host": "Order Host", "Disabled": "Disabled", "Maker": "掛單方", "Onchain payouts enabled": "Onchain payouts enabled",