Switch from cra to vite

This commit is contained in:
Gilbert
2024-04-11 21:48:58 -05:00
parent cc8f9527da
commit f8d706233e
36 changed files with 5163 additions and 6582 deletions
+19
View File
@@ -0,0 +1,19 @@
import { LitGoogleAuth } from "@snowballtools/auth-lit";
import { Snowball, SnowballChain } from "@snowballtools/js-sdk";
// import { LinkLitAlchemyLight } from '@snowballtools/link-lit-alchemy-light';
export const DOMAIN = import.meta.env.VITE_DOMAIN || "localhost";
export const ORIGIN =
import.meta.env.VITE_VERCEL_ENV === "production"
? `https://${DOMAIN}`
: `http://${DOMAIN}:3000`;
// prettier-ignore
export const snowball = Snowball.withAuth(
LitGoogleAuth.configure({
litReplayApiKey: import.meta.env.VITE_LIT_RELAY_API_KEY!,
}),
).create({
initialChain: SnowballChain.sepolia,
});
@@ -0,0 +1,13 @@
import { useEffect, useState } from 'react';
import { snowball } from './snowball';
export function useSnowball() {
const [state, setState] = useState(100);
useEffect(() => {
// Subscribe and directly return the unsubscribe function
return snowball.subscribe(() => setState(state + 1));
}, [snowball]);
return snowball;
}