Merge changes from legacy GUI, allow daemon logs to be attached to feedback (#115)

This PR applies all remaining changes from https://github.com/UnstoppableSwap/unstoppableswap-gui/pull/210


- Added checkbox option to attach daemon logs when submitting feedback
- Added "Outdated" chip with warning icon for providers running outdated asb versions
- Updated `BitcoinPunishedPage` to display different messages for BtcPunished and CooperativeRedeemRejected states (including reason for failed cooperative redeem)
- Added "Attempt recovery" button for swaps in BtcPunished state
- Modified `getBitcoinTxExplorerUrl` to use mempool.space instead of blockchair.com
- Added `useResumeableSwapsCountExcludingPunished` hook to count resumable swaps excluding punished ones, use it for the badge and alert
- Updated `sortProviderList` function to filter out incompatible providers before sorting
- Added `TauriSwapProgressEventExt` type to extract specific event types from TauriSwapProgressEvent
This commit is contained in:
binarybaron 2024-10-13 22:04:47 +06:00 committed by GitHub
parent 639f540876
commit 2bffe40a37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 116 additions and 50 deletions

View file

@ -30,9 +30,9 @@ export function isBtcAddressValid(address: string, testnet: boolean) {
}
export function getBitcoinTxExplorerUrl(txid: string, testnet: boolean) {
return `https://blockchair.com/bitcoin${
return `https://mempool.space/${
testnet ? "/testnet" : ""
}/transaction/${txid}`;
}/tx/${txid}`;
}
export function getMoneroTxExplorerUrl(txid: string, stagenet: boolean) {

View file

@ -3,7 +3,7 @@ import { Multiaddr } from "multiaddr";
import semver from "semver";
import { isTestnet } from "store/config";
const MIN_ASB_VERSION = "0.12.0";
const MIN_ASB_VERSION = "0.13.3";
export function providerToConcatenatedMultiAddr(provider: Provider) {
return new Multiaddr(provider.multiAddr)
@ -14,11 +14,16 @@ export function providerToConcatenatedMultiAddr(provider: Provider) {
export function isProviderCompatible(
provider: ExtendedProviderStatus,
): boolean {
if (provider.version) {
if (!semver.satisfies(provider.version, `>=${MIN_ASB_VERSION}`))
return provider.testnet === isTestnet();
}
export function isProviderOutdated(provider: ExtendedProviderStatus): boolean {
if (provider.version != null) {
if (semver.satisfies(provider.version, `>=${MIN_ASB_VERSION}`))
return false;
} else {
return false;
}
if (provider.testnet !== isTestnet()) return false;
return true;
}
}

View file

@ -1,19 +1,23 @@
import { ExtendedProviderStatus } from "models/apiModel";
import { isProviderCompatible } from "./multiAddrUtils";
export function sortProviderList(list: ExtendedProviderStatus[]) {
return list.concat().sort((firstEl, secondEl) => {
// If neither of them have a relevancy score, sort by max swap amount
if (firstEl.relevancy === undefined && secondEl.relevancy === undefined) {
if (firstEl.maxSwapAmount > secondEl.maxSwapAmount) {
return list
.filter(isProviderCompatible)
.concat()
.sort((firstEl, secondEl) => {
// If neither of them have a relevancy score, sort by max swap amount
if (firstEl.relevancy === undefined && secondEl.relevancy === undefined) {
if (firstEl.maxSwapAmount > secondEl.maxSwapAmount) {
return -1;
}
}
// If only on of the two don't have a relevancy score, prioritize the one that does
if (firstEl.relevancy === undefined) return 1;
if (secondEl.relevancy === undefined) return -1;
if (firstEl.relevancy > secondEl.relevancy) {
return -1;
}
}
// If only on of the two don't have a relevancy score, prioritize the one that does
if (firstEl.relevancy === undefined) return 1;
if (secondEl.relevancy === undefined) return -1;
if (firstEl.relevancy > secondEl.relevancy) {
return -1;
}
return 1;
});
}
return 1;
});
}