-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
488 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,46 @@ | ||
<script lang="ts"> | ||
import Spinner from "$lib/components/Spinner.svelte" | ||
import type { HTMLButtonAttributes, HTMLAnchorAttributes } from "svelte/elements" | ||
let { children, class: className = "", loading = false, ...props } = $props() | ||
interface Props extends HTMLButtonAttributes, HTMLAnchorAttributes { | ||
children?: any | ||
class?: string | ||
loading?: boolean | ||
variant?: "primary" | "secondary" | ||
href?: string | ||
} | ||
let { | ||
children, | ||
class: className = "", | ||
loading = false, | ||
variant = "primary", | ||
href, | ||
...props | ||
}: Props = $props() | ||
const styles = { | ||
primary: "bg-union-accent-500 text-black hover:text-black", | ||
secondary: "bg-transparent text-white border-2 border-white hover:bg-neutral-800" | ||
} | ||
const getClass = (type: "primary" | "secondary") => styles[type] || styles.primary | ||
let combinedClasses = $derived( | ||
`flex items-center w-fit gap-2 px-4 py-2 font-bold uppercase justify-center ${getClass(variant)} ${className}` | ||
) | ||
</script> | ||
|
||
<button | ||
{...props} | ||
class={`flex items-center w-fit gap-2 px-4 py-2 text-black font-bold hover:text-black bg-union-accent-500 uppercase justify-center ${className}`}> | ||
{@render children()} | ||
{#if loading} | ||
<Spinner class="size-4"/> | ||
{/if} | ||
</button> | ||
{#if href} | ||
<a {href} class={combinedClasses} {...props}> | ||
{@render children()} | ||
{#if loading} | ||
<Spinner class="size-4"/> | ||
{/if} | ||
</a> | ||
{:else} | ||
<button class={combinedClasses} {...props}> | ||
{@render children()} | ||
{#if loading} | ||
<Spinner class="size-4"/> | ||
{/if} | ||
</button> | ||
{/if} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,91 +1,63 @@ | ||
<script lang="ts"> | ||
import type { ContributorState } from "$lib/stores/state.svelte.ts" | ||
import H1 from "$lib/components/typography/H1.svelte" | ||
import H3 from "$lib/components/typography/H3.svelte" | ||
import H2 from "$lib/components/typography/H2.svelte" | ||
import { generateSecret, start } from "$lib/client" | ||
import Reward from "$lib/components/Reward.svelte" | ||
import Download from "$lib/components/Download.svelte" | ||
import Queue from "$lib/components/Queue.svelte" | ||
import Install from "$lib/components/Install.svelte" | ||
import { start } from "$lib/client" | ||
import { AddressForm, type ValidState } from "$lib/components/address" | ||
import Blink from "$lib/components/Blink.svelte" | ||
import Tweet from "$lib/components/Tweet.svelte" | ||
import SwimLoad from "$lib/components/SwimLoad.svelte" | ||
import { getNumberSuffix } from "$lib/utils/utils.ts" | ||
import Text from "$lib/components/typography/Text.svelte" | ||
import Status from "$lib/components/Status.svelte" | ||
import Thanks from "$lib/components/Thanks.svelte" | ||
import { user } from "$lib/stores/user.svelte.ts" | ||
type Props = { | ||
contributor: ContributorState | ||
} | ||
let { contributor }: Props = $props() | ||
async function generate() { | ||
const email = user.session?.user.email | ||
await generateSecret(email) | ||
} | ||
$effect(() => { | ||
if (contributor?.contributionState === "contribute" && contributor.state !== "contributing") { | ||
console.log("Call client start") | ||
start() | ||
} | ||
if (contributor.clientState !== "offline") { | ||
generate() | ||
} | ||
}) | ||
let addressValidState: ValidState = $state("PENDING") | ||
window.addEventListener("beforeunload", (e: BeforeUnloadEvent) => { | ||
e.preventDefault() | ||
e.returnValue = "" | ||
}) | ||
</script> | ||
|
||
<div class="p-8 w-full flex items-center justify-center flex-col"> | ||
|
||
{#if contributor.state === 'inQueue'} | ||
|
||
<Status {contributor} /> | ||
|
||
<div class="border p-8 w-full max-w-4xl flex flex-col items-center"> | ||
<H1 class="mb-6">You are <span class="!text-union-accent-500">{contributor.queueState.position}<span | ||
class="lowercase">{getNumberSuffix(contributor.queueState.position)}</span> </span> in queue</H1> | ||
|
||
<SwimLoad max={contributor.queueState.count} current={contributor.queueState.position}/> | ||
|
||
<div class="mb-4 text-center"> | ||
<H2>Queue length: <span class="text-union-accent-500">{contributor.queueState.count}</span></H2> | ||
<H3>Waiting time: <span class="text-union-accent-500">{contributor.queueState.estimatedTime} minutes</span> | ||
(est.). | ||
</H3> | ||
</div> | ||
|
||
<div class="text-center"> | ||
<H2 class="mb-2">Get your nft</H2> | ||
<AddressForm class="" onValidation={result => (addressValidState = result)}/> | ||
</div> | ||
</div> | ||
|
||
|
||
{#if !contributor.userWallet} | ||
<Reward {contributor}/> | ||
{:else if contributor.clientState === 'offline'} | ||
<Install {contributor}/> | ||
{:else if !contributor.downloadedSecret} | ||
<Download {contributor}/> | ||
{:else if contributor.state === "inQueue"} | ||
<Queue {contributor}/> | ||
{:else if contributor.state === 'contribute'} | ||
<Status {contributor} /> | ||
<H1>Starting contribution...</H1> | ||
|
||
<H1>Starting contribution...</H1> | ||
{:else if contributor.state === 'contributing'} | ||
<Status {contributor} /> | ||
<H1>Contributing...</H1> | ||
|
||
<H1>Contributing...</H1> | ||
{:else if contributor.state === 'verifying'} | ||
<Status {contributor} /> | ||
<H1>Verifying your contribution...</H1> | ||
|
||
<H1>Verifying your contribution...</H1> | ||
{:else if contributor.state === 'contributed'} | ||
|
||
<div class="flex flex-col justify-center items-center gap-4"> | ||
<H1>Thank you! Your contribution is completed.</H1> | ||
<Tweet/> | ||
</div> | ||
|
||
{:else if contributor.state === 'noClient'} | ||
|
||
<Status {contributor} /> | ||
<H1>No client. Cannot start contribution.</H1> | ||
|
||
<Thanks {contributor}/> | ||
{:else} | ||
<H1>Not able to contribute at this time</H1> | ||
|
||
<H1>Not able to contribute at this time</H1> | ||
{/if} | ||
|
||
</div> | ||
|
||
|
||
<div class="absolute bottom-10 flex flex-col px-8 text-center gap-4"> | ||
</div> | ||
<div class="absolute bottom-10 flex flex-col px-8 text-center gap-4"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<script lang="ts"> | ||
import Button from "$lib/components/Button.svelte" | ||
import H1 from "$lib/components/typography/H1.svelte" | ||
import Text from "$lib/components/typography/Text.svelte" | ||
import { ContributorState } from "$lib/stores/state.svelte.ts" | ||
import { onMount } from "svelte" | ||
import { user } from "$lib/stores/user.svelte.ts" | ||
import { generateSecret } from "$lib/client" | ||
type Props = { | ||
contributor: ContributorState | ||
} | ||
let { contributor }: Props = $props() | ||
let download = $state(false) | ||
function handleDownload(event: MouseEvent) { | ||
event.preventDefault() | ||
const newUrl = "http://localhost:4919/secret_key" | ||
window.open(newUrl, "_blank") | ||
download = true | ||
} | ||
function setDownloadedSecret() { | ||
localStorage.setItem("downloaded-secret", "true") | ||
contributor.downloadedSecret = true | ||
} | ||
</script> | ||
|
||
{#if !download} | ||
<H1>Generate your PGP secret</H1> | ||
<Text class="text-center mb-4"> | ||
The MPC client automatically uses this secret to sign your contribution.<br> | ||
Your secret is locally generated through the MPC client. | ||
</Text> | ||
<Button variant="primary" onclick={handleDownload}>Generate secret</Button> | ||
{:else} | ||
<H1>Store your PGP secret</H1> | ||
<Text class="text-center mb-4"> | ||
Please store your secret somewhere safe, such as in your password manager. | ||
<br> Never share your secret. | ||
<br> This secret key is the only way to prove that you have contributed. | ||
</Text> | ||
<div class="flex gap-4"> | ||
<Button variant="primary" onclick={setDownloadedSecret}>I've generated and stored my secret</Button> | ||
<Button variant="secondary" href="http://localhost:4919/secret_key" target="_blank">Generate again</Button> | ||
</div> | ||
{/if} |
Oops, something went wrong.