diff --git a/api/src/database.ts b/api/src/database.ts index 5d104da..236f27b 100644 --- a/api/src/database.ts +++ b/api/src/database.ts @@ -148,12 +148,14 @@ export default class Database { return { kaspadVersion: "", processingVersion: "", + network: "", apiVersion: "", } } return { kaspadVersion: result.rows[0].kaspad_version, processingVersion: result.rows[0].processing_version, + network: result.rows[0].network, apiVersion: packageVersion, }; } diff --git a/api/src/model.ts b/api/src/model.ts index e095b5c..4dbdb7e 100644 --- a/api/src/model.ts +++ b/api/src/model.ts @@ -41,5 +41,6 @@ export type BlockHashById = { export type AppConfig = { kaspadVersion: string, processingVersion: string, + network: string, apiVersion: string, } \ No newline at end of file diff --git a/processing/database/database.go b/processing/database/database.go index 4ada0ce..c86677a 100644 --- a/processing/database/database.go +++ b/processing/database/database.go @@ -375,7 +375,7 @@ func (db *Database) GetAppConfig(databaseTransaction *pg.Tx) (*model.AppConfig, // Consequently, the database stores at most one AppConfig row. func (db *Database) StoreAppConfig(databaseTransaction *pg.Tx, appConfig *model.AppConfig) error { appConfig.ID = true - _, err := databaseTransaction.Model(appConfig).OnConflict("(id) DO UPDATE SET kaspad_version = EXCLUDED.kaspad_version, processing_version = EXCLUDED.processing_version").Insert() + _, err := databaseTransaction.Model(appConfig).OnConflict("(id) DO UPDATE SET kaspad_version = EXCLUDED.kaspad_version, processing_version = EXCLUDED.processing_version, network = EXCLUDED.network").Insert() if err != nil { return err } diff --git a/processing/database/migrations/000007_app_config_network.up.sql b/processing/database/migrations/000007_app_config_network.up.sql new file mode 100644 index 0000000..76a1150 --- /dev/null +++ b/processing/database/migrations/000007_app_config_network.up.sql @@ -0,0 +1,5 @@ +ALTER TABLE app_config + ADD COLUMN network TEXT NULL; +UPDATE app_config SET network = ''; +ALTER TABLE app_config ALTER + COLUMN network SET NOT NULL; diff --git a/processing/database/model/model.go b/processing/database/model/model.go index 3532a08..9f68045 100644 --- a/processing/database/model/model.go +++ b/processing/database/model/model.go @@ -42,4 +42,5 @@ type AppConfig struct { ID bool `pg:"id,pk"` KaspadVersion string `pg:"kaspad_version"` ProcessingVersion string `pg:"processing_version"` + Network string `pg:"network"` } diff --git a/processing/main.go b/processing/main.go index 885f16a..94d0914 100644 --- a/processing/main.go +++ b/processing/main.go @@ -24,6 +24,7 @@ func main() { logging.Logger().Infof("Application version %s", versionPackage.Version()) logging.Logger().Infof("Embedded kaspad version %s", version.Version()) + logging.Logger().Infof("Network %s", config.ActiveNetParams.Name) database, err := databasePackage.Connect(config.DatabaseConnectionString) if err != nil { diff --git a/processing/processing/processing.go b/processing/processing/processing.go index 8c0f4ac..dfee84b 100644 --- a/processing/processing/processing.go +++ b/processing/processing/processing.go @@ -37,6 +37,7 @@ func NewProcessing(config *configPackage.Config, ID: true, KaspadVersion: version.Version(), ProcessingVersion: versionPackage.Version(), + Network: config.ActiveNetParams.Name, } processing := &Processing{ diff --git a/web/src/App.tsx b/web/src/App.tsx index c4fa05c..39cf8cb 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -117,6 +117,11 @@ const theme = createTheme({ paper: "#fff" }, + brand: { + logo: { + main: "#71c9bb", + }, + }, block: { blue: { main: "#5581AA", diff --git a/web/src/components/sidebar/KaspaButton.tsx b/web/src/components/sidebar/KaspaButton.tsx index bfd7437..6826986 100644 --- a/web/src/components/sidebar/KaspaButton.tsx +++ b/web/src/components/sidebar/KaspaButton.tsx @@ -1,19 +1,39 @@ import { Box, ButtonBase, Tooltip, useTheme } from "@mui/material"; -import { AppConfig } from "../../model/AppConfig"; +import { AppConfig, isMainnet, isTestnet } from "../../model/AppConfig"; import AnimatedCircle from "../base/AnimatedCircle"; const KaspaLogo = ({ appConfig }: {appConfig: AppConfig | null}) => { const theme = useTheme(); + let logoColor = theme.palette.brand.logo.main; + let logoBkgColor = theme.palette.background.paper; + + if (appConfig) { + if (isMainnet(appConfig)) { + // Do nothing + } else if (isTestnet(appConfig)) { + logoColor = theme.palette.background.paper; + logoBkgColor = theme.palette.brand.logo.main; + } else { + logoColor = theme.palette.primary.light; + } + + } + return ( - Kaspa Graph Inspector (KGI)
+ + Kaspa Graph Inspector (KGI)
+
+ KGI: v{appConfig ? appConfig.webVersion : "n/a"}
+ Kaspad: v{appConfig ? appConfig.kaspadVersion : "n/a"}

- KGI v{appConfig ? appConfig.webVersion : "n/a"}
- Kaspad v{appConfig ? appConfig.kaspadVersion : "n/a"} - + Network: {appConfig ? appConfig.network : "n/a"} +
} placement="left" arrow @@ -23,14 +43,14 @@ const KaspaLogo = ({ appConfig }: {appConfig: AppConfig | null}) => { - + diff --git a/web/src/model/AppConfig.ts b/web/src/model/AppConfig.ts index 327cafb..8eb9499 100644 --- a/web/src/model/AppConfig.ts +++ b/web/src/model/AppConfig.ts @@ -3,6 +3,7 @@ import { packageVersion } from "../version"; export type AppConfig = { kaspadVersion: string, processingVersion: string, + network: string, apiVersion: string, webVersion: string, }; @@ -11,6 +12,7 @@ export function getDefaultAppConfig(): AppConfig { return { kaspadVersion: "n/a", processingVersion: "n/a", + network: "n/a", apiVersion: "n/a", webVersion: packageVersion, }; @@ -19,7 +21,15 @@ export function getDefaultAppConfig(): AppConfig { export function areAppConfigsEqual(left: AppConfig, right: AppConfig): boolean { return left.kaspadVersion === right.kaspadVersion && left.processingVersion === right.processingVersion + && left.network === right.network && left.apiVersion === right.apiVersion && left.webVersion === right.webVersion; } - \ No newline at end of file + +export function isTestnet(appConfig: AppConfig): boolean { + return appConfig.network === "kaspa-testnet"; +} + +export function isMainnet(appConfig: AppConfig): boolean { + return appConfig.network === "kaspa-mainnet"; +} diff --git a/web/src/types/createPalette.d.ts b/web/src/types/createPalette.d.ts index 6723bfe..c0147ce 100644 --- a/web/src/types/createPalette.d.ts +++ b/web/src/types/createPalette.d.ts @@ -3,6 +3,10 @@ import { BlockColor as BaseBlockColor } from "./Base"; declare module '@mui/material/styles/createPalette' { interface PaletteOptions { + brand: { + logo?: PaletteColorOptions; + } + block: { blue?: PaletteColorOptions; red?: PaletteColorOptions; @@ -11,6 +15,10 @@ declare module '@mui/material/styles/createPalette' { } interface Palette { + brand: { + logo: PaletteColor; + } + block: { blue: PaletteColor; red: PaletteColor;