Skip to content

Commit

Permalink
feat(persistence-ethereum): migrate to separate db schema
Browse files Browse the repository at this point in the history
- Move all database entities relating to ethereum persistence plugin to
  a seprate schema. Adjust all the files the test to work as expected after
  that change.
- Remove sample SQL data from GUI package, one from persistence packages should
  be used instead.
- Upgrade web3-utils in persistence-ethereum to fix a bug when running the
  standalone script.

Depends on #3340

Signed-off-by: Michal Bajer <[email protected]>
  • Loading branch information
outSH authored and petermetz committed Aug 9, 2024
1 parent d0e4539 commit 3aca556
Show file tree
Hide file tree
Showing 13 changed files with 611 additions and 1,712 deletions.
10 changes: 0 additions & 10 deletions packages/cacti-ledger-browser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,6 @@ npm install
- Execute `yarn run start` or `npm start` in this package directory.
- The running application address: http://localhost:3001/ (can be changed in [Vite configuration](./vite.config.ts))

#### Sample Data

- To preview the GUI without running the persistence plugins you can use historic sample data located at `packages/cacti-ledger-browser/src/test/sql/sample-data.sql`.
- Use `psql` tool to import it to your supabase postgres DB instance.
- example:

```bash
psql "postgres://postgres.DB_NAME:[email protected]:5432/postgres" -f src/test/sql/sample-data.sql
```

## Contributing

We welcome contributions to Hyperledger Cacti in many forms, and there’s always plenty to do!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* @todo Move to separate directory if this file becomes too complex.
*/

import { createClient } from "@supabase/supabase-js";
import { queryOptions } from "@tanstack/react-query";
import { supabase, supabaseQueryKey } from "../../common/supabase-client";
import {
Transaction,
Block,
Expand All @@ -13,6 +13,15 @@ import {
TokenERC20,
} from "../../common/supabase-types";

// TODO - Configure for an app
const supabaseQueryKey = "supabase:ethereum";
const supabaseUrl = "__SUPABASE_URL__";
const supabaseKey = "__SUPABASE_KEY__";

export const supabase = createClient(supabaseUrl, supabaseKey, {
schema: "ethereum",
});

function createQueryKey(
tableName: string,
pagination: { page: number; pageSize: number },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from "react";
import { useQuery } from "@tanstack/react-query";
import { GetStatusResponse } from "../types/app";
import { useNotification } from "../context/NotificationContext";
import { persistencePluginStatus } from "../queries";

/**
Expand All @@ -13,11 +12,9 @@ export function usePersistenceAppStatus(pluginName: string): GetStatusResponse {
const { isError, isPending, data, error } = useQuery(
persistencePluginStatus(pluginName),
);
const { showNotification } = useNotification();

React.useEffect(() => {
isError &&
showNotification(`Could get ${pluginName} status: ${error}`, "error");
isError && console.error(`Could get ${pluginName} status: ${error}`);
}, [isError]);

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import CircularProgress from "@mui/material/CircularProgress";

import StackedRowItems from "../ui/StackedRowItems";
import { persistencePluginStatus } from "../../common/queries";
import { useNotification } from "../../common/context/NotificationContext";

type DateTimeStringProps = {
dateString: string | undefined;
Expand All @@ -31,11 +30,9 @@ export default function PersistencePluginStatus({
const { isError, isPending, data, error } = useQuery(
persistencePluginStatus(pluginName),
);
const { showNotification } = useNotification();

React.useEffect(() => {
isError &&
showNotification(`Could get ${pluginName} status: ${error}`, "error");
isError && console.error(`Could get ${pluginName} status: ${error}`);
}, [isError]);

return (
Expand Down
Loading

0 comments on commit 3aca556

Please sign in to comment.