Skip to content

Commit

Permalink
feat(neuron-ui): update the explorer url according to chain type.
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-CY committed Nov 10, 2019
1 parent 8f71903 commit 67aceb8
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions packages/neuron-ui/src/components/Transaction/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ const CompactAddress = ({ address }: { address: string }) => (
const Transaction = () => {
const [t] = useTranslation()
const [transaction, setTransaction] = useState(transactionState)
const [addressPrefix, setAddressPrefix] = useState(ckbCore.utils.AddressPrefix.Mainnet)
const [isMainnet, setIsMainnet] = useState(false)
const [error, setError] = useState({ code: '', message: '' })

const addressPrefix = isMainnet ? ckbCore.utils.AddressPrefix.Mainnet : ckbCore.utils.AddressPrefix.Testnet

const inputColumns: IColumn[] = useMemo(
() =>
[
Expand Down Expand Up @@ -198,9 +200,7 @@ const Transaction = () => {
throw new Error('Cannot find current network in the network list')
}

setAddressPrefix(
network.chain === MAINNET_TAG ? ckbCore.utils.AddressPrefix.Mainnet : ckbCore.utils.AddressPrefix.Testnet
)
setIsMainnet(network.chain === MAINNET_TAG)
}
})
.catch(err => console.warn(err))
Expand Down Expand Up @@ -245,10 +245,9 @@ const Transaction = () => {
}, [])

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

const basicInfoItems = useMemo(
() => [
Expand Down

0 comments on commit 67aceb8

Please sign in to comment.