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.
- Add `sample-persistence-plugin-setup` script for performing end-to-end tests
  of the persistence ethereum plugin.
- Upgrade web3-utils in persistence-ethereum to fix a bug when running the
  standalone script.

Depends on hyperledger-cacti#3340

Signed-off-by: Michal Bajer <michal.bajer@fujitsu.com>
  • Loading branch information
outSH committed Jun 21, 2024
1 parent 45ab083 commit 81d7bfd
Show file tree
Hide file tree
Showing 15 changed files with 474 additions and 1,444 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 @@ -50,16 +50,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:DB_PASS@aws-0-eu-central-1.pooler.supabase.com: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,16 @@ import {
TokenERC20,
} from "../../common/supabase-types";

// TODO - Configure for an app
const supabaseQueryKey = "supabase:ethereum";
const supabaseUrl = "http://localhost:8000";
const supabaseKey =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE";

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 81d7bfd

Please sign in to comment.