Skip to content

Commit

Permalink
Merge pull request #397 from BibliothecaDAO/feat/prod-app
Browse files Browse the repository at this point in the history
Feat/prod app
  • Loading branch information
starknetdev authored Oct 16, 2023
2 parents 48c7a02 + 2929654 commit cfd0beb
Show file tree
Hide file tree
Showing 92 changed files with 519 additions and 3,345 deletions.
Empty file.
2,683 changes: 0 additions & 2,683 deletions ui/src/app/abi/openzeppelin070Account.sierra.json.json

This file was deleted.

3 changes: 0 additions & 3 deletions ui/src/app/api/hello/route.ts

This file was deleted.

24 changes: 11 additions & 13 deletions ui/src/app/components/ArcadeDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import React, { useEffect } from "react";
import { useState } from "react";
import useUIStore from "@/app/hooks/useUIStore";
import { Button } from "./buttons/Button";
import { useBurner } from "../lib/burner";
import { Connector, useAccount, useConnectors } from "@starknet-react/core";
import React, { useEffect, useState, useCallback } from "react";
import { AccountInterface } from "starknet";
import { useCallback } from "react";
import { useContracts } from "../hooks/useContracts";
import { MIN_BALANCE } from "../lib/constants";
import PixelatedImage from "./animations/PixelatedImage";
import { getArcadeConnectors } from "../lib/connectors";
import SpriteAnimation from "./animations/SpriteAnimation";
import { fetchBalances } from "../lib/balances";
import { Connector, useAccount, useConnectors } from "@starknet-react/core";
import useUIStore from "@/app/hooks/useUIStore";
import { Button } from "@/app/components/buttons/Button";
import { useBurner } from "@/app/lib/burner";
import { useContracts } from "@/app/hooks/useContracts";
import { MIN_BALANCE } from "@/app/lib/constants";
import PixelatedImage from "@/app/components/animations/PixelatedImage";
import { getArcadeConnectors } from "@/app/lib/connectors";
import SpriteAnimation from "@/app/components/animations/SpriteAnimation";
import { fetchBalances } from "@/app/lib/balances";

export const ArcadeDialog = () => {
const [fetchedBalances, setFetchedBalances] = useState(false);
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/components/CountDown.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect, useRef } from "react";
import { useCountUp } from "react-countup";
import { useState } from "react";
import { penaltyTime } from "../lib/constants";
import { penaltyTime } from "@/app/lib/constants";

const formatTime = (totalSeconds: number) => {
const hours = Math.floor(totalSeconds / 3600);
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/components/KeyboardControls.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useCallback, useEffect, useRef, useState } from "react";
import { Button } from "./buttons/Button";
import { Button } from "@/app/components/buttons/Button";

export interface ButtonData {
id: number;
Expand Down
15 changes: 7 additions & 8 deletions ui/src/app/components/TopUpDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useAccount } from "@starknet-react/core";
import useUIStore from "../hooks/useUIStore";
import { Button } from "./buttons/Button";
import useUIStore from "@/app/hooks/useUIStore";
import { Button } from "@/app/components/buttons/Button";
import { useConnectors } from "@starknet-react/core";
import Storage from "../lib/storage";
import { BurnerStorage } from "../types";
import { useBurner } from "../lib/burner";
import { getArcadeConnectors, getWalletConnectors } from "../lib/connectors";
import Storage from "@/app/lib/storage";
import { BurnerStorage } from "@/app/types";
import { useBurner } from "@/app/lib/burner";
import { getArcadeConnectors, getWalletConnectors } from "@/app/lib/connectors";

interface TopUpDialogProps {
token: "ETH" | "LORDS";
Expand All @@ -17,8 +17,7 @@ export const TopUpDialog = ({ token }: TopUpDialogProps) => {
const showTopUpDialog = useUIStore((state) => state.showTopUpDialog);
const topUpAccount = useUIStore((state) => state.topUpAccount);
const setTopUpAccount = useUIStore((state) => state.setTopUpAccount);
const { topUpEth, isToppingUpEth, topUpLords, isToppingUpLords } =
useBurner();
const { topUpEth, isToppingUpEth } = useBurner();

const arcadeConnectors = getArcadeConnectors(available);
const walletConnectors = getWalletConnectors(available);
Expand Down
6 changes: 3 additions & 3 deletions ui/src/app/components/actions/Discovery.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useQueriesStore } from "../../hooks/useQueryStore";
import { DiscoveryDisplay } from "./DiscoveryDisplay";
import LootIconLoader from "../icons/Loader";
import { useQueriesStore } from "@/app/hooks/useQueryStore";
import { DiscoveryDisplay } from "@/app/components/actions/DiscoveryDisplay";
import LootIconLoader from "@/app/components/icons/Loader";
import { Discovery } from "@/app/types";

interface DiscoveryProps {
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/components/actions/DiscoveryDisplay.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { processBeastName } from "../../lib/utils";
import { processBeastName } from "@/app/lib/utils";
import {
CoinIcon,
GiBruteIcon,
Expand All @@ -7,7 +7,7 @@ import {
GiSandsOfTimeIcon,
TwoCoinIcon,
HealthPotionIcon,
} from "../icons/Icons";
} from "@/app/components/icons/Icons";
import { Discovery } from "@/app/types";

interface DiscoveryProps {
Expand Down
18 changes: 9 additions & 9 deletions ui/src/app/components/adventurer/DeathDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import React, { useEffect, useState, useRef } from "react";
import TwitterShareButton from "../buttons/TwitterShareButtons";
import useAdventurerStore from "../../hooks/useAdventurerStore";
import useLoadingStore from "../../hooks/useLoadingStore";
import { Button } from "../buttons/Button";
import useUIStore from "../../hooks/useUIStore";
import { getRankFromList, getOrdinalSuffix } from "../../lib/utils";
import TwitterShareButton from "@/app/components/buttons/TwitterShareButtons";
import useAdventurerStore from "@/app/hooks/useAdventurerStore";
import useLoadingStore from "@/app/hooks/useLoadingStore";
import { Button } from "@/app/components/buttons/Button";
import useUIStore from "@/app/hooks/useUIStore";
import { getRankFromList, getOrdinalSuffix } from "@/app/lib/utils";
import { getAppUrl } from "@/app/lib/constants";
import { getAdventurerByXP } from "@/app/hooks/graphql/queries";
import useCustomQuery from "@/app/hooks/useCustomQuery";
import { NullAdventurer, Adventurer } from "@/app/types";
import { useQueriesStore } from "@/app/hooks/useQueryStore";
import GlitchEffect from "../animations/GlitchEffect";
import PixelatedImage from "../animations/PixelatedImage";
import { getDeathMessageByRank } from "../../lib/utils";
import GlitchEffect from "@/app/components/animations/GlitchEffect";
import PixelatedImage from "@/app/components/animations/PixelatedImage";
import { getDeathMessageByRank } from "@/app/lib/utils";

export const DeathDialog = () => {
const messageRef = useRef<HTMLSpanElement>(null);
Expand Down
18 changes: 11 additions & 7 deletions ui/src/app/components/adventurer/Info.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import { Adventurer, NullAdventurer, NullItem } from "../../types";
import { HeartIcon, CoinIcon, QuestionMarkIcon } from "../icons/Icons";
import { Adventurer, NullAdventurer, NullItem } from "@/app/types";
import {
HeartIcon,
CoinIcon,
QuestionMarkIcon,
} from "@/app/components/icons/Icons";
import { ItemDisplay } from "./ItemDisplay";
import LevelBar from "./LevelBar";
import { getKeyFromValue } from "../../lib/utils";
import { useQueriesStore } from "../../hooks/useQueryStore";
import useUIStore from "../../hooks/useUIStore";
import { getKeyFromValue } from "@/app/lib/utils";
import { useQueriesStore } from "@/app/hooks/useQueryStore";
import useUIStore from "@/app/hooks/useUIStore";
import { Item } from "@/app/types";
import { HealthCountDown } from "../CountDown";
import { GameData } from "../GameData";
import { HealthCountDown } from "@/app/components/CountDown";
import { GameData } from "@/app/lib/data/GameData";
import { useContracts } from "@/app/hooks/useContracts";
import useTransactionCartStore from "@/app/hooks/useTransactionCartStore";

Expand Down
8 changes: 4 additions & 4 deletions ui/src/app/components/adventurer/InventoryDisplay.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import LootIcon from "../icons/LootIcon";
import Efficacyicon from "../icons/EfficacyIcon";
import LootIcon from "@/app/components/icons/LootIcon";
import Efficacyicon from "@/app/components/icons/EfficacyIcon";
import { Item } from "@/app/types";
import {
getItemData,
Expand All @@ -8,9 +8,9 @@ import {
getKeyFromValue,
} from "@/app/lib/utils";
import { MdClose } from "react-icons/md";
import { Button } from "../buttons/Button";
import { Button } from "@/app/components/buttons/Button";
import useUIStore from "@/app/hooks/useUIStore";
import { GameData } from "../GameData";
import { GameData } from "@/app/lib/data/GameData";
import { useContracts } from "@/app/hooks/useContracts";
import useAdventurerStore from "@/app/hooks/useAdventurerStore";
import useTransactionCartStore from "@/app/hooks/useTransactionCartStore";
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/components/adventurer/ItemBar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { calculateLevel } from "../../lib/utils";
import { calculateLevel } from "@/app/lib/utils";

interface ItemBarProps {
xp: number;
Expand Down
20 changes: 10 additions & 10 deletions ui/src/app/components/adventurer/ItemDisplay.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React, { useEffect, useState } from "react";
import { Item } from "../../types";
import LootIcon from "../icons/LootIcon";
import Efficacyicon from "../icons/EfficacyIcon";
import { processItemName, calculateLevel, getItemData } from "../../lib/utils";
import ItemBar from "./ItemBar";
import { GameData } from "../GameData";
import { getKeyFromValue, getValueFromKey } from "../../lib/utils";
import { SwapIcon, DownArrowIcon } from "../icons/Icons";
import { Button } from "../buttons/Button";
import { Item } from "@/app/types";
import LootIcon from "@/app/components/icons/LootIcon";
import Efficacyicon from "@/app/components/icons/EfficacyIcon";
import { processItemName, calculateLevel, getItemData } from "@/app/lib/utils";
import ItemBar from "@/app/components/adventurer/ItemBar";
import { GameData } from "@/app/lib/data/GameData";
import { getKeyFromValue, getValueFromKey } from "@/app/lib/utils";
import { SwapIcon, DownArrowIcon } from "@/app/components/icons/Icons";
import { Button } from "@/app/components/buttons/Button";
import useUIStore from "@/app/hooks/useUIStore";
import { InventoryDisplay } from "./InventoryDisplay";
import { InventoryDisplay } from "@/app/components/adventurer/InventoryDisplay";
import { useQueriesStore } from "@/app/hooks/useQueryStore";

interface ItemDisplayProps {
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/components/adventurer/LevelBar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { calculateLevel } from "../../lib/utils";
import { calculateLevel } from "@/app/lib/utils";

interface LevelBarProps {
xp: number;
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/components/adventurer/Player.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Info from "./Info";
import useAdventurerStore from "../../hooks/useAdventurerStore";
import Info from "@/app/components/adventurer/Info";
import useAdventurerStore from "@/app/hooks/useAdventurerStore";

export default function Player() {
const adventurer = useAdventurerStore((state) => state.adventurer);
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/components/animations/GlitchEffect.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useRef } from "react";
import "../../GlitchEffect.css";
import "@/app/GlitchEffect.css";

const GlitchEffect: React.FC = () => {
const textRef = useRef<HTMLDivElement | null>(null);
Expand Down
51 changes: 21 additions & 30 deletions ui/src/app/components/beast/BattleDisplay.tsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,39 @@
import TwitterShareButton from "../buttons/TwitterShareButtons";
import useAdventurerStore from "../../hooks/useAdventurerStore";
import { useQueriesStore } from "../../hooks/useQueryStore";
import { getRankFromList, getOrdinalSuffix } from "../../lib/utils";
import { processBeastName, getBeastData } from "../../lib/utils";
import { processBeastName, getBeastData } from "@/app/lib/utils";
import { Battle } from "@/app/types";
import Head from "../../../../public/icons/loot/head.svg";
import Hand from "../../../../public/icons/loot/hand.svg";
import Chest from "../../../../public/icons/loot/chest.svg";
import Waist from "../../../../public/icons/loot/waist.svg";
import Foot from "../../../../public/icons/loot/foot.svg";
// import Head from "public/icons/loot/head.svg";
// import Hand from "public/icons/loot/hand.svg";
// import Chest from "public/icons/loot/chest.svg";
// import Waist from "public/icons/loot/waist.svg";
// import Foot from "public/icons/loot/foot.svg";
import { getAppUrl } from "@/app/lib/constants";
import {
GiWalkingBootIcon,
GiFootTripIcon,
GiBattleGearIcon,
SkullCrossedBonesIcon,
} from "../icons/Icons";
} from "@/app/components/icons/Icons";

interface BattleDisplayProps {
battleData: Battle;
beastName: string;
}

const getAttackLocationIcon = (attackLocation: string) => {
if (!attackLocation) return null;
// const getAttackLocationIcon = (attackLocation: string) => {
// if (!attackLocation) return null;

if (attackLocation == "Hand")
return <Hand className="self-center w-6 h-6 fill-current" />;
if (attackLocation == "Chest")
return <Chest className="self-center w-6 h-6 fill-current" />;
if (attackLocation == "Waist")
return <Waist className="self-center w-6 h-6 fill-current" />;
if (attackLocation == "Foot")
return <Foot className="self-center w-6 h-6 fill-current" />;
if (attackLocation == "Head")
return <Head className="self-center w-6 h-6 fill-current" />;
};
// if (attackLocation == "Hand")
// return <Hand className="self-center w-6 h-6 fill-current" />;
// if (attackLocation == "Chest")
// return <Chest className="self-center w-6 h-6 fill-current" />;
// if (attackLocation == "Waist")
// return <Waist className="self-center w-6 h-6 fill-current" />;
// if (attackLocation == "Foot")
// return <Foot className="self-center w-6 h-6 fill-current" />;
// if (attackLocation == "Head")
// return <Head className="self-center w-6 h-6 fill-current" />;
// };

/**
* @component
Expand All @@ -46,7 +44,7 @@ export const BattleDisplay = ({
beastName,
}: BattleDisplayProps) => {
const damageLocation = battleData?.damageLocation ?? "";
const damageIcon = getAttackLocationIcon(damageLocation);
// const damageIcon = getAttackLocationIcon(damageLocation);
const BeastFled = battleData.fled;
const AdventurerAttack = battleData.attacker === "Adventurer";
const BeastAttack = battleData.attacker === "Beast";
Expand Down Expand Up @@ -208,13 +206,6 @@ export const NotificationBattleDisplay = ({
};

const { beastName, beastLevel, tier } = handleBeastInfo();
const { data } = useQueriesStore();
const rank = getRankFromList(
adventurer?.id ?? 0,
data.adventurersByXPQuery?.adventurers ?? []
);
const ordinalRank = getOrdinalSuffix(rank + 1 ?? 0);

const BeastFled = isArray && battleData.some((data) => data.fled);
const FailedToFlee =
isArray &&
Expand Down
11 changes: 5 additions & 6 deletions ui/src/app/components/beast/BeastDisplay.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import Image from "next/image";
import { getBeastData } from "../../lib/utils";
import { HeartIcon } from "../icons/Icons";
import EfficacyIcon from "../icons/EfficacyIcon";
import { processBeastName } from "../../lib/utils";
import { getBeastData } from "@/app/lib/utils";
import { HeartIcon } from "@/app/components/icons/Icons";
import EfficacyIcon from "@/app/components/icons/EfficacyIcon";
import { processBeastName } from "@/app/lib/utils";
import { Beast } from "@/app/types";

import { HealthCountDown } from "../CountDown";
import { HealthCountDown } from "@/app/components/CountDown";

interface BeastDisplayProps {
beastData: Beast;
Expand Down
10 changes: 3 additions & 7 deletions ui/src/app/components/buttons/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
"use client";

import * as React from "react";
import { VariantProps, cva } from "class-variance-authority";

import { cn } from "@/app/lib/utils";
import Link from "next/link";
import { soundSelector, useUiSounds } from "../../hooks/useUiSound";
import { soundSelector, useUiSounds } from "@/app/hooks/useUiSound";

const buttonVariants = cva(
"active:scale-95 inline-flex items-center justify-center font-medium transition-colors focus:outline-none focus:ring-offset-2 disabled:bg-terminal-black disabled:text-terminal-green disabled:pointer-events-none data-[state=open]:bg-slate-100 uppercase font-sans-serif border border-transparent disabled:text-slate-600",
Expand All @@ -32,8 +29,7 @@ const buttonVariants = cva(
sm: "h-9 px-3 text-sm sm:h-10 sm:px-4 sm:text-base md:h-11 md:px-5 md:text-base lg:h-12 lg:px-6 lg:text-base xl:h-13 xl:px-7 xl:text-base",
md: "h-8 px-2 text-sm sm:h-9 sm:px-3 sm:text-base md:h-10 md:px-4 md:text-base lg:h-11 lg:px-5 lg:text-lg xl:h-12 xl:px-6 xl:text-lg",
lg: "h-11 px-8 text-lg sm:h-12 sm:px-9 sm:text-lg md:h-13 md:px-10 md:text-lg lg:h-14 lg:px-11 lg:text-xl xl:h-15 xl:px-12 xl:text-xl",
xl: "h-12 px-10 text-xl sm:h-13 sm:px-11 sm:text-2xl md:h-14 md:px-12 md:text-2xl lg:h-15 lg:px-13 lg:text-2xl xl:h-16 xl:px-14 xl:text-2xl"

xl: "h-12 px-10 text-xl sm:h-13 sm:px-11 sm:text-2xl md:h-14 md:px-12 md:text-2xl lg:h-15 lg:px-13 lg:text-2xl xl:h-16 xl:px-14 xl:text-2xl",
},
},
defaultVariants: {
Expand All @@ -45,7 +41,7 @@ const buttonVariants = cva(

export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
VariantProps<typeof buttonVariants> {
children: React.ReactNode;
href?: string;
loading?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/components/buttons/QuantityButtons.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { Button } from "./Button";
import { Button } from "@/app/components/buttons/Button";

interface ButtonProps {
amount: number;
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/components/buttons/TwitterShareButtons.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { Button } from "./Button";
import { TwitterIcon } from "../icons/Icons";
import { Button } from "@/app/components/buttons/Button";
import { TwitterIcon } from "@/app/components/icons/Icons";

interface Props {
text: string;
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/components/icons/EfficacyIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
ClothIcon,
HideIcon,
MetalIcon,
} from "./Icons";
} from "@/app/components/icons/Icons";

export type IconSize = "w-4" | "w-5" | "w-6" | "w-7" | "w-8" | "w-10";

Expand Down
Loading

1 comment on commit cfd0beb

@vercel
Copy link

@vercel vercel bot commented on cfd0beb Oct 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.