Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show federation expiration metadata #1129

Merged
merged 3 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions e2e/roundtrip.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,23 @@ test("rountrip receive and send", async ({ page }) => {
// The SVG's value property includes "lightning:l"
expect(value).toContain("lightning:l");

const lightningInvoice = value?.split("lightning:")[1];

// Post the lightning invoice to the server
const _response = await fetch(
"https://faucet.mutinynet.com/api/lightning",
{
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
bolt11: lightningInvoice
})
}
);
const response = await fetch("https://faucet.mutinynet.com/api/lightning", {
method: "POST",
mode: "cors",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
bolt11: value
})
});

if (!response.ok) {
response.text().then((text) => {
throw new Error("failed to post invoice to faucet: " + text);
});
}

// Wait for an h1 to appear in the dom that says "Payment Received"
await page.waitForSelector("text=Payment Received", { timeout: 30000 });
Expand Down
13 changes: 11 additions & 2 deletions public/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@
"back_home": "back home"
},
"start_a_chat": "Start a chat?",
"start_a_chat_are_you_sure": "This user isn't in your contact list."
"start_a_chat_are_you_sure": "This user isn't in your contact list.",
"federation_message": "Federation Message"
},
"scanner": {
"paste": "Paste Something",
Expand Down Expand Up @@ -561,7 +562,9 @@
"descriptionpart2": "Each one is run by a group of different inviduals or companies. Discover one that you or your friends might trust below.",
"join_me": "Join me",
"recommend": "Recommend federation",
"recommended_by_you": "Recommended by you"
"recommended_by_you": "Recommended by you",
"transfer_funds": "Transfer funds",
"transfer_funds_message": "Add a second federation to enable transfers."
},
"gift": {
"give_sats_link": "Give sats as a gift",
Expand Down Expand Up @@ -782,5 +785,11 @@
"nowish": "Nowish",
"seconds_future": "Seconds from now",
"seconds_past": "Just now"
},
"transfer": {
"completed": "Transfer Completed",
"sats_moved": "+{{amount}} sats have been moved to {{federation_name}}",
"confirm": "Confirm Transfer",
"title": "Transfer funds"
}
}
4 changes: 4 additions & 0 deletions src/components/Activity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
Button,
ButtonCard,
ContactButton,
FederationPopup,
LoadingShimmer,
NiceP,
SimpleDialog
Expand Down Expand Up @@ -424,6 +425,9 @@ export function CombinedActivity() {
/>
</Show>
<Suspense fallback={<LoadingShimmer />}>
<Show when={state.expiration_warning}>
<FederationPopup />
</Show>
<Show when={!state.has_backed_up}>
<ButtonCard
red
Expand Down
14 changes: 8 additions & 6 deletions src/components/AmountEditable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@ import {
} from "~/utils";

export type MethodChoice = {
method: "lightning" | "onchain";
method: "lightning" | "onchain" | "fedimint";
maxAmountSats?: bigint;
};

// Make sure to update this when we get the fedi option in here!
function methodToIcon(method: MethodChoice["method"]) {
if (method === "lightning") {
return "lightning";
} else if (method === "onchain") {
return "chain";
switch (method) {
case "lightning":
return "lightning";
case "onchain":
return "chain";
case "fedimint":
return "community";
}
}

Expand Down
45 changes: 45 additions & 0 deletions src/components/FederationPopup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { useNavigate } from "@solidjs/router";
import { Users } from "lucide-solid";
import { createSignal } from "solid-js";

import { ButtonCard, NiceP, SimpleDialog } from "~/components/layout";
import { useI18n } from "~/i18n/context";
import { useMegaStore } from "~/state/megaStore";

export function FederationPopup() {
const [state, actions, _sw] = useMegaStore();
const [
showFederationExpirationWarning,
setShowFederationExpirationWarning
] = createSignal(!state.expiration_warning_seen);

const i18n = useI18n();
const navigate = useNavigate();

return (
<SimpleDialog
title={`${i18n.t("activity.federation_message")}: ${state.expiration_warning?.federationName}`}
open={showFederationExpirationWarning()}
setOpen={(open: boolean) => {
if (!open) {
setShowFederationExpirationWarning(false);
actions.clearExpirationWarning();
}
}}
>
<NiceP>{state.expiration_warning?.expiresMessage}</NiceP>
<ButtonCard
onClick={() => {
actions.clearExpirationWarning();
setShowFederationExpirationWarning(false);
navigate("/settings/federations");
}}
>
<div class="flex items-center gap-2">
<Users class="inline-block text-m-red" />
<NiceP>{i18n.t("profile.manage_federation")}</NiceP>
</div>
</ButtonCard>
</SimpleDialog>
);
}
1 change: 1 addition & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ export * from "./EditProfileForm";
export * from "./ImportNsecForm";
export * from "./LightningAddressShower";
export * from "./FederationInviteShower";
export * from "./FederationPopup";
4 changes: 3 additions & 1 deletion src/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ import {
Search,
Send,
Swap,
SwapLightning
SwapLightning,
Transfer
} from "~/routes";
import {
Admin,
Expand Down Expand Up @@ -179,6 +180,7 @@ export function Router() {
<Route path="/send" component={Send} />
<Route path="/swap" component={Swap} />
<Route path="/swaplightning" component={SwapLightning} />
<Route path="/transfer" component={Transfer} />
<Route path="/search" component={Search} />
<Route path="/settings">
<Route path="/" component={Settings} />
Expand Down
7 changes: 1 addition & 6 deletions src/routes/Send.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import { MutinyInvoice, TagItem } from "@mutinywallet/mutiny-wasm";
import {
createAsync,
useLocation,
useNavigate,
useSearchParams
} from "@solidjs/router";
import { useLocation, useNavigate, useSearchParams } from "@solidjs/router";
import { Eye, EyeOff, Link, X, Zap } from "lucide-solid";
import {
createEffect,
Expand Down
2 changes: 1 addition & 1 deletion src/routes/Swap.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createForm, required } from "@modular-forms/solid";
import { MutinyChannel } from "@mutinywallet/mutiny-wasm";
import { createAsync, useNavigate } from "@solidjs/router";
import { useNavigate } from "@solidjs/router";
import {
createEffect,
createMemo,
Expand Down
Loading
Loading