mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
refactor EtherscanLink
This commit is contained in:
parent
3fdf26aaa2
commit
6a7c6819e4
@ -1,19 +1,21 @@
|
|||||||
import React, { ReactElement, ReactNode } from 'react'
|
import React, { ReactElement, ReactNode } from 'react'
|
||||||
|
import { getNetworkName } from '../../utils/wallet'
|
||||||
import { ReactComponent as External } from '../../images/external.svg'
|
import { ReactComponent as External } from '../../images/external.svg'
|
||||||
import styles from './EtherscanLink.module.css'
|
import styles from './EtherscanLink.module.css'
|
||||||
|
|
||||||
export default function EtherscanLink({
|
export default function EtherscanLink({
|
||||||
network,
|
networkId,
|
||||||
path,
|
path,
|
||||||
children
|
children
|
||||||
}: {
|
}: {
|
||||||
network?: 'rinkeby' | 'kovan' | 'ropsten'
|
networkId: number
|
||||||
path: string
|
path: string
|
||||||
children: ReactNode
|
children: ReactNode
|
||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
const url = network
|
const url =
|
||||||
? `https://${network}.etherscan.io`
|
networkId === 1
|
||||||
: `https://etherscan.io`
|
? `https://etherscan.io`
|
||||||
|
: `https://${getNetworkName(networkId).toLowerCase()}.etherscan.io`
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<a
|
<a
|
||||||
|
@ -4,6 +4,7 @@ import Button from '../../../atoms/Button'
|
|||||||
import styles from './Actions.module.css'
|
import styles from './Actions.module.css'
|
||||||
import EtherscanLink from '../../../atoms/EtherscanLink'
|
import EtherscanLink from '../../../atoms/EtherscanLink'
|
||||||
import SuccessConfetti from '../../../atoms/SuccessConfetti'
|
import SuccessConfetti from '../../../atoms/SuccessConfetti'
|
||||||
|
import { useOcean } from '@oceanprotocol/react'
|
||||||
|
|
||||||
export default function Actions({
|
export default function Actions({
|
||||||
isLoading,
|
isLoading,
|
||||||
@ -18,6 +19,8 @@ export default function Actions({
|
|||||||
actionName: string
|
actionName: string
|
||||||
action: () => void
|
action: () => void
|
||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
|
const { networkId } = useOcean()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className={styles.actions}>
|
<div className={styles.actions}>
|
||||||
@ -33,7 +36,7 @@ export default function Actions({
|
|||||||
<SuccessConfetti
|
<SuccessConfetti
|
||||||
success="Successfully added liquidity."
|
success="Successfully added liquidity."
|
||||||
action={
|
action={
|
||||||
<EtherscanLink network="rinkeby" path={`/tx/${txId}`}>
|
<EtherscanLink networkId={networkId} path={`/tx/${txId}`}>
|
||||||
See on Etherscan
|
See on Etherscan
|
||||||
</EtherscanLink>
|
</EtherscanLink>
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement {
|
|||||||
const data = useStaticQuery(contentQuery)
|
const data = useStaticQuery(contentQuery)
|
||||||
const content = data.content.edges[0].node.childContentJson.pool
|
const content = data.content.edges[0].node.childContentJson.pool
|
||||||
|
|
||||||
const { ocean, accountId } = useOcean()
|
const { ocean, accountId, networkId } = useOcean()
|
||||||
const { price } = useMetadata(ddo)
|
const { price } = useMetadata(ddo)
|
||||||
const { dtSymbol } = usePricing(ddo)
|
const { dtSymbol } = usePricing(ddo)
|
||||||
|
|
||||||
@ -153,12 +153,15 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement {
|
|||||||
<Tooltip content={content.tooltips.price} />
|
<Tooltip content={content.tooltips.price} />
|
||||||
<div className={styles.dataTokenLinks}>
|
<div className={styles.dataTokenLinks}>
|
||||||
<EtherscanLink
|
<EtherscanLink
|
||||||
network="rinkeby"
|
networkId={networkId}
|
||||||
path={`address/${price.address}`}
|
path={`address/${price.address}`}
|
||||||
>
|
>
|
||||||
Pool
|
Pool
|
||||||
</EtherscanLink>
|
</EtherscanLink>
|
||||||
<EtherscanLink network="rinkeby" path={`token/${ddo.dataToken}`}>
|
<EtherscanLink
|
||||||
|
networkId={networkId}
|
||||||
|
path={`token/${ddo.dataToken}`}
|
||||||
|
>
|
||||||
Datatoken
|
Datatoken
|
||||||
</EtherscanLink>
|
</EtherscanLink>
|
||||||
</div>
|
</div>
|
||||||
|
@ -5,7 +5,7 @@ import styles from './MetaFull.module.css'
|
|||||||
import { MetadataMarket } from '../../../@types/MetaData'
|
import { MetadataMarket } from '../../../@types/MetaData'
|
||||||
import { DDO } from '@oceanprotocol/lib'
|
import { DDO } from '@oceanprotocol/lib'
|
||||||
import EtherscanLink from '../../atoms/EtherscanLink'
|
import EtherscanLink from '../../atoms/EtherscanLink'
|
||||||
import { usePricing } from '@oceanprotocol/react'
|
import { useOcean, usePricing } from '@oceanprotocol/react'
|
||||||
|
|
||||||
export default function MetaFull({
|
export default function MetaFull({
|
||||||
ddo,
|
ddo,
|
||||||
@ -14,6 +14,7 @@ export default function MetaFull({
|
|||||||
ddo: DDO
|
ddo: DDO
|
||||||
metadata: MetadataMarket
|
metadata: MetadataMarket
|
||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
|
const { networkId } = useOcean()
|
||||||
const { id, dataToken } = ddo
|
const { id, dataToken } = ddo
|
||||||
const { dateCreated, datePublished, author, license } = metadata.main
|
const { dateCreated, datePublished, author, license } = metadata.main
|
||||||
const { dtSymbol, dtName } = usePricing(ddo)
|
const { dtSymbol, dtName } = usePricing(ddo)
|
||||||
@ -48,7 +49,7 @@ export default function MetaFull({
|
|||||||
<MetaItem
|
<MetaItem
|
||||||
title="Datatoken"
|
title="Datatoken"
|
||||||
content={
|
content={
|
||||||
<EtherscanLink network="rinkeby" path={`token/${dataToken}`}>
|
<EtherscanLink networkId={networkId} path={`token/${dataToken}`}>
|
||||||
{dtName ? `${dtName} - ${dtSymbol}` : <code>{dataToken}</code>}
|
{dtName ? `${dtName} - ${dtSymbol}` : <code>{dataToken}</code>}
|
||||||
</EtherscanLink>
|
</EtherscanLink>
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ function AssetTitle({ did }: { did: string }): ReactElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Title({ row }: { row: PoolTransaction }) {
|
function Title({ row }: { row: PoolTransaction }) {
|
||||||
const { ocean } = useOcean()
|
const { ocean, networkId } = useOcean()
|
||||||
const [dtSymbol, setDtSymbol] = useState<string>()
|
const [dtSymbol, setDtSymbol] = useState<string>()
|
||||||
|
|
||||||
const title = row.tokenAmountIn
|
const title = row.tokenAmountIn
|
||||||
@ -37,7 +37,7 @@ function Title({ row }: { row: PoolTransaction }) {
|
|||||||
}, [ocean, row])
|
}, [ocean, row])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<EtherscanLink network="rinkeby" path={`/tx/${row.transactionHash}`}>
|
<EtherscanLink networkId={networkId} path={`/tx/${row.transactionHash}`}>
|
||||||
{title}
|
{title}
|
||||||
</EtherscanLink>
|
</EtherscanLink>
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user