Skip to content

Commit

Permalink
remove discover federations
Browse files Browse the repository at this point in the history
  • Loading branch information
futurepaul committed Jul 1, 2024
1 parent 6e31400 commit 1969a39
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 134 deletions.
2 changes: 0 additions & 2 deletions e2e/fedimint.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ test("fedmint join, receive, send", async ({ page }) => {
// Fill the input with the federation code
await page.fill("input[name='federation_code']", SIGNET_INVITE_CODE);

await page.getByText("Mutinynet Signet Federation").waitFor();

const addButton = await page.getByRole("button", { name: "Add" }).first();

// Click the "Add" button
Expand Down
132 changes: 0 additions & 132 deletions src/routes/settings/ManageFederations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { FederationBalance, TagItem } from "@mutinywallet/mutiny-wasm";
import { A, useNavigate, useSearchParams } from "@solidjs/router";
import { BadgeCheck, LogOut, Scan, Trash } from "lucide-solid";
import {
createMemo,
createResource,
createSignal,
For,
Expand All @@ -32,9 +31,7 @@ import {
FederationPopup,
InfoBox,
KeyValue,
LabelCircle,
LargeHeader,
LoadingShimmer,
MediumHeader,
MiniStringShower,
MutinyWalletGuard,
Expand Down Expand Up @@ -100,8 +97,6 @@ export function AddFederationForm(props: {
const [error, setError] = createSignal<Error>();
const [success, setSuccess] = createSignal("");

const [loadingFederation, setLoadingFederation] = createSignal("");

const [params, setParams] = useSearchParams();

onMount(() => {
Expand All @@ -126,24 +121,13 @@ export function AddFederationForm(props: {
await onSelect([federation_code]);
};

const [federations] = createResource(async () => {
try {
const federations = await sw.discover_federations();
return federations;
} catch (e) {
console.error(e);
return [];
}
});

const onSelect = async (inviteCodes: string[]) => {
setSuccess("");
setError(undefined);
try {
for (const inviteCode of inviteCodes) {
try {
console.log("Adding federation:", inviteCode);
setLoadingFederation(inviteCode);
const newFederation = await sw.new_federation(inviteCode);
console.log("New federation added:", newFederation);
break;
Expand Down Expand Up @@ -182,7 +166,6 @@ export function AddFederationForm(props: {
console.error("Error submitting federation:", e);
setError(eify(e));
}
setLoadingFederation("");
};

return (
Expand Down Expand Up @@ -235,125 +218,10 @@ export function AddFederationForm(props: {
</VStack>
</Form>
</Show>
<Show when={!props.setup}>
<MediumHeader>
{i18n.t("settings.manage_federations.discover")}
</MediumHeader>
</Show>

<Suspense>
<Switch>
<Match when={federations.loading}>
<FancyCard>
<LoadingShimmer />
</FancyCard>
</Match>
<Match when={federations.latest}>
<For each={federations()}>
{(fed) => (
<FederationFormItem
fed={fed}
onSelect={onSelect}
loadingFederation={loadingFederation()}
setup={!!props.setup}
/>
)}
</For>
</Match>
</Switch>
</Suspense>
</div>
);
}

function FederationFormItem(props: {
fed: DiscoveredFederation;
onSelect: (invite_codes: string[]) => void;
loadingFederation: string;
setup: boolean;
}) {
const [state, _actions, _sw] = useMegaStore();
const i18n = useI18n();

const alreadyAdded = createMemo(() => {
const matches = state.federations?.find((f) =>
props.fed.invite_codes.includes(f.invite_code)
);
return matches !== undefined;
});
return (
<FancyCard>
<VStack>
<div class="flex items-center gap-2 md:gap-4">
<LabelCircle
name={props.fed.metadata?.name}
image_url={props.fed.metadata?.picture}
contact={false}
label={false}
/>
<div>
<header class={`font-semibold`}>
{props.fed.metadata?.name}
</header>
<Show when={props.fed.metadata?.about}>
<p>{props.fed.metadata?.about}</p>
</Show>
</div>
</div>
<Show when={!props.setup}>
<KeyValue
key={i18n.t(
"settings.manage_federations.federation_id"
)}
>
<MiniStringShower text={props.fed.id} />
</KeyValue>
</Show>
<Show when={props.fed.created_at}>
<KeyValue
key={i18n.t("settings.manage_federations.created_at")}
>
<time>{timeAgo(props.fed.created_at)}</time>
</KeyValue>
</Show>
<Show when={props.fed.recommendations.length > 0}>
<KeyValue
key={i18n.t(
"settings.manage_federations.recommended_by"
)}
>
<div class="flex items-center gap-2 overflow-scroll md:gap-4">
<For each={props.fed.recommendations}>
{(contact) => (
<LabelCircle
name={contact.name}
image_url={contact.image_url}
contact={true}
label={false}
/>
)}
</For>
</div>
</KeyValue>
</Show>
<Show
when={!alreadyAdded() && !(state.federations?.length === 2)}
>
<Button
intent="blue"
onClick={() => props.onSelect(props.fed.invite_codes)}
loading={props.fed.invite_codes.includes(
props.loadingFederation
)}
>
{i18n.t("settings.manage_federations.add")}
</Button>
</Show>
</VStack>
</FancyCard>
);
}

function RecommendButton(props: { fed: MutinyFederationIdentity }) {
const [_state, _actions, sw] = useMegaStore();
const i18n = useI18n();
Expand Down

0 comments on commit 1969a39

Please sign in to comment.