diff --git a/cfg/cspell-dictionary.txt b/cfg/cspell-dictionary.txt index 5f7d2f0e2..1742e73b6 100644 --- a/cfg/cspell-dictionary.txt +++ b/cfg/cspell-dictionary.txt @@ -42,6 +42,7 @@ merperson moai mybuilder nazar +nextjs nohup octa oden diff --git a/src/typescript/.env.example b/src/typescript/.env.example new file mode 100644 index 000000000..414cbe68f --- /dev/null +++ b/src/typescript/.env.example @@ -0,0 +1,18 @@ + +# To run your own local node for e2e testing, set this to "false" +START_LOCAL_NODE_FOR_TEST="true" + +# The Aptos network to use +NEXT_PUBLIC_APTOS_NETWORK="local" + +# Randomly generated private key for tests +PUBLISHER_PK="29479e9e5fe47ba9a8af509dd6da1f907510bcf8917bfb19b7079d8c63c0b720" + +# The address of the main `emojicoin_dot_fun` contract module +NEXT_PUBLIC_MODULE_ADDRESS="0x4bab58978ec1b1bef032eeb285ad47a6a9b997d646c19b598c35f46b26ff9ece" + +# The default URL for a local inbox deployment. Do not add a slash to the end +INBOX_URL="http://localhost:3000" + +## A `nextjs` setting to determine the query revalidation length +SHORT_REVALIDATE="true" diff --git a/src/typescript/.env.test b/src/typescript/.env.test new file mode 100644 index 000000000..b222753b0 --- /dev/null +++ b/src/typescript/.env.test @@ -0,0 +1,10 @@ +START_LOCAL_NODE_FOR_TEST="false" +SHORT_REVALIDATE="true" + +NEXT_PUBLIC_APTOS_NETWORK="local" +NEXT_PUBLIC_INTEGRATOR_ADDRESS="0x4bab58978ec1b1bef032eeb285ad47a6a9b997d646c19b598c35f46b26ff9ece" +NEXT_PUBLIC_MODULE_ADDRESS="0x4bab58978ec1b1bef032eeb285ad47a6a9b997d646c19b598c35f46b26ff9ece" + +PUBLISHER_PK="29479e9e5fe47ba9a8af509dd6da1f907510bcf8917bfb19b7079d8c63c0b720" + +INBOX_URL="http://localhost:3000" diff --git a/src/typescript/.gitignore b/src/typescript/.gitignore index 4daaa5fe2..e09713661 100644 --- a/src/typescript/.gitignore +++ b/src/typescript/.gitignore @@ -3,3 +3,6 @@ build/** dist/** .next/** node_modules/ +.env*.local +**/*.env*.local +.env diff --git a/src/typescript/README.md b/src/typescript/README.md new file mode 100644 index 000000000..86827d2bf --- /dev/null +++ b/src/typescript/README.md @@ -0,0 +1,65 @@ +# How to build and deploy this application + +## Ensure the environment variables are loaded + +This repository loads environment variables in multiple ways. + +To load environment variables while running test scripts, each `package.json` +file in the `sdk` folder specifies how to load these environment variables. Most +scripts run the `dotenv-cli` package as a wrapper, like so: + +```shell +# In sdk/package.json: +"test": "dotenv -e ../.env.test -- pnpm jest", + +# I run this command +pnpm run test + +# Which loads the env variables in `../.env.test` and runs `jest` +``` + +Where `../.env.test` is the environment file located in the `typescript` parent +directory. + +To avoid having to define environment variables in multiple places, we've +intentionally omitted environment variables from the `frontend` directory to +enforce that the project be built and run in a certain order. + +## Copy the `.env.example` file to an `.env` or `.env.local` file + +Most commands load `.env.local` first then `.env`, so copy the environment +example file to your own file. + +```shell +# With the highest precedence. +cp .env.example .env.local +# or just `.env.`, which will be superseded by `.env.local` in loading order +cp .env.example .env +``` + +## Run the `frontend` application + +```shell +cd src/typescript +pnpm i + +# to rebuild everything and run +pnpm run build +pnpm run start + +# or, for hot reloads (does not rebuild) +pnpm run dev +``` + +Sometimes, `turbo` and `next` have build caches that persist and cause errors. +This can be avoided with a clever build process, however, you can also just +delete the `.next` and `.turbo` folders in each directory. + +You can also run: + +```shell +pnpm run full-clean +``` + +Note this remove's each project's `node_modules`, although it does not remove +the `pnpm-lock.yaml` file. diff --git a/src/typescript/frontend/.env.example b/src/typescript/frontend/.env.example deleted file mode 100644 index aa0790176..000000000 --- a/src/typescript/frontend/.env.example +++ /dev/null @@ -1,12 +0,0 @@ -# The Aptos network to use. -NEXT_PUBLIC_APTOS_NETWORK="local" - -# Whether or not revalidation times should be short. This should be set to "true" for local development -# and "false" for production. -NEXT_PUBLIC_SHORT_REVALIDATE="true" - -# Whether or not to fetch static JSON files, likely in a staging environment. -NEXT_PUBLIC_FORCE_STATIC_FETCH="true" - -# The address of the main `emojicoin_dot_fun` contract module. -NEXT_PUBLIC_MODULE_ADDRESS="4bab58978ec1b1bef032eeb285ad47a6a9b997d646c19b598c35f46b26ff9ece" diff --git a/src/typescript/frontend/.env.production b/src/typescript/frontend/.env.production deleted file mode 100644 index 0b66d76d8..000000000 --- a/src/typescript/frontend/.env.production +++ /dev/null @@ -1,4 +0,0 @@ -NEXT_PUBLIC_APTOS_NETWORK="local" -NEXT_PUBLIC_SHORT_REVALIDATE="false" -NEXT_PUBLIC_FORCE_STATIC_FETCH="true" -NEXT_PUBLIC_MODULE_ADDRESS="4bab58978ec1b1bef032eeb285ad47a6a9b997d646c19b598c35f46b26ff9ece" diff --git a/src/typescript/frontend/next.config.mjs b/src/typescript/frontend/next.config.mjs index c6d41c7eb..183696617 100644 --- a/src/typescript/frontend/next.config.mjs +++ b/src/typescript/frontend/next.config.mjs @@ -25,9 +25,6 @@ const debugConfigOptions = { /** @type {import('next').NextConfig} */ const nextConfig = { - env: { - "INBOX_URL": process.env.INBOX_URL ?? "http://localhost:3000", - }, crossOrigin: "use-credentials", typescript: { tsconfigPath: "tsconfig.json", @@ -41,7 +38,7 @@ const nextConfig = { return [ { source: "/emojicoin", - destination: "/emojicoin/0", + destination: "/emojicoin/1", permanent: true, }, ]; diff --git a/src/typescript/frontend/package.json b/src/typescript/frontend/package.json index d7510ad76..bb44a6dac 100644 --- a/src/typescript/frontend/package.json +++ b/src/typescript/frontend/package.json @@ -12,7 +12,7 @@ ] }, "dependencies": { - "@aptos-labs/wallet-adapter-react": "^2.5.1", + "@aptos-labs/wallet-adapter-react": "^3.0.2", "@econia-labs/emojicoin-sdk": "workspace:*", "@emotion/is-prop-valid": "^1.2.2", "@headlessui/react": "^2.0.4", @@ -37,6 +37,7 @@ "react-toastify": "^9.1.3", "redux": "^5.0.1", "redux-logger": "^3.0.6", + "server-only": "^0.0.1", "socket.io-client": "^4.7.2", "styled-components": "^6.1.8", "styled-system": "^5.1.5", @@ -70,8 +71,8 @@ "scripts": { "_format": "prettier './**/*.{js,jsx,ts,tsx,css,md}' --config ./.prettierrc.js", "build": "next build", - "build:debug": "BUILD_DEBUG=true && pnpm clean && next build --no-lint --no-mangling --debug", - "clean": "rm -rf .next", + "build:debug": "BUILD_DEBUG=true && pnpm clean && pnpm i && next build --no-lint --no-mangling --debug", + "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist && rm -rf .next", "dev": "NODE_OPTIONS='--inspect' next dev --turbo", "format": "pnpm _format --write", "format:check": "pnpm _format --check", diff --git a/src/typescript/frontend/src/app/connect-wallet/page.tsx b/src/typescript/frontend/src/app/connect-wallet/page.tsx deleted file mode 100644 index cf366bfa6..000000000 --- a/src/typescript/frontend/src/app/connect-wallet/page.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import ConnectWallet from "components/pages/connect-wallet"; - -export default function ConnectWalletPage() { - return ; -} diff --git a/src/typescript/frontend/src/app/emojicoin/[market]/page.tsx b/src/typescript/frontend/src/app/emojicoin/[market]/page.tsx index a34312900..a1c1e9f79 100644 --- a/src/typescript/frontend/src/app/emojicoin/[market]/page.tsx +++ b/src/typescript/frontend/src/app/emojicoin/[market]/page.tsx @@ -1,12 +1,11 @@ -import Emojicoin from "components/pages/emojicoin"; -import { SHORT_REVALIDATE } from "lib/env"; import getInitialChatData from "lib/queries/initial/chats"; import { fetchTopMarkets } from "lib/queries/initial/markets"; import { fetchLastMarketState } from "lib/queries/initial/state"; import getInitialSwapData from "lib/queries/initial/swaps"; +import ClientEmojicoinPage from "components/pages/emojicoin/ClientEmojicoinPage"; // We will revalidate the data cache every hour. This can be adjusted later based on how much data is fetched. -export const revalidate = SHORT_REVALIDATE ? 10 : 3600; +export const revalidate = process.env.SHORT_REVALIDATE === "true" ? 10 : 3600; type StaticParams = { market: string; @@ -33,7 +32,7 @@ const EmojicoinPage = async (params: EmojicoinPageProps) => { const swapData = await getInitialSwapData(marketID); return ( - { ); } - return ; + return ; }; export default EmojicoinPage; diff --git a/src/typescript/frontend/src/app/global.css b/src/typescript/frontend/src/app/global.css index 2dd9dc934..1fec15f3a 100644 --- a/src/typescript/frontend/src/app/global.css +++ b/src/typescript/frontend/src/app/global.css @@ -4,6 +4,13 @@ @tailwind components; @tailwind utilities; +:root { + .Toastify__toast-container > * { + font-family: var(--font-forma) !important; + line-height: 1.4rem; + } +} + .med-pixel-text { font-size: 20px; line-height: 25px; diff --git a/src/typescript/frontend/src/app/home/page.tsx b/src/typescript/frontend/src/app/home/page.tsx index 7d62a94b9..97ffc2d55 100644 --- a/src/typescript/frontend/src/app/home/page.tsx +++ b/src/typescript/frontend/src/app/home/page.tsx @@ -1,8 +1,8 @@ -import Home from "components/pages/home"; +import ClientHomePage from "components/pages/home/ClientHomePage"; import { fetchTopMarkets } from "lib/queries/initial/markets"; export default async function HomePage() { const data = await fetchTopMarkets(); - return ; + return ; } diff --git a/src/typescript/frontend/src/app/launch-emojicoin/page.tsx b/src/typescript/frontend/src/app/launch-emojicoin/page.tsx index 81935a20f..e7c1981d7 100644 --- a/src/typescript/frontend/src/app/launch-emojicoin/page.tsx +++ b/src/typescript/frontend/src/app/launch-emojicoin/page.tsx @@ -1,5 +1,5 @@ -import LaunchEmojicoin from "components/pages/launch-emojicoin"; +import ClientLaunchEmojicoinPage from "../../components/pages/launch-emojicoin/ClientLaunchEmojicoinPage"; export default function LaunchEmojicoinPage() { - return ; + return ; } diff --git a/src/typescript/frontend/src/app/pools/page.tsx b/src/typescript/frontend/src/app/pools/page.tsx index 025b3d3a9..6c89647ed 100644 --- a/src/typescript/frontend/src/app/pools/page.tsx +++ b/src/typescript/frontend/src/app/pools/page.tsx @@ -1,5 +1,5 @@ -import Pools from "components/pages/pools"; +import ClientPoolsPage from "components/pages/pools/ClientPoolsPage"; export default function PoolsPage() { - return ; + return ; } diff --git a/src/typescript/frontend/src/components/header/components/mobile-menu/index.tsx b/src/typescript/frontend/src/components/header/components/mobile-menu/index.tsx index 5d43d30c8..4e9c869b6 100644 --- a/src/typescript/frontend/src/components/header/components/mobile-menu/index.tsx +++ b/src/typescript/frontend/src/components/header/components/mobile-menu/index.tsx @@ -11,7 +11,7 @@ import { MobileMenuItem } from "../index"; import { type MobileMenuProps } from "./types"; import { slideVariants } from "./animations"; -import ConnectWalletButton from "components/header/wallet-button/ConnectWalletButton"; +import ButtonWithConnectWalletFallback from "components/header/wallet-button/ConnectWalletButton"; export const MobileMenu: React.FC = ({ isOpen, @@ -42,7 +42,7 @@ export const MobileMenu: React.FC = ({ ); })} - + diff --git a/src/typescript/frontend/src/components/header/index.tsx b/src/typescript/frontend/src/components/header/index.tsx index 10076d6ec..b28c0419a 100644 --- a/src/typescript/frontend/src/components/header/index.tsx +++ b/src/typescript/frontend/src/components/header/index.tsx @@ -19,7 +19,7 @@ import { slideTopVariants } from "./animations"; import { type HeaderProps } from "./types"; import { translationFunction } from "context/language-context"; -import ConnectWalletButton from "./wallet-button/ConnectWalletButton"; +import ButtonWithConnectWalletFallback from "./wallet-button/ConnectWalletButton"; const Header: React.FC = ({ isOpen, setIsOpen }) => { const { isDesktop } = useMatchBreakpoints(); @@ -68,7 +68,7 @@ const Header: React.FC = ({ isOpen, setIsOpen }) => { ); })} - + )} diff --git a/src/typescript/frontend/src/components/header/wallet-button/ConnectWalletButton.tsx b/src/typescript/frontend/src/components/header/wallet-button/ConnectWalletButton.tsx index 55b654e9e..07a64f8cf 100644 --- a/src/typescript/frontend/src/components/header/wallet-button/ConnectWalletButton.tsx +++ b/src/typescript/frontend/src/components/header/wallet-button/ConnectWalletButton.tsx @@ -12,7 +12,7 @@ export interface ConnectWalletProps extends PropsWithChildren<{ className?: stri const DEFAULT_TEXT = "Connect Wallet"; -export const ConnectWalletButton: React.FC = ({ +export const ButtonWithConnectWalletFallback: React.FC = ({ mobile, children, className, @@ -98,4 +98,4 @@ export const ConnectWalletButton: React.FC = ({ ); }; -export default ConnectWalletButton; +export default ButtonWithConnectWalletFallback; diff --git a/src/typescript/frontend/src/components/pages/connect-wallet/index.tsx b/src/typescript/frontend/src/components/pages/connect-wallet/index.tsx deleted file mode 100644 index f05bd8710..000000000 --- a/src/typescript/frontend/src/components/pages/connect-wallet/index.tsx +++ /dev/null @@ -1,18 +0,0 @@ -"use client"; - -import React from "react"; - -import Heading from "components/heading"; -import { Page } from "components/layout/components/page"; - -const ConnectWallet: React.FC = () => { - return ( - - - Connect wallet page - - - ); -}; - -export default ConnectWallet; diff --git a/src/typescript/frontend/src/components/pages/emojicoin/index.tsx b/src/typescript/frontend/src/components/pages/emojicoin/ClientEmojicoinPage.tsx similarity index 89% rename from src/typescript/frontend/src/components/pages/emojicoin/index.tsx rename to src/typescript/frontend/src/components/pages/emojicoin/ClientEmojicoinPage.tsx index cc758e9e2..04657b670 100644 --- a/src/typescript/frontend/src/components/pages/emojicoin/index.tsx +++ b/src/typescript/frontend/src/components/pages/emojicoin/ClientEmojicoinPage.tsx @@ -13,7 +13,7 @@ import MobileGrid from "./components/mobile-grid"; import { type EmojicoinProps } from "./types"; import { EmojiNotFound } from "./components/emoji-not-found"; -const Emojicoin = (props: EmojicoinProps) => { +const ClientEmojicoinPage = (props: EmojicoinProps) => { const { isLaptopL } = useMatchBreakpoints(); return ( @@ -32,4 +32,4 @@ const Emojicoin = (props: EmojicoinProps) => { ); }; -export default Emojicoin; +export default ClientEmojicoinPage; diff --git a/src/typescript/frontend/src/components/pages/home/index.tsx b/src/typescript/frontend/src/components/pages/home/ClientHomePage.tsx similarity index 83% rename from src/typescript/frontend/src/components/pages/home/index.tsx rename to src/typescript/frontend/src/components/pages/home/ClientHomePage.tsx index bfe72ad36..63a5b802d 100644 --- a/src/typescript/frontend/src/components/pages/home/index.tsx +++ b/src/typescript/frontend/src/components/pages/home/ClientHomePage.tsx @@ -5,11 +5,11 @@ import MainCard from "./components/main-card"; import { type MarketStateProps } from "./types"; export interface HomeProps { - data: Array; + data?: Array; } -const Home = async (props: HomeProps) => { - const data = props.data; +const ClientHomePage = async (props: HomeProps) => { + const data = props.data ?? []; const featured = data.toReversed().pop(); const gridMarkets = data.slice(1); @@ -37,4 +37,4 @@ const Home = async (props: HomeProps) => { ); }; -export default Home; +export default ClientHomePage; diff --git a/src/typescript/frontend/src/components/pages/index.ts b/src/typescript/frontend/src/components/pages/index.ts index 1a4a42d33..2a792a64c 100644 --- a/src/typescript/frontend/src/components/pages/index.ts +++ b/src/typescript/frontend/src/components/pages/index.ts @@ -1,5 +1,4 @@ export * from "./not-found"; -export * from "./connect-wallet"; -export * from "./emojicoin"; -export * from "./launch-emojicoin"; +export * from "./emojicoin/ClientEmojicoinPage"; +export * from "./launch-emojicoin/ClientLaunchEmojicoinPage"; export * from "./pools/components"; diff --git a/src/typescript/frontend/src/components/pages/launch-emojicoin/index.tsx b/src/typescript/frontend/src/components/pages/launch-emojicoin/ClientLaunchEmojicoinPage.tsx similarity index 93% rename from src/typescript/frontend/src/components/pages/launch-emojicoin/index.tsx rename to src/typescript/frontend/src/components/pages/launch-emojicoin/ClientLaunchEmojicoinPage.tsx index 718ec5be2..9b1fa7a5d 100644 --- a/src/typescript/frontend/src/components/pages/launch-emojicoin/index.tsx +++ b/src/typescript/frontend/src/components/pages/launch-emojicoin/ClientLaunchEmojicoinPage.tsx @@ -13,12 +13,13 @@ import Prompt from "components/prompt"; import { Input } from "components/inputs/input"; import { InputGroup } from "components/inputs/input-group"; import { Text } from "components/text"; -import Button from "components/button"; import ClientsSlider from "components/clients-slider"; import { Column, Flex, FlexGap } from "@containers"; import { StyledFieldName } from "./styled"; +import { LaunchEmojicoinButton } from "./components/LaunchEmojicoinButton"; +import { SYMBOL_DATA } from "@sdk/emoji_data/symbol-data"; -const LaunchEmojicoin: React.FC = () => { +const ClientLaunchEmojicoinPage: React.FC = () => { const { t } = translationFunction(); const { validationSchema, initialValues } = useValidationSchema(); @@ -164,7 +165,9 @@ const LaunchEmojicoin: React.FC = () => { - {t("Launch Emojicoin")} + SYMBOL_DATA.byEmoji(e.emoji)!.hex)} + /> @@ -172,4 +175,4 @@ const LaunchEmojicoin: React.FC = () => { ); }; -export default LaunchEmojicoin; +export default ClientLaunchEmojicoinPage; diff --git a/src/typescript/frontend/src/components/pages/launch-emojicoin/components/LaunchEmojicoinButton.tsx b/src/typescript/frontend/src/components/pages/launch-emojicoin/components/LaunchEmojicoinButton.tsx new file mode 100644 index 000000000..30506fde5 --- /dev/null +++ b/src/typescript/frontend/src/components/pages/launch-emojicoin/components/LaunchEmojicoinButton.tsx @@ -0,0 +1,68 @@ +import ButtonWithConnectWalletFallback from "components/header/wallet-button/ConnectWalletButton"; +import Button from "components/button"; +import { translationFunction } from "context/language-context"; +import { RegisterMarket, RegistryView } from "@sdk/emojicoin_dot_fun/emojicoin-dot-fun"; +import { useAptos } from "context/wallet-context/AptosContextProvider"; +import { + type PendingTransactionResponse, + type UserTransactionResponse, + type HexInput, +} from "@aptos-labs/ts-sdk"; +import { INTEGRATOR_ADDRESS } from "lib/env"; +import { DEFAULT_REGISTER_MARKET_GAS_OPTIONS } from "@sdk/const"; +import { toRegistryView } from "@sdk/types"; + +export const LaunchEmojicoinButton = ({ emojis }: { emojis: Array }) => { + const { t } = translationFunction(); + const { aptos, account, submit, signThenSubmit } = useAptos(); + + const handleClick = async () => { + if (!account) { + return; + } + let _res: PendingTransactionResponse | UserTransactionResponse | null = null; + let _txFlowError: unknown; + const builderArgs = { + aptosConfig: aptos.config, + registrant: account.address, + emojis, + integrator: INTEGRATOR_ADDRESS, + }; + try { + const builderLambda = () => RegisterMarket.builder(builderArgs); + await submit(builderLambda).then((r) => { + _res = r?.response ?? null; + _txFlowError = r?.error; + }); + } catch (e) { + // TODO: Check if this works. + // If the market registration fails, it's possibly because it's the first market and the gas limit + // needs to be set very high. We'll check if the registry has 0 markets, and then try to manually + // set the gas limits and submit again. + const registryView = await RegistryView.view({ + aptos, + }).then((r) => toRegistryView(r)); + + const builderLambda = () => + RegisterMarket.builder({ + ...builderArgs, + options: DEFAULT_REGISTER_MARKET_GAS_OPTIONS, + }); + + if (registryView.numMarkets === 0n) { + await signThenSubmit(builderLambda).then((r) => { + _res = r?.response ?? null; + _txFlowError = r?.error; + }); + } + } + }; + + return ( + + + {t("Launch Emojicoin")} + + + ); +}; diff --git a/src/typescript/frontend/src/components/pages/launch-emojicoin/hooks/use-validation-schema.ts b/src/typescript/frontend/src/components/pages/launch-emojicoin/hooks/use-validation-schema.ts index 67048f42e..900aa3c2e 100644 --- a/src/typescript/frontend/src/components/pages/launch-emojicoin/hooks/use-validation-schema.ts +++ b/src/typescript/frontend/src/components/pages/launch-emojicoin/hooks/use-validation-schema.ts @@ -2,6 +2,7 @@ import * as yup from "yup"; import { type InitialValues } from "./types"; import { translationFunction } from "context/language-context"; +import { SYMBOL_DATA } from "@sdk/emoji_data"; const useValidationSchema = () => { const initialValues: InitialValues = { @@ -15,7 +16,7 @@ const useValidationSchema = () => { emoji: yup.string().test("emoji", `${t("Byte limit reached")}`, (value) => { const encoder = new TextEncoder(); const bytes = encoder.encode(value); - return bytes.length <= 10; + return bytes.length <= 10 && SYMBOL_DATA.hasHex(bytes); }), }); diff --git a/src/typescript/frontend/src/components/pages/pools/index.tsx b/src/typescript/frontend/src/components/pages/pools/ClientPoolsPage.tsx similarity index 97% rename from src/typescript/frontend/src/components/pages/pools/index.tsx rename to src/typescript/frontend/src/components/pages/pools/ClientPoolsPage.tsx index 4e59eeb04..59967e740 100644 --- a/src/typescript/frontend/src/components/pages/pools/index.tsx +++ b/src/typescript/frontend/src/components/pages/pools/ClientPoolsPage.tsx @@ -18,7 +18,7 @@ import { } from "components/pages/pools/styled"; import { isDisallowedEventKey } from "utils"; -export const Pools = () => { +export const ClientPoolsPage = () => { const { isMobile } = useMatchBreakpoints(); const { targetRef, tooltip } = useEmojicoinPicker({ @@ -97,4 +97,4 @@ export const Pools = () => { ); }; -export default Pools; +export default ClientPoolsPage; diff --git a/src/typescript/frontend/src/context/providers.tsx b/src/typescript/frontend/src/context/providers.tsx index 268bb0f56..25ab4223c 100644 --- a/src/typescript/frontend/src/context/providers.tsx +++ b/src/typescript/frontend/src/context/providers.tsx @@ -5,7 +5,7 @@ import React, { Suspense, useEffect, useMemo, useState } from "react"; import { Provider } from "react-redux"; import { ThemeProvider } from "styled-components"; -import { GlobalStyle, StyledToastContainer } from "styles"; +import { GlobalStyle } from "styles"; import ThemeContextProvider, { useThemeContext } from "./theme-context"; import store from "store/store"; import Loader from "components/loader"; @@ -18,6 +18,8 @@ import { ConnectWalletContextProvider } from "./wallet-context/ConnectWalletCont import { PontemWallet } from "@pontem/wallet-adapter-plugin"; import { RiseWallet } from "@rise-wallet/wallet-adapter"; import { MartianWallet } from "@martianwallet/aptos-wallet-adapter"; +import { AptosContextProvider } from "./wallet-context/AptosContextProvider"; +import StyledToaster from "styles/StyledToaster"; const ThemedApp: React.FC<{ children: React.ReactNode }> = ({ children }) => { const { theme } = useThemeContext(); @@ -33,17 +35,19 @@ const ThemedApp: React.FC<{ children: React.ReactNode }> = ({ children }) => { - - }> - - - - - {children} - - - - + + + }> + + + + + {children} + + + + + diff --git a/src/typescript/frontend/src/context/wallet-context/AptosContextProvider.tsx b/src/typescript/frontend/src/context/wallet-context/AptosContextProvider.tsx index b1172750d..a3b5e79de 100644 --- a/src/typescript/frontend/src/context/wallet-context/AptosContextProvider.tsx +++ b/src/typescript/frontend/src/context/wallet-context/AptosContextProvider.tsx @@ -1,70 +1,131 @@ -import { type Aptos, type PendingTransactionResponse } from "@aptos-labs/ts-sdk"; -import { useWallet } from "@aptos-labs/wallet-adapter-react"; +import { + AptosApiError, + type Aptos, + type PendingTransactionResponse, + type UserTransactionResponse, +} from "@aptos-labs/ts-sdk"; +import { type NetworkInfo, useWallet } from "@aptos-labs/wallet-adapter-react"; import { createContext, type PropsWithChildren, useCallback, useContext, useMemo } from "react"; import { toast } from "react-toastify"; -import { getAptos } from "@sdk/utils/aptos-client"; import { APTOS_NETWORK } from "lib/env"; +import { type EntryFunctionTransactionBuilder } from "@sdk/emojicoin_dot_fun/payload-builders"; +import { getAptos } from "lib/utils/aptos-client"; +import { checkNetworkAndToast, parseAPIErrorAndToast, successfulTransactionToast } from "./toasts"; type WalletContextState = ReturnType; +type SubmissionResponse = Promise<{ + response: PendingTransactionResponse | UserTransactionResponse | null; + error: unknown; +} | null>; export type AptosContextState = { - aptosClient: Aptos; - signAndSubmitTransaction: WalletContextState["signAndSubmitTransaction"]; + aptos: Aptos; + submit: (builderFn: () => Promise) => SubmissionResponse; + signThenSubmit: (builderFn: () => Promise) => SubmissionResponse; account: WalletContextState["account"]; }; export const AptosContext = createContext(undefined); export function AptosContextProvider({ children }: PropsWithChildren) { - const { signAndSubmitTransaction: adapterSignAndSubmitTxn, account, network } = useWallet(); - const aptosClient = useMemo(() => { - if (network?.name !== APTOS_NETWORK) { - const warningMessage = "Your wallet network is different from the dapp's network."; - const toAvoidMessage = `To avoid undefined behavior, please set your wallet network to ${APTOS_NETWORK}`; - toast.warning(`${warningMessage} ${toAvoidMessage}`); + const { + signAndSubmitTransaction: adapterSignAndSubmitTxn, + account, + network, + submitTransaction, + signTransaction, + } = useWallet(); + + const aptos = useMemo(() => { + if (checkNetworkAndToast(network)) { + return getAptos(network.name); } - return getAptos(network?.name ?? APTOS_NETWORK); + return getAptos(APTOS_NETWORK); }, [network]); - const signAndSubmitTransaction = useCallback( - async (...args: Parameters) => { - const transaction = args[0]; - + const handleTransactionSubmission = useCallback( + async ( + network: NetworkInfo, + trySubmit: () => Promise<{ aptos: Aptos; res: PendingTransactionResponse }> + ) => { + let response: PendingTransactionResponse | UserTransactionResponse | null = null; + let error: unknown; try { - transaction.data.functionArguments = transaction.data.functionArguments.map((arg) => { - if (typeof arg === "bigint") { - return arg.toString(); - } else { - return arg; - } - }); - const res: PendingTransactionResponse = await adapterSignAndSubmitTxn(transaction); + const { aptos, res } = await trySubmit(); + response = res; try { - await aptosClient.waitForTransaction({ + const awaitedResponse = (await aptos.waitForTransaction({ transactionHash: res.hash, - }); - toast.success("Transaction confirmed"); - return true; - } catch (error) { + })) as UserTransactionResponse; + successfulTransactionToast(awaitedResponse, network); + response = awaitedResponse; + } catch (e) { toast.error("Transaction failed"); - console.error(error); - return false; + console.error(e); + error = e; } - //eslint-disable-next-line - } catch (error: any) { - if (error && error?.includes("Account not found")) { - toast.error("You need APT balance!"); + } catch (e: unknown) { + if (e instanceof AptosApiError) { + parseAPIErrorAndToast(network, e); + } else { + console.error(e); } + error = e; + } + return { response, error }; + }, + [] + ); + + const submit = useCallback( + async (builderFn: () => Promise) => { + if (checkNetworkAndToast(network, true)) { + const trySubmit = async () => { + const builder = await builderFn(); + const input = builder.payloadBuilder.toInputPayload(); + return adapterSignAndSubmitTxn(input).then((res) => ({ + aptos: builder.aptos, + res, + })); + }; + + return await handleTransactionSubmission(network, trySubmit); + } + return null; + }, + [network, handleTransactionSubmission, adapterSignAndSubmitTxn] + ); + + // To manually enforce explicit gas options, we can use this transaction submission flow. + // Note that you need to pass the options to the builder, not here. It's possible to do it here, but it's + // unnecessary to support that and I'm not gonna write the code for it. + const signThenSubmit = useCallback( + async (builderFn: () => Promise) => { + if (checkNetworkAndToast(network, true)) { + const trySubmit = async () => { + const builder = await builderFn(); + const senderAuthenticator = await signTransaction(builder.rawTransactionInput); + return submitTransaction({ + transaction: builder.rawTransactionInput, + senderAuthenticator, + }).then((res) => ({ + aptos: builder.aptos, + res, + })); + }; + return await handleTransactionSubmission(network, trySubmit); } + return null; }, - [adapterSignAndSubmitTxn, aptosClient] + [network, handleTransactionSubmission, signTransaction, submitTransaction] ); const value: AptosContextState = { - aptosClient, + aptos, account, - signAndSubmitTransaction, + submit, + signThenSubmit, }; return {children}; diff --git a/src/typescript/frontend/src/context/wallet-context/WalletItem.tsx b/src/typescript/frontend/src/context/wallet-context/WalletItem.tsx index 171bf72fd..c25a02d7d 100644 --- a/src/typescript/frontend/src/context/wallet-context/WalletItem.tsx +++ b/src/typescript/frontend/src/context/wallet-context/WalletItem.tsx @@ -90,6 +90,8 @@ export const WalletItem: React.FC<{ const [hover, setHover] = useState(false); const { wallet: current } = useWallet(); + console.warn(wallet.readyState); + const inner = ( <> {WALLET_ICON[wallet.name.toLowerCase()]} @@ -98,7 +100,10 @@ export const WalletItem: React.FC<{ diff --git a/src/typescript/frontend/src/context/wallet-context/toasts.tsx b/src/typescript/frontend/src/context/wallet-context/toasts.tsx new file mode 100644 index 000000000..75f4be52b --- /dev/null +++ b/src/typescript/frontend/src/context/wallet-context/toasts.tsx @@ -0,0 +1,102 @@ +import { AptosApiError, type UserTransactionResponse } from "@aptos-labs/ts-sdk"; +import { type NetworkInfo } from "@aptos-labs/wallet-adapter-react"; +import { CandlestickResolution } from "@sdk/const"; +import { getCurrentPeriodBoundary } from "@sdk/utils/misc"; +import { APTOS_NETWORK } from "lib/env"; +import { toast } from "react-toastify"; +import { ExplorerLink } from "components/link/component"; + +const debouncedToastKey = (s: string, debouncePeriod: CandlestickResolution) => { + const periodBoundary = getCurrentPeriodBoundary(debouncePeriod); + return `${s}-${periodBoundary}`; +}; + +export const checkNetworkAndToast = ( + network: NetworkInfo | null, + notifyIfDisconnected = true +): network is NetworkInfo => { + if (!network) { + if (!notifyIfDisconnected) { + toast.info("Please connect your wallet.", { + toastId: debouncedToastKey("connect-wallet", CandlestickResolution.PERIOD_15S), + }); + } + return false; + } + if (network.name !== APTOS_NETWORK && typeof network.name !== "undefined") { + const message = ( + + + + {"Your wallet network is set to "} + + {network.name} + + {" but this"} + + + {" dapp is using the "}{" "} + + {APTOS_NETWORK} + + {" network."} + + + + ); + toast.warning(message, { + toastId: debouncedToastKey("network-warning", CandlestickResolution.PERIOD_15S), + }); + } + return true; +}; + +export const parseAPIErrorAndToast = (network: NetworkInfo, error: AptosApiError) => { + if (error instanceof AptosApiError) { + if (error.data?.error_code === "account_not_found") { + const message = ( + + + {"Your account doesn't exist on the "} + + {network.name} + + {" network. Have you created an account?"} + + + ); + toast.error(message, { + toastId: debouncedToastKey("account-not-found", CandlestickResolution.PERIOD_15S), + }); + } + } +}; + +export const successfulTransactionToast = ( + response: UserTransactionResponse, + network: NetworkInfo +) => { + const message = ( + <> + + + {"Transaction confirmed! "} + + {response.hash} + + + + > + ); + toast.success(message, { + toastId: debouncedToastKey("transaction-success", CandlestickResolution.PERIOD_1S), + className: "cursor-text", + closeOnClick: false, + autoClose: 8000, + }); +}; diff --git a/src/typescript/frontend/src/lib/env.ts b/src/typescript/frontend/src/lib/env.ts index e70a0e3c6..94edf58d5 100644 --- a/src/typescript/frontend/src/lib/env.ts +++ b/src/typescript/frontend/src/lib/env.ts @@ -1,7 +1,7 @@ import { type Network } from "@aptos-labs/wallet-adapter-react"; let APTOS_NETWORK: Network; -let SHORT_REVALIDATE: boolean; +let INTEGRATOR_ADDRESS: string; if (process.env.NEXT_PUBLIC_APTOS_NETWORK) { const network = process.env.NEXT_PUBLIC_APTOS_NETWORK; @@ -14,17 +14,18 @@ if (process.env.NEXT_PUBLIC_APTOS_NETWORK) { throw new Error("Environment variable NEXT_PUBLIC_APTOS_NETWORK is undefined."); } -if (process.env.NEXT_PUBLIC_SHORT_REVALIDATE) { - SHORT_REVALIDATE = process.env.NEXT_PUBLIC_SHORT_REVALIDATE === "true"; +if (process.env.NEXT_PUBLIC_INTEGRATOR_ADDRESS) { + INTEGRATOR_ADDRESS = process.env.NEXT_PUBLIC_INTEGRATOR_ADDRESS; } else { - throw new Error("Environment variable NEXT_PUBLIC_SHORT_REVALIDATE is undefined."); + throw new Error("Environment variable NEXT_PUBLIC_INTEGRATOR_ADDRESS is undefined."); } const vercel = process.env.VERCEL === "1"; const local = process.env.INBOX_URL === "http://localhost:3000"; if (vercel && local) { - console.warn("Warning: This vercel build is using `localhost:3000` as the inbox endpoint."); - console.warn("Using sample market data."); + throw new Error( + "Should not be using `localhost` as the `inbox` endpoint during Vercel deployment." + ); } -export { APTOS_NETWORK, SHORT_REVALIDATE }; +export { APTOS_NETWORK, INTEGRATOR_ADDRESS }; diff --git a/src/typescript/frontend/src/lib/queries/initial/cache-helper.ts b/src/typescript/frontend/src/lib/queries/initial/cache-helper.ts index ba10123bc..fdfa18e0c 100644 --- a/src/typescript/frontend/src/lib/queries/initial/cache-helper.ts +++ b/src/typescript/frontend/src/lib/queries/initial/cache-helper.ts @@ -1,14 +1,12 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ +"use server"; + import { UnitOfTime, getTime } from "@sdk/utils/misc"; import { cache } from "react"; import { INITIAL_REVALIDATION_TIMES } from "./const"; -import { SHORT_REVALIDATE } from "lib/env"; /** - * * A helper function to either cache data or fetch it from a static source, because the production * endpoint is not set up yet. - * */ export const fetchInitialWithFallback = async ({ functionArgs, @@ -19,15 +17,13 @@ export const fetchInitialWithFallback = async ({ queryFunction: (args: T2) => Promise; endpoint: string | URL; }) => { - const vercel = process.env.VERCEL === "1"; - const local = process.env.INBOX_URL === "http://localhost:3000"; - // For the inner cache, since it may be used elsewhere independently. - const revalidate = INITIAL_REVALIDATION_TIMES[SHORT_REVALIDATE ? "short" : "long"]; + const shortRevalidate = process.env.SHORT_REVALIDATE === "true"; + const revalidate = INITIAL_REVALIDATION_TIMES[shortRevalidate ? "short" : "long"]; let fn: (args: T2) => Promise; - if ((vercel && local) || process.env.NEXT_PUBLIC_FORCE_STATIC_FETCH === "true") { + if (process.env.FORCE_STATIC_FETCH === "true") { fn = async (_args: T2) => fetch(endpoint, { next: { revalidate } }).then((r) => r.json().then((j) => j as T1)); } else { @@ -36,12 +32,9 @@ export const fetchInitialWithFallback = async ({ const currentHour = Math.floor(getTime(UnitOfTime.Hours)); const cachedFunction = cache( - async (args: { vercel: boolean; local: boolean; time: number; functionArgs: T2 }) => - await fn(args.functionArgs) + async (args: { time: number; functionArgs: T2 }) => await fn(args.functionArgs) ); return await cachedFunction({ - vercel: vercel, - local: local, time: currentHour, functionArgs, }); diff --git a/src/typescript/frontend/src/lib/queries/initial/chats.ts b/src/typescript/frontend/src/lib/queries/initial/chats.ts index 445a32c8a..6d0b6eb58 100644 --- a/src/typescript/frontend/src/lib/queries/initial/chats.ts +++ b/src/typescript/frontend/src/lib/queries/initial/chats.ts @@ -1,3 +1,5 @@ +"use server"; + import { toChatEvent } from "@sdk/types"; import { paginateChatEvents } from "@sdk/queries/chat"; import { cache } from "react"; diff --git a/src/typescript/frontend/src/lib/queries/initial/markets.ts b/src/typescript/frontend/src/lib/queries/initial/markets.ts index c04010399..80cef7ac0 100644 --- a/src/typescript/frontend/src/lib/queries/initial/markets.ts +++ b/src/typescript/frontend/src/lib/queries/initial/markets.ts @@ -1,17 +1,22 @@ +"use server"; + import { SYMBOL_DATA } from "@sdk/emoji_data/"; import { MarketView } from "@sdk/emojicoin_dot_fun/emojicoin-dot-fun"; import { type JSONTypes, toMarketView, toStateEvent } from "@sdk/types"; import { paginateMarketRegistrations, getTopMarkets } from "@sdk/queries/market"; -import { getAptos } from "@sdk/utils/aptos-client"; import { APTOS_NETWORK } from "lib/env"; import { cache } from "react"; import fetchInitialWithFallback from "./cache-helper"; import { SAMPLE_DATA_BASE_URL } from "./const"; +import { getAptos } from "lib/utils/aptos-client"; export const fetchTopMarkets = cache(async () => { - if (process.env.NEXT_PUBLIC_FORCE_STATIC_FETCH === "true") { + if (process.env.FORCE_STATIC_FETCH === "true") { const res = await fetch(new URL("top-market-data.json", SAMPLE_DATA_BASE_URL)); - const data = (await res.json()).data; + const data = (await res.json()).data as Array<{ + data: JSONTypes.StateEvent; + version: number; + }>; return data.map((v) => ({ state: toStateEvent(v.data), emoji: SYMBOL_DATA.byHex(v.data.market_metadata.emoji_bytes)!, diff --git a/src/typescript/frontend/src/lib/queries/initial/state.ts b/src/typescript/frontend/src/lib/queries/initial/state.ts index b8de32b69..f27da6657 100644 --- a/src/typescript/frontend/src/lib/queries/initial/state.ts +++ b/src/typescript/frontend/src/lib/queries/initial/state.ts @@ -1,3 +1,5 @@ +"use server"; + import { cache } from "react"; import { getLastMarketState } from "@sdk/queries/state"; import { SYMBOL_DATA } from "@sdk/emoji_data"; @@ -25,7 +27,7 @@ export const staticLastSwap = async (marketID: string) => { }; export const fetchLastMarketState = cache(async (marketID: string) => { - if (process.env.NEXT_PUBLIC_FORCE_STATIC_FETCH === "true") { + if (process.env.FORCE_STATIC_FETCH === "true") { return staticLastSwap(marketID); } diff --git a/src/typescript/frontend/src/lib/queries/initial/swaps.ts b/src/typescript/frontend/src/lib/queries/initial/swaps.ts index 47a40a6ec..e7a668af9 100644 --- a/src/typescript/frontend/src/lib/queries/initial/swaps.ts +++ b/src/typescript/frontend/src/lib/queries/initial/swaps.ts @@ -1,3 +1,5 @@ +"use server"; + import { toSwapEvent } from "@sdk/types"; import { paginateSwapEvents } from "@sdk/queries/swap"; import { cache } from "react"; diff --git a/src/typescript/frontend/src/lib/utils/aptos-client.ts b/src/typescript/frontend/src/lib/utils/aptos-client.ts index e69de29bb..0c0939720 100644 --- a/src/typescript/frontend/src/lib/utils/aptos-client.ts +++ b/src/typescript/frontend/src/lib/utils/aptos-client.ts @@ -0,0 +1,19 @@ +/* eslint-disable import/no-unused-modules */ // Used in the frontend repo. +import { Aptos, AptosConfig, NetworkToNetworkName } from "@aptos-labs/ts-sdk"; +import { APTOS_NETWORK } from "lib/env"; + +// Get an Aptos config based off of the network environment variables. +export const getAptosConfig = (networkString?: string): AptosConfig => { + // Check if it's a valid network. + const network = NetworkToNetworkName[networkString ?? APTOS_NETWORK]; + if (!network) { + throw new Error(`Invalid network: ${networkString}`); + } + return new AptosConfig({ network }); +}; + +// Get an Aptos client based off of the network environment variables. +export const getAptos = (networkString?: string): Aptos => { + const cfg = getAptosConfig(networkString); + return new Aptos(cfg); +}; diff --git a/src/typescript/frontend/src/styles/StyledToastContainer.tsx b/src/typescript/frontend/src/styles/StyledToastContainer.tsx deleted file mode 100644 index 468abeec6..000000000 --- a/src/typescript/frontend/src/styles/StyledToastContainer.tsx +++ /dev/null @@ -1,101 +0,0 @@ -import styled from "styled-components"; -import { ToastContainer } from "react-toastify"; - -const StyledContainer = styled(ToastContainer)` - /** Used to define container behavior: width, position: fixed etc... **/ - .Toastify__toast-container { - } - - /** Used to define the position of the ToastContainer **/ - .Toastify__toast-container--top-left { - } - .Toastify__toast-container--top-center { - } - .Toastify__toast-container--top-right { - } - .Toastify__toast-container--bottom-left { - } - .Toastify__toast-container--bottom-center { - } - .Toastify__toast-container--bottom-right { - } - - /** Classes for the displayed toast **/ - .Toastify__toast { - } - .Toastify__toast--rtl { - } - // https://styled-components.com/docs/faqs#how-can-i-override-styles-with-higher-specificity - .Toastify__toast-body { - align-items: flex-start; - } - - /** Used to position the icon **/ - .Toastify__toast-icon { - } - - /** handle the notification color and the text color based on the theme **/ - .Toastify__toast-theme--dark { - } - .Toastify__toast-theme--light { - } - .Toastify__toast-theme--colored.Toastify__toast--default { - } - .Toastify__toast--info { - background-color: ${({ theme }) => theme.colors.econiaBlue}; - } - .Toastify__toast--success { - background-color: ${({ theme }) => theme.colors.green}; - } - .Toastify__toast--warning { - background-color: ${({ theme }) => theme.colors.warning}; - } - .Toastify__toast--error { - background-color: ${({ theme }) => theme.colors.error}; - } - - .Toastify__progress-bar { - } - .Toastify__progress-bar--rtl { - } - .Toastify__progress-bar-theme--light { - } - .Toastify__progress-bar-theme--dark { - } - .Toastify__progress-bar--info { - background-color: ${({ theme }) => theme.colors.econiaBlue}; - } - .Toastify__progress-bar--success { - background-color: ${({ theme }) => theme.colors.green}; - } - .Toastify__progress-bar--warning { - background-color: ${({ theme }) => theme.colors.warning}; - } - .Toastify__progress-bar--error { - background-color: ${({ theme }) => theme.colors.error}; - } - /** colored notifications share the same progress bar color **/ - .Toastify__progress-bar-theme--colored.Toastify__progress-bar--info, - .Toastify__progress-bar-theme--colored.Toastify__progress-bar--success, - .Toastify__progress-bar-theme--colored.Toastify__progress-bar--warning, - .Toastify__progress-bar-theme--colored.Toastify__progress-bar--error { - } - - /** Classes for the close button. Better use your own closeButton **/ - .Toastify__close-button { - color: ${({ theme }) => theme.colors.black}; - width: 20px; - height: 20px; - } - .Toastify__close-button--default { - } - .Toastify__close-button > svg { - width: 20px; - height: 20px; - } - .Toastify__close-button:hover, - .Toastify__close-button:focus { - } -`; - -export default StyledContainer; diff --git a/src/typescript/frontend/src/styles/StyledToaster.tsx b/src/typescript/frontend/src/styles/StyledToaster.tsx new file mode 100644 index 000000000..8424eb5fa --- /dev/null +++ b/src/typescript/frontend/src/styles/StyledToaster.tsx @@ -0,0 +1,9 @@ +import { ToastContainer } from "react-toastify"; + +export const StyledToaster = () => { + return ( + + ); +}; + +export default StyledToaster; diff --git a/src/typescript/frontend/src/styles/index.ts b/src/typescript/frontend/src/styles/index.ts index 268ac8f15..c65f9675f 100644 --- a/src/typescript/frontend/src/styles/index.ts +++ b/src/typescript/frontend/src/styles/index.ts @@ -1,3 +1,2 @@ export { default as GlobalStyle } from "./GlobalStyle"; -export { default as StyledToastContainer } from "./StyledToastContainer"; export { clearfix, clearfixDisplayNone } from "./clearfix"; diff --git a/src/typescript/frontend/src/types/server-only.d.ts b/src/typescript/frontend/src/types/server-only.d.ts new file mode 100644 index 000000000..06c30491c --- /dev/null +++ b/src/typescript/frontend/src/types/server-only.d.ts @@ -0,0 +1 @@ +declare module "server-only"; diff --git a/src/typescript/package.json b/src/typescript/package.json index 31e90e01a..68251df23 100644 --- a/src/typescript/package.json +++ b/src/typescript/package.json @@ -1,8 +1,9 @@ { "dependencies": { - "@aptos-labs/ts-sdk": "^1.16.0" + "@aptos-labs/ts-sdk": "^1.17.0" }, "devDependencies": { + "dotenv-cli": "^7.4.2", "prettier": "^3.2.5", "tsx": "^4.11.0", "turbo": "latest" @@ -15,16 +16,17 @@ "keyv": "npm:@keyvhq/core@2.1.1" }, "scripts": { - "build": "pnpm run clean && turbo run build", + "build": "pnpm i && dotenv -e .env.local -e .env -- turbo run build", + "build:clean": "turbo run clean && pnpm i && dotenv -e .env.local -e .env -- pnpm run build", "clean": "turbo run clean && pnpm i", - "dev": "turbo run dev --no-cache --parallel --continue", + "dev": "dotenv -e .env.local -e .env -- turbo run dev --no-cache --parallel --continue", "format": "turbo run format -- --write", "format:check": "turbo run format -- --check", "full-clean": "rm -rf node_modules && rm -rf .turbo && rm -rf sdk/.turbo && rm -rf sdk/node_modules && rm -rf frontend/.turbo && rm -rf frontend/node_modules && rm -rf frontend/.next", "lint": "turbo run lint", "lint:fix": "turbo run lint -- --fix", - "start": "turbo run start", - "test": "turbo run test" + "start": "dotenv -e .env.local -e .env -- turbo run start", + "test": "dotenv -e .env.test -- turbo run test" }, "version": "0.0.0", "workspaces": [ diff --git a/src/typescript/pnpm-lock.yaml b/src/typescript/pnpm-lock.yaml index aae993eaa..b519a3b0c 100644 --- a/src/typescript/pnpm-lock.yaml +++ b/src/typescript/pnpm-lock.yaml @@ -12,9 +12,12 @@ importers: .: dependencies: '@aptos-labs/ts-sdk': - specifier: ^1.16.0 - version: 1.16.0 + specifier: ^1.17.0 + version: 1.17.0 devDependencies: + dotenv-cli: + specifier: ^7.4.2 + version: 7.4.2 prettier: specifier: ^3.2.5 version: 3.2.5 @@ -28,8 +31,8 @@ importers: frontend: dependencies: '@aptos-labs/wallet-adapter-react': - specifier: ^2.5.1 - version: 2.5.1(@aptos-labs/ts-sdk@1.16.0)(aptos@1.21.0)(react@18.3.1) + specifier: ^3.0.2 + version: 3.0.2(@aptos-labs/ts-sdk@1.17.0)(@wallet-standard/core@1.0.3)(aptos@1.21.0)(react@18.3.1) '@econia-labs/emojicoin-sdk': specifier: workspace:* version: link:../sdk @@ -41,7 +44,7 @@ importers: version: 2.0.4(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@headlessui/tailwindcss': specifier: ^0.2.0 - version: 0.2.0(tailwindcss@3.4.3(ts-node@10.9.2(@types/node@20.12.12)(typescript@5.3.3))) + version: 0.2.1(tailwindcss@3.4.3(ts-node@10.9.2(@types/node@20.12.13)(typescript@5.3.3))) '@martianwallet/aptos-wallet-adapter': specifier: ^0.0.5 version: 0.0.5 @@ -77,7 +80,7 @@ importers: version: 14.2.3(react-dom@18.3.1(react@18.3.1))(react@18.3.1) petra-plugin-wallet-adapter: specifier: ^0.4.5 - version: 0.4.5(@aptos-labs/ts-sdk@1.16.0)(aptos@1.21.0) + version: 0.4.5(@aptos-labs/ts-sdk@1.17.0)(@wallet-standard/core@1.0.3)(aptos@1.21.0) react: specifier: ^18.3.1 version: 18.3.1 @@ -102,6 +105,9 @@ importers: redux-logger: specifier: ^3.0.6 version: 3.0.6 + server-only: + specifier: ^0.0.1 + version: 0.0.1 socket.io-client: specifier: ^4.7.2 version: 4.7.5 @@ -126,7 +132,7 @@ importers: version: 4.17.4 '@types/node': specifier: ^20.12.12 - version: 20.12.12 + version: 20.12.13 '@types/react': specifier: ^18.3.2 version: 18.3.3 @@ -162,7 +168,7 @@ importers: version: 3.2.5 tailwindcss: specifier: ^3.4.3 - version: 3.4.3(ts-node@10.9.2(@types/node@20.12.12)(typescript@5.3.3)) + version: 3.4.3(ts-node@10.9.2(@types/node@20.12.13)(typescript@5.3.3)) typescript: specifier: 5.3.3 version: 5.3.3 @@ -170,8 +176,8 @@ importers: sdk: dependencies: '@aptos-labs/ts-sdk': - specifier: ^1.16.0 - version: 1.16.0 + specifier: ^1.17.0 + version: 1.17.0 '@keyvhq/core': specifier: ^2.1.1 version: 2.1.1 @@ -180,16 +186,16 @@ importers: version: 1.4.0 '@supabase/postgrest-js': specifier: ^1.15.2 - version: 1.15.4 - dotenv: - specifier: ^16.4.5 - version: 16.4.5 + version: 1.15.5 find-git-root: specifier: ^1.0.4 version: 1.0.4 postgres: specifier: ^3.4.4 version: 3.4.4 + server-only: + specifier: ^0.0.1 + version: 0.0.1 devDependencies: '@aptos-labs/aptos-cli': specifier: ^0.1.2 @@ -198,14 +204,17 @@ importers: specifier: ^29.5.12 version: 29.5.12 '@types/node': - specifier: ^20.12.7 - version: 20.12.12 + specifier: ^20.12.13 + version: 20.12.13 '@typescript-eslint/eslint-plugin': specifier: ^6.14.0 version: 6.21.0(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.3.3))(eslint@8.57.0)(typescript@5.3.3) '@typescript-eslint/parser': specifier: ^6.14.0 version: 6.21.0(eslint@8.57.0)(typescript@5.3.3) + dotenv-cli: + specifier: ^7.4.2 + version: 7.4.2 eslint: specifier: ^8.55.0 version: 8.57.0 @@ -226,7 +235,7 @@ importers: version: 3.2.0(@typescript-eslint/eslint-plugin@6.21.0(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.3.3))(eslint@8.57.0)(typescript@5.3.3))(eslint@8.57.0) jest: specifier: ^29.7.0 - version: 29.7.0(@types/node@20.12.12)(ts-node@10.9.2(@types/node@20.12.12)(typescript@5.3.3)) + version: 29.7.0(@types/node@20.12.13)(ts-node@10.9.2(@types/node@20.12.13)(typescript@5.3.3)) prettier: specifier: ^3.2.5 version: 3.2.5 @@ -235,10 +244,10 @@ importers: version: 1.2.2 ts-jest: specifier: ^29.1.1 - version: 29.1.4(@babel/core@7.24.6)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.24.6))(jest@29.7.0(@types/node@20.12.12)(ts-node@10.9.2(@types/node@20.12.12)(typescript@5.3.3)))(typescript@5.3.3) + version: 29.1.4(@babel/core@7.24.6)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.24.6))(jest@29.7.0(@types/node@20.12.13)(ts-node@10.9.2(@types/node@20.12.13)(typescript@5.3.3)))(typescript@5.3.3) ts-node: specifier: ^10.9.2 - version: 10.9.2(@types/node@20.12.12)(typescript@5.3.3) + version: 10.9.2(@types/node@20.12.13)(typescript@5.3.3) typescript: specifier: 5.3.3 version: 5.3.3 @@ -261,8 +270,8 @@ packages: resolution: {integrity: sha512-q3s6pPq8H2buGp+tPuIRInWsYOuhSEwuNJPwd2YnsiID3YSLihn2ug39ktDJAcSOprUcp7Nid8WK7hKqnUmSdA==} engines: {node: '>=15.10.0'} - '@aptos-labs/ts-sdk@1.16.0': - resolution: {integrity: sha512-NqJDx39sHN0o7BpxpQzishoZjGBzvXqSVxO+bRm6OPP/Oe+Kb51R5x8dWvW9i3amO3QNdocg/p4jFRCwzqy2Gg==} + '@aptos-labs/ts-sdk@1.17.0': + resolution: {integrity: sha512-+fXNvz4kchZFZRT2qXOy47U5F8C8+Pi1J0iVgrs8CBiUay5rF/aycRX9RqukqMVgXD0pWA7kLFJsPGKDTH57dg==} engines: {node: '>=11.0.0'} '@aptos-labs/wallet-adapter-core@0.1.7': @@ -280,19 +289,28 @@ packages: '@aptos-labs/ts-sdk': ^1.13.2 aptos: ^1.21.0 - '@aptos-labs/wallet-adapter-react@2.5.1': - resolution: {integrity: sha512-zNbFRuQx/wq8bYBBJGLoHwTgXLRPJnJeDcXz91VagfqzZU47vp9uGl7BAtWJkZKZ0ZBLz3m/HvmAXYuVFGXbnw==} + '@aptos-labs/wallet-adapter-core@4.1.1': + resolution: {integrity: sha512-d08hnAhURSiMHuNTPrxtpQAkIeGJzikmr/ZD95rkZAUzWBsVYWRP8i+e0rOrt4whw1Zt8EwrVFq3rNzRfd0FVg==} + peerDependencies: + '@aptos-labs/ts-sdk': ^1.13.2 + aptos: ^1.21.0 + + '@aptos-labs/wallet-adapter-react@3.0.2': + resolution: {integrity: sha512-DAoobE/m2trpSzOcUbQkZZSNd4Jb3rL//GCl3lteiX7wje9aWaHrEvNA7BYfhlmJ5jP2kiLWthcTVbSTZdJ15g==} peerDependencies: react: ^18 '@aptos-labs/wallet-standard@0.0.11': resolution: {integrity: sha512-8dygyPBby7TaMJjUSyeVP4R1WC9D/FPpX9gVMMLaqTKCXrSbkzhGDxcuwbMZ3ziEwRmx3zz+d6BIJbDhd0hm5g==} - '@aptos-labs/wallet-standard@0.0.12': - resolution: {integrity: sha512-j6A8rHds/ueoFBJ1pjRZq9nKIfWrDV9/URH9VgUpVKY7ASi7frn7XAZgoYFRAYyk57m5er3kcXciD4BFpxwbMw==} + '@aptos-labs/wallet-standard@0.0.13': + resolution: {integrity: sha512-9w/eY84sQMGiNASe1DUlbIgu8yK9kDhEgLFS+XxdSJgDaOeELYjbeloyy8arwp5JAygpd2hnrZGqmliTRwpAxw==} + peerDependencies: + '@aptos-labs/ts-sdk': ^1.16.0 + '@wallet-standard/core': ^1.0.3 - '@atomrigslab/aptos-wallet-adapter@0.1.10': - resolution: {integrity: sha512-NdWVIuotp8g0hrbfSqeEUptSLJrHEGIhkk/xx0InE0k+k5BzNsmV2fTaMCuGsQeTEiNY/pyPj2tvMoJ4ux4kmg==} + '@atomrigslab/aptos-wallet-adapter@0.1.11': + resolution: {integrity: sha512-3Uu1QglYkrEaOf9bQv+NRZq4fhLdeL4gaxKuPbCqyZopVP5V6rjlQbhtqZHFEe/Fma3dMfblkdWr429ABRSHpA==} peerDependencies: '@aptos-labs/ts-sdk': ^1.9.0 @@ -678,8 +696,8 @@ packages: react: ^18 react-dom: ^18 - '@headlessui/tailwindcss@0.2.0': - resolution: {integrity: sha512-fpL830Fln1SykOCboExsWr3JIVeQKieLJ3XytLe/tt1A0XzqUthOftDmjcCYLW62w7mQI7wXcoPXr3tZ9QfGxw==} + '@headlessui/tailwindcss@0.2.1': + resolution: {integrity: sha512-2+5+NZ+RzMyrVeCZOxdbvkUSssSxGvcUxphkIfSVLpRiKsj+/63T2TOL9dBYMXVfj/CGr6hMxSRInzXv6YY7sA==} engines: {node: '>=10'} peerDependencies: tailwindcss: ^3.0 @@ -1020,12 +1038,15 @@ packages: resolution: {integrity: sha512-1ibVeYUacxWYi9i0cf5efil6adJ9WRyZBLivgjs+AUpewx1F3xPi7gLgaASI2SmIQxPoCEjAsLAzKPgMJVgOUQ==} engines: {node: 4.x || >=6.0.0} - '@supabase/postgrest-js@1.15.4': - resolution: {integrity: sha512-Zjj3j5hVmerQRGnlo/Y9jqn7sdqRkiXf23oy5tGT5zi1jwyUDkj9vkydalY3nkgLgcBnVJDaNGzeBDr6Zn3/XQ==} + '@supabase/postgrest-js@1.15.5': + resolution: {integrity: sha512-YR4TiitTE2hizT7mB99Cl3V9i00RAY5sUxS2/NuWWzkreM7OeYlP2OqnqVwwb4z6ILn+j8x9e/igJDepFhjswQ==} '@swc/counter@0.1.3': resolution: {integrity: sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==} + '@swc/helpers@0.5.11': + resolution: {integrity: sha512-YNlnKRWF2sVojTpIyzwou9XoTNbzbzONwRhOoniEioF1AtaitTvVZblaQRrAzChWQ1bLYyYSWzM18y4WwgzJ+A==} + '@swc/helpers@0.5.5': resolution: {integrity: sha512-KGYxvIOXcceOAbEk4bi/dVLEK9z8sZ0uBB3Il5b1rhfClSpcX0yfRO0KmTkqR2cnQDymwLB+25ZyMzICg/cm/A==} @@ -1114,8 +1135,8 @@ packages: '@types/lodash@4.17.4': resolution: {integrity: sha512-wYCP26ZLxaT3R39kiN2+HcJ4kTd3U1waI/cY7ivWYqFP6pW3ZNpvi6Wd6PHZx7T/t8z0vlkXMg3QYLa7DZ/IJQ==} - '@types/node@20.12.12': - resolution: {integrity: sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw==} + '@types/node@20.12.13': + resolution: {integrity: sha512-gBGeanV41c1L171rR7wjbMiEpEI/l5XFQdLLfhr/REwpgDy/4U8y89+i8kRiLzDyZdOkXh+cRaTetUnCYutoXA==} '@types/prop-types@15.7.12': resolution: {integrity: sha512-5zvhXYtRNRluoE/jAp4GVsSduVUzNWKkOZrCDBWYtE7biZywwdC2AcEzg+cSMLFRfVgeAFqpfNabiPjxFddV1Q==} @@ -1526,8 +1547,8 @@ packages: camelize@1.0.1: resolution: {integrity: sha512-dU+Tx2fsypxTgtLoE36npi3UqcjSSMNYfkqgmoEhtZrraP5VWq0K7FkWVTYa8eMPtnU/G2txVsfdCJTn9uzpuQ==} - caniuse-lite@1.0.30001624: - resolution: {integrity: sha512-0dWnQG87UevOCPYaOR49CBcLBwoZLpws+k6W37nLjWUhumP1Isusj0p2u+3KhjNloRWK9OKMgjBBzPujQHw4nA==} + caniuse-lite@1.0.30001625: + resolution: {integrity: sha512-4KE9N2gcRH+HQhpeiRZXd+1niLB/XNLAhSy4z7fI8EzcbcPoAqjNInxVHTiTwWfTIV4w096XG8OtCOCQQKPv3w==} chalk@2.4.2: resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==} @@ -1748,6 +1769,14 @@ packages: resolution: {integrity: sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==} engines: {node: '>=6.0.0'} + dotenv-cli@7.4.2: + resolution: {integrity: sha512-SbUj8l61zIbzyhIbg0FwPJq6+wjbzdn9oEtozQpZ6kW2ihCcapKVZj49oCT3oPM+mgQm+itgvUQcG5szxVrZTA==} + hasBin: true + + dotenv-expand@10.0.0: + resolution: {integrity: sha512-GopVGCpVS1UKH75VKHGuQFqS1Gusej0z4FyQkPdwjil2gNIv+LNsqBlboOzpJFZKVT95GkCyWJbBSdFEFUWI2A==} + engines: {node: '>=12'} + dotenv@16.4.5: resolution: {integrity: sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==} engines: {node: '>=12'} @@ -1755,8 +1784,8 @@ packages: eastasianwidth@0.2.0: resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} - electron-to-chromium@1.4.783: - resolution: {integrity: sha512-bT0jEz/Xz1fahQpbZ1D7LgmPYZ3iHVY39NcWWro1+hA2IvjiPeaXtfSqrQ+nXjApMvQRE2ASt1itSLRrebHMRQ==} + electron-to-chromium@1.4.787: + resolution: {integrity: sha512-d0EFmtLPjctczO3LogReyM2pbBiiZbnsKnGF+cdZhsYzHm/A0GV7W94kqzLD8SN4O3f3iHlgLUChqghgyznvCQ==} emittery@0.13.1: resolution: {integrity: sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ==} @@ -2167,6 +2196,11 @@ packages: engines: {node: '>=16 || 14 >=14.17'} hasBin: true + glob@10.4.1: + resolution: {integrity: sha512-2jelhlq3E4ho74ZyVLN03oKdAZVUa6UDZzFLVH1H7dnoax+y9qyaq8zBkfDIggjniU19z0wU18y16jMB2eyVIw==} + engines: {node: '>=16 || 14 >=14.18'} + hasBin: true + glob@7.2.3: resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} deprecated: Glob versions prior to v9 are no longer supported @@ -2440,6 +2474,10 @@ packages: resolution: {integrity: sha512-N3yCS/NegsOBokc8GAdM8UcmfsKiSS8cipheD/nivzr700H+nsMOxJjQnvwOcRYVuFkdH0wGUvW2WbXGmrZGbQ==} engines: {node: '>=14'} + jackspeak@3.1.2: + resolution: {integrity: sha512-kWmLKn2tRtfYMF/BakihVVRzBKOxz4gJMiL2Rj91WnAB5TPZumSH99R/Yf1qE1u4uRimvCSJfm6hnxohXeEXjQ==} + engines: {node: '>=14'} + jest-changed-files@29.7.0: resolution: {integrity: sha512-fEArFiwf1BpQ+4bXSprcDc3/x4HSzL4al2tozwVpDFpsxALjLYdyiIK4e5Vz66GQJIbXJ82+35PtysofptNX2w==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} @@ -3201,6 +3239,9 @@ packages: engines: {node: '>=10'} hasBin: true + server-only@0.0.1: + resolution: {integrity: sha512-qepMx2JxAa5jjfzxG79yPPq+8BuFToHd1hm7kI+Z4zAq1ftQiP7HcxMhDDItrbtwVeLg/cY2JnKnrcFkmiswNA==} + set-function-length@1.2.2: resolution: {integrity: sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==} engines: {node: '>= 0.4'} @@ -3725,7 +3766,7 @@ snapshots: transitivePeerDependencies: - debug - '@aptos-labs/ts-sdk@1.16.0': + '@aptos-labs/ts-sdk@1.17.0': dependencies: '@aptos-labs/aptos-cli': 0.1.8 '@aptos-labs/aptos-client': 0.1.0 @@ -3763,48 +3804,61 @@ snapshots: transitivePeerDependencies: - debug - '@aptos-labs/wallet-adapter-core@3.16.0(@aptos-labs/ts-sdk@1.16.0)(aptos@1.21.0)': + '@aptos-labs/wallet-adapter-core@3.16.0(@aptos-labs/ts-sdk@1.17.0)(@wallet-standard/core@1.0.3)(aptos@1.21.0)': dependencies: - '@aptos-labs/ts-sdk': 1.16.0 + '@aptos-labs/ts-sdk': 1.17.0 '@aptos-labs/wallet-standard': 0.0.11 - '@atomrigslab/aptos-wallet-adapter': 0.1.10(@aptos-labs/ts-sdk@1.16.0) + '@atomrigslab/aptos-wallet-adapter': 0.1.11(@aptos-labs/ts-sdk@1.17.0)(@wallet-standard/core@1.0.3) aptos: 1.21.0 buffer: 6.0.3 eventemitter3: 4.0.7 tweetnacl: 1.0.3 transitivePeerDependencies: + - '@wallet-standard/core' - debug - '@aptos-labs/wallet-adapter-react@2.5.1(@aptos-labs/ts-sdk@1.16.0)(aptos@1.21.0)(react@18.3.1)': + '@aptos-labs/wallet-adapter-core@4.1.1(@aptos-labs/ts-sdk@1.17.0)(@wallet-standard/core@1.0.3)(aptos@1.21.0)': dependencies: - '@aptos-labs/wallet-adapter-core': 3.16.0(@aptos-labs/ts-sdk@1.16.0)(aptos@1.21.0) + '@aptos-labs/ts-sdk': 1.17.0 + '@aptos-labs/wallet-standard': 0.0.11 + '@atomrigslab/aptos-wallet-adapter': 0.1.11(@aptos-labs/ts-sdk@1.17.0)(@wallet-standard/core@1.0.3) + aptos: 1.21.0 + buffer: 6.0.3 + eventemitter3: 4.0.7 + tweetnacl: 1.0.3 + transitivePeerDependencies: + - '@wallet-standard/core' + - debug + + '@aptos-labs/wallet-adapter-react@3.0.2(@aptos-labs/ts-sdk@1.17.0)(@wallet-standard/core@1.0.3)(aptos@1.21.0)(react@18.3.1)': + dependencies: + '@aptos-labs/wallet-adapter-core': 4.1.1(@aptos-labs/ts-sdk@1.17.0)(@wallet-standard/core@1.0.3)(aptos@1.21.0) react: 18.3.1 transitivePeerDependencies: - '@aptos-labs/ts-sdk' + - '@wallet-standard/core' - aptos - debug '@aptos-labs/wallet-standard@0.0.11': dependencies: - '@aptos-labs/ts-sdk': 1.16.0 + '@aptos-labs/ts-sdk': 1.17.0 '@wallet-standard/core': 1.0.3 transitivePeerDependencies: - debug - '@aptos-labs/wallet-standard@0.0.12': + '@aptos-labs/wallet-standard@0.0.13(@aptos-labs/ts-sdk@1.17.0)(@wallet-standard/core@1.0.3)': dependencies: - '@aptos-labs/ts-sdk': 1.16.0 + '@aptos-labs/ts-sdk': 1.17.0 '@wallet-standard/core': 1.0.3 - transitivePeerDependencies: - - debug - '@atomrigslab/aptos-wallet-adapter@0.1.10(@aptos-labs/ts-sdk@1.16.0)': + '@atomrigslab/aptos-wallet-adapter@0.1.11(@aptos-labs/ts-sdk@1.17.0)(@wallet-standard/core@1.0.3)': dependencies: - '@aptos-labs/ts-sdk': 1.16.0 - '@aptos-labs/wallet-standard': 0.0.12 + '@aptos-labs/ts-sdk': 1.17.0 + '@aptos-labs/wallet-standard': 0.0.13(@aptos-labs/ts-sdk@1.17.0)(@wallet-standard/core@1.0.3) '@atomrigslab/dekey-web-wallet-provider': 1.2.0 transitivePeerDependencies: - - debug + - '@wallet-standard/core' '@atomrigslab/dekey-web-wallet-provider@1.2.0': dependencies: @@ -4172,9 +4226,9 @@ snapshots: react: 18.3.1 react-dom: 18.3.1(react@18.3.1) - '@headlessui/tailwindcss@0.2.0(tailwindcss@3.4.3(ts-node@10.9.2(@types/node@20.12.12)(typescript@5.3.3)))': + '@headlessui/tailwindcss@0.2.1(tailwindcss@3.4.3(ts-node@10.9.2(@types/node@20.12.13)(typescript@5.3.3)))': dependencies: - tailwindcss: 3.4.3(ts-node@10.9.2(@types/node@20.12.12)(typescript@5.3.3)) + tailwindcss: 3.4.3(ts-node@10.9.2(@types/node@20.12.13)(typescript@5.3.3)) '@humanwhocodes/config-array@0.11.14': dependencies: @@ -4210,27 +4264,27 @@ snapshots: '@jest/console@29.7.0': dependencies: '@jest/types': 29.6.3 - '@types/node': 20.12.12 + '@types/node': 20.12.13 chalk: 4.1.2 jest-message-util: 29.7.0 jest-util: 29.7.0 slash: 3.0.0 - '@jest/core@29.7.0(ts-node@10.9.2(@types/node@20.12.12)(typescript@5.3.3))': + '@jest/core@29.7.0(ts-node@10.9.2(@types/node@20.12.13)(typescript@5.3.3))': dependencies: '@jest/console': 29.7.0 '@jest/reporters': 29.7.0 '@jest/test-result': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.12.12 + '@types/node': 20.12.13 ansi-escapes: 4.3.2 chalk: 4.1.2 ci-info: 3.9.0 exit: 0.1.2 graceful-fs: 4.2.11 jest-changed-files: 29.7.0 - jest-config: 29.7.0(@types/node@20.12.12)(ts-node@10.9.2(@types/node@20.12.12)(typescript@5.3.3)) + jest-config: 29.7.0(@types/node@20.12.13)(ts-node@10.9.2(@types/node@20.12.13)(typescript@5.3.3)) jest-haste-map: 29.7.0 jest-message-util: 29.7.0 jest-regex-util: 29.6.3 @@ -4255,7 +4309,7 @@ snapshots: dependencies: '@jest/fake-timers': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.12.12 + '@types/node': 20.12.13 jest-mock: 29.7.0 '@jest/expect-utils@29.7.0': @@ -4273,7 +4327,7 @@ snapshots: dependencies: '@jest/types': 29.6.3 '@sinonjs/fake-timers': 10.3.0 - '@types/node': 20.12.12 + '@types/node': 20.12.13 jest-message-util: 29.7.0 jest-mock: 29.7.0 jest-util: 29.7.0 @@ -4295,7 +4349,7 @@ snapshots: '@jest/transform': 29.7.0 '@jest/types': 29.6.3 '@jridgewell/trace-mapping': 0.3.25 - '@types/node': 20.12.12 + '@types/node': 20.12.13 chalk: 4.1.2 collect-v8-coverage: 1.0.2 exit: 0.1.2 @@ -4365,7 +4419,7 @@ snapshots: '@jest/schemas': 29.6.3 '@types/istanbul-lib-coverage': 2.0.6 '@types/istanbul-reports': 3.0.4 - '@types/node': 20.12.12 + '@types/node': 20.12.13 '@types/yargs': 17.0.32 chalk: 4.1.2 @@ -4480,7 +4534,7 @@ snapshots: '@react-aria/interactions': 3.21.3(react@18.3.1) '@react-aria/utils': 3.24.1(react@18.3.1) '@react-types/shared': 3.23.1(react@18.3.1) - '@swc/helpers': 0.5.5 + '@swc/helpers': 0.5.11 clsx: 2.1.1 react: 18.3.1 @@ -4489,12 +4543,12 @@ snapshots: '@react-aria/ssr': 3.9.4(react@18.3.1) '@react-aria/utils': 3.24.1(react@18.3.1) '@react-types/shared': 3.23.1(react@18.3.1) - '@swc/helpers': 0.5.5 + '@swc/helpers': 0.5.11 react: 18.3.1 '@react-aria/ssr@3.9.4(react@18.3.1)': dependencies: - '@swc/helpers': 0.5.5 + '@swc/helpers': 0.5.11 react: 18.3.1 '@react-aria/utils@3.24.1(react@18.3.1)': @@ -4502,13 +4556,13 @@ snapshots: '@react-aria/ssr': 3.9.4(react@18.3.1) '@react-stately/utils': 3.10.1(react@18.3.1) '@react-types/shared': 3.23.1(react@18.3.1) - '@swc/helpers': 0.5.5 + '@swc/helpers': 0.5.11 clsx: 2.1.1 react: 18.3.1 '@react-stately/utils@3.10.1(react@18.3.1)': dependencies: - '@swc/helpers': 0.5.5 + '@swc/helpers': 0.5.11 react: 18.3.1 '@react-types/shared@3.23.1(react@18.3.1)': @@ -4621,12 +4675,16 @@ snapshots: dependencies: whatwg-url: 5.0.0 - '@supabase/postgrest-js@1.15.4': + '@supabase/postgrest-js@1.15.5': dependencies: '@supabase/node-fetch': 2.6.15 '@swc/counter@0.1.3': {} + '@swc/helpers@0.5.11': + dependencies: + tslib: 2.6.2 + '@swc/helpers@0.5.5': dependencies: '@swc/counter': 0.1.3 @@ -4677,7 +4735,7 @@ snapshots: dependencies: '@types/http-cache-semantics': 4.0.4 '@types/keyv': 3.1.4 - '@types/node': 20.12.12 + '@types/node': 20.12.13 '@types/responselike': 1.0.3 '@types/chrome@0.0.136': @@ -4693,7 +4751,7 @@ snapshots: '@types/graceful-fs@4.1.9': dependencies: - '@types/node': 20.12.12 + '@types/node': 20.12.13 '@types/har-format@1.2.15': {} @@ -4725,11 +4783,11 @@ snapshots: '@types/keyv@3.1.4': dependencies: - '@types/node': 20.12.12 + '@types/node': 20.12.13 '@types/lodash@4.17.4': {} - '@types/node@20.12.12': + '@types/node@20.12.13': dependencies: undici-types: 5.26.5 @@ -4750,7 +4808,7 @@ snapshots: '@types/responselike@1.0.3': dependencies: - '@types/node': 20.12.12 + '@types/node': 20.12.13 '@types/semver@7.5.8': {} @@ -5108,7 +5166,7 @@ snapshots: autoprefixer@10.4.19(postcss@8.4.38): dependencies: browserslist: 4.23.0 - caniuse-lite: 1.0.30001624 + caniuse-lite: 1.0.30001625 fraction.js: 4.3.7 normalize-range: 0.1.2 picocolors: 1.0.1 @@ -5206,8 +5264,8 @@ snapshots: browserslist@4.23.0: dependencies: - caniuse-lite: 1.0.30001624 - electron-to-chromium: 1.4.783 + caniuse-lite: 1.0.30001625 + electron-to-chromium: 1.4.787 node-releases: 2.0.14 update-browserslist-db: 1.0.16(browserslist@4.23.0) @@ -5260,7 +5318,7 @@ snapshots: camelize@1.0.1: {} - caniuse-lite@1.0.30001624: {} + caniuse-lite@1.0.30001625: {} chalk@2.4.2: dependencies: @@ -5337,13 +5395,13 @@ snapshots: core-util-is@1.0.3: {} - create-jest@29.7.0(@types/node@20.12.12)(ts-node@10.9.2(@types/node@20.12.12)(typescript@5.3.3)): + create-jest@29.7.0(@types/node@20.12.13)(ts-node@10.9.2(@types/node@20.12.13)(typescript@5.3.3)): dependencies: '@jest/types': 29.6.3 chalk: 4.1.2 exit: 0.1.2 graceful-fs: 4.2.11 - jest-config: 29.7.0(@types/node@20.12.12)(ts-node@10.9.2(@types/node@20.12.12)(typescript@5.3.3)) + jest-config: 29.7.0(@types/node@20.12.13)(ts-node@10.9.2(@types/node@20.12.13)(typescript@5.3.3)) jest-util: 29.7.0 prompts: 2.4.2 transitivePeerDependencies: @@ -5456,11 +5514,20 @@ snapshots: dependencies: esutils: 2.0.3 + dotenv-cli@7.4.2: + dependencies: + cross-spawn: 7.0.3 + dotenv: 16.4.5 + dotenv-expand: 10.0.0 + minimist: 1.2.8 + + dotenv-expand@10.0.0: {} + dotenv@16.4.5: {} eastasianwidth@0.2.0: {} - electron-to-chromium@1.4.783: {} + electron-to-chromium@1.4.787: {} emittery@0.13.1: {} @@ -6093,6 +6160,14 @@ snapshots: minipass: 7.1.2 path-scurry: 1.11.1 + glob@10.4.1: + dependencies: + foreground-child: 3.1.1 + jackspeak: 3.1.2 + minimatch: 9.0.4 + minipass: 7.1.2 + path-scurry: 1.11.1 + glob@7.2.3: dependencies: fs.realpath: 1.0.0 @@ -6377,6 +6452,12 @@ snapshots: optionalDependencies: '@pkgjs/parseargs': 0.11.0 + jackspeak@3.1.2: + dependencies: + '@isaacs/cliui': 8.0.2 + optionalDependencies: + '@pkgjs/parseargs': 0.11.0 + jest-changed-files@29.7.0: dependencies: execa: 5.1.1 @@ -6389,7 +6470,7 @@ snapshots: '@jest/expect': 29.7.0 '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.12.12 + '@types/node': 20.12.13 chalk: 4.1.2 co: 4.6.0 dedent: 1.5.3 @@ -6409,16 +6490,16 @@ snapshots: - babel-plugin-macros - supports-color - jest-cli@29.7.0(@types/node@20.12.12)(ts-node@10.9.2(@types/node@20.12.12)(typescript@5.3.3)): + jest-cli@29.7.0(@types/node@20.12.13)(ts-node@10.9.2(@types/node@20.12.13)(typescript@5.3.3)): dependencies: - '@jest/core': 29.7.0(ts-node@10.9.2(@types/node@20.12.12)(typescript@5.3.3)) + '@jest/core': 29.7.0(ts-node@10.9.2(@types/node@20.12.13)(typescript@5.3.3)) '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 chalk: 4.1.2 - create-jest: 29.7.0(@types/node@20.12.12)(ts-node@10.9.2(@types/node@20.12.12)(typescript@5.3.3)) + create-jest: 29.7.0(@types/node@20.12.13)(ts-node@10.9.2(@types/node@20.12.13)(typescript@5.3.3)) exit: 0.1.2 import-local: 3.1.0 - jest-config: 29.7.0(@types/node@20.12.12)(ts-node@10.9.2(@types/node@20.12.12)(typescript@5.3.3)) + jest-config: 29.7.0(@types/node@20.12.13)(ts-node@10.9.2(@types/node@20.12.13)(typescript@5.3.3)) jest-util: 29.7.0 jest-validate: 29.7.0 yargs: 17.7.2 @@ -6428,7 +6509,7 @@ snapshots: - supports-color - ts-node - jest-config@29.7.0(@types/node@20.12.12)(ts-node@10.9.2(@types/node@20.12.12)(typescript@5.3.3)): + jest-config@29.7.0(@types/node@20.12.13)(ts-node@10.9.2(@types/node@20.12.13)(typescript@5.3.3)): dependencies: '@babel/core': 7.24.6 '@jest/test-sequencer': 29.7.0 @@ -6453,8 +6534,8 @@ snapshots: slash: 3.0.0 strip-json-comments: 3.1.1 optionalDependencies: - '@types/node': 20.12.12 - ts-node: 10.9.2(@types/node@20.12.12)(typescript@5.3.3) + '@types/node': 20.12.13 + ts-node: 10.9.2(@types/node@20.12.13)(typescript@5.3.3) transitivePeerDependencies: - babel-plugin-macros - supports-color @@ -6483,7 +6564,7 @@ snapshots: '@jest/environment': 29.7.0 '@jest/fake-timers': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.12.12 + '@types/node': 20.12.13 jest-mock: 29.7.0 jest-util: 29.7.0 @@ -6493,7 +6574,7 @@ snapshots: dependencies: '@jest/types': 29.6.3 '@types/graceful-fs': 4.1.9 - '@types/node': 20.12.12 + '@types/node': 20.12.13 anymatch: 3.1.3 fb-watchman: 2.0.2 graceful-fs: 4.2.11 @@ -6532,7 +6613,7 @@ snapshots: jest-mock@29.7.0: dependencies: '@jest/types': 29.6.3 - '@types/node': 20.12.12 + '@types/node': 20.12.13 jest-util: 29.7.0 jest-pnp-resolver@1.2.3(jest-resolve@29.7.0): @@ -6567,7 +6648,7 @@ snapshots: '@jest/test-result': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.12.12 + '@types/node': 20.12.13 chalk: 4.1.2 emittery: 0.13.1 graceful-fs: 4.2.11 @@ -6595,7 +6676,7 @@ snapshots: '@jest/test-result': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.12.12 + '@types/node': 20.12.13 chalk: 4.1.2 cjs-module-lexer: 1.3.1 collect-v8-coverage: 1.0.2 @@ -6641,7 +6722,7 @@ snapshots: jest-util@29.7.0: dependencies: '@jest/types': 29.6.3 - '@types/node': 20.12.12 + '@types/node': 20.12.13 chalk: 4.1.2 ci-info: 3.9.0 graceful-fs: 4.2.11 @@ -6660,7 +6741,7 @@ snapshots: dependencies: '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.12.12 + '@types/node': 20.12.13 ansi-escapes: 4.3.2 chalk: 4.1.2 emittery: 0.13.1 @@ -6669,17 +6750,17 @@ snapshots: jest-worker@29.7.0: dependencies: - '@types/node': 20.12.12 + '@types/node': 20.12.13 jest-util: 29.7.0 merge-stream: 2.0.0 supports-color: 8.1.1 - jest@29.7.0(@types/node@20.12.12)(ts-node@10.9.2(@types/node@20.12.12)(typescript@5.3.3)): + jest@29.7.0(@types/node@20.12.13)(ts-node@10.9.2(@types/node@20.12.13)(typescript@5.3.3)): dependencies: - '@jest/core': 29.7.0(ts-node@10.9.2(@types/node@20.12.12)(typescript@5.3.3)) + '@jest/core': 29.7.0(ts-node@10.9.2(@types/node@20.12.13)(typescript@5.3.3)) '@jest/types': 29.6.3 import-local: 3.1.0 - jest-cli: 29.7.0(@types/node@20.12.12)(ts-node@10.9.2(@types/node@20.12.12)(typescript@5.3.3)) + jest-cli: 29.7.0(@types/node@20.12.13)(ts-node@10.9.2(@types/node@20.12.13)(typescript@5.3.3)) transitivePeerDependencies: - '@types/node' - babel-plugin-macros @@ -6847,7 +6928,7 @@ snapshots: '@next/env': 14.2.3 '@swc/helpers': 0.5.5 busboy: 1.6.0 - caniuse-lite: 1.0.30001624 + caniuse-lite: 1.0.30001625 graceful-fs: 4.2.11 postcss: 8.4.31 react: 18.3.1 @@ -6990,12 +7071,13 @@ snapshots: path-type@4.0.0: {} - petra-plugin-wallet-adapter@0.4.5(@aptos-labs/ts-sdk@1.16.0)(aptos@1.21.0): + petra-plugin-wallet-adapter@0.4.5(@aptos-labs/ts-sdk@1.17.0)(@wallet-standard/core@1.0.3)(aptos@1.21.0): dependencies: - '@aptos-labs/ts-sdk': 1.16.0 - '@aptos-labs/wallet-adapter-core': 3.16.0(@aptos-labs/ts-sdk@1.16.0)(aptos@1.21.0) + '@aptos-labs/ts-sdk': 1.17.0 + '@aptos-labs/wallet-adapter-core': 3.16.0(@aptos-labs/ts-sdk@1.17.0)(@wallet-standard/core@1.0.3)(aptos@1.21.0) aptos: 1.21.0 transitivePeerDependencies: + - '@wallet-standard/core' - debug picocolors@1.0.1: {} @@ -7024,13 +7106,13 @@ snapshots: camelcase-css: 2.0.1 postcss: 8.4.38 - postcss-load-config@4.0.2(postcss@8.4.38)(ts-node@10.9.2(@types/node@20.12.12)(typescript@5.3.3)): + postcss-load-config@4.0.2(postcss@8.4.38)(ts-node@10.9.2(@types/node@20.12.13)(typescript@5.3.3)): dependencies: lilconfig: 3.1.1 yaml: 2.4.2 optionalDependencies: postcss: 8.4.38 - ts-node: 10.9.2(@types/node@20.12.12)(typescript@5.3.3) + ts-node: 10.9.2(@types/node@20.12.13)(typescript@5.3.3) postcss-nested@6.0.1(postcss@8.4.38): dependencies: @@ -7268,6 +7350,8 @@ snapshots: semver@7.6.2: {} + server-only@0.0.1: {} + set-function-length@1.2.2: dependencies: define-data-property: 1.1.4 @@ -7454,7 +7538,7 @@ snapshots: dependencies: '@jridgewell/gen-mapping': 0.3.5 commander: 4.1.1 - glob: 10.3.10 + glob: 10.4.1 lines-and-columns: 1.2.4 mz: 2.7.0 pirates: 4.0.6 @@ -7476,7 +7560,7 @@ snapshots: tabbable@6.2.0: {} - tailwindcss@3.4.3(ts-node@10.9.2(@types/node@20.12.12)(typescript@5.3.3)): + tailwindcss@3.4.3(ts-node@10.9.2(@types/node@20.12.13)(typescript@5.3.3)): dependencies: '@alloc/quick-lru': 5.2.0 arg: 5.0.2 @@ -7495,7 +7579,7 @@ snapshots: postcss: 8.4.38 postcss-import: 15.1.0(postcss@8.4.38) postcss-js: 4.0.1(postcss@8.4.38) - postcss-load-config: 4.0.2(postcss@8.4.38)(ts-node@10.9.2(@types/node@20.12.12)(typescript@5.3.3)) + postcss-load-config: 4.0.2(postcss@8.4.38)(ts-node@10.9.2(@types/node@20.12.13)(typescript@5.3.3)) postcss-nested: 6.0.1(postcss@8.4.38) postcss-selector-parser: 6.1.0 resolve: 1.22.8 @@ -7547,11 +7631,11 @@ snapshots: ts-interface-checker@0.1.13: {} - ts-jest@29.1.4(@babel/core@7.24.6)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.24.6))(jest@29.7.0(@types/node@20.12.12)(ts-node@10.9.2(@types/node@20.12.12)(typescript@5.3.3)))(typescript@5.3.3): + ts-jest@29.1.4(@babel/core@7.24.6)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.24.6))(jest@29.7.0(@types/node@20.12.13)(ts-node@10.9.2(@types/node@20.12.13)(typescript@5.3.3)))(typescript@5.3.3): dependencies: bs-logger: 0.2.6 fast-json-stable-stringify: 2.1.0 - jest: 29.7.0(@types/node@20.12.12)(ts-node@10.9.2(@types/node@20.12.12)(typescript@5.3.3)) + jest: 29.7.0(@types/node@20.12.13)(ts-node@10.9.2(@types/node@20.12.13)(typescript@5.3.3)) jest-util: 29.7.0 json5: 2.2.3 lodash.memoize: 4.1.2 @@ -7565,14 +7649,14 @@ snapshots: '@jest/types': 29.6.3 babel-jest: 29.7.0(@babel/core@7.24.6) - ts-node@10.9.2(@types/node@20.12.12)(typescript@5.3.3): + ts-node@10.9.2(@types/node@20.12.13)(typescript@5.3.3): dependencies: '@cspotcode/source-map-support': 0.8.1 '@tsconfig/node10': 1.0.11 '@tsconfig/node12': 1.0.11 '@tsconfig/node14': 1.0.3 '@tsconfig/node16': 1.0.4 - '@types/node': 20.12.12 + '@types/node': 20.12.13 acorn: 8.11.3 acorn-walk: 8.3.2 arg: 4.1.3 diff --git a/src/typescript/sdk/.env.example b/src/typescript/sdk/.env.example deleted file mode 100644 index e786a6a02..000000000 --- a/src/typescript/sdk/.env.example +++ /dev/null @@ -1,15 +0,0 @@ -# If want to run your own local node for e2e testing, you should set this to "false". -START_LOCAL_NODE_FOR_TEST="true" - -# The network to use for e2e testing; e.g. local, devnet, testnet, mainnet. -APTOS_NETWORK="local" - -# Generated randomly for testing purposes. -PUBLISHER_PK="29479e9e5fe47ba9a8af509dd6da1f907510bcf8917bfb19b7079d8c63c0b720" - -# Derived from `PUBLISHER_PK`. -MODULE_ADDRESS="4bab58978ec1b1bef032eeb285ad47a6a9b997d646c19b598c35f46b26ff9ece" - -# URL of the Inbox deployment -# Warning: no / at the end -INBOX_URL="http://localhost:3000" diff --git a/src/typescript/sdk/.eslintrc.js b/src/typescript/sdk/.eslintrc.js index a004fd9cb..97efc0d72 100644 --- a/src/typescript/sdk/.eslintrc.js +++ b/src/typescript/sdk/.eslintrc.js @@ -46,7 +46,7 @@ module.exports = { { missingExports: true, unusedExports: true, - ignoreExports: ["tests/**/*", "**/index.ts"], + ignoreExports: ["tests/**/*", "**/index.ts", "src/types/server-only.d.ts"], }, ], "@typescript-eslint/consistent-type-imports": [ diff --git a/src/typescript/sdk/.gitignore b/src/typescript/sdk/.gitignore index b0bfdb5e9..c97bd4551 100644 --- a/src/typescript/sdk/.gitignore +++ b/src/typescript/sdk/.gitignore @@ -1,6 +1,7 @@ .aptos/ .DS_Store */**/.DS_Store +.env*.local .env .history/ .idea/ diff --git a/src/typescript/sdk/jest.config.js b/src/typescript/sdk/jest.config.js index 44b93511b..0c31e528e 100644 --- a/src/typescript/sdk/jest.config.js +++ b/src/typescript/sdk/jest.config.js @@ -14,7 +14,6 @@ module.exports = { ], testPathIgnorePatterns: ["dist/*"], collectCoverage: false, - setupFiles: ["dotenv/config"], coverageThreshold: { global: { branches: 50, diff --git a/src/typescript/sdk/package.json b/src/typescript/sdk/package.json index 68875e63b..3b7573787 100644 --- a/src/typescript/sdk/package.json +++ b/src/typescript/sdk/package.json @@ -1,20 +1,21 @@ { "dependencies": { - "@aptos-labs/ts-sdk": "^1.16.0", + "@aptos-labs/ts-sdk": "^1.17.0", "@keyvhq/core": "^2.1.1", "@noble/hashes": "^1.4.0", "@supabase/postgrest-js": "^1.15.2", - "dotenv": "^16.4.5", "find-git-root": "^1.0.4", - "postgres": "^3.4.4" + "postgres": "^3.4.4", + "server-only": "^0.0.1" }, "description": "TypeScript SDK for Econia's Emojicoin Dot Fun", "devDependencies": { "@aptos-labs/aptos-cli": "^0.1.2", "@types/jest": "^29.5.12", - "@types/node": "^20.12.7", + "@types/node": "^20.12.13", "@typescript-eslint/eslint-plugin": "^6.14.0", "@typescript-eslint/parser": "^6.14.0", + "dotenv-cli": "^7.4.2", "eslint": "^8.55.0", "eslint-config-airbnb-base": "^15.0.0", "eslint-config-airbnb-typescript": "^17.1.0", @@ -43,21 +44,22 @@ "packageManager": "pnpm@9.1.1+sha512.14e915759c11f77eac07faba4d019c193ec8637229e62ec99eefb7cf3c3b75c64447882b7c485142451ee3a6b408059cdfb7b7fa0341b975f12d0f7629c71195", "scripts": { "_format": "prettier 'src/**/*.ts' 'tests/**/*.ts' '.eslintrc.js'", - "build": "pnpm clean && tsc", + "build": "tsc", + "build:clean": "pnpm run clean && pnpm i && tsc", "check": "tsc --noEmit", - "clean": "rm -rf dist", - "e2e-test": "pnpm jest tests/e2e", + "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist", + "e2e-test": "dotenv -e ../.env.test -- pnpm jest tests/e2e", "format": "pnpm _format --write", "format:check": "pnpm _format --check", - "generate-data": "pnpm tsx src/utils/mock-data.ts", + "generate-data": "dotenv -e ../.env.local -e ../.env -e ../.env.test -- pnpm tsx src/utils/mock-data.ts", "lint": "eslint 'src/**/*.ts' 'tests/**/*.ts' -c .eslintrc.js", "lint:fix": "pnpm lint --fix", - "mock-test": "pnpm jest tests/mock", + "mock-test": "dotenv -e ../.env.local -e ../.env -e ../.env.test -- pnpm jest tests/mock", "pre-commit": "pnpm run pre-commit:install && pnpm run pre-commit:run", "pre-commit:install": "pre-commit install -c ../../../cfg/pre-commit-config.yaml", "pre-commit:run": "pre-commit run --all-files -c ../../../cfg/pre-commit-config.yaml", - "test": "pnpm jest", - "unit-test": "NO_TEST_SETUP=true pnpm jest tests/unit" + "test": "dotenv -e ../.env.test -- pnpm jest", + "unit-test": "dotenv -v NO_TEST_SETUP=true -e ../.env.test -- pnpm jest tests/unit" }, "typings": "dist/src/index.d.ts", "version": "0.0.1" diff --git a/src/typescript/sdk/src/const.ts b/src/typescript/sdk/src/const.ts index 243b47922..15375c1ca 100644 --- a/src/typescript/sdk/src/const.ts +++ b/src/typescript/sdk/src/const.ts @@ -1,24 +1,20 @@ import { AccountAddress } from "@aptos-labs/ts-sdk"; -import dotenv from "dotenv"; -import path from "path"; -import { getGitRoot } from "./utils/git-root"; export const VERCEL = process.env.VERCEL === "1"; -if (!VERCEL && typeof process === "object" && process.title.endsWith("node")) { - const sdkPath = path.join(getGitRoot(), "src", "typescript", "sdk", ".env"); - dotenv.config({ path: sdkPath }); - const frontendPath = path.join(getGitRoot(), "src", "typescript", "frontend", ".env"); - dotenv.config({ path: frontendPath }); -} - if (!process.env.NEXT_PUBLIC_MODULE_ADDRESS) { - throw new Error("Missing NEXT_PUBLIC_MODULE_ADDRESS environment variable"); -} else if (!process.env.INBOX_URL) { - throw new Error("Missing INBOX_URL environment variable"); + let msg = `\n\n${"-".repeat(61)}\n\nMissing NEXT_PUBLIC_MODULE_ADDRESS environment variable\n`; + if (!VERCEL) { + msg += "Please run this project from the top-level, parent directory.\n"; + } + msg += `\n${"-".repeat(61)}\n`; + throw new Error(msg); +} +if (typeof window !== "undefined" && typeof process.env.INBOX_URL !== "undefined") { + throw new Error("The `inbox` endpoint should not be exposed to any client components."); } export const MODULE_ADDRESS = (() => AccountAddress.from(process.env.NEXT_PUBLIC_MODULE_ADDRESS))(); -export const INBOX_URL = process.env.INBOX_URL!; +export const LOCAL_INBOX_URL = process.env.INBOX_URL ?? "http://localhost:3000"; export const ONE_APT = 1 * 10 ** 8; export const ONE_APTN = BigInt(ONE_APT); export const MAX_GAS_FOR_PUBLISH = 1500000; diff --git a/src/typescript/sdk/src/emojicoin_dot_fun/payload-builders.ts b/src/typescript/sdk/src/emojicoin_dot_fun/payload-builders.ts index e5d11f390..d19cbdba8 100644 --- a/src/typescript/sdk/src/emojicoin_dot_fun/payload-builders.ts +++ b/src/typescript/sdk/src/emojicoin_dot_fun/payload-builders.ts @@ -24,6 +24,9 @@ import { MimeType, postAptosFullNode, type AptosConfig, + type InputGenerateTransactionOptions, + type InputGenerateTransactionPayloadData, + type AccountAddressInput, } from "@aptos-labs/ts-sdk"; import { type WalletSignTransactionFunction } from "."; import { toConfig } from "../utils/aptos-utils"; @@ -155,6 +158,13 @@ export class EntryFunctionTransactionBuilder { } } +/* eslint-disable-next-line import/no-unused-modules */ +export type WalletInputTransactionData = { + sender?: AccountAddressInput; + data: InputGenerateTransactionPayloadData; + options?: InputGenerateTransactionOptions; +}; + export abstract class EntryFunctionPayloadBuilder extends Serializable { public abstract readonly moduleAddress: AccountAddress; @@ -189,6 +199,30 @@ export abstract class EntryFunctionPayloadBuilder extends Serializable { return new TransactionPayloadEntryFunction(entryFunction); } + toInputPayload(args?: { + multisigAddress?: AccountAddress; + options?: InputGenerateTransactionOptions; + }): WalletInputTransactionData { + const { multisigAddress, options } = args ?? {}; + const multiSigData = + typeof multisigAddress !== "undefined" + ? { + multisigAddress, + } + : {}; + return { + sender: this.primarySender, + data: { + ...multiSigData, + function: `${this.moduleAddress.toString()}::${this.moduleName}::${this.functionName}`, + typeArguments: this.typeTags, + functionArguments: this.argsToArray(), + // abi: undefined, // TODO: Add pre-defined ABIs. + }, + options, + }; + } + argsToArray(): Array { return Object.keys(this.args).map((field) => this.args[field as keyof typeof this.args]); } diff --git a/src/typescript/sdk/src/queries/candlestick.ts b/src/typescript/sdk/src/queries/candlestick.ts index 8c3ce209d..5a3f322c3 100644 --- a/src/typescript/sdk/src/queries/candlestick.ts +++ b/src/typescript/sdk/src/queries/candlestick.ts @@ -1,7 +1,6 @@ -/* eslint-disable no-console */ -/* eslint-disable no-await-in-loop */ -import { PostgrestClient } from "@supabase/postgrest-js"; -import { type CandlestickResolution, INBOX_URL } from "../const"; +import "server-only"; + +import { type CandlestickResolution } from "../const"; import { TABLE_NAME, ORDER_BY } from "./const"; import { STRUCT_STRINGS } from "../utils"; import { wrap } from "./utils"; @@ -11,18 +10,18 @@ import { type EventsAndErrors, aggregateQueryResults, } from "./query-helper"; +import { postgrest } from "./inbox-url"; export type CandlestickQueryArgs = { marketID: bigint | number; resolution?: CandlestickResolution; - inboxUrl?: string; }; export const paginateCandlesticks = async ( args: CandlestickQueryArgs & Omit ): Promise> => { - const { marketID, resolution, inboxUrl = INBOX_URL } = args; - let query = new PostgrestClient(inboxUrl) + const { marketID, resolution } = args; + let query = postgrest .from(TABLE_NAME) .select("*") .filter("type", "eq", STRUCT_STRINGS.PeriodicStateEvent) diff --git a/src/typescript/sdk/src/queries/chat.ts b/src/typescript/sdk/src/queries/chat.ts index 396fef8c9..e54496d58 100644 --- a/src/typescript/sdk/src/queries/chat.ts +++ b/src/typescript/sdk/src/queries/chat.ts @@ -1,21 +1,21 @@ -import { PostgrestClient } from "@supabase/postgrest-js"; -import { INBOX_URL } from "../const"; +import "server-only"; + import { TABLE_NAME, ORDER_BY } from "./const"; import { STRUCT_STRINGS } from "../utils"; import { type JSONTypes } from "../types"; import { wrap } from "./utils"; import { type AggregateQueryResultsArgs, aggregateQueryResults } from "./query-helper"; +import { postgrest } from "./inbox-url"; export type ChatEventQueryArgs = { marketID: number | bigint; - inboxUrl?: string; }; export const paginateChatEvents = async ( args: ChatEventQueryArgs & Omit ) => { - const { marketID, inboxUrl = INBOX_URL } = args; - const query = new PostgrestClient(inboxUrl) + const { marketID } = args; + const query = postgrest .from(TABLE_NAME) .select("*") .filter("type", "eq", STRUCT_STRINGS.ChatEvent) diff --git a/src/typescript/sdk/src/queries/const.ts b/src/typescript/sdk/src/queries/const.ts index e4e6605d5..cadf12698 100644 --- a/src/typescript/sdk/src/queries/const.ts +++ b/src/typescript/sdk/src/queries/const.ts @@ -1,3 +1,5 @@ +import "server-only"; + export const TABLE_NAME = "inbox_events"; export const LIMIT = 100; export const ORDER_BY = { diff --git a/src/typescript/sdk/src/queries/inbox-url.ts b/src/typescript/sdk/src/queries/inbox-url.ts new file mode 100644 index 000000000..cfa1db1b1 --- /dev/null +++ b/src/typescript/sdk/src/queries/inbox-url.ts @@ -0,0 +1,8 @@ +import "server-only"; + +import { PostgrestClient } from "@supabase/postgrest-js"; + +if (!process.env.INBOX_URL) { + throw new Error("The `inbox` endpoint is not defined for server actions."); +} +export const postgrest = new PostgrestClient(process.env.INBOX_URL!); diff --git a/src/typescript/sdk/src/queries/index.ts b/src/typescript/sdk/src/queries/index.ts index b7dfef7dc..b268ee63b 100644 --- a/src/typescript/sdk/src/queries/index.ts +++ b/src/typescript/sdk/src/queries/index.ts @@ -1,3 +1,5 @@ +import "server-only"; + export * from "./const"; export * from "./utils"; export * from "./candlestick"; diff --git a/src/typescript/sdk/src/queries/liquidity.ts b/src/typescript/sdk/src/queries/liquidity.ts index 405f5aef5..32a9e957e 100644 --- a/src/typescript/sdk/src/queries/liquidity.ts +++ b/src/typescript/sdk/src/queries/liquidity.ts @@ -1,5 +1,5 @@ -import { PostgrestClient } from "@supabase/postgrest-js"; -import { INBOX_URL } from "../const"; +import "server-only"; + import { type ContractTypes, type JSONTypes, toLiquidityEvent } from "../types"; import { STRUCT_STRINGS } from "../utils"; import { TABLE_NAME, ORDER_BY } from "./const"; @@ -9,6 +9,7 @@ import { aggregateQueryResults, } from "./query-helper"; import { wrap } from "./utils"; +import { postgrest } from "./inbox-url"; export enum LiquidityEventType { Provide, @@ -19,14 +20,13 @@ export type LiquidityEventQueryArgs = { user?: string; marketID?: number | bigint; liquidityEventType?: LiquidityEventType; - inboxUrl?: string; }; export const paginateLiquidityEvents = async ( args: LiquidityEventQueryArgs & Omit ): Promise> => { - const { user, marketID, liquidityEventType, inboxUrl = INBOX_URL } = args; - let query = new PostgrestClient(inboxUrl) + const { user, marketID, liquidityEventType } = args; + let query = postgrest .from(TABLE_NAME) .select("*") .filter("type", "eq", STRUCT_STRINGS.LiquidityEvent) diff --git a/src/typescript/sdk/src/queries/market.ts b/src/typescript/sdk/src/queries/market.ts index e604cf200..49f44eb22 100644 --- a/src/typescript/sdk/src/queries/market.ts +++ b/src/typescript/sdk/src/queries/market.ts @@ -1,10 +1,12 @@ -import { PostgrestClient } from "@supabase/postgrest-js"; -import { INBOX_URL, MODULE_ADDRESS } from "../const"; +import "server-only"; + +import { MODULE_ADDRESS } from "../const"; import { SYMBOL_DATA, type SymbolEmojiData } from "../emoji_data"; import { TABLE_NAME, ORDER_BY } from "./const"; import { STRUCT_STRINGS } from "../utils"; import { type ContractTypes, type JSONTypes, toMarketRegistrationEvent } from "../types"; import { type AggregateQueryResultsArgs, aggregateQueryResults } from "./query-helper"; +import { postgrest } from "./inbox-url"; export type TopMarketsDataResponse = Array<{ data: JSONTypes.StateEvent; @@ -19,8 +21,7 @@ export type TopMarketsDataResponse = Array<{ * @param args * @returns */ -export const getTopMarkets = async (inboxUrl: string = INBOX_URL) => { - const postgrest = new PostgrestClient(inboxUrl); +export const getTopMarkets = async () => { const res = await postgrest .rpc("get_top_markets", { module_address: MODULE_ADDRESS.toString(), @@ -28,7 +29,12 @@ export const getTopMarkets = async (inboxUrl: string = INBOX_URL) => { .select("*"); const { data } = res; return { - data: data ? data.map((v) => ({ data: v.data, version: v.transaction_version })) : [], + data: data + ? data.map((v) => ({ + data: v.data as JSONTypes.StateEvent, + version: Number(v.transaction_version), + })) + : [], error: res.error, }; }; @@ -36,8 +42,6 @@ export const getTopMarkets = async (inboxUrl: string = INBOX_URL) => { export const paginateMarketRegistrations = async ( args?: Omit ) => { - const inboxUrl = args?.inboxUrl ?? INBOX_URL; - const postgrest = new PostgrestClient(inboxUrl); const res = await aggregateQueryResults({ ...args, query: postgrest diff --git a/src/typescript/sdk/src/queries/query-helper.ts b/src/typescript/sdk/src/queries/query-helper.ts index 46c71b2df..f952ebf8f 100644 --- a/src/typescript/sdk/src/queries/query-helper.ts +++ b/src/typescript/sdk/src/queries/query-helper.ts @@ -1,3 +1,5 @@ +import "server-only"; + import { type PostgrestError, type PostgrestFilterBuilder } from "@supabase/postgrest-js"; import { LIMIT, type TABLE_NAME } from "./const"; @@ -18,7 +20,6 @@ export type EventsAndErrors = { export type AggregateQueryResultsArgs = { query: PostgrestFilterBuilder; maxNumQueries?: number; - inboxUrl?: string; }; type InnerResponseType = Array<{ @@ -43,7 +44,7 @@ type InnerResponseType = Array<{ * */ export const aggregateQueryResults = async ( - args: Omit + args: AggregateQueryResultsArgs ): Promise> => { const { query, maxNumQueries = Infinity } = args; const aggregated: (T & { version: number })[] = []; diff --git a/src/typescript/sdk/src/queries/state.ts b/src/typescript/sdk/src/queries/state.ts index 163639fb6..9f18e4149 100644 --- a/src/typescript/sdk/src/queries/state.ts +++ b/src/typescript/sdk/src/queries/state.ts @@ -1,11 +1,11 @@ -import { PostgrestClient } from "@supabase/postgrest-js"; +import "server-only"; + import { type ContractTypes, toGlobalStateEvent, toStateEvent, toMarketRegistrationEvent, } from "../types/contract-types"; -import { INBOX_URL } from "../const"; import { STRUCT_STRINGS } from "../utils/type-tags"; import { TABLE_NAME, ORDER_BY } from "./const"; import { wrap } from "./utils"; @@ -15,17 +15,10 @@ import { aggregateQueryResults, } from "./query-helper"; import type JSONTypes from "../types/json-types"; +import { postgrest } from "./inbox-url"; -export const getLastMarketState = async ({ - marketID, - inboxUrl = INBOX_URL, -}: { - marketID: string; - inboxUrl?: string; -}) => { - const postgrest = new PostgrestClient(inboxUrl); - - const { state, version: stateEventVersion } = await postgrest +export const getLastMarketState = async ({ marketID }: { marketID: string }) => { + const { state, version: stateVersion } = await postgrest .from(TABLE_NAME) .select("*") .filter("type", "eq", STRUCT_STRINGS.StateEvent) @@ -38,7 +31,7 @@ export const getLastMarketState = async ({ _stateError: r.error, })); - const { market, version: marketRegistrationVersion } = await postgrest + const { market, version: mktRegistrationVersion } = await postgrest .from(TABLE_NAME) .select("*") .filter("type", "eq", STRUCT_STRINGS.MarketRegistrationEvent) @@ -62,11 +55,11 @@ export const getLastMarketState = async ({ return { state: { ...toStateEvent(state), - version: stateEventVersion as number, + version: stateVersion as number, }, market: { ...toMarketRegistrationEvent(market!), - version: marketRegistrationVersion as number, + version: mktRegistrationVersion as number, }, }; }; @@ -74,9 +67,6 @@ export const getLastMarketState = async ({ export const paginateGlobalStateEvents = async ( args: Omit ): Promise> => { - const inboxUrl = args?.inboxUrl ?? INBOX_URL; - const postgrest = new PostgrestClient(inboxUrl); - const res = await aggregateQueryResults({ ...args, query: postgrest @@ -94,15 +84,12 @@ export const paginateGlobalStateEvents = async ( export type PaginateStateEventsByMarketIDQueryArgs = { marketID: number | bigint; - inboxUrl?: string; }; export const paginateStateEventsByMarketID = async ( args: PaginateStateEventsByMarketIDQueryArgs ): Promise> => { - const { inboxUrl = INBOX_URL, marketID } = args; - const postgrest = new PostgrestClient(inboxUrl); - + const { marketID } = args; const res = await aggregateQueryResults({ query: postgrest .from(TABLE_NAME) diff --git a/src/typescript/sdk/src/queries/swap.ts b/src/typescript/sdk/src/queries/swap.ts index 9784856cc..cbfa6b68f 100644 --- a/src/typescript/sdk/src/queries/swap.ts +++ b/src/typescript/sdk/src/queries/swap.ts @@ -1,5 +1,5 @@ -import { PostgrestClient } from "@supabase/postgrest-js"; -import { INBOX_URL } from "../const"; +import "server-only"; + import { type ContractTypes, type JSONTypes, toSwapEvent } from "../types"; import { STRUCT_STRINGS } from "../utils"; import { TABLE_NAME, ORDER_BY } from "./const"; @@ -9,6 +9,7 @@ import { aggregateQueryResults, } from "./query-helper"; import { wrap } from "./utils"; +import { postgrest } from "./inbox-url"; export const paginateSwapEvents = async ( args: Omit & { @@ -16,9 +17,9 @@ export const paginateSwapEvents = async ( marketID?: number | bigint; } ) => { - const { inboxUrl = INBOX_URL, swapper, marketID } = args; + const { swapper, marketID } = args; - let query = new PostgrestClient(inboxUrl) + let query = postgrest .from(TABLE_NAME) .select("*") .filter("type", "eq", STRUCT_STRINGS.SwapEvent) @@ -44,9 +45,6 @@ export const paginateSwapEvents = async ( export const getAllPostBondingCurveMarkets = async ( args: Omit ): Promise> => { - const inboxUrl = args?.inboxUrl ?? INBOX_URL; - const postgrest = new PostgrestClient(inboxUrl); - const res = await aggregateQueryResults({ ...args, query: postgrest diff --git a/src/typescript/sdk/src/queries/utils.ts b/src/typescript/sdk/src/queries/utils.ts index 615054f20..75f86c652 100644 --- a/src/typescript/sdk/src/queries/utils.ts +++ b/src/typescript/sdk/src/queries/utils.ts @@ -1,3 +1,5 @@ +import "server-only"; + import { type ContractTypes } from "../types"; import { paginateMarketRegistrations } from "./market"; diff --git a/src/typescript/sdk/src/types/server-only.d.ts b/src/typescript/sdk/src/types/server-only.d.ts new file mode 100644 index 000000000..06c30491c --- /dev/null +++ b/src/typescript/sdk/src/types/server-only.d.ts @@ -0,0 +1 @@ +declare module "server-only"; diff --git a/src/typescript/sdk/src/utils/aptos-client.ts b/src/typescript/sdk/src/utils/aptos-client.ts deleted file mode 100644 index 8a316a431..000000000 --- a/src/typescript/sdk/src/utils/aptos-client.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { Aptos, AptosConfig, NetworkToNetworkName } from "@aptos-labs/ts-sdk"; - -// Get the aptos client based off of the network environment variables. -/* eslint-disable-next-line import/no-unused-modules */ -export const getAptos = (networkString: string): Aptos => { - // Check if it's a valid network. - const network = NetworkToNetworkName[networkString]; - if (!network) { - throw new Error(`Invalid network: ${networkString}`); - } - const cfg = new AptosConfig({ network }); - return new Aptos(cfg); -}; diff --git a/src/typescript/sdk/src/utils/git-root.ts b/src/typescript/sdk/src/utils/git-root.ts deleted file mode 100644 index d5acca86d..000000000 --- a/src/typescript/sdk/src/utils/git-root.ts +++ /dev/null @@ -1,13 +0,0 @@ -import findGitRoot from "find-git-root"; -import path from "path"; - -/** - * Returns the path to the root of the repository by removing - * the .git directory from the path. - * - * @returns the path to the closest .git directory. - */ -export function getGitRoot(): string { - const gitRoot = findGitRoot(process.cwd()); - return path.dirname(gitRoot); -} diff --git a/src/typescript/sdk/src/utils/mock-data.ts b/src/typescript/sdk/src/utils/mock-data.ts index 43c7e7474..692ea2da9 100644 --- a/src/typescript/sdk/src/utils/mock-data.ts +++ b/src/typescript/sdk/src/utils/mock-data.ts @@ -8,7 +8,7 @@ * Run with `pnpm tsx ` or `pnpm run generate-data`. * * This assumes you already have a docker instance running with the postgrest API URL at - * the env variable `INBOX_URL`. + * the env variable `LOCAL_INBOX_URL`. * * It also implicitly uses the `START_NODE_FOR_TEST` env variable to determine whether or not to * start a new Aptos node for the test. This is similar to how the e2e unit tests work. @@ -32,7 +32,7 @@ import { registerMarketAndGetEmojicoinInfo, } from "../markets/utils"; import { getRegistryAddress, getEvents } from "../emojicoin_dot_fun"; -import { publishForTest } from "../../tests/utils"; +import { getAptosClient, publishForTest } from "../../tests/utils"; import { Chat, MarketMetadataByEmojiBytes, Swap } from "../emojicoin_dot_fun/emojicoin-dot-fun"; import { BatchTransferCoins, ExistsAt } from "../emojicoin_dot_fun/aptos-framework"; import { type Events } from "../emojicoin_dot_fun/events"; @@ -41,7 +41,6 @@ import { getRandomEmoji } from "../emoji_data/symbol-data"; import { ONE_APT, QUOTE_VIRTUAL_FLOOR, QUOTE_VIRTUAL_CEILING, MODULE_ADDRESS } from "../const"; import { type SymbolEmojiData, getEmojiData } from "../emoji_data"; import { divideWithPrecision, sleep } from "./misc"; -import { getAptos } from "./aptos-client"; import { truncateAddress } from "./misc"; const NUM_TRADERS = 900; @@ -60,7 +59,7 @@ if (!(NUM_TRADERS % CHUNK_SIZE === 0)) { } async function main() { - const aptos = getAptos(process.env.APTOS_NETWORK!); + const { aptos } = getAptosClient(); const registryAddress = await setupTest(aptos); // Create distributors that will bear the sequence number for each transaction. diff --git a/src/typescript/sdk/tests/e2e/chat.test.ts b/src/typescript/sdk/tests/e2e/chat.test.ts index 25d5ac23c..25e1d0062 100644 --- a/src/typescript/sdk/tests/e2e/chat.test.ts +++ b/src/typescript/sdk/tests/e2e/chat.test.ts @@ -1,6 +1,6 @@ import { Account } from "@aptos-labs/ts-sdk"; import { PostgrestClient } from "@supabase/postgrest-js"; -import { INBOX_URL, ONE_APT } from "../../src/const"; +import { LOCAL_INBOX_URL, ONE_APT } from "../../src/const"; import { getRegistryAddress, toChatEvent } from "../../src"; import { EmojicoinDotFun } from "../../src/emojicoin_dot_fun"; import { sleep } from "../../src/utils"; @@ -114,7 +114,7 @@ describe("emits a chat message event successfully", () => { const secondChatEvent = toChatEvent(secondChatEventJSON); expect(secondChatEvent.message).toEqual(indices.map((i) => chatEmojis[i][1]).join("")); - const postgrest = new PostgrestClient(INBOX_URL); + const postgrest = new PostgrestClient(LOCAL_INBOX_URL); // Wait to make sure events were processed and saved by Inbox. await sleep(1000); diff --git a/src/typescript/sdk/tests/mock/mock-data.test.ts b/src/typescript/sdk/tests/mock/mock-data.test.ts index a637bbe28..1cf1e8027 100644 --- a/src/typescript/sdk/tests/mock/mock-data.test.ts +++ b/src/typescript/sdk/tests/mock/mock-data.test.ts @@ -1,6 +1,6 @@ import { PostgrestClient } from "@supabase/postgrest-js"; import { - INBOX_URL, + LOCAL_INBOX_URL, ONE_APT, ONE_APTN, deriveEmojicoinPublisherAddress, @@ -41,7 +41,7 @@ describe("tests a simple faucet fund account request", () => { objectAddress: derivedNamedObjectAddress, }); - const postgrest = new PostgrestClient(INBOX_URL); + const postgrest = new PostgrestClient(LOCAL_INBOX_URL); // Wait to make sure events were processed and saved by Inbox. await sleep(1000); diff --git a/src/typescript/sdk/tests/post-test.js b/src/typescript/sdk/tests/post-test.js index 22c9aa82f..2ecae24a8 100644 --- a/src/typescript/sdk/tests/post-test.js +++ b/src/typescript/sdk/tests/post-test.js @@ -1,4 +1,3 @@ -require("dotenv").config(); let inbox = require("./utils/inbox.ts"); module.exports = async function () { diff --git a/src/typescript/sdk/tests/pre-test.js b/src/typescript/sdk/tests/pre-test.js index c98038a38..720fc4b49 100644 --- a/src/typescript/sdk/tests/pre-test.js +++ b/src/typescript/sdk/tests/pre-test.js @@ -1,4 +1,3 @@ -require("dotenv").config(); const { Account, Hex, Ed25519PrivateKey } = require("@aptos-labs/ts-sdk"); const fs = require("fs"); const path = require("path"); diff --git a/src/typescript/sdk/tests/unit/git-root.test.ts b/src/typescript/sdk/tests/unit/git-root.test.ts index 41944570c..f85321336 100644 --- a/src/typescript/sdk/tests/unit/git-root.test.ts +++ b/src/typescript/sdk/tests/unit/git-root.test.ts @@ -1,5 +1,5 @@ import path from "path"; -import { getGitRoot } from "../../src/utils/git-root"; +import { getGitRoot } from "../utils/helpers"; describe("ensures find git root works as expected", () => { it("should find the correct git root", () => { diff --git a/src/typescript/sdk/tests/utils/helpers.ts b/src/typescript/sdk/tests/utils/helpers.ts index 824187a53..08ec2862a 100644 --- a/src/typescript/sdk/tests/utils/helpers.ts +++ b/src/typescript/sdk/tests/utils/helpers.ts @@ -1,9 +1,9 @@ import { Account, Ed25519PrivateKey, Hex } from "@aptos-labs/ts-sdk"; import fs from "fs"; import path from "path"; +import findGitRoot from "find-git-root"; import { getAptosClient } from "./aptos-client"; import { type TestHelpers } from "./types"; -import { getGitRoot } from "../../src/utils/git-root"; export const TS_UNIT_TEST_DIR = path.join(getGitRoot(), "src/typescript/sdk/tests"); export const PK_PATH = path.resolve(path.join(TS_UNIT_TEST_DIR, ".tmp", ".pk")); @@ -32,3 +32,14 @@ export function getTestHelpers(): TestHelpers { publishPackageResult, }; } + +/** + * Returns the path to the root of the repository by removing + * the .git directory from the path. + * + * @returns the path to the closest .git directory. + */ +export function getGitRoot(): string { + const gitRoot = findGitRoot(process.cwd()); + return path.dirname(gitRoot); +} diff --git a/src/typescript/sdk/tests/utils/publish.ts b/src/typescript/sdk/tests/utils/publish.ts index 0bcadc9f6..3728a6def 100644 --- a/src/typescript/sdk/tests/utils/publish.ts +++ b/src/typescript/sdk/tests/utils/publish.ts @@ -12,7 +12,7 @@ import path from "path"; import { type PublishPackageResult, type ResultJSON } from "./types"; import { getAptosClient } from "./aptos-client"; import { MAX_GAS_FOR_PUBLISH, ONE_APT, EMOJICOIN_DOT_FUN_MODULE_NAME } from "../../src"; -import { getGitRoot } from "../../src/utils/git-root"; +import { getGitRoot } from "./helpers"; export async function publishPackage(args: { pk: PrivateKey; diff --git a/src/typescript/turbo.json b/src/typescript/turbo.json index 621e63676..fbf75f421 100644 --- a/src/typescript/turbo.json +++ b/src/typescript/turbo.json @@ -1,5 +1,9 @@ { "$schema": "https://turbo.build/schema.json", + "globalEnv": [ + "INBOX_URL", + "SHORT_REVALIDATE" + ], "pipeline": { "build": { "dependsOn": [
+ {network.name} +
+ {APTOS_NETWORK} +