diff --git a/ceremony/src/lib/components/Terminal/Activity.svelte b/ceremony/src/lib/components/Terminal/Activity.svelte index 09fbcee2c5..8bc027e568 100644 --- a/ceremony/src/lib/components/Terminal/Activity.svelte +++ b/ceremony/src/lib/components/Terminal/Activity.svelte @@ -21,25 +21,26 @@ function formatTimestamp(timestamp: string): string { {#if activity.data} - {#each activity.data as item, i (item)} - {@const type = item.message.type} - {@const user = item.message.user} - - {formatTimestamp(item.created_at)} - - {#if type === "join_waitlist"} - {user} joined the waitlist - {:else if type === "redeem"} - {user} have redeemed a code - {:else if type === "join_queue"} - {user} joined the queue - {:else if type === "contribution_started"} - {user} have started their contribution - {:else if type === "contribution_submitted"} - {user} has submitted their contribution - {:else if type === "contribution_verified"} - {user} contribution just verified - {/if} - - - {/each} +
+ {#each activity.data as item, i (item)} + {@const type = item.message.type} + {@const user = item.message.user} + + {formatTimestamp(item.created_at)} - + {#if type === "join_waitlist"} + {user} joined the waitlist + {:else if type === "redeem"} + {user} has redeemed a code + {:else if type === "join_queue"} + {user} joined the queue + {:else if type === "contribution_started"} + {user} has started their contribution + {:else if type === "contribution_submitted"} + {user} has submitted their contribution + {:else if type === "contribution_verified"} + {user}'s contribution has just been verified + {/if} + + {/each} +
{/if} \ No newline at end of file diff --git a/ceremony/src/lib/components/Terminal/Authenticate.svelte b/ceremony/src/lib/components/Terminal/Authenticate.svelte index 61843e52ae..e2f1ba24dd 100644 --- a/ceremony/src/lib/components/Terminal/Authenticate.svelte +++ b/ceremony/src/lib/components/Terminal/Authenticate.svelte @@ -1,68 +1,39 @@ {#if !redirecting} - - {#each providers as provider, index} - - {/each} + trigger(value)} />
- By logging in, I acknowledge that my name, email address, and optional wallet address will be part of the publicly viewable MPC ceremony data. I agree that this data will never be deleted as it is encoded in my contribution. - + By signing in, I acknowledge that my public GPG key and signature will be permanently publicly available as it is cryptographically part of the MPC ceremony data. I am aware that my GPG key contains the email address I use to sign in. {/if} \ No newline at end of file diff --git a/ceremony/src/lib/components/Terminal/Button.svelte b/ceremony/src/lib/components/Terminal/Button.svelte index 56ae3f3347..f18c461a5f 100644 --- a/ceremony/src/lib/components/Terminal/Button.svelte +++ b/ceremony/src/lib/components/Terminal/Button.svelte @@ -1,14 +1,28 @@ \ No newline at end of file diff --git a/ceremony/src/lib/components/Terminal/Ceremony.svelte b/ceremony/src/lib/components/Terminal/Ceremony.svelte index 049fb5ce1f..ff258df1f1 100644 --- a/ceremony/src/lib/components/Terminal/Ceremony.svelte +++ b/ceremony/src/lib/components/Terminal/Ceremony.svelte @@ -29,7 +29,7 @@ onDestroy(() => { {:else if contributor.state === "verifying"} {terminal.setStep(9)} - {terminal.updateHistory("Verifying your contribution...", {replace: true})} + {terminal.updateHistory({text:"Verifying your contribution...", replace: true})} {:else if contributor.clientState === "offline" || contributor.clientState === undefined} {terminal.setStep(5)} @@ -41,11 +41,11 @@ onDestroy(() => { {:else if contributor.state === 'contribute'} {terminal.setStep(8)} - {terminal.updateHistory("Starting contribution...", {replace: true})} + {terminal.updateHistory({text: "Starting contribution...", replace: true})} {:else if contributor.state === "contributing"} {terminal.setStep(9)} - {terminal.updateHistory("Contributing...", {replace: true})} + {terminal.updateHistory({text: "Contributing...", replace: true})} {:else} Not able to contribute at this time diff --git a/ceremony/src/lib/components/Terminal/Code.svelte b/ceremony/src/lib/components/Terminal/Code.svelte index cd0be1716c..8c648cf3d1 100644 --- a/ceremony/src/lib/components/Terminal/Code.svelte +++ b/ceremony/src/lib/components/Terminal/Code.svelte @@ -2,9 +2,11 @@ import { getState } from "$lib/state/index.svelte.ts" import { onDestroy, onMount } from "svelte" import Print from "$lib/components/Terminal/Print.svelte" -import Confirm from "$lib/components/Terminal/Confirm.svelte" +import Buttons from "$lib/components/Terminal/Install/Buttons.svelte" +import { sleep } from "$lib/utils/utils.ts" +import { callJoinQueue } from "$lib/supabase" -const { terminal } = getState() +const { terminal, contributor } = getState() let inputCode: string = $state("") let normalizedCode = $derived(normalizeString(inputCode)) @@ -12,15 +14,57 @@ let inputElement: HTMLInputElement let showConfirm = $state(false) let showInput = $state(true) -function normalizeString(input: string): string { - return input.toLowerCase().replace(/[^a-z0-9]/gi, "") -} - function handleKeyDown(event: KeyboardEvent) { if (event.key === "Enter") { + console.log("XX keydown") event.preventDefault() - showConfirm = true + terminal.updateHistory({ text: `Entered code: ${inputCode}`, duplicate: true }) + terminal.updateHistory({ + text: "If you enter the queue then you must have your browser and terminal open when it is your turn. you cannot leave the queue, and when it is your turn you need to contribute", + type: "warning", + duplicate: true + }) + terminal.updateHistory({ text: "", lineBreak: true }) showInput = false + showConfirm = true + } +} + +onMount(() => { + if (inputElement) { + inputElement.focus() + } +}) + +onDestroy(() => { + if (inputElement) { + inputElement.blur() + } + terminal.clearHistory() +}) + +function normalizeString(input: string): string { + return input.toLowerCase().replace(/[^a-z0-9]/gi, "") +} + +async function handleCodeJoin() { + try { + terminal.updateHistory({ text: "Checking code...", duplicate: true }) + console.log("code: ", normalizedCode) + await sleep(1000) + const codeOk = await callJoinQueue(normalizedCode) + if (codeOk) { + contributor.setAllowanceState("hasRedeemed") + terminal.updateHistory({ text: "Code successfully redeemed" }) + } else { + terminal.updateHistory({ text: "The code is not valid", duplicate: true }) + terminal.updateHistory({ text: "", lineBreak: true, duplicate: true }) + onCancel() + } + } catch (error) { + console.error("Error redeeming code:", error) + terminal.updateHistory({ text: "An error occurred while redeeming the code" }) + onCancel() } } @@ -29,9 +73,14 @@ function onCancel() { showConfirm = false } -onDestroy(() => { - terminal.clearHistory() -}) +function trigger(value: "enter" | "cancel") { + console.log("XX trigger 2") + if (value === "enter") { + handleCodeJoin() + } else if (value === "cancel") { + onCancel() + } +} {#if showInput} @@ -50,6 +99,10 @@ onDestroy(() => { {/if} -{#if showConfirm} - +{#if showConfirm && !showInput} + trigger(value)} + /> {/if} diff --git a/ceremony/src/lib/components/Terminal/Confirm.svelte b/ceremony/src/lib/components/Terminal/Confirm.svelte deleted file mode 100644 index 5d3ef8002b..0000000000 --- a/ceremony/src/lib/components/Terminal/Confirm.svelte +++ /dev/null @@ -1,95 +0,0 @@ - - -IF YOU ENTER THE QUEUE THEN YOU MUST HAVE YOUR BROWSER AND TERMINAL OPEN WHEN IT IS YOUR - TURN. - YOU CANNOT LEAVE THE QUEUE, AND WHEN IT IS YOUR TURN YOU NEED TO CONTRIBUTE - -
- - - - diff --git a/ceremony/src/lib/components/Terminal/Contributors.svelte b/ceremony/src/lib/components/Terminal/Contributors.svelte index b008a7febd..8c2d89da50 100644 --- a/ceremony/src/lib/components/Terminal/Contributors.svelte +++ b/ceremony/src/lib/components/Terminal/Contributors.svelte @@ -1,63 +1,34 @@ - - {#each contributions.data as contributor, index} - - {/each} \ No newline at end of file + trigger(value)} +/> diff --git a/ceremony/src/lib/components/Terminal/Install/Buttons.svelte b/ceremony/src/lib/components/Terminal/Install/Buttons.svelte new file mode 100644 index 0000000000..b209d73d62 --- /dev/null +++ b/ceremony/src/lib/components/Terminal/Install/Buttons.svelte @@ -0,0 +1,62 @@ + + +{#each data as btn, index} + {#key btn} + + {/key} +{/each} \ No newline at end of file diff --git a/ceremony/src/lib/components/Terminal/Install/Linux.svelte b/ceremony/src/lib/components/Terminal/Install/Linux.svelte index 0ef7006e1b..af39ff6fab 100644 --- a/ceremony/src/lib/components/Terminal/Install/Linux.svelte +++ b/ceremony/src/lib/components/Terminal/Install/Linux.svelte @@ -1,9 +1,8 @@ {#if showButtons} - - + trigger(value)}/> {/if} diff --git a/ceremony/src/lib/components/Terminal/Install/MacOS.svelte b/ceremony/src/lib/components/Terminal/Install/MacOS.svelte index 84eb72a02b..870b3dd143 100644 --- a/ceremony/src/lib/components/Terminal/Install/MacOS.svelte +++ b/ceremony/src/lib/components/Terminal/Install/MacOS.svelte @@ -1,9 +1,8 @@ {#if showButtons} - - + trigger(value)}/> {/if} diff --git a/ceremony/src/lib/components/Terminal/Install/SelectOS.svelte b/ceremony/src/lib/components/Terminal/Install/SelectOS.svelte index 87da3cf84b..8a8a79bd00 100644 --- a/ceremony/src/lib/components/Terminal/Install/SelectOS.svelte +++ b/ceremony/src/lib/components/Terminal/Install/SelectOS.svelte @@ -1,12 +1,11 @@ - {#if showButtons} - {#each selections as os, index} - - {/each} + trigger(value)}/> + {/if} + diff --git a/ceremony/src/lib/components/Terminal/Install/index.svelte b/ceremony/src/lib/components/Terminal/Install/index.svelte index 9774d11d43..63a322fb10 100644 --- a/ceremony/src/lib/components/Terminal/Install/index.svelte +++ b/ceremony/src/lib/components/Terminal/Install/index.svelte @@ -7,7 +7,7 @@ import MacOS from "$lib/components/Terminal/Install/MacOS.svelte" import Linux from "$lib/components/Terminal/Install/Linux.svelte" let os = $state(undefined) -let selectedOs = $state(undefined) +let selectedOs = $state(undefined) const { terminal } = getState() @@ -16,15 +16,16 @@ onMount(async () => { }) let change = async () => { - terminal.updateHistory(`Loading supported os..`, { duplicate: true }) + terminal.updateHistory({ text: `Loading supported os..`, duplicate: true }) await sleep(500) selectedOs = undefined } -let select = async (value: DetectedOS) => { - terminal.updateHistory(`Loading ${value} instructions..`, { duplicate: true }) +let select = async (value: string) => { + terminal.updateHistory({ text: `Loading ${value} instructions..`, duplicate: true }) await sleep(500) selectedOs = value + console.log("XX", value) } onDestroy(() => { @@ -34,9 +35,9 @@ onDestroy(() => { {#if !selectedOs} -{:else if selectedOs === "macOS"} +{:else if selectedOs === "macos"} -{:else if selectedOs === "Linux"} +{:else if selectedOs === "linux"} {/if} diff --git a/ceremony/src/lib/components/Terminal/Join.svelte b/ceremony/src/lib/components/Terminal/Join.svelte index 804afd1298..ef001d9040 100644 --- a/ceremony/src/lib/components/Terminal/Join.svelte +++ b/ceremony/src/lib/components/Terminal/Join.svelte @@ -6,28 +6,24 @@ import { onDestroy, onMount } from "svelte" import { cn, sleep } from "$lib/utils/utils.ts" import Code from "$lib/components/Terminal/Code.svelte" import Button from "$lib/components/Terminal/Button.svelte" +import Buttons from "$lib/components/Terminal/Install/Buttons.svelte" const { contributor, terminal } = getState() -const buttons = [ - { - label: "I have an invitation code", - action: "code" - }, - { - label: "I want to join the waitlist", - action: "waitlist" - } -] - let isOpenToPublic = $state(false) -let waitlistLoading = $state(false) let selected = $state(false) let code = $state(false) -let focusedIndex = $state(0) + +onMount(() => { + terminal.updateHistory({ text: "Access the ceremony", replace: true }) + terminal.setStep(2) +}) + +onDestroy(() => { + terminal.clearHistory() +}) async function handleWaitlistJoin() { - waitlistLoading = true try { await callJoinQueue(null) if (isOpenToPublic) { @@ -37,78 +33,38 @@ async function handleWaitlistJoin() { } } catch (error) { console.error("Error joining waitlist:", error) - } finally { - waitlistLoading = false } } -let unsubscribe: (() => void) | undefined -let subscriptionTimeout: NodeJS.Timeout | undefined -onMount(() => { - terminal.setStep(2) - terminal.updateHistory("Please authenticate using one of the following") - subscriptionTimeout = setTimeout(() => { - unsubscribe = terminal.keys.subscribe(event => { - if (event) { - if (code) return - if (event.type === "keydown") { - if (event.key === "ArrowUp") { - focusedIndex = (focusedIndex - 1 + buttons.length) % buttons.length - } else if (event.key === "ArrowDown") { - focusedIndex = (focusedIndex + 1) % buttons.length - } else if (event.key === "Enter") { - handleAction(buttons[focusedIndex].action) - } - } - } - }) - }, 200) - return () => { - if (subscriptionTimeout) { - clearTimeout(subscriptionTimeout) - } - if (unsubscribe) { - unsubscribe() - } - } -}) - -async function handleAction(action: string) { - if (action === "waitlist") { +async function trigger(value: string) { + if (value === "waitlist") { selected = true - terminal.updateHistory("Adding user to the waitlist...") + terminal.updateHistory({ text: "Adding user to the waitlist..." }) await sleep(1000) handleWaitlistJoin() - } else if (action === "code") { + } else if (value === "code") { code = true } } -onDestroy(() => { - if (unsubscribe) { - unsubscribe() +const buttons = [ + { + text: "I have an invitation code", + action: "code" + }, + { + text: "I want to join the waitlist", + action: "waitlist" } - terminal.clearHistory() -}) +] -{terminal.updateHistory("Access the ceremony")} - {#if !selected} {#if code } {:else } - {#each buttons as button, index} - - {/each} + trigger(value)}/> {/if} - {/if} diff --git a/ceremony/src/lib/components/Terminal/Printer.svelte b/ceremony/src/lib/components/Terminal/Printer.svelte new file mode 100644 index 0000000000..0f4fbf0076 --- /dev/null +++ b/ceremony/src/lib/components/Terminal/Printer.svelte @@ -0,0 +1,22 @@ + + +
+ {#each terminal.history as content} + {#if content.lineBreak} +
+ {:else} +

{@html content.text}

+ {/if} + {/each} +
\ No newline at end of file diff --git a/ceremony/src/lib/components/Terminal/Queue.svelte b/ceremony/src/lib/components/Terminal/Queue.svelte index 30a2e9c336..347ec78ea9 100644 --- a/ceremony/src/lib/components/Terminal/Queue.svelte +++ b/ceremony/src/lib/components/Terminal/Queue.svelte @@ -7,7 +7,7 @@ import LoadingBar from "$lib/components/Terminal/LoadingBar.svelte" const { contributor, terminal } = getState() onMount(() => { - terminal.updateHistory("You are in queue") + terminal.updateHistory({ text: "You are in queue" }) }) onDestroy(() => { diff --git a/ceremony/src/lib/components/Terminal/Reward.svelte b/ceremony/src/lib/components/Terminal/Reward.svelte index 2b69f52861..7be63c7963 100644 --- a/ceremony/src/lib/components/Terminal/Reward.svelte +++ b/ceremony/src/lib/components/Terminal/Reward.svelte @@ -13,8 +13,12 @@ let validation = (val: ValidState) => { } onMount(() => { - terminal.updateHistory("Add an address, you may receive rewards for successful contributions.") - terminal.updateHistory('You can enter your union or any cosmos address, or type "skip".') + terminal.updateHistory({ + text: "Add an address, you may receive rewards for successful contributions." + }) + terminal.updateHistory({ + text: 'You can enter your union or any cosmos address, or type "skip".' + }) }) onDestroy(() => { diff --git a/ceremony/src/lib/components/Terminal/Secret.svelte b/ceremony/src/lib/components/Terminal/Secret.svelte index 6e0a94280e..d952455a06 100644 --- a/ceremony/src/lib/components/Terminal/Secret.svelte +++ b/ceremony/src/lib/components/Terminal/Secret.svelte @@ -1,9 +1,9 @@ {#if !generating} {#if !generated} - + trigger(value)}/> {:else} - - + trigger(value)}/> {/if} {/if} diff --git a/ceremony/src/lib/components/Terminal/Thanks.svelte b/ceremony/src/lib/components/Terminal/Thanks.svelte index e280ccda53..7667b02397 100644 --- a/ceremony/src/lib/components/Terminal/Thanks.svelte +++ b/ceremony/src/lib/components/Terminal/Thanks.svelte @@ -1,82 +1,38 @@ -{#if showButtons} - {#each buttons as btn, index} - - {/each} -{/if} \ No newline at end of file + trigger(value)}/> diff --git a/ceremony/src/lib/components/Terminal/Waitlist.svelte b/ceremony/src/lib/components/Terminal/Waitlist.svelte index 8270db1166..d24775b9d9 100644 --- a/ceremony/src/lib/components/Terminal/Waitlist.svelte +++ b/ceremony/src/lib/components/Terminal/Waitlist.svelte @@ -1,19 +1,23 @@ -
+
@@ -103,11 +83,7 @@ function autoScroll(node: HTMLElement) {
{#if terminal.tab === 1} -
- {#each terminal.history as text} - {text} - {/each} -
+
{@render children()} {:else if terminal.tab === 2} diff --git a/ceremony/src/lib/components/address/AddressForm.svelte b/ceremony/src/lib/components/address/AddressForm.svelte index 2856195bf9..39a7173177 100644 --- a/ceremony/src/lib/components/address/AddressForm.svelte +++ b/ceremony/src/lib/components/address/AddressForm.svelte @@ -31,7 +31,7 @@ const onAddressSubmit = async (event: Event) => { } validation("PENDING") - terminal.updateHistory("Checking address") + terminal.updateHistory({ text: "Checking address" }) await sleep(1000) const addressValidation = isValidBech32Address(inputText) validState = addressValidation ? "VALID" : "INVALID" @@ -47,25 +47,25 @@ const onAddressSubmit = async (event: Event) => { wallet: inputText }) if (result) { - terminal.updateHistory("Saving address...") + terminal.updateHistory({ text: "Saving address..." }) await sleep(2000) - terminal.updateHistory("Wallet address saved successfully") + terminal.updateHistory({ text: "Wallet address saved successfully" }) await sleep(2000) contributor.checkUserWallet(user.session?.user.id) } else { - terminal.updateHistory("Failed to save wallet address") + terminal.updateHistory({ text: "Failed to save wallet address" }) } } catch (error) { console.error("Error saving wallet address:", error) - terminal.updateHistory("An error occurred while saving the wallet address") + terminal.updateHistory({ text: "An error occurred while saving the wallet address" }) } } else if (validState === "INVALID") { - terminal.updateHistory("Wallet address not valid, try again..", { duplicate: true }) + terminal.updateHistory({ text: "Wallet address not valid, try again..", duplicate: true }) } } const skip = async () => { - terminal.updateHistory("Skipping reward step") + terminal.updateHistory({ text: "Skipping reward step" }) validation("SKIPPED") try { if (!contributor.userId) return @@ -74,15 +74,18 @@ const skip = async () => { wallet: "SKIPPED" }) if (result) { - terminal.updateHistory("Saving to db...") + terminal.updateHistory({ text: "Saving to db..." }) await sleep(2000) contributor.userWallet = "SKIPPED" } else { - terminal.updateHistory("Failed to save wallet address", { duplicate: true }) + terminal.updateHistory({ text: "Failed to save wallet address", duplicate: true }) } } catch (error) { console.error("Error saving wallet address:", error) - terminal.updateHistory("An error occurred while saving the wallet address", { duplicate: true }) + terminal.updateHistory({ + text: "An error occurred while saving the wallet address", + duplicate: true + }) } } diff --git a/ceremony/src/lib/layout/Navbar/NavLink.svelte b/ceremony/src/lib/layout/Navbar/NavLink.svelte deleted file mode 100644 index 9b7a592c32..0000000000 --- a/ceremony/src/lib/layout/Navbar/NavLink.svelte +++ /dev/null @@ -1,7 +0,0 @@ - - - - {@render children()} - \ No newline at end of file diff --git a/ceremony/src/lib/layout/Navbar/index.svelte b/ceremony/src/lib/layout/Navbar/index.svelte deleted file mode 100644 index 657f2c7709..0000000000 --- a/ceremony/src/lib/layout/Navbar/index.svelte +++ /dev/null @@ -1,84 +0,0 @@ - - -
- -
\ No newline at end of file diff --git a/ceremony/src/lib/state/contributions.svelte.ts b/ceremony/src/lib/state/contributions.svelte.ts index 529677fe5e..2689092275 100644 --- a/ceremony/src/lib/state/contributions.svelte.ts +++ b/ceremony/src/lib/state/contributions.svelte.ts @@ -1,7 +1,12 @@ import { getContributions } from "$lib/supabase" +type ContributionsData = { + public_key_hash: string + payload_id: string +} + export class Contributions { - data = $state() + data = $state>([]) private readonly intervalId: NodeJS.Timeout | null = null constructor() { @@ -11,7 +16,7 @@ export class Contributions { async loadContributions() { try { - this.data = await getContributions() + this.data = (await getContributions()) ?? [] } catch (error) { console.error("Failed to load contributions:", error) } diff --git a/ceremony/src/lib/state/contributor.svelte.ts b/ceremony/src/lib/state/contributor.svelte.ts index fa1d40a335..5156f6e8ae 100644 --- a/ceremony/src/lib/state/contributor.svelte.ts +++ b/ceremony/src/lib/state/contributor.svelte.ts @@ -109,14 +109,14 @@ export class Contributor { if (this.userId === undefined && userId) { this.userId = userId this.loggedIn = true - this.checkWaitListPosition(userId) + this.checkWaitListPosition() this.checkUserWallet(userId) this.checkCurrentUserState(userId) this.startPolling() } } - async checkWaitListPosition(_userId: string | undefined): Promise { + async checkWaitListPosition(): Promise { this.waitListPosition = await getWaitListPosition() return this.waitListPosition } diff --git a/ceremony/src/lib/state/live.svelte.ts b/ceremony/src/lib/state/live.svelte.ts index c81b9410a3..7923e448a0 100644 --- a/ceremony/src/lib/state/live.svelte.ts +++ b/ceremony/src/lib/state/live.svelte.ts @@ -19,7 +19,7 @@ export class Activity { .from("log") .select("message, created_at") .order("created_at", { ascending: false }) - .limit(10) + .limit(50) if (error) { console.error("Error fetching initial data:", error) diff --git a/ceremony/src/lib/state/session.svelte.ts b/ceremony/src/lib/state/session.svelte.ts index 36eb33ec7d..d81518d723 100644 --- a/ceremony/src/lib/state/session.svelte.ts +++ b/ceremony/src/lib/state/session.svelte.ts @@ -36,11 +36,11 @@ export async function logout(terminal: Terminal): Promise { await goto("/") if (!user.session) { - terminal.updateHistory("User already logged out", { duplicate: true }) + terminal.updateHistory({ text: "User already logged out", duplicate: true }) return } - terminal.updateHistory("Logging out user...") + terminal.updateHistory({ text: "Logging out user..." }) await sleep(1000) try { @@ -49,7 +49,7 @@ export async function logout(terminal: Terminal): Promise { terminal.setHash(undefined) await invalidateAll() } catch (error) { - terminal.updateHistory(`error logging out`) + terminal.updateHistory({ text: "Error logging out" }) terminal.setHash(undefined) terminal.setTab(1) diff --git a/ceremony/src/lib/state/terminal.svelte.ts b/ceremony/src/lib/state/terminal.svelte.ts index 9f5686efaf..0185c3d46a 100644 --- a/ceremony/src/lib/state/terminal.svelte.ts +++ b/ceremony/src/lib/state/terminal.svelte.ts @@ -4,9 +4,13 @@ import { readable } from "svelte/store" export type AuthProviders = "GitHub" | "Google" export type State = "hasRedeemed" | "inQueue" | "inWaitlist" | "join" | undefined -interface UpdateHistoryOptions { - duplicate?: boolean - replace?: boolean +interface UpdateHistory { + text: string + type?: "warning" | "info" | undefined + uppercase?: boolean | undefined + lineBreak?: boolean | undefined + duplicate?: boolean | undefined + replace?: boolean | undefined } export type KeyEvent = { @@ -18,7 +22,7 @@ export type KeyEvent = { export class Terminal { state = $state(undefined) - history = $state>([]) + history = $state>([]) tab = $state<1 | 2 | 3 | number>(1) hash = $state(undefined) currentStep = $state(0) @@ -51,18 +55,15 @@ export class Terminal { console.log("Creating terminal state") } - updateHistory(text: string, options: UpdateHistoryOptions = {}) { - const { duplicate = false, replace = false } = options + updateHistory(content: UpdateHistory) { + const index = this.history.findIndex(item => item.text === content.text) - const index = this.history.indexOf(text) - - if (duplicate) { - this.history.push(text) - } else if (replace && index !== -1) { - this.history.splice(index, 1) - this.history.push(text) - } else if (!this.history.includes(text)) { - this.history.push(text) + if (content.duplicate) { + this.history.push(content) + } else if (content.replace && index !== -1) { + this.history[index] = content + } else if (index === -1) { + this.history.push(content) } } diff --git a/ceremony/src/routes/+layout.svelte b/ceremony/src/routes/+layout.svelte index 3e5352ee22..40aaf29534 100644 --- a/ceremony/src/routes/+layout.svelte +++ b/ceremony/src/routes/+layout.svelte @@ -9,16 +9,15 @@ import Timer from "$lib/components/Terminal/Timer.svelte" import "../styles/tailwind.css" import { onMount } from "svelte" -import { getAverageTimes } from "$lib/supabase" let { children } = $props() -let { user, contributor, terminal } = createState() +let { user, contributor } = createState() $effect(() => { const { data: { subscription } - } = supabase.auth.onAuthStateChange((event, session) => { + } = supabase.auth.onAuthStateChange(() => { checkAuth() }) return () => { @@ -49,12 +48,15 @@ $effect(() => { document.getElementById("glitch-video").play() } }) -let showBootSequence = $state(true) +let showBootSequence = $state(localStorage?.getItem("ceremony:show-boot-sequence") !== "false") let bootSequenceVideoElement = $state(null) onMount(() => bootSequenceVideoElement?.play()) -const hideBootSequenceVideo = () => (showBootSequence = false) +const hideBootSequenceVideo = () => { + showBootSequence = false + localStorage?.setItem("ceremony:show-boot-sequence", "false") +} {#if showBootSequence} @@ -106,15 +108,15 @@ const hideBootSequenceVideo = () => (showBootSequence = false) {/if} diff --git a/ceremony/src/routes/+page.svelte b/ceremony/src/routes/+page.svelte index be2065a484..86e7099d9f 100644 --- a/ceremony/src/routes/+page.svelte +++ b/ceremony/src/routes/+page.svelte @@ -26,6 +26,6 @@ onMount(() => { {/if} {:else if user.session === null && terminal.tab === 1} - + {/if} {/if} diff --git a/ceremony/src/routes/contributions/[hash]/+page.svelte b/ceremony/src/routes/contributions/[hash]/+page.svelte index 6b645ac1db..2b68117947 100644 --- a/ceremony/src/routes/contributions/[hash]/+page.svelte +++ b/ceremony/src/routes/contributions/[hash]/+page.svelte @@ -1,52 +1,23 @@ @@ -104,33 +81,20 @@ const imagePath = "https://ceremony.union.build/images/ceremony.png" -{#await getUserContribution(hash)} +{#if contribution} +
{decodeHexString(contribution?.public_key)}
+
{decodeHexString(contribution?.signature)}
+ {#each prints as print} + {print} + {/each} +
+ trigger(value)} + /> +{:else} Loading -{:then contribution} - {#if contribution} -
{decodeHexString(contribution.public_key)}
-
{decodeHexString(contribution.signature)}
- {#each prints as print} - {print} - {/each} - {#if showButtons} -
- - - {/if} - {/if} -{/await} - +{/if}