Skip to content

Commit

Permalink
feat: Move explorer URL determination to ChainInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
ashchan committed Oct 31, 2019
1 parent 05a8806 commit 83c69c7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/neuron-wallet/src/controllers/app/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { UpdateController } from 'controllers'
import { showWindow } from './show-window'
import NetworksService from 'services/networks'
import WalletsService from 'services/wallets'
import ChainInfo from 'models/chain-info'
import CommandSubject from 'models/subjects/command'

enum URL {
Expand Down Expand Up @@ -437,7 +438,7 @@ const contextMenuTemplate: {
},
{
label: i18n.t('contextMenu.view-on-explorer'),
click: () => { shell.openExternal(`${env.explorer}/address/${address}`) }
click: () => { shell.openExternal(`${ChainInfo.getInstance().explorerUrl()}/address/${address}`) }
},
]
},
Expand All @@ -455,7 +456,7 @@ const contextMenuTemplate: {
},
{
label: i18n.t('contextMenu.view-on-explorer'),
click: () => { shell.openExternal(`${env.explorer}/transaction/${hash}`) }
click: () => { shell.openExternal(`${ChainInfo.getInstance().explorerUrl()}/transaction/${hash}`) }
},
]
},
Expand Down
2 changes: 0 additions & 2 deletions packages/neuron-wallet/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ interface ENV {
current: 'testnet'
list: NetworkWithID[]
}
explorer: string
isTestMode: boolean
}
const env: ENV = {
Expand All @@ -66,7 +65,6 @@ const env: ENV = {
},
],
},
explorer: 'https://explorer.nervos.org',
isTestMode,
}

Expand Down
7 changes: 7 additions & 0 deletions packages/neuron-wallet/src/models/chain-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,11 @@ export default class ChainInfo {
public isMainnet = (): boolean => {
return this.chain === 'ckb'
}

public explorerUrl = (): string => {
if (this.isMainnet()) {
return "https://explorer.nervos.org"
}
return "https://explorer.nervos.org" // TODO: change this to proper testnet explorer URL
}
}

0 comments on commit 83c69c7

Please sign in to comment.