forked from cerc-io/snowballtools-base
Switch from cra to vite
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user