mirror of
https://github.com/RoboSats/robosats.git
synced 2024-12-13 19:06:26 +00:00
Merge pull request #1632 from RoboSats/filter-deepth-chart-by-host
Filter deepth chart by host
This commit is contained in:
commit
ce4a96b9ca
@ -38,6 +38,15 @@ repos:
|
||||
files: ^frontend/
|
||||
types_or: [javascript, jsx, ts, tsx, css, markdown, json] # uses https://github.com/pre-commit/identify
|
||||
entry: bash -c 'cd frontend && npm run format'
|
||||
- id: lintern-frontend
|
||||
name: lintern-frontend
|
||||
stages:
|
||||
- commit
|
||||
- merge-commit
|
||||
language: system
|
||||
files: ^frontend/
|
||||
types_or: [javascript, jsx, ts, tsx, css, markdown, json] # uses https://github.com/pre-commit/identify
|
||||
entry: bash -c 'cd frontend && npm run lint'
|
||||
- id: prettier-mobile
|
||||
name: prettier-mobile
|
||||
stages:
|
||||
@ -47,6 +56,15 @@ repos:
|
||||
files: ^mobile/
|
||||
types_or: [javascript, jsx, ts, tsx, css, markdown, json] # uses https://github.com/pre-commit/identify
|
||||
entry: bash -c 'cd mobile && npm run format'
|
||||
- id: lintern-mobile
|
||||
name: lintern-mobile
|
||||
stages:
|
||||
- commit
|
||||
- merge-commit
|
||||
language: system
|
||||
files: ^mobile/
|
||||
types_or: [javascript, jsx, ts, tsx, css, markdown, json] # uses https://github.com/pre-commit/identify
|
||||
entry: bash -c 'cd mobile && npm run lint'
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.1.13
|
||||
hooks:
|
||||
|
@ -12,7 +12,7 @@ import { NoRobotDialog } from '../../components/Dialogs';
|
||||
import { FederationContext, type UseFederationStoreType } from '../../contexts/FederationContext';
|
||||
import { GarageContext, type UseGarageStoreType } from '../../contexts/GarageContext';
|
||||
import VisitThirdParty from '../../components/Dialogs/VisitThirdParty';
|
||||
import { PublicOrder } from '../../models';
|
||||
import { type PublicOrder } from '../../models';
|
||||
|
||||
const MakerPage = (): JSX.Element => {
|
||||
const { fav, windowSize, navbarHeight } = useContext<UseAppStoreType>(AppContext);
|
||||
|
@ -22,7 +22,6 @@ import CheckBoxOutlineBlankIcon from '@mui/icons-material/CheckBoxOutlineBlank';
|
||||
import SwapCalls from '@mui/icons-material/SwapCalls';
|
||||
import { FederationContext, type UseFederationStoreType } from '../../contexts/FederationContext';
|
||||
import RobotAvatar from '../RobotAvatar';
|
||||
import RoboSats from '../Icons/RoboSats';
|
||||
import RoboSatsNoText from '../Icons/RoboSatsNoText';
|
||||
|
||||
interface BookControlProps {
|
||||
|
@ -56,14 +56,17 @@ const DepthChart: React.FC<DepthChartProps> = ({
|
||||
const [xRange, setXRange] = useState<number>(8);
|
||||
const [xType, setXType] = useState<string>('premium');
|
||||
const [currencyCode, setCurrencyCode] = useState<number>(0);
|
||||
const [coordinatorFilter, setCoordinatorFilter] = useState<string>('all');
|
||||
const [center, setCenter] = useState<number>();
|
||||
|
||||
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<DepthChartProps> = ({
|
||||
});
|
||||
setEnrichedOrders(enriched);
|
||||
}
|
||||
}, [federationUpdatedAt, currencyCode]);
|
||||
}, [federationUpdatedAt, currencyCode, coordinatorFilter]);
|
||||
|
||||
useEffect(() => {
|
||||
if (enrichedOrders.length > 0) {
|
||||
@ -119,14 +122,20 @@ const DepthChart: React.FC<DepthChartProps> = ({
|
||||
setXRange(8);
|
||||
setRangeSteps(0.5);
|
||||
}
|
||||
}, [enrichedOrders, xType, federationUpdatedAt, currencyCode]);
|
||||
}, [enrichedOrders, xType, federationUpdatedAt, currencyCode, coordinatorFilter]);
|
||||
|
||||
const generateSeries: () => void = () => {
|
||||
const sortedOrders: PublicOrder[] =
|
||||
xType === 'base_price'
|
||||
? enrichedOrders
|
||||
.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(
|
||||
(order1: PublicOrder | null, order2: PublicOrder | null) =>
|
||||
@ -134,7 +143,13 @@ const DepthChart: React.FC<DepthChartProps> = ({
|
||||
)
|
||||
: enrichedOrders
|
||||
.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(
|
||||
(order1: PublicOrder | null, order2: PublicOrder | null) =>
|
||||
|
@ -38,7 +38,14 @@ const ExchangeDialog = ({ open = false, onClose }: Props): JSX.Element => {
|
||||
const [loadingInfo, setLoadingInfo] = useState<boolean>(true);
|
||||
|
||||
useEffect(() => {
|
||||
if (open) federation.loadInfo();
|
||||
if (open) {
|
||||
federation
|
||||
.loadInfo()
|
||||
.then(() => {})
|
||||
.catch((error) => {
|
||||
console.error('Error loading info:', error);
|
||||
});
|
||||
}
|
||||
}, [open]);
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -87,7 +87,12 @@ const MakerForm = ({
|
||||
const amountSafeThresholds = [1.03, 0.98];
|
||||
|
||||
useEffect(() => {
|
||||
federation.loadInfo();
|
||||
federation
|
||||
.loadInfo()
|
||||
.then(() => {})
|
||||
.catch((error) => {
|
||||
console.error('Error loading info:', error);
|
||||
});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -10,7 +10,7 @@ import {
|
||||
CircularProgress,
|
||||
Stack,
|
||||
} from '@mui/material';
|
||||
import { Bolt, Link, Info } from '@mui/icons-material';
|
||||
import { Link } from '@mui/icons-material';
|
||||
import RobotAvatar from '../RobotAvatar';
|
||||
import { AppContext, type UseAppStoreType } from '../../contexts/AppContext';
|
||||
import { useTheme } from '@emotion/react';
|
||||
|
@ -25,6 +25,7 @@ export interface PublicOrder {
|
||||
maker_status?: 'Active' | 'Seen recently' | 'Inactive';
|
||||
coordinatorShortAlias?: string;
|
||||
link?: string;
|
||||
federated?: boolean;
|
||||
}
|
||||
|
||||
export interface Book {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { type PublicOrder, type Favorites, type Federation, Coordinator } from '../models';
|
||||
import { type PublicOrder, type Favorites, type Federation } from '../models';
|
||||
import thirdParties from '../../static/thirdparties.json';
|
||||
|
||||
interface AmountFilter {
|
||||
@ -35,7 +35,7 @@ const filterByHost = function (
|
||||
): boolean {
|
||||
if (shortAlias === 'any') {
|
||||
return true;
|
||||
} else if (shortAlias == 'robosats') {
|
||||
} else if (shortAlias === 'robosats') {
|
||||
const coordinator = federation.getCoordinator(order.coordinatorShortAlias ?? '');
|
||||
return coordinator?.federated ?? false;
|
||||
} else {
|
||||
@ -84,7 +84,7 @@ const filterOrders = function ({
|
||||
const coordinatorCheck = [...enabledCoordinators, ...Object.keys(thirdParties)].includes(
|
||||
order.coordinatorShortAlias ?? '',
|
||||
);
|
||||
const typeChecks = order.type === baseFilter.type || baseFilter.type == null;
|
||||
const typeChecks = order.type === baseFilter.type || baseFilter.type === null;
|
||||
const modeChecks = baseFilter.mode === 'fiat' ? !(order.currency === 1000) : true;
|
||||
const premiumChecks = premium !== null ? filterByPremium(order, premium) : true;
|
||||
const currencyChecks = order.currency === baseFilter.currency || baseFilter.currency === 0;
|
||||
|
@ -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]) {
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user