Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Ceremony terminal #3023

Merged
merged 42 commits into from
Sep 27, 2024
Merged
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
523034c
feat(ceremony): terminal progress
Swepool Sep 25, 2024
2737101
feat(ceremony): save terminal progress
Swepool Sep 25, 2024
bb04935
feat(ceremony): save progress on terminal
Swepool Sep 25, 2024
4b40a54
feat(ceremony): save terminal progress
Swepool Sep 25, 2024
4ef14be
feat(ceremony): save terminal progress
Swepool Sep 25, 2024
8cab55a
feat(ceremony): save progress
Swepool Sep 25, 2024
96ce1b2
feat(ceremony): save progress
Swepool Sep 25, 2024
5046293
feat(ceremony): save terminal progress
Swepool Sep 25, 2024
de496ae
feat(ceremony): save terminal progress
Swepool Sep 25, 2024
e383656
feat(ceremony): save terminal progress
Swepool Sep 26, 2024
16f78d9
feat(ceremony): save terminal progress
Swepool Sep 26, 2024
8806b92
fix(ceremony): remove logs
Swepool Sep 26, 2024
18a1145
fix(ceremony): save progress terminal
Swepool Sep 26, 2024
25611d2
fix(ceremony): install missing package and fix hash
Swepool Sep 26, 2024
3d0d6c2
feat(ceremony): save progress on terminal
Swepool Sep 26, 2024
a115790
feat(ceremony): save terminal progress
Swepool Sep 26, 2024
0174bcf
feat(ceremony): save progress terminal
Swepool Sep 26, 2024
8db460e
fix(ceremony): fix build
Swepool Sep 26, 2024
7ac9881
feat(ceremony): save progress
Swepool Sep 26, 2024
d818d97
feat(ceremony): save progress
Swepool Sep 26, 2024
3cdf48b
feat(ceremony): save progress
Swepool Sep 26, 2024
7ce9e66
feat: video background
o-az Sep 26, 2024
6f938c6
feat(ceremony): save progress
Swepool Sep 26, 2024
8cab7b0
feat: webm format
o-az Sep 26, 2024
12a7cb6
feat: autoplay firefox
o-az Sep 26, 2024
9f7360d
feat: actually autoplay on firefox maybe
o-az Sep 26, 2024
0163e2a
feat(ceremony): save progress
Swepool Sep 26, 2024
06cb3c8
Merge branch 'ceremony-terminal' of ssh://github.com/unionlabs/union …
Swepool Sep 26, 2024
4c6291b
feat: bootloader sequence
o-az Sep 26, 2024
1f9262e
feat: bootloader sequence
o-az Sep 26, 2024
b95010a
feat(ceremony): save progress
Swepool Sep 26, 2024
68c6e1d
Merge branch 'ceremony-terminal' of ssh://github.com/unionlabs/union …
Swepool Sep 26, 2024
7722464
fix: os-specific install instructions
cor Sep 26, 2024
f22e473
chore: fmt/spellcheck
cor Sep 26, 2024
ab1d801
chore: fix biome
cor Sep 26, 2024
ad795a5
feat: outro video
o-az Sep 27, 2024
5799afe
fix: fmt
o-az Sep 27, 2024
5541d95
feat(ceremony): save progress
Swepool Sep 27, 2024
eaae32c
feat(ceremony): fix color
Swepool Sep 27, 2024
3c8caed
chore: revert outro
o-az Sep 27, 2024
3320bdb
feat(ceremony): save progress
Swepool Sep 27, 2024
fbcd654
fix(ceremony): fix link
Swepool Sep 27, 2024
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
Prev Previous commit
Next Next commit
feat(ceremony): save terminal progress
  • Loading branch information
Swepool committed Sep 25, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 5046293d52dc4b718e29a28ad21c831dcb1ce8c1
112 changes: 56 additions & 56 deletions ceremony/src/lib/components/Terminal/index.svelte
Original file line number Diff line number Diff line change
@@ -1,74 +1,74 @@
<script lang="ts">
import {getState} from "$lib/state/index.svelte.ts"
import {logout} from "$lib/state/session.svelte.ts"
import Contributions from "./Contributors.svelte"
import {goto} from "$app/navigation"
import {onDestroy} from "svelte"
import Print from "$lib/components/Terminal/Print.svelte"
import Activity from "$lib/components/Terminal/Activity.svelte"
import Blink from "$lib/components/Blink.svelte";
import { getState } from "$lib/state/index.svelte.ts"
import { logout } from "$lib/state/session.svelte.ts"
import Contributions from "./Contributors.svelte"
import { goto } from "$app/navigation"
import { onDestroy } from "svelte"
import Print from "$lib/components/Terminal/Print.svelte"
import Activity from "$lib/components/Terminal/Activity.svelte"
import Blink from "$lib/components/Blink.svelte"

const {terminal} = getState()
const { terminal } = getState()

let {children} = $props()
let { children } = $props()

const changeTab = async (tab: number) => {
if (tab === 4 && terminal.hash) {
console.log("change tab 4", tab)
terminal.setTab(tab)
await goto(`/0____0/${terminal.hash}`)
} else if (tab <= 3) {
console.log("change tab 1, 2, 3", tab)
terminal.setTab(tab)
await goto("/")
}
const changeTab = async (tab: number) => {
if (tab === 4 && terminal.hash) {
console.log("change tab 4", tab)
terminal.setTab(tab)
await goto(`/0____0/${terminal.hash}`)
} else if (tab <= 3) {
console.log("change tab 1, 2, 3", tab)
terminal.setTab(tab)
await goto("/")
}
}

const unsubscribe = terminal.keys.subscribe(event => {
if (event) {
if (event.type === "keydown" && (event.shiftKey || event.ctrlKey)) {
switch (event.key) {
case "!": {
changeTab(1)
break
}
case "@": {
changeTab(2)
break
}
case "#": {
changeTab(3)
break
}
case "$": {
changeTab(4)
break
}
case "X": {
logout(terminal)
break
}
const unsubscribe = terminal.keys.subscribe(event => {
if (event) {
if (event.type === "keydown" && (event.shiftKey || event.ctrlKey)) {
switch (event.key) {
case "!": {
changeTab(1)
break
}
case "@": {
changeTab(2)
break
}
case "#": {
changeTab(3)
break
}
case "$": {
changeTab(4)
break
}
case "X": {
logout(terminal)
break
}
}
}
})
}
})

onDestroy(unsubscribe)
onDestroy(unsubscribe)

function autoScroll(node: HTMLElement) {
const scroll = () => {
node.scrollTop = node.scrollHeight
}
function autoScroll(node: HTMLElement) {
const scroll = () => {
node.scrollTop = node.scrollHeight
}

const observer = new MutationObserver(scroll)
observer.observe(node, {childList: true, subtree: true})
const observer = new MutationObserver(scroll)
observer.observe(node, { childList: true, subtree: true })

return {
destroy() {
observer.disconnect()
}
return {
destroy() {
observer.disconnect()
}
}
}
</script>

<section class="flex flex-col sm:justify-center items-center w-full h-full z-10">
32 changes: 21 additions & 11 deletions ceremony/src/lib/state/contributor.svelte.ts
Original file line number Diff line number Diff line change
@@ -4,8 +4,7 @@ import {
getUserQueueInfo,
getContributionState,
getUserWallet,
getWaitListPosition,
checkIfOpen
getWaitListPosition
} from "$lib/supabase"

type IntervalID = NodeJS.Timeout | number
@@ -22,6 +21,7 @@ type State =
| "noClient"

export type AllowanceState = "hasRedeemed" | "inWaitlist" | "inQueue" | "join" | undefined

export type ContributionState = "contribute" | "contributed" | "verifying" | "notContributed"

interface UserContext {
@@ -45,6 +45,7 @@ interface QueueInfoError {
type QueueInfoResult = QueueInfoSuccess | QueueInfoError

const second = 1000
const CLIENT_POLING_INTERVAL = second
const CONTRIBUTION_POLLING_INTERVAL = second * 5
const QUEUE_POLLING_INTERVAL = second * 5

@@ -55,12 +56,10 @@ export class Contributor {
pollingState = $state<"stopped" | "polling">("stopped")
state = $state<State>("loading")

openToPublic = $state(false)
contributionState = $state<ContributionState>("notContributed")
userWallet = $state("")
waitListPosition = $state<number | undefined>(undefined)
downloadedSecret = $state<boolean>(localStorage.getItem("downloaded-secret") === "true")

queueState = $state<UserContext>({
position: null,
count: null,
@@ -69,11 +68,9 @@ export class Contributor {
})

private pollIntervals: {
client: IntervalID | null
queue: IntervalID | null
contribution: IntervalID | null
} = {
client: null,
queue: null,
contribution: null
}
@@ -83,7 +80,6 @@ export class Contributor {
this.userId = userId
this.loggedIn = true
this.checkCurrentUserState(userId)
this.checkIfOpen()
this.startPolling()
}
onDestroy(() => {
@@ -102,10 +98,6 @@ export class Contributor {
}
}

async checkIfOpen() {
this.openToPublic = await checkIfOpen()
}

async checkWaitListPosition(_userId: string | undefined): Promise<number | undefined> {
this.waitListPosition = await getWaitListPosition()
return this.waitListPosition
@@ -155,13 +147,15 @@ export class Contributor {
this.stopContributionStatePolling()
}


private stopClientStatePolling() {
if (this.pollIntervals.client) {
clearInterval(this.pollIntervals.client)
this.pollIntervals.client = null
}
}


private startQueueInfoPolling() {
this.pollQueueInfo()
this.pollIntervals.queue = setInterval(
@@ -212,6 +206,7 @@ export class Contributor {
}
}


private updateQueueInfo(queueInfo: QueueInfoResult) {
if (queueInfo.inQueue) {
this.queueState = {
@@ -228,16 +223,31 @@ export class Contributor {
estimatedTime: null
}
}
this.updateState()
}

private updateContributionState(state: ContributionState) {
this.contributionState = state
this.updateState()
}

private setError(message: string) {
this.queueState = { ...this.queueState, error: message }
this.state = "error"
}

private updateState() {
if (this.contributionState === "contribute") {
} else if (this.queueState.position !== null) {
this.state = "inQueue"
} else if (this.contributionState === "contributed") {
this.state = "contributed"
} else if (this.contributionState === "verifying") {
this.state = "verifying"
} else {
this.state = "loading"
}
}
}

const CONTRIBUTOR_KEY = Symbol("CONTRIBUTOR")
2 changes: 1 addition & 1 deletion ceremony/src/lib/supabase/index.ts
Original file line number Diff line number Diff line change
@@ -121,11 +121,11 @@ export const getCurrentUserState = async (userId: string | undefined): Promise<A
const { data, error } = await queryCurrentUserState()
if (error || !data) return undefined

return "inQueue"
if (data.has_redeemed) return "hasRedeemed"
if (data.in_queue) return "inQueue"
if (data.in_waitlist) return "inWaitlist"

return "join"
}

export const getContributions = async () => {
2 changes: 1 addition & 1 deletion ceremony/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import "../styles/tailwind.css"
import { watch } from "runed"
import { checkAuth } from "$lib/state/session.svelte.ts"
import Terminal from "$lib/components/Terminal/index.svelte"
import Circles from "$lib/components/Circles.svelte";
import Circles from "$lib/components/Circles.svelte"

let { children } = $props()