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

Bump aquarius version (#837)

* sort, update models/queries

* fix cancelation token

* remove console.log

* remove searchquery type

* fix canceltoken

Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>

* remove aquarius2

Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>

* bump lib

* fix type

* remove QueryString
This commit is contained in:
mihaisc 2021-09-24 12:38:32 +03:00 committed by GitHub
parent ae229d1698
commit bf03a62f49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 393 additions and 76 deletions

348
package-lock.json generated
View File

@ -13,7 +13,7 @@
"@coingecko/cryptoformat": "^0.4.4",
"@loadable/component": "^5.15.0",
"@oceanprotocol/art": "^3.2.0",
"@oceanprotocol/lib": "^0.17.3",
"@oceanprotocol/lib": "^0.18.0",
"@oceanprotocol/typographies": "^0.1.0",
"@portis/web3": "^4.1.0",
"@sindresorhus/slugify": "^2.1.0",
@ -5666,9 +5666,9 @@
}
},
"node_modules/@oceanprotocol/lib": {
"version": "0.17.3",
"resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-0.17.3.tgz",
"integrity": "sha512-vBu84tP5vWgEu0mzwUfuoeTHzS2AcQXg1xDifh7ZxFlIhmYSlHeJrUcsm+6Pyojixs7rQuWdMuMVgPSai4xTNg==",
"version": "0.18.0",
"resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-0.18.0.tgz",
"integrity": "sha512-iZL4bKtK5JDBYGqrzaA/bom5Uq/kgrwBQ76m2sU2U4qCkluN67kyAHD9EwOE/g+osZ4E56v+JVnzi3bGurxmsw==",
"dependencies": {
"@ethereum-navigator/navigator": "^0.5.3",
"@oceanprotocol/contracts": "^0.6.5",
@ -5681,10 +5681,193 @@
"save-file": "^2.3.1",
"uuid": "^8.3.2",
"web3": "^1.5.2",
"web3-core": "^1.5.3",
"web3-eth-contract": "^1.5.2"
},
"peerDependencies": {
"web3": "^1.3.5"
"web3": ">=1.3.5"
}
},
"node_modules/@oceanprotocol/lib/node_modules/@types/node": {
"version": "12.20.26",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.26.tgz",
"integrity": "sha512-gIt+h4u2uTho2bsH1K250fUv5fHU71ET1yWT7bM4523zV/XrFb9jlWBOV4DO8FpscY+Sz/WEr1EEjIP2H4yumQ=="
},
"node_modules/@oceanprotocol/lib/node_modules/bignumber.js": {
"version": "9.0.1",
"resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.1.tgz",
"integrity": "sha512-IdZR9mh6ahOBv/hYGiXyVuyCetmGJhtYkqLBpTStdhEGjegpPlUawydyaF3pbIOFynJTpllEs+NP+CS9jKFLjA==",
"engines": {
"node": "*"
}
},
"node_modules/@oceanprotocol/lib/node_modules/bn.js": {
"version": "4.12.0",
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz",
"integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA=="
},
"node_modules/@oceanprotocol/lib/node_modules/eth-lib": {
"version": "0.2.8",
"resolved": "https://registry.npmjs.org/eth-lib/-/eth-lib-0.2.8.tgz",
"integrity": "sha512-ArJ7x1WcWOlSpzdoTBX8vkwlkSQ85CjjifSZtV4co64vWxSV8geWfPI9x4SVYu3DSxnX4yWFVTtGL+j9DUFLNw==",
"dependencies": {
"bn.js": "^4.11.6",
"elliptic": "^6.4.0",
"xhr-request-promise": "^0.1.2"
}
},
"node_modules/@oceanprotocol/lib/node_modules/eventemitter3": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.4.tgz",
"integrity": "sha512-rlaVLnVxtxvoyLsQQFBx53YmXHDxRIzzTLbdfxqi4yocpSjAxXwkU0cScM5JgSKMqEhrZpnvQ2D9gjylR0AimQ=="
},
"node_modules/@oceanprotocol/lib/node_modules/web3-core": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/web3-core/-/web3-core-1.5.3.tgz",
"integrity": "sha512-ACTbu8COCu+0eUNmd9pG7Q9EVsNkAg2w3Y7SqhDr+zjTgbSHZV01jXKlapm9z+G3AN/BziV3zGwudClJ4u4xXQ==",
"dependencies": {
"@types/bn.js": "^4.11.5",
"@types/node": "^12.12.6",
"bignumber.js": "^9.0.0",
"web3-core-helpers": "1.5.3",
"web3-core-method": "1.5.3",
"web3-core-requestmanager": "1.5.3",
"web3-utils": "1.5.3"
},
"engines": {
"node": ">=8.0.0"
}
},
"node_modules/@oceanprotocol/lib/node_modules/web3-core-helpers": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/web3-core-helpers/-/web3-core-helpers-1.5.3.tgz",
"integrity": "sha512-Ip1IjB3S8vN7Kf1PPjK41U5gskmMk6IJQlxIVuS8/1U7n/o0jC8krqtpRwiMfAgYyw3TXwBFtxSRTvJtnLyXZw==",
"dependencies": {
"web3-eth-iban": "1.5.3",
"web3-utils": "1.5.3"
},
"engines": {
"node": ">=8.0.0"
}
},
"node_modules/@oceanprotocol/lib/node_modules/web3-core-method": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/web3-core-method/-/web3-core-method-1.5.3.tgz",
"integrity": "sha512-8wJrwQ2qD9ibWieF9oHXwrJsUGrv3XAtEkNeyvyNMpktNTIjxJ2jaFGQUuLiyUrMubD18XXgLk4JS6PJU4Loeg==",
"dependencies": {
"@ethereumjs/common": "^2.4.0",
"@ethersproject/transactions": "^5.0.0-beta.135",
"web3-core-helpers": "1.5.3",
"web3-core-promievent": "1.5.3",
"web3-core-subscriptions": "1.5.3",
"web3-utils": "1.5.3"
},
"engines": {
"node": ">=8.0.0"
}
},
"node_modules/@oceanprotocol/lib/node_modules/web3-core-promievent": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/web3-core-promievent/-/web3-core-promievent-1.5.3.tgz",
"integrity": "sha512-CFfgqvk3Vk6PIAxtLLuX+pOMozxkKCY+/GdGr7weMh033mDXEPvwyVjoSRO1PqIKj668/hMGQsVoIgbyxkJ9Mg==",
"dependencies": {
"eventemitter3": "4.0.4"
},
"engines": {
"node": ">=8.0.0"
}
},
"node_modules/@oceanprotocol/lib/node_modules/web3-core-requestmanager": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/web3-core-requestmanager/-/web3-core-requestmanager-1.5.3.tgz",
"integrity": "sha512-9k/Bze2rs8ONix5IZR+hYdMNQv+ark2Ek2kVcrFgWO+LdLgZui/rn8FikPunjE+ub7x7pJaKCgVRbYFXjo3ZWg==",
"dependencies": {
"util": "^0.12.0",
"web3-core-helpers": "1.5.3",
"web3-providers-http": "1.5.3",
"web3-providers-ipc": "1.5.3",
"web3-providers-ws": "1.5.3"
},
"engines": {
"node": ">=8.0.0"
}
},
"node_modules/@oceanprotocol/lib/node_modules/web3-core-subscriptions": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/web3-core-subscriptions/-/web3-core-subscriptions-1.5.3.tgz",
"integrity": "sha512-L2m9vG1iRN6thvmv/HQwO2YLhOQlmZU8dpLG6GSo9FBN14Uch868Swk0dYVr3rFSYjZ/GETevSXU+O+vhCummA==",
"dependencies": {
"eventemitter3": "4.0.4",
"web3-core-helpers": "1.5.3"
},
"engines": {
"node": ">=8.0.0"
}
},
"node_modules/@oceanprotocol/lib/node_modules/web3-eth-iban": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/web3-eth-iban/-/web3-eth-iban-1.5.3.tgz",
"integrity": "sha512-vMzmGqolYZvRHwP9P4Nf6G8uYM5aTLlQu2a34vz78p0KlDC+eV1th3+90Qeaupa28EG7OO0IT1F0BejiIauOPw==",
"dependencies": {
"bn.js": "^4.11.9",
"web3-utils": "1.5.3"
},
"engines": {
"node": ">=8.0.0"
}
},
"node_modules/@oceanprotocol/lib/node_modules/web3-providers-http": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/web3-providers-http/-/web3-providers-http-1.5.3.tgz",
"integrity": "sha512-5DpUyWGHtDAr2RYmBu34Fu+4gJuBAuNx2POeiJIooUtJ+Mu6pIx4XkONWH6V+Ez87tZAVAsFOkJRTYuzMr3rPw==",
"dependencies": {
"web3-core-helpers": "1.5.3",
"xhr2-cookies": "1.1.0"
},
"engines": {
"node": ">=8.0.0"
}
},
"node_modules/@oceanprotocol/lib/node_modules/web3-providers-ipc": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/web3-providers-ipc/-/web3-providers-ipc-1.5.3.tgz",
"integrity": "sha512-JmeAptugVpmXI39LGxUSAymx0NOFdgpuI1hGQfIhbEAcd4sv7fhfd5D+ZU4oLHbRI8IFr4qfGU0uhR8BXhDzlg==",
"dependencies": {
"oboe": "2.1.5",
"web3-core-helpers": "1.5.3"
},
"engines": {
"node": ">=8.0.0"
}
},
"node_modules/@oceanprotocol/lib/node_modules/web3-providers-ws": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/web3-providers-ws/-/web3-providers-ws-1.5.3.tgz",
"integrity": "sha512-6DhTw4Q7nm5CFYEUHOJM0gAb3xFx+9gWpVveg3YxJ/ybR1BUvEWo3bLgIJJtX56cYX0WyY6DS35a7f0LOI1kVg==",
"dependencies": {
"eventemitter3": "4.0.4",
"web3-core-helpers": "1.5.3",
"websocket": "^1.0.32"
},
"engines": {
"node": ">=8.0.0"
}
},
"node_modules/@oceanprotocol/lib/node_modules/web3-utils": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.5.3.tgz",
"integrity": "sha512-56nRgA+Ad9SEyCv39g36rTcr5fpsd4L9LgV3FK0aB66nAMazLAA6Qz4lH5XrUKPDyBIPGJIR+kJsyRtwcu2q1Q==",
"dependencies": {
"bn.js": "^4.11.9",
"eth-lib": "0.2.8",
"ethereum-bloom-filters": "^1.0.6",
"ethjs-unit": "0.1.6",
"number-to-bn": "1.7.0",
"randombytes": "^2.1.0",
"utf8": "3.0.0"
},
"engines": {
"node": ">=8.0.0"
}
},
"node_modules/@oceanprotocol/typographies": {
@ -62944,9 +63127,9 @@
}
},
"@oceanprotocol/lib": {
"version": "0.17.3",
"resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-0.17.3.tgz",
"integrity": "sha512-vBu84tP5vWgEu0mzwUfuoeTHzS2AcQXg1xDifh7ZxFlIhmYSlHeJrUcsm+6Pyojixs7rQuWdMuMVgPSai4xTNg==",
"version": "0.18.0",
"resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-0.18.0.tgz",
"integrity": "sha512-iZL4bKtK5JDBYGqrzaA/bom5Uq/kgrwBQ76m2sU2U4qCkluN67kyAHD9EwOE/g+osZ4E56v+JVnzi3bGurxmsw==",
"requires": {
"@ethereum-navigator/navigator": "^0.5.3",
"@oceanprotocol/contracts": "^0.6.5",
@ -62959,7 +63142,156 @@
"save-file": "^2.3.1",
"uuid": "^8.3.2",
"web3": "^1.5.2",
"web3-core": "^1.5.3",
"web3-eth-contract": "^1.5.2"
},
"dependencies": {
"@types/node": {
"version": "12.20.26",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.26.tgz",
"integrity": "sha512-gIt+h4u2uTho2bsH1K250fUv5fHU71ET1yWT7bM4523zV/XrFb9jlWBOV4DO8FpscY+Sz/WEr1EEjIP2H4yumQ=="
},
"bignumber.js": {
"version": "9.0.1",
"resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.1.tgz",
"integrity": "sha512-IdZR9mh6ahOBv/hYGiXyVuyCetmGJhtYkqLBpTStdhEGjegpPlUawydyaF3pbIOFynJTpllEs+NP+CS9jKFLjA=="
},
"bn.js": {
"version": "4.12.0",
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz",
"integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA=="
},
"eth-lib": {
"version": "0.2.8",
"resolved": "https://registry.npmjs.org/eth-lib/-/eth-lib-0.2.8.tgz",
"integrity": "sha512-ArJ7x1WcWOlSpzdoTBX8vkwlkSQ85CjjifSZtV4co64vWxSV8geWfPI9x4SVYu3DSxnX4yWFVTtGL+j9DUFLNw==",
"requires": {
"bn.js": "^4.11.6",
"elliptic": "^6.4.0",
"xhr-request-promise": "^0.1.2"
}
},
"eventemitter3": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.4.tgz",
"integrity": "sha512-rlaVLnVxtxvoyLsQQFBx53YmXHDxRIzzTLbdfxqi4yocpSjAxXwkU0cScM5JgSKMqEhrZpnvQ2D9gjylR0AimQ=="
},
"web3-core": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/web3-core/-/web3-core-1.5.3.tgz",
"integrity": "sha512-ACTbu8COCu+0eUNmd9pG7Q9EVsNkAg2w3Y7SqhDr+zjTgbSHZV01jXKlapm9z+G3AN/BziV3zGwudClJ4u4xXQ==",
"requires": {
"@types/bn.js": "^4.11.5",
"@types/node": "^12.12.6",
"bignumber.js": "^9.0.0",
"web3-core-helpers": "1.5.3",
"web3-core-method": "1.5.3",
"web3-core-requestmanager": "1.5.3",
"web3-utils": "1.5.3"
}
},
"web3-core-helpers": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/web3-core-helpers/-/web3-core-helpers-1.5.3.tgz",
"integrity": "sha512-Ip1IjB3S8vN7Kf1PPjK41U5gskmMk6IJQlxIVuS8/1U7n/o0jC8krqtpRwiMfAgYyw3TXwBFtxSRTvJtnLyXZw==",
"requires": {
"web3-eth-iban": "1.5.3",
"web3-utils": "1.5.3"
}
},
"web3-core-method": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/web3-core-method/-/web3-core-method-1.5.3.tgz",
"integrity": "sha512-8wJrwQ2qD9ibWieF9oHXwrJsUGrv3XAtEkNeyvyNMpktNTIjxJ2jaFGQUuLiyUrMubD18XXgLk4JS6PJU4Loeg==",
"requires": {
"@ethereumjs/common": "^2.4.0",
"@ethersproject/transactions": "^5.0.0-beta.135",
"web3-core-helpers": "1.5.3",
"web3-core-promievent": "1.5.3",
"web3-core-subscriptions": "1.5.3",
"web3-utils": "1.5.3"
}
},
"web3-core-promievent": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/web3-core-promievent/-/web3-core-promievent-1.5.3.tgz",
"integrity": "sha512-CFfgqvk3Vk6PIAxtLLuX+pOMozxkKCY+/GdGr7weMh033mDXEPvwyVjoSRO1PqIKj668/hMGQsVoIgbyxkJ9Mg==",
"requires": {
"eventemitter3": "4.0.4"
}
},
"web3-core-requestmanager": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/web3-core-requestmanager/-/web3-core-requestmanager-1.5.3.tgz",
"integrity": "sha512-9k/Bze2rs8ONix5IZR+hYdMNQv+ark2Ek2kVcrFgWO+LdLgZui/rn8FikPunjE+ub7x7pJaKCgVRbYFXjo3ZWg==",
"requires": {
"util": "^0.12.0",
"web3-core-helpers": "1.5.3",
"web3-providers-http": "1.5.3",
"web3-providers-ipc": "1.5.3",
"web3-providers-ws": "1.5.3"
}
},
"web3-core-subscriptions": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/web3-core-subscriptions/-/web3-core-subscriptions-1.5.3.tgz",
"integrity": "sha512-L2m9vG1iRN6thvmv/HQwO2YLhOQlmZU8dpLG6GSo9FBN14Uch868Swk0dYVr3rFSYjZ/GETevSXU+O+vhCummA==",
"requires": {
"eventemitter3": "4.0.4",
"web3-core-helpers": "1.5.3"
}
},
"web3-eth-iban": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/web3-eth-iban/-/web3-eth-iban-1.5.3.tgz",
"integrity": "sha512-vMzmGqolYZvRHwP9P4Nf6G8uYM5aTLlQu2a34vz78p0KlDC+eV1th3+90Qeaupa28EG7OO0IT1F0BejiIauOPw==",
"requires": {
"bn.js": "^4.11.9",
"web3-utils": "1.5.3"
}
},
"web3-providers-http": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/web3-providers-http/-/web3-providers-http-1.5.3.tgz",
"integrity": "sha512-5DpUyWGHtDAr2RYmBu34Fu+4gJuBAuNx2POeiJIooUtJ+Mu6pIx4XkONWH6V+Ez87tZAVAsFOkJRTYuzMr3rPw==",
"requires": {
"web3-core-helpers": "1.5.3",
"xhr2-cookies": "1.1.0"
}
},
"web3-providers-ipc": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/web3-providers-ipc/-/web3-providers-ipc-1.5.3.tgz",
"integrity": "sha512-JmeAptugVpmXI39LGxUSAymx0NOFdgpuI1hGQfIhbEAcd4sv7fhfd5D+ZU4oLHbRI8IFr4qfGU0uhR8BXhDzlg==",
"requires": {
"oboe": "2.1.5",
"web3-core-helpers": "1.5.3"
}
},
"web3-providers-ws": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/web3-providers-ws/-/web3-providers-ws-1.5.3.tgz",
"integrity": "sha512-6DhTw4Q7nm5CFYEUHOJM0gAb3xFx+9gWpVveg3YxJ/ybR1BUvEWo3bLgIJJtX56cYX0WyY6DS35a7f0LOI1kVg==",
"requires": {
"eventemitter3": "4.0.4",
"web3-core-helpers": "1.5.3",
"websocket": "^1.0.32"
}
},
"web3-utils": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.5.3.tgz",
"integrity": "sha512-56nRgA+Ad9SEyCv39g36rTcr5fpsd4L9LgV3FK0aB66nAMazLAA6Qz4lH5XrUKPDyBIPGJIR+kJsyRtwcu2q1Q==",
"requires": {
"bn.js": "^4.11.9",
"eth-lib": "0.2.8",
"ethereum-bloom-filters": "^1.0.6",
"ethjs-unit": "0.1.6",
"number-to-bn": "1.7.0",
"randombytes": "^2.1.0",
"utf8": "3.0.0"
}
}
}
},
"@oceanprotocol/typographies": {

View File

@ -28,7 +28,7 @@
"@coingecko/cryptoformat": "^0.4.4",
"@loadable/component": "^5.15.0",
"@oceanprotocol/art": "^3.2.0",
"@oceanprotocol/lib": "^0.17.3",
"@oceanprotocol/lib": "^0.18.0",
"@oceanprotocol/typographies": "^0.1.0",
"@portis/web3": "^4.1.0",
"@sindresorhus/slugify": "^2.1.0",

View File

@ -159,7 +159,7 @@ export default function Compute({
query: `${algorithmQuery} service.attributes.main.type:algorithm AND chainId:${chainId} -isInPurgatory:true`
}
},
sort: { created: -1 }
sort: { created: 'desc' }
}
return query
}

View File

@ -1,9 +1,6 @@
import React, { ReactElement, useEffect, useState } from 'react'
import AssetList from '../organisms/AssetList'
import {
QueryResult,
SearchQuery
} from '@oceanprotocol/lib/dist/node/metadatacache/MetadataCache'
import { SearchQuery } from '@oceanprotocol/lib/dist/node/metadatacache/MetadataCache'
import Button from '../atoms/Button'
import Bookmarks from '../molecules/Bookmarks'
import axios from 'axios'
@ -23,8 +20,7 @@ async function getQueryHighest(
): Promise<[SearchQuery, string]> {
const [dids, didsLength] = await getHighestLiquidityDIDs(chainIds)
const queryHighest = {
page: 1,
offset: didsLength > 0 ? didsLength : 1,
size: didsLength > 0 ? didsLength : 1,
query: {
query_string: {
query: `${dids && `(${dids}) AND`}(${transformChainIdsListToQuery(
@ -38,10 +34,9 @@ async function getQueryHighest(
return [queryHighest, dids]
}
function getQueryLatest(chainIds: number[]): SearchQuery {
function getQueryLatest(chainIds: number[]): any {
return {
page: 1,
offset: 9,
size: 9,
query: {
query_string: {
query: `(${transformChainIdsListToQuery(
@ -49,7 +44,7 @@ function getQueryLatest(chainIds: number[]): SearchQuery {
)}) AND -isInPurgatory:true `
}
},
sort: { created: -1 }
sort: { created: 'desc' }
}
}
@ -73,7 +68,7 @@ function SectionQueryResult({
}) {
const { appConfig } = useSiteMetadata()
const { chainIds } = useUserPreferences()
const [result, setResult] = useState<QueryResult>()
const [result, setResult] = useState<any>()
const [loading, setLoading] = useState<boolean>()
useEffect(() => {
@ -82,7 +77,7 @@ function SectionQueryResult({
async function init() {
if (chainIds.length === 0) {
const result: QueryResult = {
const result: any = {
results: [],
page: 0,
totalPages: 0,
@ -94,6 +89,7 @@ function SectionQueryResult({
try {
setLoading(true)
const result = await queryMetadata(query, source.token)
if (queryData && result.totalResults > 0) {
const searchDIDs = queryData.split(' ')
const sortedAssets = sortElements(result.results, searchDIDs)

View File

@ -1,5 +1,4 @@
import { Logger } from '@oceanprotocol/lib'
import { QueryResult } from '@oceanprotocol/lib/dist/node/metadatacache/MetadataCache'
import React, { ReactElement, useEffect, useState } from 'react'
import AssetList from '../../../organisms/AssetList'
import { getPublishedAssets } from '../../../../utils/aquarius'
@ -17,7 +16,7 @@ export default function PublishedList({
const { appConfig } = useSiteMetadata()
const { chainIds } = useUserPreferences()
const [queryResult, setQueryResult] = useState<QueryResult>()
const [queryResult, setQueryResult] = useState<any>()
const [isLoading, setIsLoading] = useState(false)
const [page, setPage] = useState<number>(1)
const [service, setServiceType] = useState('dataset OR algorithm')

View File

@ -1,6 +1,5 @@
import React, { ReactElement, useState, useEffect } from 'react'
import Permission from '../../organisms/Permission'
import { QueryResult } from '@oceanprotocol/lib/dist/node/metadatacache/MetadataCache'
import AssetList from '../../organisms/AssetList'
import queryString from 'query-string'
import Filters from './Filters'
@ -10,6 +9,7 @@ import { navigate } from 'gatsby'
import { updateQueryStringParameter } from '../../../utils'
import { useSiteMetadata } from '../../../hooks/useSiteMetadata'
import { useUserPreferences } from '../../../providers/UserPreferences'
import axios from 'axios'
import styles from './index.module.css'
export default function SearchPage({
@ -26,7 +26,7 @@ export default function SearchPage({
const { text, owner, tags, page, sort, sortOrder, serviceType, accessType } =
parsed
const { chainIds } = useUserPreferences()
const [queryResult, setQueryResult] = useState<QueryResult>()
const [queryResult, setQueryResult] = useState<any>()
const [loading, setLoading] = useState<boolean>()
const [service, setServiceType] = useState<string>(serviceType as string)
const [access, setAccessType] = useState<string>(accessType as string)
@ -36,21 +36,21 @@ export default function SearchPage({
)
useEffect(() => {
if (!appConfig.metadataCacheUri) return
const source = axios.CancelToken.source()
async function initSearch() {
setLoading(true)
setTotalResults(undefined)
const queryResult = await getResults(
parsed,
appConfig.metadataCacheUri,
chainIds
)
const queryResult = await getResults(parsed, chainIds, source.token)
setQueryResult(queryResult)
setTotalResults(queryResult.totalResults)
setTotalPagesNumber(queryResult.totalPages)
setLoading(false)
}
initSearch()
return () => {
source.cancel()
}
}, [
text,
owner,
@ -60,7 +60,6 @@ export default function SearchPage({
serviceType,
accessType,
sortOrder,
appConfig.metadataCacheUri,
chainIds
])

View File

@ -12,7 +12,7 @@ import classNames from 'classnames/bind'
const cx = classNames.bind(styles)
const sortItems = [
// { display: 'Relevance', value: SortTermOptions.Relevance },
{ display: 'Relevance', value: SortTermOptions.Relevance },
{ display: 'Published', value: SortTermOptions.Created }
]

View File

@ -1,11 +1,10 @@
import { QueryResult } from '@oceanprotocol/lib/dist/node/metadatacache/MetadataCache'
import { Logger } from '@oceanprotocol/lib'
import {
queryMetadata,
transformChainIdsListToQuery
} from '../../../utils/aquarius'
import queryString from 'query-string'
import axios from 'axios'
import { CancelToken } from 'axios'
export const SortTermOptions = {
Created: 'created',
@ -61,8 +60,6 @@ export function getSearchQuery(
serviceType?: string,
accessType?: string
): any {
const sortTerm = getSortType(sort)
const sortValue = sortOrder === SortValueOptions.Ascending ? 1 : -1
const emptySearchTerm = text === undefined || text === ''
let searchTerm = owner
? `(publicKey.owner:${owner})`
@ -96,8 +93,8 @@ export function getSearchQuery(
'service.attributes.additionalInformation.tags'
]
return {
page: Number(page) || 1,
offset: Number(offset) || 21,
from: (Number(page) || 0) * (Number(offset) || 21),
size: Number(offset) || 21,
query: {
bool: {
must: [
@ -167,7 +164,7 @@ export function getSearchQuery(
}
},
sort: {
[sortTerm]: sortValue
[sort]: sortOrder
}
}
}
@ -185,9 +182,9 @@ export async function getResults(
serviceType?: string
accessType?: string
},
metadataCacheUri: string,
chainIds: number[]
): Promise<QueryResult> {
chainIds: number[],
cancelToken?: CancelToken
): Promise<any> {
const {
text,
owner,
@ -214,9 +211,7 @@ export async function getResults(
serviceType,
accessType
)
const source = axios.CancelToken.source()
// const queryResult = await metadataCache.queryMetadata(searchQuery)
const queryResult = await queryMetadata(searchQuery, source.token)
const queryResult = await queryMetadata(searchQuery, cancelToken)
return queryResult
}
@ -240,7 +235,7 @@ export async function addExistingParamsToUrl(
} else {
// sort should be relevance when fixed in aqua
urlLocation = `${urlLocation}sort=${encodeURIComponent(
SortTermOptions.Created
SortTermOptions.Relevance
)}&sortOrder=${SortValueOptions.Descending}&`
}
urlLocation = urlLocation.slice(0, -1)

View File

@ -5,16 +5,11 @@ import {
publisherTrustedAlgorithm as PublisherTrustedAlgorithm
} from '@oceanprotocol/lib/'
import {
QueryResult,
SearchQuery
} from '@oceanprotocol/lib/dist/node/metadatacache/MetadataCache'
import { AssetSelectionAsset } from '../components/molecules/FormFields/AssetSelection'
import { PriceList, getAssetsPriceList } from './subgraph'
import axios, { CancelToken, AxiosResponse } from 'axios'
import { OrdersData_tokenOrders as OrdersData } from '../@types/apollo/OrdersData'
import { metadataCacheUri } from '../../app.config'
import web3 from '../../tests/unit/__mocks__/web3'
export interface DownloadedAsset {
dtSymbol: string
@ -41,24 +36,25 @@ function getQueryForAlgorithmDatasets(algorithmDid: string, chainId?: number) {
// and not just strings of DDOs. For now, taken from
// https://github.com/oceanprotocol/ocean.js/blob/main/src/metadatacache/MetadataCache.ts#L361-L375
export function transformQueryResult(
{
results,
page,
total_pages: totalPages,
total_results: totalResults
}: any = {
result: [],
queryResult: any,
from = 0,
size = 21
): any {
const result: any = {
results: [],
page: 0,
total_pages: 0,
total_results: 0
}
): QueryResult {
return {
results: (results || []).map((ddo: DDO) => new DDO(ddo as DDO)),
page,
totalPages,
totalResults
totalPages: 0,
totalResults: 0
}
result.results = (queryResult.hits.hits || []).map(
(hit: any) => new DDO(hit._source as DDO)
)
result.totalResults = queryResult.hits.total
result.totalPages = Math.floor(result.totalResults / size)
result.page = from ? from / size : 1
return result
}
export function transformChainIdsListToQuery(chainIds: number[]): string {
@ -71,17 +67,17 @@ export function transformChainIdsListToQuery(chainIds: number[]): string {
}
export async function queryMetadata(
query: SearchQuery,
query: any,
cancelToken: CancelToken
): Promise<QueryResult> {
): Promise<any> {
try {
const response: AxiosResponse<any> = await axios.post(
`${metadataCacheUri}/api/v1/aquarius/assets/ddo/query`,
`${metadataCacheUri}/api/v1/aquarius/assets/query`,
{ ...query },
{ cancelToken }
)
if (!response || response.status !== 200 || !response.data) return
return transformQueryResult(response.data)
return transformQueryResult(response.data, query.from, query.size)
} catch (error) {
if (axios.isCancel(error)) {
Logger.log(error.message)
@ -221,7 +217,7 @@ export async function getPublishedAssets(
cancelToken: CancelToken,
page?: number,
type?: string
): Promise<QueryResult> {
): Promise<any> {
if (!accountId) return
page = page || 1
@ -256,7 +252,7 @@ export async function getAssetsFromDidList(
didList: string[],
chainIds: number[],
cancelToken: CancelToken
): Promise<QueryResult> {
): Promise<any> {
try {
// TODO: figure out cleaner way to transform string[] into csv
const searchDids = JSON.stringify(didList)
@ -309,7 +305,7 @@ export async function getDownloadAssets(
for (let i = 0; i < tokenOrders?.length; i++) {
const ddo = ddoList.filter(
(ddo) =>
(ddo: { dataToken: string }) =>
tokenOrders[i].datatokenId.address.toLowerCase() ===
ddo.dataToken.toLowerCase()
)[0]