mirror of
https://github.com/oceanprotocol/react.git
synced 2025-02-14 21:10:38 +01:00
remove search exchange in getFirstExchangePrice
Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>
This commit is contained in:
parent
7b0daa11de
commit
f031b8902b
@ -11,8 +11,7 @@ import {
|
|||||||
getBuyDTFeedback,
|
getBuyDTFeedback,
|
||||||
getSellDTFeedback,
|
getSellDTFeedback,
|
||||||
sleep,
|
sleep,
|
||||||
getDataTokenPrice,
|
getDataTokenPrice
|
||||||
getBestDataTokenPrice
|
|
||||||
} from 'utils'
|
} from 'utils'
|
||||||
|
|
||||||
interface UsePricing {
|
interface UsePricing {
|
||||||
|
@ -110,14 +110,11 @@ export async function getCheapestExchangePrice(
|
|||||||
|
|
||||||
export async function getFirstExchangePrice(
|
export async function getFirstExchangePrice(
|
||||||
ocean: Ocean,
|
ocean: Ocean,
|
||||||
dataTokenAddress: string
|
exchangeId?: string
|
||||||
): Promise<BestPrice> {
|
): Promise<BestPrice> {
|
||||||
try {
|
try {
|
||||||
const tokenExchanges = await ocean.fixedRateExchange.searchforDT(
|
if (!exchangeId) {
|
||||||
dataTokenAddress,
|
Logger.log('exchangeId is undefined in getFirstExchangePrice')
|
||||||
'1'
|
|
||||||
)
|
|
||||||
if (tokenExchanges === undefined || tokenExchanges.length === 0) {
|
|
||||||
return {
|
return {
|
||||||
type: '',
|
type: '',
|
||||||
address: '',
|
address: '',
|
||||||
@ -128,7 +125,19 @@ export async function getFirstExchangePrice(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const [tokenExchange] = tokenExchanges
|
const tokenExchange = await ocean.fixedRateExchange.getExchange(exchangeId)
|
||||||
|
|
||||||
|
if (tokenExchange === undefined) {
|
||||||
|
Logger.log('tokenExchange is undefined in getFirstExchangePrice')
|
||||||
|
return {
|
||||||
|
type: '',
|
||||||
|
address: '',
|
||||||
|
pools: [],
|
||||||
|
datatoken: 0,
|
||||||
|
value: 0,
|
||||||
|
isConsumable: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: 'exchange',
|
type: 'exchange',
|
||||||
@ -235,14 +244,14 @@ export async function getDataTokenPrice(
|
|||||||
ocean: Ocean,
|
ocean: Ocean,
|
||||||
dataTokenAddress: string,
|
dataTokenAddress: string,
|
||||||
type?: string,
|
type?: string,
|
||||||
poolAddress?: string
|
address?: string
|
||||||
): Promise<BestPrice> {
|
): Promise<BestPrice> {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'pool': {
|
case 'pool': {
|
||||||
return await getFirstPoolPrice(ocean, dataTokenAddress, poolAddress)
|
return await getFirstPoolPrice(ocean, dataTokenAddress, address)
|
||||||
}
|
}
|
||||||
case 'exchange': {
|
case 'exchange': {
|
||||||
return await getFirstExchangePrice(ocean, dataTokenAddress)
|
return await getFirstExchangePrice(ocean, address)
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
return await getBestDataTokenPrice(ocean, dataTokenAddress)
|
return await getBestDataTokenPrice(ocean, dataTokenAddress)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user