Skip to content
New issue

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

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

Already on GitHub? # to your account

redeem cashu token #885

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
"@kobalte/core": "^0.9.8",
"@kobalte/tailwindcss": "^0.5.0",
"@modular-forms/solid": "^0.18.1",
"@mutinywallet/mutiny-wasm": "0.5.8",
"@mutinywallet/waila-wasm": "^0.2.6",
"@mutinywallet/mutiny-wasm": "file:../mutiny-node/mutiny-wasm/pkg",
"@mutinywallet/waila-wasm": "file:../bitcoin-waila/waila-wasm/pkg",
"@solid-primitives/upload": "^0.0.111",
"@solidjs/meta": "^0.29.1",
"@solidjs/router": "^0.9.0",
Expand Down
27 changes: 15 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/logic/waila.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type ParsedParams = {
fedimint_invite?: string;
is_lnurl_auth?: boolean;
contact_id?: string;
cashu_token?: string;
};

export function toParsedParams(
Expand Down Expand Up @@ -67,7 +68,8 @@ export function toParsedParams(
lightning_address: params.lightning_address,
nostr_wallet_auth: params.nostr_wallet_auth,
is_lnurl_auth: params.is_lnurl_auth,
fedimint_invite: params.fedimint_invite_code
fedimint_invite: params.fedimint_invite_code,
cashu_token: params.cashu_token
}
};
}
2 changes: 2 additions & 0 deletions src/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
Main,
NotFound,
Receive,
RedeemCashu,
Scanner,
Search,
Send,
Expand Down Expand Up @@ -128,6 +129,7 @@ export function Router() {
component={ManageFederations}
/>
</Route>
<Route path="/redeemcashu" component={RedeemCashu} />
<Route path="/*all" component={NotFound} />
</Routes>
<Toaster />
Expand Down
66 changes: 66 additions & 0 deletions src/routes/RedeemCashu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { useNavigate } from "@solidjs/router";
import { createSignal } from "solid-js";

import {
AmountSats,
Button,
DefaultMain,
Indicator,
LargeHeader,
MutinyWalletGuard,
NavBar
} from "~/components";
import { useI18n } from "~/i18n/context";
import { useMegaStore } from "~/state/megaStore";

export type ReceiveFlavor = "unified" | "lightning" | "onchain";
type ReceiveState = "edit" | "show" | "paid";

export function RedeemCashu() {
const [state, actions] = useMegaStore();
const navigate = useNavigate();
const i18n = useI18n();

const [receiveState, setReceiveState] = createSignal<ReceiveState>("edit");

// loading state for the continue button
const [loading, setLoading] = createSignal(false);

async function onSubmit(e: Event) {
e.preventDefault();
meltCashuToken();
}

async function meltCashuToken() {
const res = await state.mutiny_wallet?.melt_cashu_token(
String(state.scan_result?.cashu_token)
);
}

return (
<MutinyWalletGuard>
<DefaultMain>
<LargeHeader
action={
receiveState() === "show" && (
<Indicator>{i18n.t("receive.checking")}</Indicator>
)
}
>
Redeem Cashu token
</LargeHeader>
</DefaultMain>
<div class="flex-1 self-center">
<p class="text-center text-white">
Do you wish to redeem this Cashu token for
<AmountSats amountSats={state.scan_result?.amount_sats} />
</p>
<Button intent="green" onClick={onSubmit} loading={loading()}>
Redeem
</Button>
</div>
{/* {i18n.t("common.redeem")} */}
<NavBar activeTab="receive" />
</MutinyWalletGuard>
);
}
1 change: 1 addition & 0 deletions src/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ export * from "./Send";
export * from "./Swap";
export * from "./SwapLightning";
export * from "./Search";
export * from "./RedeemCashu";
4 changes: 4 additions & 0 deletions src/state/megaStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,10 @@ export const Provider: ParentComponent = (props) => {
encodeURIComponent(result.value?.nostr_wallet_auth)
);
}
if (result.value?.cashu_token) {
actions.setScanResult(result.value);
navigate("/redeemcashu");
}
}
},
setBetaWarned() {
Expand Down