mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-08-24 22:19:37 -04:00

* bump(rust): Toolchain to 1.82 * bump(tauri): Bump some Tauri peer-dependencies * fix(gui): Prefer maker with known version, bump MIN_ASB_VERSION to 1.1.0-rc.3 * amend: CHANGELOG.md
29 lines
No EOL
1 KiB
TypeScript
29 lines
No EOL
1 KiB
TypeScript
import { ExtendedMakerStatus } from "models/apiModel";
|
|
import { isMakerOnCorrectNetwork, isMakerOutdated } from "./multiAddrUtils";
|
|
import _ from 'lodash';
|
|
|
|
export function sortMakerList(list: ExtendedMakerStatus[]) {
|
|
return _(list)
|
|
// Filter out makers that are on the wrong network (testnet / mainnet)
|
|
.filter(isMakerOnCorrectNetwork)
|
|
// Sort by criteria
|
|
.orderBy(
|
|
[
|
|
// Prefer makers that have a 'version' attribute
|
|
// If we don't have a version, we cannot clarify if it's outdated or not
|
|
m => (m.version ? 0 : 1),
|
|
// Prefer makers that are not outdated
|
|
m => (isMakerOutdated(m) ? 1 : 0),
|
|
// Prefer makers that have a relevancy score
|
|
m => (m.relevancy == null ? 1 : 0),
|
|
// Prefer makers with a higher relevancy score
|
|
m => -(m.relevancy ?? 0),
|
|
// Prefer makers with a lower price
|
|
m => m.price
|
|
],
|
|
['asc', 'asc', 'asc', 'asc', 'asc']
|
|
)
|
|
// Remove duplicate makers
|
|
.uniqBy(m => m.peerId)
|
|
.value();
|
|
} |