Skip to content

Commit

Permalink
Simplify network config
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaw3d committed Dec 13, 2022
1 parent 026c9c1 commit d2c298b
Showing 1 changed file with 0 additions and 75 deletions.
75 changes: 0 additions & 75 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,77 +1,5 @@
export enum BackendAPIs {
OasisMonitor = 'oasismonitor',
OasisScan = 'oasisscan',
}

export type NetworkType = 'local' | 'testnet' | 'mainnet'

export const consensusDecimals = 9

type BackendApiUrls = {
explorer: string
blockExplorer: string
blockExplorerParatimes?: string
}

type BackendProviders = {
grpc: string
ticker: string // from nic.stakingTokenSymbol()
min_delegation: number // from nic.stakingConsensusParameters().min_delegation
[BackendAPIs.OasisMonitor]: BackendApiUrls
[BackendAPIs.OasisScan]: BackendApiUrls
}

type BackendConfig = {
[key in NetworkType]: BackendProviders
}

export const config: BackendConfig = {
mainnet: {
grpc: 'https://grpc.oasis.dev',
ticker: 'ROSE',
min_delegation: 100,
[BackendAPIs.OasisMonitor]: {
explorer: 'https://monitor.oasis.dev',
blockExplorer: 'https://oasismonitor.com/operation/{{txHash}}',
},
[BackendAPIs.OasisScan]: {
explorer: 'https://api.oasisscan.com/mainnet',
blockExplorer: 'https://oasisscan.com/transactions/{{txHash}}',
blockExplorerParatimes: 'https://oasisscan.com/paratimes/transactions/{{txHash}}?runtime={{runtimeId}}',
},
},
testnet: {
grpc: 'https://testnet.grpc.oasis.dev',
ticker: 'TEST',
min_delegation: 100,
[BackendAPIs.OasisMonitor]: {
explorer: 'https://monitor.oasis.dev/api/testnet',
blockExplorer: 'https://testnet.oasismonitor.com/operation/{{txHash}}',
},
[BackendAPIs.OasisScan]: {
explorer: 'https://api.oasisscan.com/testnet',
blockExplorer: 'https://testnet.oasisscan.com/transactions/{{txHash}}',
blockExplorerParatimes:
'https://testnet.oasisscan.com/paratimes/transactions/{{txHash}}?runtime={{runtimeId}}',
},
},
local: {
grpc: 'http://localhost:42280',
ticker: 'TEST',
min_delegation: 100,
[BackendAPIs.OasisMonitor]: {
explorer: 'http://localhost:9001',
blockExplorer: 'http://localhost:9001/data/transactions?operation_id={{txHash}}',
},
[BackendAPIs.OasisScan]: {
explorer: 'http://localhost:9001',
blockExplorer: 'http://localhost:9001/data/transactions?operation_id={{txHash}}',
blockExplorerParatimes:
'http://localhost:9001/data/paratimes/transactions/{{txHash}}?runtime={{runtimeId}}',
},
},
}

type ParaTimeNetwork = {
address: string | undefined
runtimeId: string | undefined
Expand Down Expand Up @@ -157,6 +85,3 @@ export const paraTimesConfig: ParaTimesConfig = {
[ParaTime.Emerald]: emeraldConfig,
[ParaTime.Sapphire]: sapphireConfig,
}

// https://github.com/mozilla/webextension-polyfill/blob/6e3e26c/src/browser-polyfill.js#L9
export const runtimeIs = (window as any).chrome?.runtime?.id ? 'extension' : 'webapp'

0 comments on commit d2c298b

Please sign in to comment.