1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

SHowing asset network name in the algorithm selection form

This commit is contained in:
Jamie Hewitt 2022-12-08 15:25:28 +03:00
parent 5d629382d5
commit 0c64b1e5e7
4 changed files with 37 additions and 5 deletions

View File

@ -2,6 +2,7 @@ import { getAccessDetailsForAssets } from './accessDetailsAndPricing'
import { PublisherTrustedAlgorithm, Asset } from '@oceanprotocol/lib' import { PublisherTrustedAlgorithm, Asset } from '@oceanprotocol/lib'
import { AssetSelectionAsset } from '@shared/FormInput/InputElement/AssetSelection' import { AssetSelectionAsset } from '@shared/FormInput/InputElement/AssetSelection'
import { getServiceByName } from './ddo' import { getServiceByName } from './ddo'
import { chainIds } from 'app.config'
export async function transformAssetToAssetSelection( export async function transformAssetToAssetSelection(
datasetProviderEndpoint: string, datasetProviderEndpoint: string,
@ -32,7 +33,8 @@ export async function transformAssetToAssetSelection(
name: asset.metadata.name, name: asset.metadata.name,
price: asset.accessDetails.price, price: asset.accessDetails.price,
checked: selected, checked: selected,
symbol: asset.datatokens[0].symbol symbol: asset.datatokens[0].symbol,
chainId: asset.chainId
} }
selected selected
? algorithmList.unshift(algorithmAsset) ? algorithmList.unshift(algorithmAsset)

View File

@ -0,0 +1,24 @@
export function chainIdToNetworkName(chainId: number): string {
switch (chainId) {
case 1:
return 'Ethereum'
case 137:
return 'Polygon'
case 56:
return 'Binance Smart Chain'
case 1285:
return 'Moonriver'
case 246:
return 'Energy Web Chain'
case 80001:
return 'Mumbai'
case 8996:
return 'Development'
case 5:
return 'Görli'
case 2021000:
return 'GAIA-X'
default:
return 'Unknown Network'
}
}

View File

@ -9,21 +9,24 @@ describe('@shared/FormInput/InputElement/AssetSelection', () => {
name: 'Asset', name: 'Asset',
price: '10', price: '10',
checked: false, checked: false,
symbol: 'OCEAN' symbol: 'OCEAN',
chainId: 1
}, },
{ {
did: 'did:op:yyy', did: 'did:op:yyy',
name: 'Asset', name: 'Asset',
price: '10', price: '10',
checked: true, checked: true,
symbol: 'OCEAN' symbol: 'OCEAN',
chainId: 137
}, },
{ {
did: 'did:op:zzz', did: 'did:op:zzz',
name: 'Asset', name: 'Asset',
price: '0', price: '0',
checked: false, checked: false,
symbol: 'OCEAN' symbol: 'OCEAN',
chainId: 5
} }
] ]

View File

@ -6,6 +6,7 @@ import External from '@images/external.svg'
import InputElement from '@shared/FormInput/InputElement' import InputElement from '@shared/FormInput/InputElement'
import Loader from '@shared/atoms/Loader' import Loader from '@shared/atoms/Loader'
import styles from './index.module.css' import styles from './index.module.css'
import { chainIdToNetworkName } from '@utils/chainIdToNetworkName'
export interface AssetSelectionAsset { export interface AssetSelectionAsset {
did: string did: string
@ -13,6 +14,7 @@ export interface AssetSelectionAsset {
price: string price: string
checked: boolean checked: boolean
symbol: string symbol: string
chainId: number
} }
function Empty() { function Empty() {
@ -101,7 +103,8 @@ export default function AssetSelection({
</h3> </h3>
<Dotdotdot clamp={1} tagName="code" className={styles.did}> <Dotdotdot clamp={1} tagName="code" className={styles.did}>
{asset.symbol} | {asset.did} {chainIdToNetworkName(asset.chainId)} | {asset.symbol} |{' '}
{asset.did}
</Dotdotdot> </Dotdotdot>
</label> </label>