Skip to content

Commit

Permalink
feat(ceremony): text and axiom
Browse files Browse the repository at this point in the history
  • Loading branch information
Swepool committed Oct 2, 2024
1 parent 2034fee commit 7e00de3
Show file tree
Hide file tree
Showing 20 changed files with 105 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ceremony/ceremony.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ _: {
{
packages = {
ceremony = unstablePkgs.buildNpmPackage {
npmDepsHash = "sha256-H8IOpVmeV1rTpTJKHz3ku0KyzD+R65sLFMnkf4RXRzg=";
npmDepsHash = "sha256-2s556is4PJaGmxQhIUPZLINh6J6ngeTf32bwDtl+v6Q=";
src = ./.;
sourceRoot = "ceremony";
npmFlags = [ "--legacy-peer-deps" ];
Expand Down
29 changes: 29 additions & 0 deletions ceremony/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ceremony/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"vite": "^5.0.3"
},
"dependencies": {
"@axiomhq/js": "^1.2.0",
"@scure/base": "^1.1.8",
"@splinetool/runtime": "^1.9.23",
"@supabase/supabase-js": "^2.45.3",
Expand Down
2 changes: 2 additions & 0 deletions ceremony/src/lib/components/Terminal/Ceremony.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import Secret from "$lib/components/Terminal/Secret.svelte"
import { onDestroy } from "svelte"
import Missed from "$lib/components/Terminal/Missed.svelte"
import Print from "$lib/components/Terminal/Print.svelte"
import {user} from "$lib/state/session.svelte.ts";
import {axiom} from "$lib/utils/axiom.ts";
const { contributor, terminal } = getState()
Expand Down
5 changes: 5 additions & 0 deletions ceremony/src/lib/components/Terminal/Code.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import Print from "$lib/components/Terminal/Print.svelte"
import Buttons from "$lib/components/Terminal/Install/Buttons.svelte"
import { sleep } from "$lib/utils/utils.ts"
import { callJoinQueue } from "$lib/supabase"
import {axiom} from "$lib/utils/axiom.ts";
import {user} from "$lib/state/session.svelte.ts";
const { terminal, contributor } = getState()
Expand All @@ -30,6 +32,8 @@ function handleKeyDown(event: KeyboardEvent) {
}
onMount(() => {
terminal.clearHistory()
terminal.updateHistory({ text: "Please enter your invitation code", lineBreak: true, duplicate: true })
if (inputElement) {
inputElement.focus()
}
Expand Down Expand Up @@ -58,6 +62,7 @@ async function handleCodeJoin() {
} else {
terminal.updateHistory({ text: "The code is not valid", duplicate: true })
terminal.updateHistory({ text: "", lineBreak: true, duplicate: true })
axiom.ingest('monitor', [{ user: user.session?.user.id, type: 'invalid_code' }])
onCancel()
}
} catch (error) {
Expand Down
3 changes: 3 additions & 0 deletions ceremony/src/lib/components/Terminal/Install/Linux.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { onDestroy, onMount } from "svelte"
import { getState } from "$lib/state/index.svelte.ts"
import { sleep } from "$lib/utils/utils.ts"
import Buttons from "$lib/components/Terminal/Install/Buttons.svelte"
import {axiom} from "$lib/utils/axiom.ts";
import {user} from "$lib/state/session.svelte.ts";
type Props = {
change: () => void
Expand All @@ -17,6 +19,7 @@ let command =
"mkdir -p ceremony && docker pull ghcr.io/unionlabs/union/mpc-client:latest && docker run -v $(pwd)/ceremony:/ceremony -w /ceremony -p 4919:4919 --rm -it ghcr.io/unionlabs/union/mpc-client:latest"
onMount(() => {
axiom.ingest('monitor', [{ user: user.session?.user.id, type: 'mount_linux' }])
const messages = [
{
text: "You must have docker installed and running in order to contribute. Once you have docker running, copy the following command in your terminal:"
Expand Down
3 changes: 3 additions & 0 deletions ceremony/src/lib/components/Terminal/Install/MacOS.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { onDestroy, onMount } from "svelte"
import { getState } from "$lib/state/index.svelte.ts"
import { sleep } from "$lib/utils/utils.ts"
import Buttons from "$lib/components/Terminal/Install/Buttons.svelte"
import {axiom} from "$lib/utils/axiom.ts";
import {user} from "$lib/state/session.svelte.ts";
type Props = {
change: () => void
Expand All @@ -17,6 +19,7 @@ let command =
"mkdir -p ceremony && docker pull ghcr.io/unionlabs/union/mpc-client:latest && docker run -v $(pwd)/ceremony:/ceremony -w /ceremony -p 4919:4919 --rm -it ghcr.io/unionlabs/union/mpc-client:latest"
onMount(() => {
axiom.ingest('monitor', [{ user: user.session?.user.id, type: 'mount_macos' }])
const messages = [
{
text: "You must have OrbStack installed in order to contribute, because Docker Desktop is too slow. If you use Docker Desktop it is extremely likely that you will lose your contribution slot."
Expand Down
5 changes: 5 additions & 0 deletions ceremony/src/lib/components/Terminal/Install/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { getState } from "$lib/state/index.svelte.ts"
import SelectOS from "$lib/components/Terminal/Install/SelectOS.svelte"
import MacOS from "$lib/components/Terminal/Install/MacOS.svelte"
import Linux from "$lib/components/Terminal/Install/Linux.svelte"
import {axiom} from "$lib/utils/axiom.ts";
import {user} from "$lib/state/session.svelte.ts";
let os = $state<DetectedOS | undefined>(undefined)
let selectedOs = $state<string | undefined>(undefined)
Expand All @@ -13,16 +15,19 @@ const { terminal } = getState()
onMount(async () => {
os = await detectOS()
axiom.ingest('monitor', [{ user: user.session?.user.id, type: 'mount_install' }])
})
let change = async () => {
terminal.updateHistory({ text: `Loading supported os..`, duplicate: true })
axiom.ingest('monitor', [{ user: user.session?.user.id, type: 'change_install' }])
await sleep(500)
selectedOs = undefined
}
let select = async (value: string) => {
terminal.updateHistory({ text: `Loading ${value} instructions..`, duplicate: true })
axiom.ingest('monitor', [{ user: user.session?.user.id, type: 'select_install' }])
await sleep(500)
selectedOs = value
}
Expand Down
8 changes: 7 additions & 1 deletion ceremony/src/lib/components/Terminal/Join.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ 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"
import {axiom} from "$lib/utils/axiom.ts";
import {user} from "$lib/state/session.svelte.ts";
const { contributor, terminal } = getState()
Expand All @@ -16,9 +18,11 @@ let code = $state(false)
onMount(() => {
terminal.updateHistory({ text: "Access the ceremony", replace: true })
terminal.updateHistory({text: "", lineBreak: true})
terminal.updateHistory({text: "We officially support Linux and macOS on Chrome, Firefox, or Brave browsers.", replace: true, type: "warning"})
terminal.updateHistory({text: "Please be advised that we do not support Windows or Windows Subsystem for Linux (WSL).", replace: true, type: "warning"})
terminal.setStep(2)
})
onDestroy(() => {
terminal.clearHistory()
})
Expand All @@ -42,8 +46,10 @@ async function trigger(value: string) {
terminal.updateHistory({ text: "Adding user to the waitlist..." })
await sleep(1000)
handleWaitlistJoin()
axiom.ingest('monitor', [{ user: user.session?.user.id, type: 'join_waitlist' }])
} else if (value === "code") {
code = true
axiom.ingest('monitor', [{ user: user.session?.user.id, type: 'join_code' }])
}
}
Expand Down
3 changes: 3 additions & 0 deletions ceremony/src/lib/components/Terminal/Missed.svelte
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<script lang="ts">
import { onDestroy, onMount } from "svelte"
import { getState } from "$lib/state/index.svelte.ts"
import {axiom} from "$lib/utils/axiom.ts";
import {user} from "$lib/state/session.svelte.ts";
const { terminal } = getState()
onMount(() => {
terminal.updateHistory({ text: "Too bad, you missed your slot.", replace: true })
axiom.ingest('monitor', [{ user: user.session?.user.id, type: 'missed' }])
})
onDestroy(() => {
Expand Down
3 changes: 3 additions & 0 deletions ceremony/src/lib/components/Terminal/Queue.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { getState } from "$lib/state/index.svelte.ts"
import Print from "$lib/components/Terminal/Print.svelte"
import LoadingBar from "$lib/components/Terminal/LoadingBar.svelte"
import { getAverageTimes, type TimeResult } from "$lib/supabase"
import {axiom} from "$lib/utils/axiom.ts";
import {user} from "$lib/state/session.svelte.ts";
const { contributor, terminal } = getState()
Expand All @@ -12,6 +14,7 @@ let averages = $state<TimeResult>()
onMount(async () => {
terminal.updateHistory({ text: "You are in queue" })
axiom.ingest('monitor', [{ user: user.session?.user.id, type: 'mount_queue' }])
averages = await getAverageTimes()
console.log(averages)
})
Expand Down
3 changes: 3 additions & 0 deletions ceremony/src/lib/components/Terminal/Reward.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { AddressForm, type ValidState } from "$lib/components/address"
import { getState } from "$lib/state/index.svelte.ts"
import { onDestroy, onMount } from "svelte"
import Print from "$lib/components/Terminal/Print.svelte"
import {axiom} from "$lib/utils/axiom.ts";
import {user} from "$lib/state/session.svelte.ts";
let { terminal } = getState()
Expand All @@ -19,6 +21,7 @@ onMount(() => {
terminal.updateHistory({
text: 'You can enter your union or any cosmos address, or type "skip".'
})
axiom.ingest('monitor', [{ user: user.session?.user.id, type: 'mount_address' }])
})
onDestroy(() => {
Expand Down
9 changes: 8 additions & 1 deletion ceremony/src/lib/components/Terminal/Secret.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
import { getState } from "$lib/state/index.svelte.ts"
import { sleep } from "$lib/utils/utils.ts"
import { generateSecret } from "$lib/client"
import { onDestroy } from "svelte"
import {onDestroy, onMount} from "svelte"
import Buttons from "$lib/components/Terminal/Install/Buttons.svelte"
import {axiom} from "$lib/utils/axiom.ts";
const { contributor, terminal, user } = getState()
Expand All @@ -12,20 +13,26 @@ let generating = $state(false)
let buttons = $state<Array<HTMLButtonElement>>([])
let focusedIndex = $state(0)
onMount(() => {
axiom.ingest('monitor', [{ user: user.session?.user.id, type: 'mount_secret' }])
})
function handleDownload() {
const newUrl = "http://localhost:4919/secret_key"
window.open(newUrl, "_blank")
}
function stored() {
localStorage.setItem("downloaded-secret", "true")
axiom.ingest('monitor', [{ user: user.session?.user.id, type: 'stored_secret' }])
contributor.downloadedSecret = true
}
async function generate() {
if (contributor.state !== "noClient") {
generating = true
terminal.updateHistory({ text: "Generating secret..." })
axiom.ingest('monitor', [{ user: user.session?.user.id, type: 'generated_secret' }])
await sleep(3000)
generateSecret(user.session?.user.email)
terminal.updateHistory({ text: "Initialize saving..." })
Expand Down
4 changes: 4 additions & 0 deletions ceremony/src/lib/components/Terminal/Thanks.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { getState } from "$lib/state/index.svelte.ts"
import { sleep } from "$lib/utils/utils.ts"
import { onDestroy, onMount } from "svelte"
import Buttons from "$lib/components/Terminal/Install/Buttons.svelte"
import {axiom} from "$lib/utils/axiom.ts";
import {user} from "$lib/state/session.svelte.ts";
const { terminal } = getState()
Expand All @@ -14,13 +16,15 @@ onMount(() => {
text: "Your contribution is complete. Thank you for securing the Union network. Tweet your cryptographic attestation for extra transparency.",
replace: true
})
axiom.ingest('monitor', [{ user: user.session?.user.id, type: 'mount_thanks' }])
})
async function shareOnTwitter() {
terminal.updateHistory({ text: "Preparing tweet...", duplicate: true })
let hash = await getPublicHash()
await sleep(2000)
terminal.updateHistory({ text: "Opening X (twitter)...", duplicate: true })
axiom.ingest('monitor', [{ user: user.session?.user.id, type: 'tweet' }])
await sleep(2000)
let url = `https://ceremony.union.build/contributions/${hash}`
const tweetText = `I just contributed to the @union_build Trusted Setup Ceremony, to secure its ZK circuit for trustless, decentralized interoperability. \n\nI attest to my contribution. My public key hash is: \n\n${url}\n\n#JoinTheUnion`
Expand Down
6 changes: 4 additions & 2 deletions ceremony/src/lib/components/Terminal/Waitlist.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { getNumberSuffix, sleep } from "$lib/utils/utils.ts"
import { getState } from "$lib/state/index.svelte.ts"
import Code from "$lib/components/Terminal/Code.svelte"
import { onDestroy, onMount } from "svelte"
import {axiom} from "$lib/utils/axiom.ts";
import {user} from "$lib/state/session.svelte.ts";
const { contributor, terminal } = getState()
const { terminal } = getState()
onMount(async () => {
terminal.setStep(3)
Expand All @@ -16,8 +18,8 @@ onMount(async () => {
text: "You will receive an email 12-18 hours before the public phase begins."
})
terminal.updateHistory({ text: "Received an invite? You can skip the waitlist and join now." })
axiom.ingest('monitor', [{ user: user.session?.user.id, type: 'mount_waitlist' }])
await sleep(500)
await contributor.checkWaitListPosition()
})
onDestroy(() => {
Expand Down
3 changes: 3 additions & 0 deletions ceremony/src/lib/components/address/AddressForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { insertWalletData } from "$lib/supabase"
import { user } from "$lib/state/session.svelte.ts"
import { getState } from "$lib/state/index.svelte.ts"
import { sleep } from "$lib/utils/utils.ts"
import {axiom} from "$lib/utils/axiom.ts";
interface Props extends HTMLInputAttributes {
class?: string
Expand Down Expand Up @@ -50,6 +51,7 @@ const onAddressSubmit = async (event: Event) => {
terminal.updateHistory({ text: "Saving address..." })
await sleep(2000)
terminal.updateHistory({ text: "Wallet address saved successfully" })
axiom.ingest('monitor', [{ user: user.session?.user.id, type: 'added_address' }])
await sleep(2000)
contributor.checkUserWallet(user.session?.user.id)
} else {
Expand All @@ -75,6 +77,7 @@ const skip = async () => {
})
if (result) {
terminal.updateHistory({ text: "Saving to db..." })
axiom.ingest('monitor', [{ user: user.session?.user.id, type: 'skipped_address' }])
await sleep(2000)
contributor.userWallet = "SKIPPED"
} else {
Expand Down
Loading

0 comments on commit 7e00de3

Please sign in to comment.