aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/sign
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2025-01-15 12:45:04 -0800
committerAdam Soltys <[email protected]>2025-01-15 12:45:04 -0800
commitcc3899a4fa8d0744777457d59fb4c9f3a2a37cd0 (patch)
treefb59368cafd993a557e5df6690f66da83db591f9 /src/routes/(app)/sign
parent9a3a3648c0a8281821c8880f1ac7af69dd3901fa (diff)
downloadcoinos-ui-cc3899a4fa8d0744777457d59fb4c9f3a2a37cd0.tar.gz
coinos-ui-cc3899a4fa8d0744777457d59fb4c9f3a2a37cd0.zip
sign page
Diffstat (limited to 'src/routes/(app)/sign')
-rw-r--r--src/routes/(app)/sign/+page.server.ts19
-rw-r--r--src/routes/(app)/sign/+page.svelte33
2 files changed, 52 insertions, 0 deletions
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>