@@ -30,9 +30,11 @@ const CompactAddress = ({ address }: { address: string }) => (
3030const 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