Skip to content

Commit

Permalink
#99 Remove old graphql codegen config (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
nevendyulgerov authored Feb 2, 2024
1 parent 37045ff commit 07abb2b
Show file tree
Hide file tree
Showing 25 changed files with 104 additions and 129 deletions.
24 changes: 0 additions & 24 deletions apps/web/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,6 @@ import type { Types } from "@graphql-codegen/plugin-helpers";
import { join, sep } from "path";

const schema = "https://mainnet.api.cartesiscan.io/graphql";
const plugins = [
{
add: {
content:
'import type { DocumentNode } from "graphql/language/ast";',
},
},
"typescript",
"typescript-operations",
"typescript-urql",
];

const config = {
withHooks: true,
};

console.info(`Codegen will use schema URL: ${schema}`);

Expand Down Expand Up @@ -92,15 +77,6 @@ const generateConfig = (configs: CommonConfig[]): Generates => {

const codegenConfig: CodegenConfig = {
generates: {
/**
* @deprecated Will be removed in future updates see {@link https://github.com/cartesi/rollups-explorer/issues/99}
*/
"src/graphql/index.tsx": {
schema,
documents: "./graphql/queries.graphql",
plugins,
config,
},
...generateConfig(setup),
},
};
Expand Down
10 changes: 5 additions & 5 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
"dependencies": {
"@cartesi/rollups-explorer-ui": "*",
"@cartesi/rollups-wagmi": "*",
"@mantine/core": "^7.3.0",
"@mantine/form": "^7.3.0",
"@mantine/hooks": "^7.3.0",
"@mantine/notifications": "^7.3.0",
"@mantine/core": "^7.5.0",
"@mantine/form": "^7.5.0",
"@mantine/hooks": "^7.5.0",
"@mantine/notifications": "^7.5.0",
"@rainbow-me/rainbowkit": "1.2.0",
"@react-spring/web": "^9.7.3",
"abitype": "^0.9",
Expand Down Expand Up @@ -66,7 +66,7 @@
"jsdom": "22.1.0",
"npm-run-all": "^4",
"postcss": "^8",
"postcss-preset-mantine": "^1.6",
"postcss-preset-mantine": "^1.12.3",
"postcss-simple-vars": "^7",
"ts-node": "^10",
"typescript": "^5",
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/applications/applicationRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ActionIcon, Table, Tooltip } from "@mantine/core";
import Address from "../address";
import Link from "next/link";
import { TbInbox, TbPlugConnected, TbPlugConnectedX } from "react-icons/tb";
import { Application } from "../../graphql";
import { Application } from "../../graphql/explorer/types";
import { useConnectionConfig } from "../../providers/connectionConfig/hooks";

export interface ApplicationRowProps {
Expand Down
6 changes: 2 additions & 4 deletions apps/web/src/components/applications/applications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import { Stack } from "@mantine/core";
import { FC, useCallback, useState } from "react";
import {
ApplicationOrderByInput,
useApplicationsConnectionQuery,
} from "../../graphql";
import { ApplicationOrderByInput } from "../../graphql/explorer/types";
import { useApplicationsConnectionQuery } from "../../graphql/explorer/hooks/queries";
import ApplicationsTable from "../applications/applicationsTable";
import Paginated from "../paginated";

Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/applications/applicationsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import { Loader, Table } from "@mantine/core";
import { FC } from "react";
import ApplicationRow from "./applicationRow";
import type { ApplicationItemFragment } from "../../graphql";
import { Application } from "../../graphql";
import { ApplicationItemFragment } from "../../graphql/explorer/operations";
import { Application } from "../../graphql/explorer/types";

export interface ApplicationsTableProps {
applications: ApplicationItemFragment[];
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/connection/connectionForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
ApplicationsDocument,
ApplicationsQuery,
ApplicationsQueryVariables,
} from "../../graphql";
} from "../../graphql/explorer/operations";
import {
CheckStatusDocument,
CheckStatusQuery,
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/entriesSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { Summary } from "@cartesi/rollups-explorer-ui";
import { FC } from "react";
import { useStatsQuery } from "../graphql";
import { useStatsQuery } from "../graphql/explorer/hooks/queries";

const EntriesSummary: FC = () => {
const [{ data: stats }] = useStatsQuery();
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/inputs/inputCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Group, Paper, Stack, Text } from "@mantine/core";
import { FC } from "react";
import prettyMilliseconds from "pretty-ms";
import Jazzicon, { jsNumberForAddress } from "react-jazzicon";
import { InputItemFragment } from "../../graphql";
import { InputItemFragment } from "../../graphql/explorer/operations";

export type InputCardProps = {
input: InputItemFragment;
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/inputs/inputDetailsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { omit, pathOr } from "ramda";
import { FC, useEffect, useState } from "react";
import { useQuery } from "urql";
import { Address } from "viem";
import { InputItemFragment } from "../../graphql";
import { InputItemFragment } from "../../graphql/explorer/operations";
import {
InputDetailsDocument,
InputDetailsQuery,
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/inputs/inputRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import prettyMilliseconds from "pretty-ms";
import { FC } from "react";
import { TbArrowRight, TbFileText, TbX } from "react-icons/tb";
import { Address as AddressType, formatUnits, getAddress } from "viem";
import { InputItemFragment } from "../../graphql";
import { InputItemFragment } from "../../graphql/explorer/operations";
import Address from "../address";
import InputDetailsView from "./inputDetailsView";

Expand Down
5 changes: 3 additions & 2 deletions apps/web/src/components/inputs/inputs.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"use client";

import { Stack } from "@mantine/core";
import { FC, useCallback, useEffect, useState } from "react";
import { InputOrderByInput, useInputsQuery } from "../../graphql";
import { FC, useCallback, useState } from "react";
import { InputOrderByInput } from "../../graphql/explorer/types";
import { useInputsQuery } from "../../graphql/explorer/hooks/queries";
import InputsTable from "../inputs/inputsTable";
import Paginated from "../paginated";

Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/inputs/inputsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from "@mantine/core";
import { FC, useCallback, useRef, useState } from "react";
import InputRow from "./inputRow";
import type { InputItemFragment } from "../../graphql";
import type { InputItemFragment } from "../../graphql/explorer/operations";
import { useElementVisibility } from "../../hooks/useElementVisibility";
import { TableResponsiveWrapper } from "../tableResponsiveWrapper";

Expand Down
14 changes: 11 additions & 3 deletions apps/web/src/components/latestEntries.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
"use client";
import { Card } from "@cartesi/rollups-explorer-ui";
import { Button, Grid, Group, Text, useMantineTheme } from "@mantine/core";
import {
Button,
Card,
Grid,
Group,
Text,
useMantineTheme,
} from "@mantine/core";
import type { FC } from "react";
import Link from "next/link";
import { TbApps, TbInbox } from "react-icons/tb";
import LatestEntriesTable, { Entry } from "./latestEntriesTable";
import {
ApplicationOrderByInput,
InputOrderByInput,
} from "../graphql/explorer/types";
import {
useApplicationsConnectionQuery,
useInputsQuery,
} from "../graphql";
} from "../graphql/explorer/hooks/queries";
import type { Address as AddressType } from "abitype/dist/types/abi";
import { IconType } from "react-icons";
import { useMediaQuery } from "@mantine/hooks";
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/hooks/useSearchApplications.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { useApplicationsQuery } from "../graphql";
import { useApplicationsQuery } from "../graphql/explorer/hooks/queries";

export const useSearchApplications = ({
address,
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/hooks/useSearchTokens.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { useTokensQuery } from "../graphql";
import { useTokensQuery } from "../graphql/explorer/hooks/queries";

export const useSearchTokens = ({
address,
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/providers/styleProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { MantineProvider } from "@mantine/core";
import { Notifications } from "@mantine/notifications";
import { FC } from "react";
import type { FC, ReactNode } from "react";
import { theme } from "./theme";

export type StyleProviderProps = {
children?: React.ReactNode;
children?: ReactNode;
};

const StyleProvider: FC<StyleProviderProps> = (props) => {
Expand Down
7 changes: 7 additions & 0 deletions apps/web/src/providers/theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
List,
MantineThemeOverride,
Modal,
Card,
createTheme,
mergeMantineTheme,
} from "@mantine/core";
Expand Down Expand Up @@ -44,6 +45,12 @@ const themeOverride: MantineThemeOverride = createTheme({
spacing: "0.5rem",
},
}),
Card: Card.extend({
defaultProps: {
shadow: "sm",
withBorder: true,
},
}),
},
});

Expand Down
8 changes: 5 additions & 3 deletions apps/web/test/components/latestEntries.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it } from "vitest";
import { fireEvent, render, screen } from "@testing-library/react";
import { render, screen } from "@testing-library/react";
import { withMantineTheme } from "../utils/WithMantineTheme";
import LatestEntries from "../../src/components/latestEntries";

Expand Down Expand Up @@ -196,8 +196,10 @@ const applications = [
},
];

vi.mock("../../src/graphql", async () => {
const actual = await vi.importActual("../../src/graphql");
vi.mock("../../src/graphql/explorer/hooks/queries", async () => {
const actual = await vi.importActual(
"../../src/graphql/explorer/hooks/queries",
);
return {
...(actual as any),
useInputsQuery: () => [
Expand Down
18 changes: 13 additions & 5 deletions apps/web/test/components/sendTransaction.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import SendTransaction from "../../src/components/sendTransaction";
import withMantineTheme from "../utils/WithMantineTheme";
const Component = withMantineTheme(SendTransaction);

vi.mock("../../src/graphql", async () => {
vi.mock("../../src/graphql/explorer/hooks/queries", async () => {
return {
useApplicationsQuery: () => [{ data: {}, fetching: false }],
useTokensQuery: () => [{ data: {}, fetching: false }],
Expand Down Expand Up @@ -108,7 +108,9 @@ describe("SendTransaction component", () => {

it("should initially query 10 applications with no predefined search", async () => {
const mockedFn = vi.fn().mockReturnValue([{ data: {} }]);
const graphqlModule = await import("../../src/graphql");
const graphqlModule = await import(
"../../src/graphql/explorer/hooks/queries"
);
graphqlModule.useApplicationsQuery = vi
.fn()
.mockImplementation(mockedFn);
Expand All @@ -129,7 +131,9 @@ describe("SendTransaction component", () => {
render(<Component initialDepositType="input" />);

const mockedFn = vi.fn().mockReturnValue([{ data: {} }]);
const graphqlModule = await import("../../src/graphql");
const graphqlModule = await import(
"../../src/graphql/explorer/hooks/queries"
);
graphqlModule.useApplicationsQuery = vi
.fn()
.mockImplementation(mockedFn);
Expand Down Expand Up @@ -174,7 +178,9 @@ describe("SendTransaction component", () => {

it("should initially query 10 tokens with no predefined search", async () => {
const mockedFn = vi.fn().mockReturnValue([{ data: {} }]);
const graphqlModule = await import("../../src/graphql");
const graphqlModule = await import(
"../../src/graphql/explorer/hooks/queries"
);
graphqlModule.useTokensQuery = vi.fn().mockImplementation(mockedFn);

render(<Component initialDepositType="input" />);
Expand All @@ -193,7 +199,9 @@ describe("SendTransaction component", () => {
render(<Component initialDepositType="erc20" />);

const mockedFn = vi.fn().mockReturnValue([{ data: {} }]);
const graphqlModule = await import("../../src/graphql");
const graphqlModule = await import(
"../../src/graphql/explorer/hooks/queries"
);
graphqlModule.useTokensQuery = vi.fn().mockImplementation(mockedFn);

const tokenInputForm = screen.queryByTestId(
Expand Down
2 changes: 1 addition & 1 deletion apps/web/test/utils/useQueryMock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
ApplicationsDocument,
ApplicationsQuery,
ApplicationsQueryVariables,
} from "../../src/graphql";
} from "../../src/graphql/explorer/operations";
import {
CheckStatusDocument,
CheckStatusQuery,
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
},
"dependencies": {
"@cartesi/rollups-wagmi": "*",
"@mantine/core": "^7.3.0",
"@mantine/hooks": "^7.3.0",
"@mantine/core": "^7.5.0",
"@mantine/hooks": "^7.5.0",
"@react-spring/web": "^9.7.3",
"ramda": "^0.29.0",
"react-icons": "^4",
Expand Down
31 changes: 0 additions & 31 deletions packages/ui/src/Card.tsx

This file was deleted.

3 changes: 1 addition & 2 deletions packages/ui/src/SummaryCard.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"use client";
import { Group, Text } from "@mantine/core";
import { Card, Group, Text } from "@mantine/core";
import { FC } from "react";
import { IconType } from "react-icons";
import { Card } from "./Card";
import TweenedNumber from "./TweenedNumber";

export type SummaryCardProps = {
Expand Down
1 change: 0 additions & 1 deletion packages/ui/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export { Card } from "./Card";
export { ERC20DepositForm } from "./ERC20DepositForm";
export { EtherDepositForm } from "./EtherDepositForm";
export {
Expand Down
Loading

0 comments on commit 07abb2b

Please sign in to comment.