Skip to content

Commit e1cfae2

Browse files
futurepaulAnthonyRonning
authored andcommitted
put federations in megastore
1 parent 6dcdbae commit e1cfae2

File tree

8 files changed

+147
-149
lines changed

8 files changed

+147
-149
lines changed

e2e/routes.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ const settingsRoutes = [
2525
"/plus",
2626
"/restore",
2727
"/servers",
28-
"/syncnostrcontacts"
29-
"/managefederations"
28+
"/syncnostrcontacts",
29+
"/federations"
3030
];
3131

3232
const settingsRoutesPrefixed = settingsRoutes.map((route) => {
@@ -128,7 +128,7 @@ test("visit each route", async ({ page }) => {
128128
// Manage Federations
129129
await checkRoute(
130130
page,
131-
"/settings/managefederations",
131+
"/settings/federations",
132132
"Manage Federations",
133133
checklist
134134
);

src/components/AmountEditable.tsx

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import currencySwap from "~/assets/icons/currency-swap.svg";
1919
import pencil from "~/assets/icons/pencil.svg";
2020
import { Button, FeesModal, InfoBox, InlineAmount, VStack } from "~/components";
2121
import { useI18n } from "~/i18n/context";
22-
import { Network } from "~/logic/mutinyWalletSetup";
2322
import { useMegaStore } from "~/state/megaStore";
2423
import { DIALOG_CONTENT, DIALOG_POSITIONER } from "~/styles/dialogs";
2524
import { Currency, fiatToSats, satsToFiat } from "~/utils";
@@ -404,17 +403,13 @@ export const AmountEditable: ParentComponent<{
404403
});
405404

406405
const warningText = () => {
406+
if (state.federations?.length !== 0) {
407+
return undefined;
408+
}
407409
if ((state.balance?.lightning || 0n) === 0n) {
408-
const network = state.mutiny_wallet?.get_network() as Network;
409-
if (network === "bitcoin") {
410-
return i18n.t("receive.amount_editable.receive_too_small", {
411-
amount: "100,000"
412-
});
413-
} else {
414-
return i18n.t("receive.amount_editable.receive_too_small", {
415-
amount: "10,000"
416-
});
417-
}
410+
return i18n.t("receive.amount_editable.receive_too_small", {
411+
amount: "100,000"
412+
});
418413
}
419414

420415
const parsed = Number(localSats());

src/components/BalanceBox.tsx

Lines changed: 20 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { A, useNavigate } from "@solidjs/router";
2-
import { createResource, Match, Show, Suspense, Switch } from "solid-js";
2+
import { Match, Show, Switch } from "solid-js";
33

44
import shuffle from "~/assets/icons/shuffle.svg";
55
import {
@@ -91,10 +91,25 @@ export function BalanceBox(props: { loading?: boolean }) {
9191
</Match>
9292
</Switch>
9393
</Show>
94-
<Show when={!props.loading && !state.safe_mode}>
95-
<Suspense>
96-
<FederationsBalance />
97-
</Suspense>
94+
<Show when={state.federations && state.federations.length}>
95+
<Show when={!props.loading} fallback={<LoadingShimmer />}>
96+
<hr class="my-2 border-m-grey-750" />
97+
<div class="flex flex-col gap-1">
98+
<div class="text-2xl">
99+
<AmountSats
100+
amountSats={state.balance?.federation || 0}
101+
icon="community"
102+
denominationSize="lg"
103+
/>
104+
</div>
105+
<div class="text-lg text-white/70">
106+
<AmountFiat
107+
amountSats={state.balance?.federation || 0n}
108+
denominationSize="sm"
109+
/>
110+
</div>
111+
</div>
112+
</Show>
98113
</Show>
99114
<hr class="my-2 border-m-grey-750" />
100115
<Show when={!props.loading} fallback={<LoadingShimmer />}>
@@ -157,39 +172,3 @@ export function BalanceBox(props: { loading?: boolean }) {
157172
</>
158173
);
159174
}
160-
161-
function FederationsBalance() {
162-
const [state, _actions] = useMegaStore();
163-
164-
async function fetchFederations() {
165-
const result = await state.mutiny_wallet?.list_federations();
166-
return result ?? [];
167-
}
168-
169-
const [federations] = createResource(fetchFederations);
170-
171-
return (
172-
<Show when={federations() && federations().length}>
173-
<hr class="my-2 border-m-grey-750" />
174-
<Switch>
175-
<Match when={true}>
176-
<div class="flex flex-col gap-1">
177-
<div class="text-2xl">
178-
<AmountSats
179-
amountSats={state.balance?.federation || 0}
180-
icon="community"
181-
denominationSize="lg"
182-
/>
183-
</div>
184-
<div class="text-lg text-white/70">
185-
<AmountFiat
186-
amountSats={state.balance?.federation || 0n}
187-
denominationSize="sm"
188-
/>
189-
</div>
190-
</div>
191-
</Match>
192-
</Switch>
193-
</Show>
194-
);
195-
}

src/i18n/en/translations.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,10 +538,15 @@ export default {
538538
federation_code_label: "Federation code",
539539
federation_code_required: "Federation code can't be blank",
540540
federation_added_success: "Federation added successfully",
541+
federation_remove_confirm:
542+
"Are you sure you want to remove this federation? Make sure any funds you have are transferred to your lightning balance or another wallet first.",
541543
add: "Add",
542544
remove: "Remove",
543545
expires: "Expires",
544-
federation_id: "Federation ID"
546+
federation_id: "Federation ID",
547+
description:
548+
"Mutiny has experimental support for the Fedimint protocol. You'll need a federation invite code to use this feature. These funds are currently not backed up remotely. Store funds in a federation at your own risk!",
549+
learn_more: "Learn more about Fedimint."
545550
},
546551
gift: {
547552
give_sats_link: "Give sats as a gift",

src/router.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ import {
2626
EmergencyKit,
2727
Encrypt,
2828
Gift,
29+
ManageFederations,
2930
Plus,
3031
Restore,
3132
Servers,
3233
Settings,
33-
SyncNostrContacts,
34-
ManageFederations
34+
SyncNostrContacts
3535
} from "~/routes/settings";
3636

3737
import { useMegaStore } from "./state/megaStore";
@@ -119,7 +119,10 @@ export function Router() {
119119
path="/syncnostrcontacts"
120120
component={SyncNostrContacts}
121121
/>
122-
<Route path="/managefederations" component={ManageFederations} />
122+
<Route
123+
path="/federations"
124+
component={ManageFederations}
125+
/>
123126
</Route>
124127
<Route path="/*all" component={NotFound} />
125128
</Routes>

0 commit comments

Comments
 (0)