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

fix algorithms selection list on allowAllPublisher case

This commit is contained in:
Bogdan Fazakas 2022-03-03 17:42:29 +02:00
parent 6a449eadcb
commit fac744e94a
2 changed files with 19 additions and 46 deletions

View File

@ -149,11 +149,13 @@ export function getQuerryString(
sort: { sortBy: SortTermOptions.Created }, sort: { sortBy: SortTermOptions.Created },
filters: [ filters: [
getFilterTerm('metadata.type', 'algorithm'), getFilterTerm('metadata.type', 'algorithm'),
getFilterTerm('_id', algorithmDidList) algorithmDidList.length > 0 && getFilterTerm('_id', algorithmDidList)
] ]
} as BaseQueryParams } as BaseQueryParams
const query = generateBaseQuery(baseParams) const query = generateBaseQuery(baseParams)
console.log('query', query)
return query return query
} }
@ -162,22 +164,29 @@ export async function getAlgorithmsForAsset(
token: CancelToken token: CancelToken
): Promise<Asset[]> { ): Promise<Asset[]> {
const computeService: Service = getServiceByName(asset, 'compute') const computeService: Service = getServiceByName(asset, 'compute')
const publisherTrustedAlgorithms =
computeService.compute.publisherTrustedAlgorithms || []
console.log('asset', asset)
console.log('computeService', computeService)
let algorithms: Asset[] let algorithms: Asset[]
if ( if (
!computeService.compute || !computeService.compute
!computeService.compute.publisherTrustedAlgorithms || // !computeService.compute.publisherTrustedAlgorithms ||
computeService.compute.publisherTrustedAlgorithms.length === 0 // computeService.compute.publisherTrustedAlgorithms.length === 0
) { ) {
algorithms = [] algorithms = []
} else { } else {
console.log(
'computeService.compute.publisherTrustedAlgorithms',
publisherTrustedAlgorithms
)
const gueryResults = await queryMetadata( const gueryResults = await queryMetadata(
getQuerryString( getQuerryString(publisherTrustedAlgorithms, asset.chainId),
computeService.compute.publisherTrustedAlgorithms,
asset.chainId
),
token token
) )
algorithms = gueryResults?.results algorithms = gueryResults?.results
console.log('algorithms', algorithms)
} }
return algorithms return algorithms
} }
@ -188,11 +197,7 @@ export async function getAlgorithmAssetSelectionList(
): Promise<AssetSelectionAsset[]> { ): Promise<AssetSelectionAsset[]> {
const computeService: Service = getServiceByName(asset, 'compute') const computeService: Service = getServiceByName(asset, 'compute')
let algorithmSelectionList: AssetSelectionAsset[] let algorithmSelectionList: AssetSelectionAsset[]
if ( if (!computeService.compute) {
!computeService.compute ||
!computeService.compute.publisherTrustedAlgorithms ||
computeService.compute.publisherTrustedAlgorithms.length === 0
) {
algorithmSelectionList = [] algorithmSelectionList = []
} else { } else {
algorithmSelectionList = await transformAssetToAssetSelection( algorithmSelectionList = await transformAssetToAssetSelection(

View File

@ -128,7 +128,6 @@ export default function Compute({
!isAlgoConsumablePrice) !isAlgoConsumablePrice)
async function checkAssetDTBalance(asset: DDO) { async function checkAssetDTBalance(asset: DDO) {
console.log('checkAssetDTBalance asset ', asset)
if (!asset?.services[0].datatokenAddress) return if (!asset?.services[0].datatokenAddress) return
const datatokenInstance = new Datatoken(web3) const datatokenInstance = new Datatoken(web3)
const dtBalance = await datatokenInstance.balance( const dtBalance = await datatokenInstance.balance(
@ -136,38 +135,9 @@ export default function Compute({
accountId accountId
) )
setAlgorithmDTBalance(new Decimal(dtBalance).toString()) setAlgorithmDTBalance(new Decimal(dtBalance).toString())
console.log('dtBalance ', dtBalance)
setHasAlgoAssetDatatoken(Number(dtBalance) >= 1) setHasAlgoAssetDatatoken(Number(dtBalance) >= 1)
} }
async function getAlgorithmList(): Promise<AssetSelectionAsset[]> {
const computeService = asset?.services[0]
let algorithmSelectionList: AssetSelectionAsset[]
if (
!computeService.compute ||
!computeService.compute.publisherTrustedAlgorithms ||
computeService.compute.publisherTrustedAlgorithms.length === 0
) {
algorithmSelectionList = []
} else {
const gueryResults = await queryMetadata(
getQuerryString(
computeService.compute.publisherTrustedAlgorithms,
asset.chainId
),
newCancelToken()
)
setDdoAlgorithmList(gueryResults.results)
algorithmSelectionList = await transformAssetToAssetSelection(
computeService?.serviceEndpoint,
gueryResults.results,
[]
)
}
return algorithmSelectionList
}
useEffect(() => { useEffect(() => {
if (!asset?.accessDetails || !accountId) return if (!asset?.accessDetails || !accountId) return
@ -179,14 +149,12 @@ export default function Compute({
if (asset?.accessDetails?.addressOrId === ZERO_ADDRESS) return if (asset?.accessDetails?.addressOrId === ZERO_ADDRESS) return
const validUntil = getValidUntilTime() const validUntil = getValidUntilTime()
const computeEnv = await getComputeEnviroment(asset) const computeEnv = await getComputeEnviroment(asset)
console.log('asset compute env', computeEnv)
const orderPriceAndFees = await getOrderPriceAndFees( const orderPriceAndFees = await getOrderPriceAndFees(
asset, asset,
computeEnv.id, computeEnv.id,
validUntil, validUntil,
ZERO_ADDRESS ZERO_ADDRESS
) )
console.log('asset orderPriceAndFees', orderPriceAndFees)
setOrderPriceAndFees(orderPriceAndFees) setOrderPriceAndFees(orderPriceAndFees)
} }
init() init()
@ -390,7 +358,7 @@ export default function Compute({
computeAlgorithm, computeAlgorithm,
newAbortController(), newAbortController(),
null, null,
output null
) )
if (!response) { if (!response) {
setError('Error starting compute job.') setError('Error starting compute job.')