Skip to content

Commit 67aceb8

Browse files
committed
feat(neuron-ui): update the explorer url according to chain type.
1 parent 8f71903 commit 67aceb8

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

  • packages/neuron-ui/src/components/Transaction

packages/neuron-ui/src/components/Transaction/index.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ const CompactAddress = ({ address }: { address: string }) => (
3030
const Transaction = () => {
3131
const [t] = useTranslation()
3232
const [transaction, setTransaction] = useState(transactionState)
33-
const [addressPrefix, setAddressPrefix] = useState(ckbCore.utils.AddressPrefix.Mainnet)
33+
const [isMainnet, setIsMainnet] = useState(false)
3434
const [error, setError] = useState({ code: '', message: '' })
3535

36+
const addressPrefix = isMainnet ? ckbCore.utils.AddressPrefix.Mainnet : ckbCore.utils.AddressPrefix.Testnet
37+
3638
const inputColumns: IColumn[] = useMemo(
3739
() =>
3840
[
@@ -198,9 +200,7 @@ const Transaction = () => {
198200
throw new Error('Cannot find current network in the network list')
199201
}
200202

201-
setAddressPrefix(
202-
network.chain === MAINNET_TAG ? ckbCore.utils.AddressPrefix.Mainnet : ckbCore.utils.AddressPrefix.Testnet
203-
)
203+
setIsMainnet(network.chain === MAINNET_TAG)
204204
}
205205
})
206206
.catch(err => console.warn(err))
@@ -245,10 +245,9 @@ const Transaction = () => {
245245
}, [])
246246

247247
const onExplorerBtnClick = useCallback(() => {
248-
const isMainnet = false // TODO: add conditional branch on mainnet and testnet
249248
const explorerUrl = isMainnet ? 'https://explorer.nervos.org' : 'https://explorer.nervos.org/testnet'
250249
openExternal(`${explorerUrl}/transaction/${transaction.hash}`)
251-
}, [transaction.hash])
250+
}, [transaction.hash, isMainnet])
252251

253252
const basicInfoItems = useMemo(
254253
() => [

0 commit comments

Comments
 (0)