Skip to content

Commit

Permalink
refactor: directory structure (#81)
Browse files Browse the repository at this point in the history
* refactor: directory structure

* refactor: remove unnecessary extensions
  • Loading branch information
VanishMax authored Oct 4, 2024
1 parent 8716337 commit bdf9ab6
Show file tree
Hide file tree
Showing 74 changed files with 134 additions and 134 deletions.
2 changes: 1 addition & 1 deletion src/app/v2/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { ReactNode } from 'react';
import { PenumbraUIProvider } from '@penumbra-zone/ui/PenumbraUIProvider';
import { Display } from '@penumbra-zone/ui/Display';
import { Header } from '@/components/header';
import { Header } from '../../components/header';
import { SyncBar } from '@/components/header/sync-bar';
import { enableStaticRendering } from 'mobx-react-lite';

Expand Down
2 changes: 1 addition & 1 deletion src/app/v2/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { redirect } from 'next/navigation';
import { PagePath } from '@/utils/routes/pages.ts';
import { PagePath } from '@/shared/pages';

export default function RedirectPage() {
redirect(PagePath.Trade);
Expand Down
2 changes: 1 addition & 1 deletion src/components/header/connection.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Button } from '@penumbra-zone/ui/Button';
import { ProviderPopover } from './provider-popover';
import { connectionStore } from '@/state/connection';
import { connectionStore } from '@/shared/state/connection';
import { observer } from 'mobx-react-lite';

export const Connection = observer(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/header/desktop-nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useRouter } from 'next/navigation';
import { Tabs } from '@penumbra-zone/ui/Tabs';
import { Density } from '@penumbra-zone/ui/Density';
import { HEADER_LINKS } from './links';
import { usePagePath } from '@/utils/routes/usePagePath';
import { usePagePath } from '@/shared/usePagePath';

export const DesktopNav = () => {
const pagePath = usePagePath();
Expand Down
2 changes: 1 addition & 1 deletion src/components/header/links.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MoonStar, ArrowUpFromDot, Coins } from 'lucide-react';
import { PagePath } from '@/utils/routes/pages.ts';
import { PagePath } from '@/shared/pages';

export const HEADER_LINKS = [
{ label: 'Trade', value: PagePath.Trade, icon: ArrowUpFromDot },
Expand Down
2 changes: 1 addition & 1 deletion src/components/header/logo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Link from 'next/link'
import { PagePath } from '@/utils/routes/pages';
import { PagePath } from '@/shared/pages';
import PenumbraLogo from './logo.svg';

export const HeaderLogo = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/header/provider-popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Image from 'next/image';
import { Popover } from '@penumbra-zone/ui/Popover';
import { Button } from '@penumbra-zone/ui/Button';
import { Text } from '@penumbra-zone/ui/Text';
import { connectionStore } from '@/state/connection';
import { connectionStore } from '@/shared/state/connection';
import { observer } from 'mobx-react-lite';

export const ProviderPopover = observer(() => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/header/status-popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { Button } from '@penumbra-zone/ui/Button';
import { Density } from '@penumbra-zone/ui/Density';
import { Pill } from '@penumbra-zone/ui/Pill';
import { Text } from '@penumbra-zone/ui/Text';
import { statusStore } from '@/state/status';
import { connectionStore } from '@/state/connection';
import { statusStore } from '@/shared/state/status';
import { connectionStore } from '@/shared/state/connection';
import { observer } from 'mobx-react-lite';

export const StatusPopover = observer(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/header/sync-bar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Progress } from '@penumbra-zone/ui/Progress';
import { statusStore } from '@/state/status';
import { statusStore } from '@/shared/state/status';
import { observer } from 'mobx-react-lite';

export const SyncBar = observer(() => {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import {
FormControl,
NumberInputField,
} from "@chakra-ui/react";
import { LoadingSpinner } from "@/components/util/loadingSpinner";
import { LoadingSpinner } from "@/old/components/util/loadingSpinner";
import { useEffect, useRef, useState } from "react";
import { BlockSummary } from "@/components/executionHistory/blockSummary";
import { BlockInfo, LiquidityPositionEvent } from "@/utils/indexer/types/lps";
import { SwapExecutionWithBlockHeight } from "@/utils/protos/types/DexQueryServiceClientInterface";
import { BlockInfoMap, BlockSummaryData, BlockSummaryMap } from "@/utils/types/block";
import { BlockSummary } from "@/old/components/executionHistory/blockSummary";
import { BlockInfo, LiquidityPositionEvent } from "@/old/utils/indexer/types/lps";
import { SwapExecutionWithBlockHeight } from "@/old/utils/protos/types/DexQueryServiceClientInterface";
import { BlockInfoMap, BlockSummaryData, BlockSummaryMap } from "@/old/utils/types/block";

export default function Blocks() {
// Go back hardcoded N blocks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import React, { useRef, useEffect } from "react";
import { Box, HStack, Spacer, Text, VStack } from "@chakra-ui/react";
import { Position } from "@penumbra-zone/protobuf/penumbra/core/component/dex/v1/dex_pb";
import { fromBaseUnit, splitLoHi } from "@/utils/math/hiLo";
import { fromBaseUnit, splitLoHi } from "@/old/utils/math/hiLo";
import BigNumber from "bignumber.js";
import { Token } from "@/utils/types/token";
import { Token } from "@/old/utils/types/token";
import dynamic from "next/dynamic";
import { innerToBech32Address } from "@/utils/math/bech32";
import { uint8ArrayToBase64 } from "@/utils/math/base64";
import { innerToBech32Address } from "@/old/utils/math/bech32";
import { uint8ArrayToBase64 } from "@/old/utils/math/base64";

interface BuySellprops {
buySidePositions: Position[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { set, throttle } from 'lodash';
import { Chart } from 'chart.js/auto';
import { Button, HStack, Text, useBreakpoint, VStack } from '@chakra-ui/react';
import zoomPlugin, { zoom } from 'chartjs-plugin-zoom';
import { Token } from '@/utils/types/token';
import { Token } from '@/old/utils/types/token.tsx';

// Register the necessary components from chart.js
ChartJS.register(...registerables, annotationPlugin);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import React, { useEffect, useState, useRef } from 'react';
import { VStack, Text, Button, ButtonGroup, Flex } from '@chakra-ui/react';
import useComponentSize from '@rehooks/component-size';
import { Token } from '@/utils/types/token';
import { Token } from '@/old/utils/types/token';
import { LoadingSpinner } from '../util/loadingSpinner';
import ReactECharts from 'echarts-for-react';
import { format } from 'date-fns';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import React, { FC, useState } from "react";
import { CopyIcon } from "@radix-ui/react-icons";
import { HStack } from "@chakra-ui/react";
import { Constants } from "@/utils/configConstants.ts";
import { Constants } from "@/old/utils/configConstants";

interface CopyTxToClipboardProps {
txHash: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-nocheck
/* eslint-disable -- disabling this file as this was created before our strict rules */
import { BlockSummaryData } from "@/utils/types/block";
import { BlockSummaryData } from "@/old/utils/types/block";
import { VStack, Text } from "@chakra-ui/react";

export interface BlockDetailsProps {
Expand Down Expand Up @@ -32,4 +32,4 @@ export const BlockDetails = ({ blockSummary }: BlockDetailsProps) => {
</Text>
</VStack>
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { Box, HStack, Flex, Text } from "@chakra-ui/react";
import BlockTimestampView from "../blockTimestamp";
import { BlockDetails } from "./blockDetails";
import { BlockSummaryData } from "@/utils/types/block";
import { BlockSummaryData } from "@/old/utils/types/block";

export interface BlockSummaryProps {
blockHeight: number
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
Text,
HStack,
} from "@chakra-ui/react";
import { LiquidityPositionEvent } from "@/utils/indexer/types/lps";
import CopiedTxToClipboard from "@/components/copiedTx";
import { LiquidityPositionEvent } from "@/old/utils/indexer/types/lps";
import CopiedTxToClipboard from "@/old/components/copiedTx";

interface ClosedPositionStatusProps {
nftId: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import {
Position,
PositionState,
} from "@penumbra-zone/protobuf/penumbra/core/component/dex/v1/dex_pb";
import { fromBaseUnit } from "../../utils/math/hiLo";
import { uint8ArrayToBase64 } from "../../utils/math/base64";
import { fetchTokenAsset } from "../../utils/token/tokenFetch";
import { fromBaseUnit } from "@/old/utils/math/hiLo";
import { uint8ArrayToBase64 } from "@/old/utils/math/base64";
import { fetchTokenAsset } from "@/old/utils/token/tokenFetch";
import BigNumber from "bignumber.js";
import { CopyIcon } from "@radix-ui/react-icons";
import { Token } from "@/utils/types/token";
import { Token } from "@/old/utils/types/token";

interface CurrentLPStatusProps {
nftId: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import {
Position,
PositionState,
} from "@penumbra-zone/protobuf/penumbra/core/component/dex/v1/dex_pb";
import { fromBaseUnit } from "../../utils/math/hiLo";
import { uint8ArrayToBase64 } from "../../utils/math/base64";
import { fromBaseUnit } from "@/old/utils/math/hiLo";
import { uint8ArrayToBase64 } from "@/old/utils/math/base64";
import BigNumber from "bignumber.js";
import {
LiquidityPositionEvent,
PositionExecutionEvent,
} from "@/utils/indexer/types/lps";
} from "@/old/utils/indexer/types/lps";
import CopiedTxToClipboard from "../copiedTx";
import LPAssetView from "../lpAssetView";
import BlockTimestampView from "../blockTimestamp";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import {
Position,
PositionState,
} from "@penumbra-zone/protobuf/penumbra/core/component/dex/v1/dex_pb";
import { fromBaseUnit } from "../../utils/math/hiLo";
import { uint8ArrayToBase64 } from "../../utils/math/base64";
import { fromBaseUnit } from "@/old/utils/math/hiLo";
import { uint8ArrayToBase64 } from "@/old/utils/math/base64";
import BigNumber from "bignumber.js";
import { LiquidityPositionEvent } from "@/utils/indexer/types/lps";
import { LiquidityPositionEvent } from "@/old/utils/indexer/types/lps";
import CopiedTxToClipboard from "../copiedTx";
import LPAssetView from "../lpAssetView";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
/* eslint-disable -- disabling this file as this was created before our strict rules */
import React from "react";
import { Box, HStack, Text, VStack } from "@chakra-ui/react";
import { LiquidityPositionEvent } from "@/utils/indexer/types/lps";
import ClosedPositionStatus from "@/components/liquidityPositions/closedStatus";
import OpenPositionStatus from "@/components/liquidityPositions/openStatus";
import WithdrawnPositionStatus from "@/components/liquidityPositions/withdrawnStatus";
import { LiquidityPositionEvent } from "@/old/utils/indexer/types/lps";
import ClosedPositionStatus from "@/old/components/liquidityPositions/closedStatus";
import OpenPositionStatus from "@/old/components/liquidityPositions/openStatus";
import WithdrawnPositionStatus from "@/old/components/liquidityPositions/withdrawnStatus";
import BlockTimestampView from "../blockTimestamp";

interface TimelinePositionProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Text,
HStack,
} from "@chakra-ui/react";
import { LiquidityPositionEvent } from "@/utils/indexer/types/lps";
import { LiquidityPositionEvent } from "@/old/utils/indexer/types/lps";
import CopiedTxToClipboard from "../copiedTx";
import LPAssetView from "../lpAssetView";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { Avatar, HStack, VStack , Text } from "@chakra-ui/react";
import {
LiquidityPositionEvent,
PositionExecutionEvent,
} from "@/utils/indexer/types/lps";
import { fetchTokenAsset } from "@/utils/token/tokenFetch";
import { fromBaseUnit } from "@/utils/math/hiLo";
import { base64ToUint8Array } from "@/utils/math/base64";
import { Token } from "@/utils/types/token";
} from "@/old/utils/indexer/types/lps";
import { fetchTokenAsset } from "@/old/utils/token/tokenFetch";
import { fromBaseUnit } from "@/old/utils/math/hiLo";
import { base64ToUint8Array } from "@/old/utils/math/base64";
import { Token } from "@/old/utils/types/token";

interface LPAssetViewProps {
sectionTitle: string;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ export const Navbar = () => {
)}
</Box>
)
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useEffect, useState } from 'react';
import { Box, Text, Flex } from '@chakra-ui/react';
import { fetchAllTokenAssets } from '@/utils/token/tokenFetch';
import { fetchAllTokenAssets } from '@/old/utils/token/tokenFetch';
import OutsideClickHandler from 'react-outside-click-handler';
import { Token } from '@/utils/types/token';
import { Token } from '@/old/utils/types/token';

const orderedAssets = ['UM', 'USDC'];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
/* eslint-disable -- disabling this file as this was created before our strict rules */

import { useEffect, useState } from "react";
import { Price, Trace, TraceType } from "../../pages/block/[block_height]";
import { Price, Trace, TraceType } from "../../../pages/block/[block_height]";
import { Box, Link, Stack, VStack } from "@chakra-ui/react";
import {
SwapExecution,
SwapExecution_Trace,
} from "@penumbra-zone/protobuf/penumbra/core/component/dex/v1/dex_pb";
import { fetchAllTokenAssets } from "@/utils/token/tokenFetch";
import { Token } from "@/utils/types/token";
import { LoadingSpinner } from "@/components/util/loadingSpinner";
import { fetchAllTokenAssets } from "@/old/utils/token/tokenFetch";
import { Token } from "@/old/utils/types/token";
import { LoadingSpinner } from "@/old/components/util/loadingSpinner";

export const routes = [
{ path: "/lp/utils" },
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { uint8ArrayToBase64, base64ToUint8Array } from "../math/base64";
import { Constants } from "../configConstants.ts";
import { Constants } from "../configConstants";
import {
AssetId,
AssetImage,
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/pages/api/arbs/[...params].ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// pages/api/arbs/[...params].ts

import { DexQueryServiceClient } from '@/utils/protos/services/dex/dex-query-service-client';
import { DexQueryServiceClient } from '@/old/utils/protos/services/dex/dex-query-service-client';
import { NextApiRequest, NextApiResponse } from 'next';

const grpcEndpoint = process.env['PENUMBRA_GRPC_ENDPOINT'];
Expand Down
2 changes: 1 addition & 1 deletion src/pages/api/blockTimestamps/[...params].js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint-disable -- disabling this file as this was created before our strict rules */
// pages/api/blockTimestamps/[...params].js

import { IndexerQuerier } from "../../../utils/indexer/connector";
import { IndexerQuerier } from "../../../old/utils/indexer/connector";

const indexerEndpoint = process.env.PENUMBRA_INDEXER_ENDPOINT;
if (!indexerEndpoint) {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/api/blocks/[...params].js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint-disable -- disabling this file as this was created before our strict rules */
// pages/api/blocks/[...params].js

import { IndexerQuerier } from "../../../utils/indexer/connector";
import { IndexerQuerier } from "../../../old/utils/indexer/connector";

const grpcEndpoint = process.env.PENUMBRA_GRPC_ENDPOINT;
if (!grpcEndpoint) {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/api/lp/[lp_nft_id].js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-nocheck
/* eslint-disable -- disabling this file as this was created before our strict rules */
// pages/api/lp/[lp_nft_id].js
import { IndexerQuerier } from "../../../utils/indexer/connector";
import { IndexerQuerier } from "../../../old/utils/indexer/connector";

const indexerEndpoint = process.env.PENUMBRA_INDEXER_ENDPOINT
if (!indexerEndpoint) {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/api/lp/[lp_nft_id]/position.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-nocheck
/* eslint-disable -- disabling this file as this was created before our strict rules */
// pages/api/lp/[lp_nft_id]/position.ts
import { DexQueryServiceClient } from "../../../../utils/protos/services/dex/dex-query-service-client";
import { DexQueryServiceClient } from "@/old/utils/protos/services/dex/dex-query-service-client";
import {
PositionId,
Position,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/api/lp/[lp_nft_id]/trades.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-nocheck
/* eslint-disable -- disabling this file as this was created before our strict rules */
// pages/api/lp/[lp_nft_id]/trades.js
import { IndexerQuerier } from "../../../../utils/indexer/connector";
import { IndexerQuerier } from "../../../../old/utils/indexer/connector";

const indexerEndpoint = process.env.PENUMBRA_INDEXER_ENDPOINT
if (!indexerEndpoint) {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/api/lp/block/[...params].js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-nocheck
/* eslint-disable -- disabling this file as this was created before our strict rules */
// pages/api/lp/positionsByBlockHeight/[...params].js
import { IndexerQuerier } from "../../../../utils/indexer/connector";
import { IndexerQuerier } from "../../../../old/utils/indexer/connector";

const indexerEndpoint = process.env.PENUMBRA_INDEXER_ENDPOINT
if (!indexerEndpoint) {
Expand Down
6 changes: 3 additions & 3 deletions src/pages/api/lp/positionsByPrice/[...params].ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
/* eslint-disable -- disabling this file as this was created before our strict rules */
// pages/api/lp/positionsByPrice/[...params].ts
import { NextApiRequest, NextApiResponse } from "next";
import { DexQueryServiceClient } from "@/utils/protos/services/dex/dex-query-service-client";
import { DexQueryServiceClient } from "@/old/utils/protos/services/dex/dex-query-service-client";
import {
DirectedTradingPair,
Position,
} from "@penumbra-zone/protobuf/penumbra/core/component/dex/v1/dex_pb";
import { base64ToUint8Array } from "@/utils/math/base64";
import { fetchAllTokenAssets } from "@/utils/token/tokenFetch";
import { base64ToUint8Array } from "@/old/utils/math/base64";
import { fetchAllTokenAssets } from "@/old/utils/token/tokenFetch";

const grpcEndpoint = process.env.PENUMBRA_GRPC_ENDPOINT!;
if (!grpcEndpoint) {
Expand Down
Loading

0 comments on commit bdf9ab6

Please sign in to comment.