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:
parent
6a449eadcb
commit
fac744e94a
@ -149,11 +149,13 @@ export function getQuerryString(
|
||||
sort: { sortBy: SortTermOptions.Created },
|
||||
filters: [
|
||||
getFilterTerm('metadata.type', 'algorithm'),
|
||||
getFilterTerm('_id', algorithmDidList)
|
||||
algorithmDidList.length > 0 && getFilterTerm('_id', algorithmDidList)
|
||||
]
|
||||
} as BaseQueryParams
|
||||
|
||||
const query = generateBaseQuery(baseParams)
|
||||
console.log('query', query)
|
||||
|
||||
return query
|
||||
}
|
||||
|
||||
@ -162,22 +164,29 @@ export async function getAlgorithmsForAsset(
|
||||
token: CancelToken
|
||||
): Promise<Asset[]> {
|
||||
const computeService: Service = getServiceByName(asset, 'compute')
|
||||
const publisherTrustedAlgorithms =
|
||||
computeService.compute.publisherTrustedAlgorithms || []
|
||||
console.log('asset', asset)
|
||||
console.log('computeService', computeService)
|
||||
|
||||
let algorithms: Asset[]
|
||||
if (
|
||||
!computeService.compute ||
|
||||
!computeService.compute.publisherTrustedAlgorithms ||
|
||||
computeService.compute.publisherTrustedAlgorithms.length === 0
|
||||
!computeService.compute
|
||||
// !computeService.compute.publisherTrustedAlgorithms ||
|
||||
// computeService.compute.publisherTrustedAlgorithms.length === 0
|
||||
) {
|
||||
algorithms = []
|
||||
} else {
|
||||
console.log(
|
||||
'computeService.compute.publisherTrustedAlgorithms',
|
||||
publisherTrustedAlgorithms
|
||||
)
|
||||
const gueryResults = await queryMetadata(
|
||||
getQuerryString(
|
||||
computeService.compute.publisherTrustedAlgorithms,
|
||||
asset.chainId
|
||||
),
|
||||
getQuerryString(publisherTrustedAlgorithms, asset.chainId),
|
||||
token
|
||||
)
|
||||
algorithms = gueryResults?.results
|
||||
console.log('algorithms', algorithms)
|
||||
}
|
||||
return algorithms
|
||||
}
|
||||
@ -188,11 +197,7 @@ export async function getAlgorithmAssetSelectionList(
|
||||
): Promise<AssetSelectionAsset[]> {
|
||||
const computeService: Service = getServiceByName(asset, 'compute')
|
||||
let algorithmSelectionList: AssetSelectionAsset[]
|
||||
if (
|
||||
!computeService.compute ||
|
||||
!computeService.compute.publisherTrustedAlgorithms ||
|
||||
computeService.compute.publisherTrustedAlgorithms.length === 0
|
||||
) {
|
||||
if (!computeService.compute) {
|
||||
algorithmSelectionList = []
|
||||
} else {
|
||||
algorithmSelectionList = await transformAssetToAssetSelection(
|
||||
|
@ -128,7 +128,6 @@ export default function Compute({
|
||||
!isAlgoConsumablePrice)
|
||||
|
||||
async function checkAssetDTBalance(asset: DDO) {
|
||||
console.log('checkAssetDTBalance asset ', asset)
|
||||
if (!asset?.services[0].datatokenAddress) return
|
||||
const datatokenInstance = new Datatoken(web3)
|
||||
const dtBalance = await datatokenInstance.balance(
|
||||
@ -136,38 +135,9 @@ export default function Compute({
|
||||
accountId
|
||||
)
|
||||
setAlgorithmDTBalance(new Decimal(dtBalance).toString())
|
||||
console.log('dtBalance ', dtBalance)
|
||||
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(() => {
|
||||
if (!asset?.accessDetails || !accountId) return
|
||||
|
||||
@ -179,14 +149,12 @@ export default function Compute({
|
||||
if (asset?.accessDetails?.addressOrId === ZERO_ADDRESS) return
|
||||
const validUntil = getValidUntilTime()
|
||||
const computeEnv = await getComputeEnviroment(asset)
|
||||
console.log('asset compute env', computeEnv)
|
||||
const orderPriceAndFees = await getOrderPriceAndFees(
|
||||
asset,
|
||||
computeEnv.id,
|
||||
validUntil,
|
||||
ZERO_ADDRESS
|
||||
)
|
||||
console.log('asset orderPriceAndFees', orderPriceAndFees)
|
||||
setOrderPriceAndFees(orderPriceAndFees)
|
||||
}
|
||||
init()
|
||||
@ -390,7 +358,7 @@ export default function Compute({
|
||||
computeAlgorithm,
|
||||
newAbortController(),
|
||||
null,
|
||||
output
|
||||
null
|
||||
)
|
||||
if (!response) {
|
||||
setError('Error starting compute job.')
|
||||
|
Loading…
x
Reference in New Issue
Block a user