Skip to content

Commit 83c69c7

Browse files
committed
feat: Move explorer URL determination to ChainInfo
1 parent 05a8806 commit 83c69c7

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

packages/neuron-wallet/src/controllers/app/menu.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { UpdateController } from 'controllers'
66
import { showWindow } from './show-window'
77
import NetworksService from 'services/networks'
88
import WalletsService from 'services/wallets'
9+
import ChainInfo from 'models/chain-info'
910
import CommandSubject from 'models/subjects/command'
1011

1112
enum URL {
@@ -437,7 +438,7 @@ const contextMenuTemplate: {
437438
},
438439
{
439440
label: i18n.t('contextMenu.view-on-explorer'),
440-
click: () => { shell.openExternal(`${env.explorer}/address/${address}`) }
441+
click: () => { shell.openExternal(`${ChainInfo.getInstance().explorerUrl()}/address/${address}`) }
441442
},
442443
]
443444
},
@@ -455,7 +456,7 @@ const contextMenuTemplate: {
455456
},
456457
{
457458
label: i18n.t('contextMenu.view-on-explorer'),
458-
click: () => { shell.openExternal(`${env.explorer}/transaction/${hash}`) }
459+
click: () => { shell.openExternal(`${ChainInfo.getInstance().explorerUrl()}/transaction/${hash}`) }
459460
},
460461
]
461462
},

packages/neuron-wallet/src/env.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ interface ENV {
3939
current: 'testnet'
4040
list: NetworkWithID[]
4141
}
42-
explorer: string
4342
isTestMode: boolean
4443
}
4544
const env: ENV = {
@@ -66,7 +65,6 @@ const env: ENV = {
6665
},
6766
],
6867
},
69-
explorer: 'https://explorer.nervos.org',
7068
isTestMode,
7169
}
7270

packages/neuron-wallet/src/models/chain-info.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,11 @@ export default class ChainInfo {
2222
public isMainnet = (): boolean => {
2323
return this.chain === 'ckb'
2424
}
25+
26+
public explorerUrl = (): string => {
27+
if (this.isMainnet()) {
28+
return "https://explorer.nervos.org"
29+
}
30+
return "https://explorer.nervos.org" // TODO: change this to proper testnet explorer URL
31+
}
2532
}

0 commit comments

Comments
 (0)