From f4266b9632df06ad3795ec2603ec6566bf874e62 Mon Sep 17 00:00:00 2001 From: Bogdan Crisan Date: Wed, 4 Dec 2024 18:02:45 +0100 Subject: [PATCH] Address PR comments --- .../pages/launch-emojicoin/EmojiRain.tsx | 17 +++++++---------- .../sdk/src/indexer-v2/queries/app/launch.ts | 4 +++- .../sdk/src/indexer-v2/types/index.ts | 1 + .../sdk/src/indexer-v2/types/json-types.ts | 3 +-- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/typescript/frontend/src/components/pages/launch-emojicoin/EmojiRain.tsx b/src/typescript/frontend/src/components/pages/launch-emojicoin/EmojiRain.tsx index dd109fa06..1e659a1dd 100644 --- a/src/typescript/frontend/src/components/pages/launch-emojicoin/EmojiRain.tsx +++ b/src/typescript/frontend/src/components/pages/launch-emojicoin/EmojiRain.tsx @@ -1,7 +1,6 @@ import { type symbolBytesToEmojis } from "@sdk/emoji_data"; import { type AnimationPlaybackControls, useAnimate } from "framer-motion"; import { useEffect, useMemo, useState } from "react"; -import { useWindowSize } from "react-use"; const DROP_FALL_TIME = 7.5; const DROP_INTERVAL = 1; @@ -17,13 +16,11 @@ export function EmojiRainDrop({ index: number; emojis: number; }) { - const { height, width } = useWindowSize(); - // Position all emojis above the visible space. - const initialX = -200; + const initialY = -200; - // Calculate a random position on the Y axis. - const y = useMemo(() => Math.random() * (width - 20) + 10, [width]); + // Calculate a random position on the X axis. + const x = useMemo(() => Math.random() * 90 + 5, []); // Calculate a random delay for the emojis to be staggered. const delay = useMemo(() => (Math.random() + index) * DROP_INTERVAL, [index]); @@ -34,7 +31,7 @@ export function EmojiRainDrop({ useEffect(() => { const controls = animate( scope.current, - { top: height + 100 }, + { top: "110vh" }, { duration: DROP_FALL_TIME, delay, @@ -47,7 +44,7 @@ export function EmojiRainDrop({ setControls(controls); return () => controls.complete(); - }, [scope, animate, delay, height, emojis]); + }, [scope, animate, delay, emojis]); return (
controls?.play()} className="absolute emoji-rain-drop z-10 flex flex-col select-none cursor-pointer" style={{ - left: y, + left: `${x}vw`, fontSize: "2em", - top: initialX, + top: initialY, }} ref={scope} > diff --git a/src/typescript/sdk/src/indexer-v2/queries/app/launch.ts b/src/typescript/sdk/src/indexer-v2/queries/app/launch.ts index 58dd8eab3..4639e85c4 100644 --- a/src/typescript/sdk/src/indexer-v2/queries/app/launch.ts +++ b/src/typescript/sdk/src/indexer-v2/queries/app/launch.ts @@ -1,4 +1,6 @@ -import "server-only"; +if (process.env.NODE_ENV !== "test") { + require("server-only"); +} import { DatabaseRpc } from "../../types/json-types"; import { postgrest } from "../client"; diff --git a/src/typescript/sdk/src/indexer-v2/types/index.ts b/src/typescript/sdk/src/indexer-v2/types/index.ts index 3f15d852e..80a382f32 100644 --- a/src/typescript/sdk/src/indexer-v2/types/index.ts +++ b/src/typescript/sdk/src/indexer-v2/types/index.ts @@ -601,6 +601,7 @@ export const toPriceFeed = (data: DatabaseJsonType["price_feed"]) => { }; }; +/// Replace `\x` with `0x` then convert to market symbol data. export const toRandomSymbolsRPCResponse = (data: DatabaseJsonType["random_symbols"]) => symbolBytesToEmojis("0" + data.emojis.substring(1)); diff --git a/src/typescript/sdk/src/indexer-v2/types/json-types.ts b/src/typescript/sdk/src/indexer-v2/types/json-types.ts index 16cc1d7af..76c574edf 100644 --- a/src/typescript/sdk/src/indexer-v2/types/json-types.ts +++ b/src/typescript/sdk/src/indexer-v2/types/json-types.ts @@ -287,7 +287,6 @@ export enum TableName { export enum DatabaseRpc { UserPools = "user_pools", - PriceFeed = "price_feed", RandomSymbols = "random_symbols", } @@ -366,7 +365,7 @@ export type DatabaseJsonType = { ProcessedFields & UserLPCoinBalance & { daily_volume: Uint128String } >; - [DatabaseRpc.RandomSymbols]: { emojis: string }; + [DatabaseRpc.RandomSymbols]: { emojis: `\\x${string}` }; }; type Columns = DatabaseJsonType[TableName.GlobalStateEvents] &