diff options
| author | Adam Soltys <[email protected]> | 2025-01-15 12:45:04 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-01-15 12:45:04 -0800 |
| commit | cc3899a4fa8d0744777457d59fb4c9f3a2a37cd0 (patch) | |
| tree | fb59368cafd993a557e5df6690f66da83db591f9 /src | |
| parent | 9a3a3648c0a8281821c8880f1ac7af69dd3901fa (diff) | |
| download | coinos-ui-cc3899a4fa8d0744777457d59fb4c9f3a2a37cd0.tar.gz coinos-ui-cc3899a4fa8d0744777457d59fb4c9f3a2a37cd0.zip | |
sign page
Diffstat (limited to 'src')
| -rw-r--r-- | src/components/InvoiceTypes.svelte | 12 | ||||
| -rw-r--r-- | src/routes/(app)/[username]/receive/+page.svelte | 6 | ||||
| -rw-r--r-- | src/routes/(app)/sign/+page.server.ts | 19 | ||||
| -rw-r--r-- | src/routes/(app)/sign/+page.svelte | 33 |
4 files changed, 66 insertions, 4 deletions
diff --git a/src/components/InvoiceTypes.svelte b/src/components/InvoiceTypes.svelte index b3367c90..c4d7fa77 100644 --- a/src/components/InvoiceTypes.svelte +++ b/src/components/InvoiceTypes.svelte @@ -1,6 +1,7 @@ <script> import { types } from "$lib/utils"; import { goto } from "$app/navigation"; + import { page } from "$app/stores"; let { aid, invoice, user, type, t, setType } = $props(); </script> @@ -16,7 +17,8 @@ class="bg-black rounded-full w-8 h-8 items-center justify-center flex" > <div class="m-auto"> - <iconify-icon noobserver + <iconify-icon + noobserver icon="ph:lightning-fill" class="text-yellow-300 text-2xl" ></iconify-icon> @@ -61,7 +63,8 @@ </button> <button class="btn flex-nowrap" onclick={() => goto("/receive")}> - <iconify-icon noobserver icon="ph:clipboard-text-bold" width="32"></iconify-icon> + <iconify-icon noobserver icon="ph:clipboard-text-bold" width="32" + ></iconify-icon> <div class="my-auto text-lg">{t("user.send.paste")}</div> </button> </div> @@ -74,7 +77,10 @@ > <div class="bg-black rounded-full w-8 h-8 items-center justify-center flex"> <div class="m-auto"> - <iconify-icon noobserver icon="ph:lightning-fill" class="text-yellow-300 text-2xl" + <iconify-icon + noobserver + icon="ph:lightning-fill" + class="text-yellow-300 text-2xl" ></iconify-icon> </div> </div> diff --git a/src/routes/(app)/[username]/receive/+page.svelte b/src/routes/(app)/[username]/receive/+page.svelte index 9f3a3fd8..e02d6651 100644 --- a/src/routes/(app)/[username]/receive/+page.svelte +++ b/src/routes/(app)/[username]/receive/+page.svelte @@ -24,6 +24,7 @@ import SetMemo from "$comp/SetMemo.svelte"; import { t } from "$lib/translations"; import { goto, invalidate } from "$app/navigation"; + import { page } from "$app/stores"; let { data } = $props(); @@ -67,11 +68,12 @@ } }; - let setType = async (type) => { + let setType = async (type, address_type) => { $showQr = true; if (type === types.lightning && !amount) goto(`/${username}/receive`, { invalidateAll: true, noScroll: true }); else { + invoice.address_type = address_type; invoice.type = type; await update(); } @@ -118,6 +120,8 @@ onMount(() => { if ($amountPrompt && !amount) toggleAmount(); + let address_type = $page.url.searchParams.get("address_type"); + if (address_type) setType(types.bitcoin, address_type); }); </script> diff --git a/src/routes/(app)/sign/+page.server.ts b/src/routes/(app)/sign/+page.server.ts new file mode 100644 index 00000000..c10f183c --- /dev/null +++ b/src/routes/(app)/sign/+page.server.ts @@ -0,0 +1,19 @@ +import { auth, fd, post, types } from "$lib/utils"; + +export async function load({ cookies }) { + const invoice = { + address_type: "legacy", + type: types.bitcoin, + }; + + const { text: address } = await post("/invoice", { invoice }, auth(cookies)); + + return { address }; +} + +export const actions = { + default: async ({ cookies, request }) => { + const body = await fd(request); + return post("/sign", body, auth(cookies)); + }, +}; diff --git a/src/routes/(app)/sign/+page.svelte b/src/routes/(app)/sign/+page.svelte new file mode 100644 index 00000000..819ba27c --- /dev/null +++ b/src/routes/(app)/sign/+page.svelte @@ -0,0 +1,33 @@ +<script> + import { copy, focus } from "$lib/utils"; + import { enhance } from "$app/forms"; + + let { data, form } = $props(); + let { address } = $derived(data); + let message = $state(); + let { signature } = $derived(form); +</script> + +<div class="container px-4 max-w-xl mx-auto space-y-5 text-center"> + <h1 class="px-3 md:px-0 text-center text-3xl md:text-4xl font-semibold"> + Sign message with address + </h1> + + {#if form} + <div class="text-2xl break-all">{signature}</div> + + <button onclick={() => copy(signature)} type="button" class="btn grow"> + <iconify-icon noobserver icon="ph:copy-bold" width="32"></iconify-icon> + <div class="my-auto">Copy</div></button + > + {:else} + <div class="text-2xl break-all">{address}</div> + <form use:enhance method="POST" class="space-y-5"> + <input name="address" value={address} type="hidden" /> + <input name="message" bind:value={message} /> + <button use:focus type="submit" class="btn btn-accent !w-auto grow"> + <div class="my-auto">Submit</div> + </button> + </form> + {/if} +</div> |
