Filter depth chart by host

This commit is contained in:
koalasat 2024-11-25 10:29:44 +01:00
parent a600e70be0
commit 449ee79ca4
No known key found for this signature in database
GPG Key ID: 2F7F61C6146AB157
21 changed files with 31 additions and 26 deletions

View File

@ -56,14 +56,17 @@ const DepthChart: React.FC<DepthChartProps> = ({
const [xRange, setXRange] = useState<number>(8); const [xRange, setXRange] = useState<number>(8);
const [xType, setXType] = useState<string>('premium'); const [xType, setXType] = useState<string>('premium');
const [currencyCode, setCurrencyCode] = useState<number>(0); const [currencyCode, setCurrencyCode] = useState<number>(0);
const [coordinatorFilter, setCoordinatorFilter] = useState<string>('all');
const [center, setCenter] = useState<number>(); const [center, setCenter] = useState<number>();
const height = maxHeight < 10 ? 10 : maxHeight; const height = maxHeight < 10 ? 10 : maxHeight;
const width = maxWidth < 10 ? 10 : maxWidth > 72.8 ? 72.8 : maxWidth; const width = maxWidth < 10 ? 10 : maxWidth > 72.8 ? 72.8 : maxWidth;
useEffect(() => { useEffect(() => {
setCurrencyCode(fav.currency); // as selected in BookControl setCurrencyCode(fav.currency); // as selected in BookControl
}, [fav.currency]); setCoordinatorFilter(fav.coordinator);
console.log(fav.coordinator);
}, [fav.currency, fav.coordinator]);
useEffect(() => { useEffect(() => {
if (Object.values(federation.book).length > 0) { if (Object.values(federation.book).length > 0) {
@ -89,7 +92,7 @@ const DepthChart: React.FC<DepthChartProps> = ({
}); });
setEnrichedOrders(enriched); setEnrichedOrders(enriched);
} }
}, [federationUpdatedAt, currencyCode]); }, [federationUpdatedAt, currencyCode, coordinatorFilter]);
useEffect(() => { useEffect(() => {
if (enrichedOrders.length > 0) { if (enrichedOrders.length > 0) {
@ -119,7 +122,7 @@ const DepthChart: React.FC<DepthChartProps> = ({
setXRange(8); setXRange(8);
setRangeSteps(0.5); setRangeSteps(0.5);
} }
}, [enrichedOrders, xType, federationUpdatedAt, currencyCode]); }, [enrichedOrders, xType, federationUpdatedAt, currencyCode, coordinatorFilter]);
const generateSeries: () => void = () => { const generateSeries: () => void = () => {
const sortedOrders: PublicOrder[] = const sortedOrders: PublicOrder[] =
@ -128,6 +131,12 @@ const DepthChart: React.FC<DepthChartProps> = ({
.filter( .filter(
(order: PublicOrder | null) => currencyCode === 0 || order?.currency == currencyCode, (order: PublicOrder | null) => currencyCode === 0 || order?.currency == currencyCode,
) )
.filter(
(order: PublicOrder | null) =>
coordinatorFilter === 'any' ||
(coordinatorFilter === 'robosats' && order?.federated) ||
order?.coordinatorShortAlias == coordinatorFilter,
)
.sort( .sort(
(order1: PublicOrder | null, order2: PublicOrder | null) => (order1: PublicOrder | null, order2: PublicOrder | null) =>
(order1?.base_price ?? 0) - (order2?.base_price ?? 0), (order1?.base_price ?? 0) - (order2?.base_price ?? 0),
@ -136,6 +145,12 @@ const DepthChart: React.FC<DepthChartProps> = ({
.filter( .filter(
(order: PublicOrder | null) => currencyCode === 0 || order?.currency == currencyCode, (order: PublicOrder | null) => currencyCode === 0 || order?.currency == currencyCode,
) )
.filter(
(order: PublicOrder | null) =>
coordinatorFilter === 'any' ||
(coordinatorFilter === 'robosats' && order?.federated) ||
order?.coordinatorShortAlias == coordinatorFilter,
)
.sort( .sort(
(order1: PublicOrder | null, order2: PublicOrder | null) => (order1: PublicOrder | null, order2: PublicOrder | null) =>
order1?.premium - order2?.premium, order1?.premium - order2?.premium,

View File

@ -25,6 +25,7 @@ export interface PublicOrder {
maker_status?: 'Active' | 'Seen recently' | 'Inactive'; maker_status?: 'Active' | 'Seen recently' | 'Inactive';
coordinatorShortAlias?: string; coordinatorShortAlias?: string;
link?: string; link?: string;
federated?: boolean;
} }
export interface Book { export interface Book {

View File

@ -41,6 +41,7 @@ const eventToPublicOrder = (event: Event): { dTag: string; publicOrder: PublicOr
if (!coordinator || statusTag[1] !== 'pending') return { dTag: dTag[1], publicOrder: null }; if (!coordinator || statusTag[1] !== 'pending') return { dTag: dTag[1], publicOrder: null };
publicOrder.coordinatorShortAlias = coordinator?.shortAlias; publicOrder.coordinatorShortAlias = coordinator?.shortAlias;
publicOrder.federated = coordinator?.federated ?? false;
event.tags.forEach((tag) => { event.tags.forEach((tag) => {
switch (tag[0]) { switch (tag[0]) {

View File

@ -47,7 +47,8 @@
"i2p": "" "i2p": ""
}, },
"mainnetNodesPubkeys": ["0226f31c5f3a8b48bbbb7aaa97a10effcfb445b5972a676955d5c095383d35a428"], "mainnetNodesPubkeys": ["0226f31c5f3a8b48bbbb7aaa97a10effcfb445b5972a676955d5c095383d35a428"],
"testnetNodesPubkeys": ["028e7a019180a664b84edf77ba656e96f2eb84f67f56d93020341caf4109e0dbc7"] "testnetNodesPubkeys": ["028e7a019180a664b84edf77ba656e96f2eb84f67f56d93020341caf4109e0dbc7"],
"federated": true
}, },
"lake": { "lake": {
"longAlias": "TheBigLake", "longAlias": "TheBigLake",
@ -94,7 +95,8 @@
"i2p": "" "i2p": ""
}, },
"mainnetNodesPubkeys": ["0385262f7e9e2eeeba1e7d6182a0efec98e79d01154b76189f3e0b88bcee279dd0"], "mainnetNodesPubkeys": ["0385262f7e9e2eeeba1e7d6182a0efec98e79d01154b76189f3e0b88bcee279dd0"],
"testnetNodesPubkeys": ["0355f8604df9ec4bee20a284f045f94e26cdd1fc5e15dee0716a5a5dfc7cd33b7c"] "testnetNodesPubkeys": ["0355f8604df9ec4bee20a284f045f94e26cdd1fc5e15dee0716a5a5dfc7cd33b7c"],
"federated": true
}, },
"veneto": { "veneto": {
"longAlias": "BitcoinVeneto", "longAlias": "BitcoinVeneto",
@ -140,7 +142,8 @@
"i2p": "" "i2p": ""
}, },
"mainnetNodesPubkeys": ["02c5b5972b05fba2cd2c2d9269a47bc478f73fae0f248a85cb1e5af60a07c1919d"], "mainnetNodesPubkeys": ["02c5b5972b05fba2cd2c2d9269a47bc478f73fae0f248a85cb1e5af60a07c1919d"],
"testnetNodesPubkeys": ["032b698c8143f293d138c0926594f11d119194ddedb513f63a944d14c094d0e54a"] "testnetNodesPubkeys": ["032b698c8143f293d138c0926594f11d119194ddedb513f63a944d14c094d0e54a"],
"federated": true
}, },
"moon": { "moon": {
"longAlias": "Over the moon", "longAlias": "Over the moon",
@ -186,7 +189,8 @@
"i2p": "" "i2p": ""
}, },
"mainnetNodesPubkeys": ["023924542082a5d16bce188ec4c29a45f00dd439a3f5992034d82e3353232a0345"], "mainnetNodesPubkeys": ["023924542082a5d16bce188ec4c29a45f00dd439a3f5992034d82e3353232a0345"],
"testnetNodesPubkeys": ["02f0ddc838b35fe54daa13baa4abab84475c7b9f2670ff4b53c1724792843ef62a"] "testnetNodesPubkeys": ["02f0ddc838b35fe54daa13baa4abab84475c7b9f2670ff4b53c1724792843ef62a"],
"federated": true
}, },
"local": { "local": {
"longAlias": "Local Dev", "longAlias": "Local Dev",
@ -209,6 +213,7 @@
"Development Policy": "Don't look around, just buidl" "Development Policy": "Don't look around, just buidl"
}, },
"mainnetNodesPubkeys": ["..."], "mainnetNodesPubkeys": ["..."],
"testnetNodesPubkeys": ["..."] "testnetNodesPubkeys": ["..."],
"federated": true
} }
} }

View File

@ -416,7 +416,6 @@
"Maker": "Creador", "Maker": "Creador",
"Onchain payouts enabled": "Onchain payouts enabled", "Onchain payouts enabled": "Onchain payouts enabled",
"Taker": "Prenedor", "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!", "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", "#41": "Phrases in components/Notifications/index.tsx",
"Lightning routing failed": "L'enrutament Lightning ha fallat", "Lightning routing failed": "L'enrutament Lightning ha fallat",

View File

@ -412,7 +412,6 @@
"You send approx {{swapSats}} LN Sats (fees might vary)": "You send approx {{swapSats}} LN Sats (fees might vary)", "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", "Your order fixed exchange rate": "Pevný směnný kurz tvé nabídky",
"#40": "Phrases in components/MakerForm/SelectCoordinator.tsx", "#40": "Phrases in components/MakerForm/SelectCoordinator.tsx",
"Order Host": "Order Host",
"Disabled": "Disabled", "Disabled": "Disabled",
"Maker": "Tvůrce", "Maker": "Tvůrce",
"Onchain payouts enabled": "Onchain payouts enabled", "Onchain payouts enabled": "Onchain payouts enabled",

View File

@ -412,7 +412,6 @@
"You send approx {{swapSats}} LN Sats (fees might vary)": "You send approx {{swapSats}} LN Sats (fees might vary)", "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", "Your order fixed exchange rate": "Dein fixierter Order-Kurs",
"#40": "Phrases in components/MakerForm/SelectCoordinator.tsx", "#40": "Phrases in components/MakerForm/SelectCoordinator.tsx",
"Order Host": "Order Host",
"Disabled": "Disabled", "Disabled": "Disabled",
"Maker": "Maker", "Maker": "Maker",
"Onchain payouts enabled": "Onchain payouts enabled", "Onchain payouts enabled": "Onchain payouts enabled",

View File

@ -412,7 +412,6 @@
"You send approx {{swapSats}} LN Sats (fees might vary)": "You send approx {{swapSats}} LN Sats (fees might vary)", "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", "Your order fixed exchange rate": "Your order fixed exchange rate",
"#40": "Phrases in components/MakerForm/SelectCoordinator.tsx", "#40": "Phrases in components/MakerForm/SelectCoordinator.tsx",
"Order Host": "Order Host",
"Disabled": "Disabled", "Disabled": "Disabled",
"Maker": "Maker", "Maker": "Maker",
"Onchain payouts enabled": "Onchain payouts enabled", "Onchain payouts enabled": "Onchain payouts enabled",

View File

@ -412,7 +412,6 @@
"You send approx {{swapSats}} LN Sats (fees might vary)": "Envías aproximadamente {{swapSats}} LN Sats (la comisión puede variar)", "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", "Your order fixed exchange rate": "La tasa de cambio fija de tu orden",
"#40": "Phrases in components/MakerForm/SelectCoordinator.tsx", "#40": "Phrases in components/MakerForm/SelectCoordinator.tsx",
"Order Host": "Order Host",
"Disabled": "Disabled", "Disabled": "Disabled",
"Maker": "Creador", "Maker": "Creador",
"Onchain payouts enabled": "Onchain payouts enabled", "Onchain payouts enabled": "Onchain payouts enabled",

View File

@ -412,7 +412,6 @@
"You send approx {{swapSats}} LN Sats (fees might vary)": "You send approx {{swapSats}} LN Sats (fees might vary)", "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", "Your order fixed exchange rate": "Zure eskaeraren kanbio-tasa finkoa",
"#40": "Phrases in components/MakerForm/SelectCoordinator.tsx", "#40": "Phrases in components/MakerForm/SelectCoordinator.tsx",
"Order Host": "Order Host",
"Disabled": "Disabled", "Disabled": "Disabled",
"Maker": "Egile", "Maker": "Egile",
"Onchain payouts enabled": "Onchain payouts enabled", "Onchain payouts enabled": "Onchain payouts enabled",

View File

@ -412,7 +412,6 @@
"You send approx {{swapSats}} LN Sats (fees might vary)": "Vous envoyez environ {{swapSats}} LN Sats (les frais peuvent varier)", "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", "Your order fixed exchange rate": "Taux de change fixe de votre commande",
"#40": "Phrases in components/MakerForm/SelectCoordinator.tsx", "#40": "Phrases in components/MakerForm/SelectCoordinator.tsx",
"Order Host": "Order Host",
"Disabled": "Disabled", "Disabled": "Disabled",
"Maker": "Auteur", "Maker": "Auteur",
"Onchain payouts enabled": "Onchain payouts enabled", "Onchain payouts enabled": "Onchain payouts enabled",

View File

@ -412,7 +412,6 @@
"You send approx {{swapSats}} LN Sats (fees might vary)": "Invierai circa {{swapSats}} LN Sats (le commissioni possono variare)", "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", "Your order fixed exchange rate": "Il tasso di cambio fisso del tuo ordine",
"#40": "Phrases in components/MakerForm/SelectCoordinator.tsx", "#40": "Phrases in components/MakerForm/SelectCoordinator.tsx",
"Order Host": "Order Host",
"Disabled": "Disabled", "Disabled": "Disabled",
"Maker": "Maker", "Maker": "Maker",
"Onchain payouts enabled": "Onchain payouts enabled", "Onchain payouts enabled": "Onchain payouts enabled",

View File

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

View File

@ -412,7 +412,6 @@
"You send approx {{swapSats}} LN Sats (fees might vary)": "You send approx {{swapSats}} LN Sats (fees might vary)", "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", "Your order fixed exchange rate": "Your order fixed exchange rate",
"#40": "Phrases in components/MakerForm/SelectCoordinator.tsx", "#40": "Phrases in components/MakerForm/SelectCoordinator.tsx",
"Order Host": "Order Host",
"Disabled": "Disabled", "Disabled": "Disabled",
"Maker": "Maker", "Maker": "Maker",
"Onchain payouts enabled": "Onchain payouts enabled", "Onchain payouts enabled": "Onchain payouts enabled",

View File

@ -412,7 +412,6 @@
"You send approx {{swapSats}} LN Sats (fees might vary)": "Você envia aprox {{swapSats}} LN Sats (as taxas podem variar)", "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", "Your order fixed exchange rate": "Taxa de câmbio fixa do seu pedido",
"#40": "Phrases in components/MakerForm/SelectCoordinator.tsx", "#40": "Phrases in components/MakerForm/SelectCoordinator.tsx",
"Order Host": "Order Host",
"Disabled": "Disabled", "Disabled": "Disabled",
"Maker": "Maker", "Maker": "Maker",
"Onchain payouts enabled": "Onchain payouts enabled", "Onchain payouts enabled": "Onchain payouts enabled",

View File

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

View File

@ -412,7 +412,6 @@
"You send approx {{swapSats}} LN Sats (fees might vary)": "You send approx {{swapSats}} LN Sats (fees might vary)", "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", "Your order fixed exchange rate": "Din orders fasta växelkurs",
"#40": "Phrases in components/MakerForm/SelectCoordinator.tsx", "#40": "Phrases in components/MakerForm/SelectCoordinator.tsx",
"Order Host": "Order Host",
"Disabled": "Disabled", "Disabled": "Disabled",
"Maker": "Maker", "Maker": "Maker",
"Onchain payouts enabled": "Onchain payouts enabled", "Onchain payouts enabled": "Onchain payouts enabled",

View File

@ -412,7 +412,6 @@
"You send approx {{swapSats}} LN Sats (fees might vary)": "Unatuma takribani {{swapSats}} LN Sats (ada inaweza kutofautiana)", "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", "Your order fixed exchange rate": "Kiwango chako cha kubadilisha cha amri",
"#40": "Phrases in components/MakerForm/SelectCoordinator.tsx", "#40": "Phrases in components/MakerForm/SelectCoordinator.tsx",
"Order Host": "Order Host",
"Disabled": "Disabled", "Disabled": "Disabled",
"Maker": "Muumba", "Maker": "Muumba",
"Onchain payouts enabled": "Onchain payouts enabled", "Onchain payouts enabled": "Onchain payouts enabled",

View File

@ -412,7 +412,6 @@
"You send approx {{swapSats}} LN Sats (fees might vary)": "You send approx {{swapSats}} LN Sats (fees might vary)", "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", "#40": "Phrases in components/MakerForm/SelectCoordinator.tsx",
"Order Host": "Order Host",
"Disabled": "Disabled", "Disabled": "Disabled",
"Maker": "Maker", "Maker": "Maker",
"Onchain payouts enabled": "Onchain payouts enabled", "Onchain payouts enabled": "Onchain payouts enabled",

View File

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

View File

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