Skip to content

Commit

Permalink
Merge pull request #48 from kaspa-live/about
Browse files Browse the repository at this point in the history
About
  • Loading branch information
tiram88 authored Aug 12, 2022
2 parents 8bf5a74 + 76134d9 commit fd35f03
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 11 deletions.
2 changes: 2 additions & 0 deletions api/src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}
Expand Down
1 change: 1 addition & 0 deletions api/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ export type BlockHashById = {
export type AppConfig = {
kaspadVersion: string,
processingVersion: string,
network: string,
apiVersion: string,
}
2 changes: 1 addition & 1 deletion processing/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
1 change: 1 addition & 0 deletions processing/database/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
1 change: 1 addition & 0 deletions processing/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions processing/processing/processing.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func NewProcessing(config *configPackage.Config,
ID: true,
KaspadVersion: version.Version(),
ProcessingVersion: versionPackage.Version(),
Network: config.ActiveNetParams.Name,
}

processing := &Processing{
Expand Down
5 changes: 5 additions & 0 deletions web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ const theme = createTheme({
paper: "#fff"
},

brand: {
logo: {
main: "#71c9bb",
},
},
block: {
blue: {
main: "#5581AA",
Expand Down
38 changes: 29 additions & 9 deletions web/src/components/sidebar/KaspaButton.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<AnimatedCircle>
<Tooltip
title={
<div>
Kaspa Graph Inspector (KGI)<br/>
<Box sx={{
fontWeight: 'normal',
fontSize: '1.2em'
}}>
<strong>Kaspa Graph Inspector (KGI)</strong><br/>
<br/>
KGI: v{appConfig ? appConfig.webVersion : "n/a"}<br/>
Kaspad: v{appConfig ? appConfig.kaspadVersion : "n/a"}<br/>
<br/>
KGI v{appConfig ? appConfig.webVersion : "n/a"}<br/>
Kaspad v{appConfig ? appConfig.kaspadVersion : "n/a"}
</div>
Network: <strong>{appConfig ? appConfig.network : "n/a"}</strong>
</Box>
}
placement="left"
arrow
Expand All @@ -23,14 +43,14 @@ const KaspaLogo = ({ appConfig }: {appConfig: AppConfig | null}) => {
<Box sx={{
borderRadius: '50%',
borderStyle: 'solid',
borderColor: '#ffffff',
borderColor: logoBkgColor,
borderWidth: '6px',
height: '92px',
backgroundColor: '#ffffff'
backgroundColor: logoBkgColor
}}>
<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="-4 -4 132 132">
<g>
<path d="M116.27,38.3A59.47,59.47,0,0,0,103.17,19c-5.4-5.4-12.4-9.5-19.6-12.5a58.81,58.81,0,0,0-22.7-4.3c-8,0-16.2.3-23.2,3.2-7.2,3-13.3,8.7-18.7,14.1S7.17,30.7,4.17,37.9c-2.8,7-1.9,15.5-1.9,23.5s.6,15.8,3.5,22.8c3,7.3,9.1,12.4,14.5,17.8s10.4,11.9,17.6,14.9a61.11,61.11,0,0,0,23,4.9c8,0,15.8-2.4,22.8-5.3a60.41,60.41,0,0,0,32-32.4c2.9-7,6.2-14.7,6.2-22.7S119.17,45.4,116.27,38.3ZM77.57,95.6l-12.7-1.9,3.7-24.6L42,89.6l-7.8-10.2,23.3-18L34.17,43.5,42,33.3l26.6,20.5-3.7-24.6,12.7-1.9,5.1,34.1Z" style={{fill:"#71c9bb"}}/>
<path d="M116.27,38.3A59.47,59.47,0,0,0,103.17,19c-5.4-5.4-12.4-9.5-19.6-12.5a58.81,58.81,0,0,0-22.7-4.3c-8,0-16.2.3-23.2,3.2-7.2,3-13.3,8.7-18.7,14.1S7.17,30.7,4.17,37.9c-2.8,7-1.9,15.5-1.9,23.5s.6,15.8,3.5,22.8c3,7.3,9.1,12.4,14.5,17.8s10.4,11.9,17.6,14.9a61.11,61.11,0,0,0,23,4.9c8,0,15.8-2.4,22.8-5.3a60.41,60.41,0,0,0,32-32.4c2.9-7,6.2-14.7,6.2-22.7S119.17,45.4,116.27,38.3ZM77.57,95.6l-12.7-1.9,3.7-24.6L42,89.6l-7.8-10.2,23.3-18L34.17,43.5,42,33.3l26.6,20.5-3.7-24.6,12.7-1.9,5.1,34.1Z" style={{fill:logoColor}}/>
</g>
</svg>
</Box>
Expand Down
12 changes: 11 additions & 1 deletion web/src/model/AppConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { packageVersion } from "../version";
export type AppConfig = {
kaspadVersion: string,
processingVersion: string,
network: string,
apiVersion: string,
webVersion: string,
};
Expand All @@ -11,6 +12,7 @@ export function getDefaultAppConfig(): AppConfig {
return {
kaspadVersion: "n/a",
processingVersion: "n/a",
network: "n/a",
apiVersion: "n/a",
webVersion: packageVersion,
};
Expand All @@ -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;
}


export function isTestnet(appConfig: AppConfig): boolean {
return appConfig.network === "kaspa-testnet";
}

export function isMainnet(appConfig: AppConfig): boolean {
return appConfig.network === "kaspa-mainnet";
}
8 changes: 8 additions & 0 deletions web/src/types/createPalette.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -11,6 +15,10 @@ declare module '@mui/material/styles/createPalette' {
}

interface Palette {
brand: {
logo: PaletteColor;
}

block: {
blue: PaletteColor;
red: PaletteColor;
Expand Down

0 comments on commit fd35f03

Please sign in to comment.