Skip to content

Commit

Permalink
[ECO-2585] Merge main to production, PRs #439 - #458 (#459)
Browse files Browse the repository at this point in the history
Co-authored-by: Bogdan Crisan <[email protected]>
  • Loading branch information
xbtmatt and CRBl69 authored Dec 11, 2024
1 parent 550cca9 commit d333b2d
Show file tree
Hide file tree
Showing 122 changed files with 4,222 additions and 8,441 deletions.
26 changes: 13 additions & 13 deletions src/cloud-formation/deploy-indexer-fallback.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ parameters:
BrokerImageVersion: '1.1.0'
BrokerMemory: 2048
DbMaxCapacity: 8
DeployAlb: 'true'
DeployAlbDnsRecord: 'true'
DeployBastionHost: 'true'
DeployBroker: 'true'
DeployContainers: 'true'
DeployDb: 'true'
DeployNlb: 'true'
DeployNlbVpcLink: 'true'
DeployPostgrest: 'true'
DeployProcessor: 'true'
DeployRestApi: 'true'
DeployRestApiDnsRecord: 'true'
DeployStack: 'true'
DeployAlb: 'false'
DeployAlbDnsRecord: 'false'
DeployBastionHost: 'false'
DeployBroker: 'false'
DeployContainers: 'false'
DeployDb: 'false'
DeployNlb: 'false'
DeployNlbVpcLink: 'false'
DeployPostgrest: 'false'
DeployProcessor: 'false'
DeployRestApi: 'false'
DeployRestApiDnsRecord: 'false'
DeployStack: 'false'
DeployWaf: 'false'
EnableWafRulesGeneral: 'false'
EnableWafRulesRestApi: 'false'
Expand Down
4 changes: 2 additions & 2 deletions src/cloud-formation/deploy-indexer-main.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
parameters:
BrokerImageVersion: '1.1.0'
BrokerImageVersion: '2.0.0'
DeployAlb: 'true'
DeployAlbDnsRecord: 'true'
DeployBastionHost: 'true'
Expand All @@ -20,7 +20,7 @@ parameters:
EnableWafRulesWebSocket: 'false'
Environment: 'main'
Network: 'testnet'
ProcessorImageVersion: '1.1.0'
ProcessorImageVersion: '2.0.0'
VpcStackName: 'emoji-vpc'
tags: null
template-file-path: 'src/cloud-formation/indexer.cfn.yaml'
Expand Down
26 changes: 13 additions & 13 deletions src/cloud-formation/deploy-indexer-production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ parameters:
BrokerImageVersion: '1.1.0'
BrokerMemory: 2048
DbMaxCapacity: 8
DeployAlb: 'true'
DeployAlbDnsRecord: 'true'
DeployBastionHost: 'true'
DeployBroker: 'true'
DeployContainers: 'true'
DeployDb: 'true'
DeployNlb: 'true'
DeployNlbVpcLink: 'true'
DeployPostgrest: 'true'
DeployProcessor: 'true'
DeployRestApi: 'true'
DeployRestApiDnsRecord: 'true'
DeployStack: 'true'
DeployAlb: 'false'
DeployAlbDnsRecord: 'false'
DeployBastionHost: 'false'
DeployBroker: 'false'
DeployContainers: 'false'
DeployDb: 'false'
DeployNlb: 'false'
DeployNlbVpcLink: 'false'
DeployPostgrest: 'false'
DeployProcessor: 'false'
DeployRestApi: 'false'
DeployRestApiDnsRecord: 'false'
DeployStack: 'false'
DeployWaf: 'false'
EnableWafRulesGeneral: 'false'
EnableWafRulesRestApi: 'false'
Expand Down
12 changes: 4 additions & 8 deletions src/python/move_emojis/scripts/generate_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
)
TYPESCRIPT_SYMBOL_EMOJIS_PATH = os.path.join(
TYPESCRIPT_PATH_DIR,
"symbol-emojis.json",
"symbol-emojis.ts",
)
TYPESCRIPT_CHAT_EMOJIS_PATH = os.path.join(
TYPESCRIPT_PATH_DIR,
"chat-emojis.json",
"chat-emojis.ts",
)
TYPESCRIPT_SYMBOL_NAMES_PATH = os.path.join(
TYPESCRIPT_PATH_DIR,
Expand Down Expand Up @@ -125,11 +125,11 @@ def ensure_write_to_file(data: str | dict[str, Any] | list[str], fp: str):
fp_obj = pathlib.Path(fp)
pathlib.Path(fp_obj.parent).mkdir(exist_ok=True)

with open(fp, "w") as outfile:
with open(fp, "w", encoding="utf-8") as outfile:
if isinstance(data, str):
_ = outfile.write(data)
else:
json.dump(data, outfile, indent=2)
json.dump(data, outfile, indent=2, ensure_ascii=False)


if __name__ == "__main__":
Expand Down Expand Up @@ -159,12 +159,8 @@ def ensure_write_to_file(data: str | dict[str, Any] | list[str], fp: str):
ensure_write_to_file(symbol_emojis, SYMBOL_EMOJIS_ALL_DATA_PATH)
typescript_symbol_emojis = as_emoji_to_name_dict(symbol_emojis)
typescript_chat_emojis = as_emoji_to_name_dict(extended_emojis)
typescript_symbol_names = {k: None for k in typescript_symbol_emojis.values()}
typescript_chat_names = {k: None for k in typescript_chat_emojis.values()}
ensure_write_to_file(typescript_symbol_emojis, TYPESCRIPT_SYMBOL_EMOJIS_PATH)
ensure_write_to_file(typescript_symbol_names, TYPESCRIPT_SYMBOL_NAMES_PATH)
ensure_write_to_file(typescript_chat_emojis, TYPESCRIPT_CHAT_EMOJIS_PATH)
ensure_write_to_file(typescript_chat_names, TYPESCRIPT_CHAT_NAMES_PATH)
# The rust processor uses the `symbol-emojis.json` data at build time, so if the
# path for the directory exists, output the data there as well.
if pathlib.Path(RUST_JSON_PATH).parent.exists():
Expand Down
40 changes: 30 additions & 10 deletions src/typescript/frontend/src/app/pools/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import ClientPoolsPage, { type PoolsData } from "components/pages/pools/ClientPoolsPage";
import { getPoolData } from "./api/getPoolDataQuery";
import { SortMarketsBy } from "@sdk/indexer-v2/types/common";
import { symbolBytesToEmojis } from "@sdk/emoji_data/utils";
import { type Metadata } from "next";
import { emoji, parseJSON } from "utils";
import { getValidSortByForPoolsPage } from "@sdk/indexer-v2/queries/query-params";
import { safeParsePageWithDefault, handleEmptySearchBytes } from "lib/routes/home-page-params";

export const revalidate = 2;

Expand All @@ -12,16 +13,35 @@ export const metadata: Metadata = {
description: `Provide ${emoji("water wave")}liquidity${emoji("water wave")} and earn APR using your emojis !`,
};

export default async function PoolsPage({ searchParams }: { searchParams: { pool: string } }) {
type PoolsSearchParams = {
page: string | null;
sortby: string | null;
orderby: string | null;
searchBytes: string | null;
pool: string | null;
account: string | null;
};

/**
* Uses the same exact parsing logic as the /pools/api route.
* @see {@link src/pools/api/route.ts}
*/
export default async function PoolsPage({ searchParams }: { searchParams: PoolsSearchParams }) {
const page = safeParsePageWithDefault(searchParams.page);
const sortBy = getValidSortByForPoolsPage(searchParams.sortby);
const orderBy = searchParams.orderby ?? "desc";
const q = handleEmptySearchBytes(searchParams.searchBytes);
const searchEmojis = q ? symbolBytesToEmojis(q).emojis.map((e) => e.emoji) : undefined;

if (orderBy !== "asc" && orderBy !== "desc") {
throw new Error("Invalid params");
}

// The liquidity `provider`, aka the account to search for in the user liquidity pools.
const provider = searchParams.account;

const initialData: PoolsData[] = parseJSON(
await getPoolData(
1,
SortMarketsBy.AllTimeVolume,
"desc",
searchParams.pool
? symbolBytesToEmojis(searchParams.pool).emojis.map((e) => e.emoji)
: undefined
)
await getPoolData(page, sortBy, orderBy, searchEmojis, provider ?? undefined)
);

return <ClientPoolsPage initialData={initialData} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { Copy, LogOut, User } from "lucide-react";
import { useWalletModal } from "context/wallet-context/WalletModalContext";
import { AnimatePresence, useAnimationControls } from "framer-motion";
import AnimatedDropdownItem from "./components/animated-dropdown-item";
import useIsUserGeoblocked from "@hooks/use-is-user-geoblocked";

const IconClass = "w-[22px] h-[22px] m-auto ml-[3ch] mr-[1.5ch]";

Expand Down Expand Up @@ -86,17 +87,20 @@ export const MobileMenu: React.FC<MobileMenuProps> = ({
}
}
};
const geoblocked = useIsUserGeoblocked();

return (
<StyledMotion initial="hidden" animate={isOpen ? "visible" : "hidden"} variants={slideVariants}>
<MobileMenuWrapper>
<MobileMenuInner>
<ButtonWithConnectWalletFallback
className="w-full"
mobile={true}
onClick={subMenuOnClick}
arrow
/>
{!geoblocked && (
<ButtonWithConnectWalletFallback
className={"w-full"}
mobile={true}
onClick={subMenuOnClick}
arrow
/>
)}
<AnimatePresence>
{subMenuOpen && (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const AptosInputLabel = () => (
);

export const EmojiInputLabelStyles =
"pixel-heading-3 text-light-gray text-[24px] md:text-[30px] cursor-default";
"pixel-heading-4 md:pixel-heading-3 text-light-gray text-[24px] cursor-default break-keep";

export const EmojiInputLabel = ({ emoji }: { emoji: string }) => (
<Emoji className={EmojiInputLabelStyles} emojis={emoji} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,59 +1,17 @@
import { type SymbolEmojiData } from "@sdk/emoji_data/types";
import { useGenerateEvent } from "../../test-generate-event/use-generate-event";
import { type PropsWithChildren } from "react";
import { ROUTES } from "router/routes";
import { emojiNamesToPath } from "utils/pathname-helpers";
import Link from "next/link";
import { VERCEL } from "@sdk/const";
import React from "react";

/**
* To facilitate easy visual testing, we swap out the link on the grid table card with a div that triggers a
* random event when clicked. Note that the test click div will never render in Vercel build mode or in
* production. You also have to set a specific environment variable to true.
*
* We put this component in the grid table card component so that when the user clicks on the card, it will
* trigger the event (or navigate to the market page if not in test mode).
*
* @returns {JSX.Element} The link that goes to the market page, or if in test, the div that emulates triggering a
* random event in our event state store.
*/
export const GenerateEventComponent = ({
export const EmojiMarketPageLink = ({
emojis,
marketID,
...props
}: { emojis: SymbolEmojiData[]; marketID: number } & PropsWithChildren) => {
// Note that without `stateOnly: true`, the event could conflict with other events. This may cause
// visual artifacts that won't actually appear with real data.
const generateEvent = useGenerateEvent({ marketID, emojis, stateOnly: true });
}: { emojis: SymbolEmojiData[] } & PropsWithChildren) => (
<Link href={`${ROUTES.market}/${emojiNamesToPath(emojis.map((x) => x.name))}`}>
{props.children}
</Link>
);

return (
<>
<div onClick={generateEvent}>{props.children}</div>
</>
);
};

export const LinkOrAnimationTrigger = ({
emojis,
marketID,
...props
}: { emojis: SymbolEmojiData[]; marketID: number } & PropsWithChildren) => {
return (
<>
{VERCEL ||
process.env.NODE_ENV === "production" ||
process.env.NEXT_PUBLIC_ANIMATION_TEST !== "true" ? (
<Link href={`${ROUTES.market}/${emojiNamesToPath(emojis.map((x) => x.name))}`}>
{props.children}
</Link>
) : (
<GenerateEventComponent emojis={emojis} marketID={marketID}>
{props.children}
</GenerateEventComponent>
)}
</>
);
};

export default React.memo(LinkOrAnimationTrigger);
export default React.memo(EmojiMarketPageLink);
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
LAYOUT_DURATION,
tableCardVariants,
} from "./animation-variants/grid-variants";
import LinkOrAnimationTrigger from "./LinkOrAnimationTrigger";
import EmojiMarketPageLink from "./LinkOrAnimationTrigger";
import { type SymbolEmojiData } from "@sdk/emoji_data";
import { Emoji } from "utils/emoji";
import { SortMarketsBy } from "@sdk/indexer-v2/types/common";
Expand Down Expand Up @@ -205,7 +205,7 @@ const TableCard = ({
}}
{...props}
>
<LinkOrAnimationTrigger emojis={emojis} marketID={marketID}>
<EmojiMarketPageLink emojis={emojis}>
<motion.div
animate={controls}
variants={animationsOn ? glowVariants : {}}
Expand Down Expand Up @@ -290,7 +290,7 @@ const TableCard = ({
</Flex>
</motion.div>
</motion.div>
</LinkOrAnimationTrigger>
</EmojiMarketPageLink>
</motion.div>
);
};
Expand Down
Loading

0 comments on commit d333b2d

Please sign in to comment.