mirror of
https://github.com/oceanprotocol/react.git
synced 2025-02-12 08:31:05 +01:00
add getBestPool
This commit is contained in:
parent
ca058535c1
commit
881057eb4c
@ -2,7 +2,7 @@ import { useState, useEffect } from 'react'
|
|||||||
import { DID, DDO, Metadata, MetadataStore, Logger } from '@oceanprotocol/lib'
|
import { DID, DDO, Metadata, MetadataStore, Logger } from '@oceanprotocol/lib'
|
||||||
import { useOcean } from '../../providers'
|
import { useOcean } from '../../providers'
|
||||||
import ProviderStatus from '../../providers/OceanProvider/ProviderStatus'
|
import ProviderStatus from '../../providers/OceanProvider/ProviderStatus'
|
||||||
import { getBestDataTokenPrice } from '../../utils/dtUtils'
|
import { getBestDataTokenPrice, getCheapestPool } from '../../utils/dtUtils'
|
||||||
|
|
||||||
interface UseMetadata {
|
interface UseMetadata {
|
||||||
ddo: DDO
|
ddo: DDO
|
||||||
@ -12,6 +12,9 @@ interface UseMetadata {
|
|||||||
getMetadata: (did: DID | string) => Promise<Metadata>
|
getMetadata: (did: DID | string) => Promise<Metadata>
|
||||||
getTitle: (did: DID | string) => Promise<string>
|
getTitle: (did: DID | string) => Promise<string>
|
||||||
getBestPrice: (dataTokenAddress: string) => Promise<string>
|
getBestPrice: (dataTokenAddress: string) => Promise<string>
|
||||||
|
getBestPool: (
|
||||||
|
dataTokenAddress: string
|
||||||
|
) => Promise<{ poolAddress: string; poolPrice: string }>
|
||||||
}
|
}
|
||||||
|
|
||||||
function useMetadata(did?: DID | string): UseMetadata {
|
function useMetadata(did?: DID | string): UseMetadata {
|
||||||
@ -35,6 +38,11 @@ function useMetadata(did?: DID | string): UseMetadata {
|
|||||||
async function getBestPrice(dataTokenAddress: string): Promise<string> {
|
async function getBestPrice(dataTokenAddress: string): Promise<string> {
|
||||||
return await getBestDataTokenPrice(ocean, accountId, dataTokenAddress)
|
return await getBestDataTokenPrice(ocean, accountId, dataTokenAddress)
|
||||||
}
|
}
|
||||||
|
async function getBestPool(
|
||||||
|
dataTokenAddress: string
|
||||||
|
): Promise<{ poolAddress: string; poolPrice: string }> {
|
||||||
|
return await getCheapestPool(ocean, accountId, dataTokenAddress)
|
||||||
|
}
|
||||||
|
|
||||||
async function getMetadata(did: DID | string): Promise<Metadata> {
|
async function getMetadata(did: DID | string): Promise<Metadata> {
|
||||||
const ddo = await getDDO(did)
|
const ddo = await getDDO(did)
|
||||||
@ -68,7 +76,8 @@ function useMetadata(did?: DID | string): UseMetadata {
|
|||||||
getDDO,
|
getDDO,
|
||||||
getMetadata,
|
getMetadata,
|
||||||
getTitle,
|
getTitle,
|
||||||
getBestPrice
|
getBestPrice,
|
||||||
|
getBestPool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user