Skip to content
This repository was archived by the owner on Apr 21, 2025. It is now read-only.

Commit 625c0f6

Browse files
committed
warn about bad dns federations
1 parent c1445dc commit 625c0f6

File tree

7 files changed

+101
-58
lines changed

7 files changed

+101
-58
lines changed

public/i18n/en.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@
4040
"just_me": "Just Me",
4141
"friends": "Friends",
4242
"requests": "Requests"
43-
}
43+
},
44+
"federations_warn_generic": "Due to temporary issues with your current federation, we recommend you transfer your funds to a lightning channel or withdraw to another bitcoin wallet.",
45+
"transfer_lightning": "Transfer to lightning",
46+
"sent_to_another_wallet": "Send to another wallet"
4447
},
4548
"profile": {
4649
"profile": "Profile",
@@ -49,6 +52,7 @@
4952
"edit_profile": "Edit Profile",
5053
"join_federation": "Join a federation",
5154
"manage_federation": "Manage Federations",
55+
"leave_federation": "Leave Federation",
5256
"federated_custody": "Federated Custody",
5357
"self_custody": "Self Custody",
5458
"social": "Social",

src/components/Activity.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { TagItem } from "@mutinywallet/mutiny-wasm";
22
import { cache, createAsync, useNavigate } from "@solidjs/router";
3-
import { Plus, Save, Search, Shuffle, Users } from "lucide-solid";
3+
import { Plus, Save, Search, Shuffle } from "lucide-solid";
44
import {
55
createEffect,
66
createMemo,

src/components/FederationPopup.tsx

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import { useNavigate } from "@solidjs/router";
2-
import { Users } from "lucide-solid";
3-
import { createSignal } from "solid-js";
2+
import { ArrowLeftRight, ArrowUpRight, Users } from "lucide-solid";
3+
import { createSignal, Show } from "solid-js";
44

5-
import { ButtonCard, NiceP, SimpleDialog } from "~/components/layout";
5+
import {
6+
ButtonCard,
7+
ExternalLink,
8+
NiceP,
9+
SimpleDialog
10+
} from "~/components/layout";
611
import { useI18n } from "~/i18n/context";
712
import { useMegaStore } from "~/state/megaStore";
813

@@ -16,9 +21,11 @@ export function FederationPopup() {
1621
const i18n = useI18n();
1722
const navigate = useNavigate();
1823

24+
const name = state.expiration_warning?.federationName;
25+
1926
return (
2027
<SimpleDialog
21-
title={`${i18n.t("activity.federation_message")}: ${state.expiration_warning?.federationName}`}
28+
title={`${i18n.t("activity.federation_message")} ${name ? `: ${name}` : ""}`}
2229
open={showFederationExpirationWarning()}
2330
setOpen={(open: boolean) => {
2431
if (!open) {
@@ -27,7 +34,41 @@ export function FederationPopup() {
2734
}
2835
}}
2936
>
30-
<NiceP>{state.expiration_warning?.expiresMessage}</NiceP>
37+
<NiceP>
38+
{state.expiration_warning?.expiresMessage ||
39+
i18n.t("home.federations_warn_generic")}
40+
</NiceP>
41+
<Show when={!name}>
42+
<NiceP>
43+
<ExternalLink href="https://x.com/MutinyWallet/status/1805346636660429021">
44+
{i18n.t("settings.manage_federations.learn_more")}
45+
</ExternalLink>
46+
</NiceP>
47+
</Show>
48+
<ButtonCard
49+
onClick={() => {
50+
actions.clearExpirationWarning();
51+
setShowFederationExpirationWarning(false);
52+
navigate("/swaplightning");
53+
}}
54+
>
55+
<div class="flex items-center gap-2">
56+
<ArrowLeftRight class="inline-block text-m-red" />
57+
<NiceP>{i18n.t("home.transfer_lightning")}</NiceP>
58+
</div>
59+
</ButtonCard>
60+
<ButtonCard
61+
onClick={() => {
62+
actions.clearExpirationWarning();
63+
setShowFederationExpirationWarning(false);
64+
navigate("/send");
65+
}}
66+
>
67+
<div class="flex items-center gap-2">
68+
<ArrowUpRight class="inline-block text-m-red" />
69+
<NiceP>{i18n.t("home.sent_to_another_wallet")}</NiceP>
70+
</div>
71+
</ButtonCard>
3172
<ButtonCard
3273
onClick={() => {
3374
actions.clearExpirationWarning();
@@ -37,7 +78,7 @@ export function FederationPopup() {
3778
>
3879
<div class="flex items-center gap-2">
3980
<Users class="inline-block text-m-red" />
40-
<NiceP>{i18n.t("profile.manage_federation")}</NiceP>
81+
<NiceP>{i18n.t("profile.leave_federation")}</NiceP>
4182
</div>
4283
</ButtonCard>
4384
</SimpleDialog>

src/routes/settings/ManageFederations.tsx

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from "@modular-forms/solid";
88
import { FederationBalance, TagItem } from "@mutinywallet/mutiny-wasm";
99
import { A, useNavigate, useSearchParams } from "@solidjs/router";
10-
import { ArrowLeftRight, BadgeCheck, LogOut, Scan, Trash } from "lucide-solid";
10+
import { BadgeCheck, LogOut, Scan, Trash } from "lucide-solid";
1111
import {
1212
createMemo,
1313
createResource,
@@ -168,6 +168,8 @@ export function AddFederationForm(props: {
168168
setSuccess(
169169
i18n.t("settings.manage_federations.federation_added_success")
170170
);
171+
// Reset the expiration warning seen state
172+
actions.resetExpirationWarning();
171173
await actions.refreshFederations();
172174
if (props.refetch) {
173175
await props.refetch();
@@ -435,8 +437,7 @@ function FederationListItem(props: {
435437
balance?: bigint;
436438
}) {
437439
const i18n = useI18n();
438-
const [state, actions, sw] = useMegaStore();
439-
const navigate = useNavigate();
440+
const [_state, actions, sw] = useMegaStore();
440441

441442
async function removeFederation() {
442443
setConfirmLoading(true);
@@ -455,15 +456,6 @@ function FederationListItem(props: {
455456

456457
const [transferDialogOpen, setTransferDialogOpen] = createSignal(false);
457458

458-
async function transferFunds() {
459-
// If there's only one federation we need to let them know to add another
460-
if (state.federations?.length && state.federations.length < 2) {
461-
setTransferDialogOpen(true);
462-
} else {
463-
navigate("/transfer?from=" + props.fed.federation_id);
464-
}
465-
}
466-
467459
const [confirmOpen, setConfirmOpen] = createSignal(false);
468460
const [confirmLoading, setConfirmLoading] = createSignal(false);
469461

@@ -525,10 +517,6 @@ function FederationListItem(props: {
525517
inviteCode={props.fed.invite_code}
526518
/>
527519
</KeyValue>
528-
<SubtleButton onClick={transferFunds}>
529-
<ArrowLeftRight class="h-4 w-4" />
530-
{i18n.t("settings.manage_federations.transfer_funds")}
531-
</SubtleButton>
532520
<Suspense>
533521
<RecommendButton fed={props.fed} />
534522
</Suspense>

src/state/megaStore.tsx

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
BTC_OPTION,
2929
Currency,
3030
eify,
31+
federationWarning,
3132
subscriptionValid,
3233
USD_OPTION
3334
} from "~/utils";
@@ -302,23 +303,7 @@ export const makeMegaStoreContext = () => {
302303
// Get federations
303304
const federations = await sw.list_federations();
304305

305-
let expiration_warning:
306-
| {
307-
expiresTimestamp: number;
308-
expiresMessage: string;
309-
federationName: string;
310-
}
311-
| undefined = undefined;
312-
313-
federations.forEach((f) => {
314-
if (f.popup_countdown_message && f.popup_end_timestamp) {
315-
expiration_warning = {
316-
expiresTimestamp: f.popup_end_timestamp,
317-
expiresMessage: f.popup_countdown_message,
318-
federationName: f.federation_name
319-
};
320-
}
321-
});
306+
const expiration_warning = federationWarning(federations);
322307

323308
setState({
324309
wallet_loading: false,
@@ -576,23 +561,7 @@ export const makeMegaStoreContext = () => {
576561
async refreshFederations() {
577562
const federations = await sw.list_federations();
578563

579-
let expiration_warning:
580-
| {
581-
expiresTimestamp: number;
582-
expiresMessage: string;
583-
federationName: string;
584-
}
585-
| undefined = undefined;
586-
587-
federations.forEach((f) => {
588-
if (f.popup_countdown_message && f.popup_end_timestamp) {
589-
expiration_warning = {
590-
expiresTimestamp: f.popup_end_timestamp,
591-
expiresMessage: f.popup_countdown_message,
592-
federationName: f.federation_name
593-
};
594-
}
595-
});
564+
const expiration_warning = federationWarning(federations);
596565

597566
setState({ federations, expiration_warning });
598567
},
@@ -638,6 +607,9 @@ export const makeMegaStoreContext = () => {
638607
// Only show the expiration warning once per session
639608
clearExpirationWarning() {
640609
setState({ expiration_warning_seen: true });
610+
},
611+
resetExpirationWarning() {
612+
setState({ expiration_warning_seen: false });
641613
}
642614
};
643615

src/utils/federationWarning.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { MutinyFederationIdentity } from "~/routes/settings";
2+
3+
export function federationWarning(federations: MutinyFederationIdentity[]) {
4+
const FEDERATIONS_WITH_WARNINGS = [
5+
// Freedom One
6+
"c944b2fd1e7fe04ca87f9a57d7894cb69116cec6264cb52faa71228f4ec54cd6",
7+
// Bitcoin Principles
8+
"b21068c84f5b12ca4fdf93f3e443d3bd7c27e8642d0d52ea2e4dce6fdbbee9df"
9+
];
10+
11+
let expiration_warning:
12+
| {
13+
expiresTimestamp: number;
14+
expiresMessage: string;
15+
federationName: string;
16+
}
17+
| undefined = undefined;
18+
19+
federations.forEach((f) => {
20+
if (f.popup_countdown_message && f.popup_end_timestamp) {
21+
expiration_warning = {
22+
expiresTimestamp: f.popup_end_timestamp,
23+
expiresMessage: f.popup_countdown_message,
24+
federationName: f.federation_name
25+
};
26+
} else if (FEDERATIONS_WITH_WARNINGS.includes(f.federation_id)) {
27+
// If the federation has no expiration warning we'll do a generic one
28+
expiration_warning = {
29+
expiresTimestamp: 0,
30+
expiresMessage: "",
31+
federationName: ""
32+
};
33+
}
34+
});
35+
36+
return expiration_warning;
37+
}

src/utils/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ export * from "./bech32";
2121
export * from "./keypad";
2222
export * from "./debounce";
2323
export * from "./blobToBase64";
24+
export * from "./federationWarning";

0 commit comments

Comments
 (0)