diff --git a/package.json b/package.json index 9da48da..9f9955f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ghost-wallet", - "version": "0.0.27", + "version": "0.1.0", "description": "Browser extension to manage ghost blockchain light clients.", "main": "dist/src/index.js", "author": "Uncle f4ts0 ", diff --git a/src/constants.ts b/src/constants.ts index 30d4243..452f55c 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,17 +1,45 @@ -export const wellKnownGenesisHashByChainId: Record = { - casper_staging_testnet: "0x07074eb5f47a6f4dd70430674e5174d5414bc055292b90392fb6f0a28c7524d1", +type Network = { + chainId: string + label: string + value: string + logo: string + prefix: number + decimals: number } -export const wellKnownChainIdByGenesisHash: Record = { - "0x07074eb5f47a6f4dd70430674e5174d5414bc055292b90392fb6f0a28c7524d1": "casper_staging_testnet", -} +export const networks: Network[] = [ + { + chainId: "0xa217f4ee58a944470e9633ca5bd6d28a428ed64cd9b6f3e413565f359f89af90", + value: "casper_staging_testnet", + label: "CASPER", + logo: "https://cryptologos.cc/logos/ghostchain-logo.svg", + prefix: 1996, + decimals: 18, + } +] -export const wellKnownPrefixByGenesisHash: Record = { - "0x07074eb5f47a6f4dd70430674e5174d5414bc055292b90392fb6f0a28c7524d1": 1996, -} +export const wellKnownGenesisHashByChainId: Record = + networks.reduce((wellKnownChainIds, { chainId, value }) => { + wellKnownChainIds[value] = chainId + return wellKnownChainIds + }) -export const wellKnownDecimalsByGenesisHash: Record = { - "0x07074eb5f47a6f4dd70430674e5174d5414bc055292b90392fb6f0a28c7524d1": 18, -} +export const wellKnownChainIdByGenesisHash: Record = + networks.reduce((wellKnownChainName, { chainId, value }) => { + wellKnownChainName[chainId] = value + return wellKnownChainName + }) + +export const wellKnownPrefixByGenesisHash: Record = + networks.reduce((wellKnownPrefixes, { chainId, prefix }) => { + wellKnownPrefixes[chainId] = prefix + return wellKnownPrefixes + }) + +export const wellKnownDecimalsByGenesisHash: Record = + networks.reduce((wellKnownDecimals, { decimals, chainId }) => { + wellKnownDecimals[chainId] = decimals + return wellKnownDecimals + }) export const CHANNEL_ID = "ghost-extension" diff --git a/src/environment.ts b/src/environment.ts index a0194f6..2b4b2fb 100644 --- a/src/environment.ts +++ b/src/environment.ts @@ -1,3 +1,5 @@ +import { networks } from "@/constants" + export type StorageEntry = { type: "braveSetting" } export type StorageEntryType = @@ -7,7 +9,7 @@ export async function getDefaultBootnodes( chain: string, ): Promise { if ( - ["casper_staging_testnet"].includes(chain) + networks.some(network => network.value.includes(chain)) ) { const bootNodes = ( await (