indexValsTursomain.tsx2 matches
6import { truncateMessage } from "npm:openai-tokens";
78export default async function(interval: Interval) {
9const sqlite = createClient({
10url: "libsql://valsembeddings-jpvaltown.turso.io",
23);
2425function idForVal(val: any): string {
26return `${val.author_username}!!${val.name}!!${val.version}`;
27}
bloomingButtonmain.tsx7 matches
1let active = false;
23function getRandomEmoji() {
4const emojis = ["๐ณ", "๐ณ", "๐ฒ", "๐ฟ", "๐ฑ", "๐พ", "๐", "๐", "๐", "๐ท", "๐ชป", "๐"];
5const randomIndex = Math.floor(Math.random() * emojis.length);
7}
89function injectCSS(css: string) {
10const style = document.createElement("style");
11style.type = "text/css";
33const buttonBackgroundMap = new Map();
3435// Function to create or get the background div
36function getBackgroundDiv(button) {
37if (!buttonBackgroundMap.has(button)) {
38const newDiv = document.createElement("div");
49}
5051// Function to position the background div behind the button
52function positionDivBehindButton(button) {
53const rect = button.getBoundingClientRect();
54const newDiv = getBackgroundDiv(button);
63window.addEventListener("scroll", () => positionDivBehindButton(button));
6465button.addEventListener("click", function() {
66if (active) return;
67active = true;
18const resp = await fetch("https://maxm-wasmblobhost.web.val.run/jpxqvyy5tphiwehzklmioklpkpz4gpzs.wasm");
19const handler = await wasmHandler(new Uint8Array(await resp.arrayBuffer()));
20export default async function(req: Request): Promise<Response> {
21return handler(req);
22}
gptApiFrameworkmain.tsx9 matches
7980/**
81* An optional function that returns the policy to be used available at `/privacypolicy`.
82*/
83policyGetter?: (() => string) | (() => Promise<string>);
89* @returns The generated JSON schema.
90*/
91function getSchemaDesc(schema: z.Schema | null) {
92if (!schema) return null;
93return zodToJsonSchema(schema, {
140* @returns The paths of the OpenAPI spec.
141*/
142function getPathsDesc(endpoints: EndpointDefinition[]): Paths {
143const paths: Paths = {};
144for (const endpoint of endpoints) {
186* @returns The OpenAPI spec.
187*/
188function getOpenApiSpec(
189url: string,
190title: string,
258* only a status code.
259* @param endpointDef Definition of the endpoint.
260* @param handler Function that handles the request.
261*/
262jsonToNothing<TRequestSchema extends z.Schema>(
290* returns a specific JSON response.
291* @param endpointDef Definition of the endpoint.
292* @param handler Function that handles the request.
293*/
294nothingToJson<TResponseSchema extends z.Schema>(
320* returns a specific JSON response.
321* @param endpointDef Definition of the endpoint.
322* @param handler Function that handles the request.
323*/
324jsonToJson<TRequestSchema extends z.Schema, TResponseSchema extends z.Schema>(
356* Regusters a handler for a verb + path combo.
357* @param endpointDef Definition of the endpoint.
358* @param handler Function that handles the request.
359*/
360private registerHandler(
388389/**
390* Returns a function that can be used to serve the API.
391*
392* @example ValTown usage:
bloomingButtonREADME.md1 match
11import { renderToString } from "npm:react-dom/server";
1213export default async function(req: Request): Promise<Response> {
14return new Response(
15renderToString(
htmlExamplemain.tsx1 match
1// View at https://andreterron-htmlExample.web.val.run?name=Andre
2export default async function(req: Request): Promise<Response> {
3const query = new URL(req.url).searchParams;
4
uniswapV3PositionREADME.md4 matches
11This val fetches blockchain data from the following smart contracts:
1213- **NonfungiblePositionManager(`0xc36442b4a4522e871399cd717abdd847ab11fe88`)** Manages the liquidity position tokens as an ERC721 contract. The `positions` function is used to determine what tokens and tick ranges the individual liquidity position has.
14- **UniswapV3Factory (`0x1F98431c8aD98523631AE4a59f267346ea31F984`)** Contract that manages liquidity pools, and acts as a registry to record where each pairing is deployed to. The `getPool` function is used to find where the smart contract for a specific pairing of ERC20 tokens is deployed to.
15- **ERC20 tokens** Each position has two tokens it's balancing between, and each token has its own instance of an ERC20 contract deployed to the blockchain. The `name` and `symbol` functions are used to determine how to describe each token, and the `decimals` function to determine how to scale the price value for the ratio between them.
16- **UniswapV3Pool** Contract that handles swaps between specific pairs of tokens. The `slot0` function is used to fetch the current price the two tokens are swapping at.
valTownAnalyticsmain.tsx1 match
94};
9596async function handler(req: Request): Promise<Response> {
97const url = new URL(req.url);
98if (req.method === "GET" && url.pathname === "/event") {
3import { sqlite } from "https://esm.town/v/std/sqlite?v=6";
45function truncate(str: string) {
6if (str.length > 20) {
7return `${str.slice(0, 20)}...`;