mirror of
https://github.com/oceanprotocol/react.git
synced 2025-01-03 18:35:18 +01:00
update
This commit is contained in:
parent
7de06e73e1
commit
6c2353fb17
14
package-lock.json
generated
14
package-lock.json
generated
@ -1516,17 +1516,17 @@
|
||||
}
|
||||
},
|
||||
"@oceanprotocol/contracts": {
|
||||
"version": "0.4.4",
|
||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-0.4.4.tgz",
|
||||
"integrity": "sha512-0+Tp6UdoDTBJZp4yX3kkSrV+CcOS/hJ3SJ4HuWiL5FE5Nlj3JCeV86iuWPkFuXzIdgri00DaGvQhP58knzJ2Uw=="
|
||||
"version": "0.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-0.5.1.tgz",
|
||||
"integrity": "sha512-bt5uwh79D759H6O4bAv+ycGdZQISFAxi65cqIygzA9hwsu29+GuOLwu1mxrzl2lVNLs6Emxo7TaDv0jAoyqnCg=="
|
||||
},
|
||||
"@oceanprotocol/lib": {
|
||||
"version": "0.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-0.3.2.tgz",
|
||||
"integrity": "sha512-pdgY+PqDlLt64C/ZzxzZtUwN+f+pBTyBzSgXeS0j1D79BChnCtyZAeAR4JyMB/bJSarsWNv1oVUxxVPx9SJ5hw==",
|
||||
"version": "0.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-0.5.0.tgz",
|
||||
"integrity": "sha512-zyhJ+I6l1095uWlYhm48tSC0+SjheZADH+dwDehlrjAl6ipzW4dLgPemSqwueEmNWuGj0hioy+DyqFn0HN8Jfg==",
|
||||
"requires": {
|
||||
"@ethereum-navigator/navigator": "^0.5.0",
|
||||
"@oceanprotocol/contracts": "^0.4.4",
|
||||
"@oceanprotocol/contracts": "^0.5.0",
|
||||
"decimal.js": "^10.2.0",
|
||||
"fs": "0.0.1-security",
|
||||
"lzma": "^2.3.2",
|
||||
|
@ -25,7 +25,7 @@
|
||||
"dist/"
|
||||
],
|
||||
"dependencies": {
|
||||
"@oceanprotocol/lib": "^0.3.2",
|
||||
"@oceanprotocol/lib": "^0.5.0",
|
||||
"axios": "^0.20.0",
|
||||
"decimal.js": "^10.2.1",
|
||||
"web3": "^1.3.0",
|
||||
|
@ -16,7 +16,8 @@ interface UsePublish {
|
||||
asset: Metadata,
|
||||
priceOptions: PriceOptions,
|
||||
serviceConfigs: ServiceType,
|
||||
dataTokenOptions?: DataTokenOptions
|
||||
dataTokenOptions?: DataTokenOptions,
|
||||
providerUri?: string
|
||||
) => Promise<DDO | undefined | null>
|
||||
mint: (tokenAddress: string, tokensToMint: string) => void
|
||||
publishStep?: number
|
||||
@ -92,7 +93,8 @@ function usePublish(): UsePublish {
|
||||
asset: Metadata,
|
||||
priceOptions: PriceOptions,
|
||||
serviceType: ServiceType,
|
||||
dataTokenOptions?: DataTokenOptions
|
||||
dataTokenOptions?: DataTokenOptions,
|
||||
providerUri?: string
|
||||
): Promise<DDO | undefined | null> {
|
||||
if (status !== ProviderStatus.CONNECTED || !ocean || !account) return null
|
||||
|
||||
@ -178,7 +180,8 @@ function usePublish(): UsePublish {
|
||||
undefined,
|
||||
dataTokenOptions?.cap,
|
||||
dataTokenOptions?.name,
|
||||
dataTokenOptions?.symbol
|
||||
dataTokenOptions?.symbol,
|
||||
providerUri
|
||||
)
|
||||
.next(setStep)
|
||||
Logger.log('ddo created', ddo)
|
||||
|
@ -6,15 +6,11 @@ import Web3 from 'web3'
|
||||
|
||||
export async function getCheapestPool(
|
||||
ocean: Ocean,
|
||||
accountId: string,
|
||||
dataTokenAddress: string
|
||||
): Promise<Pool | null> {
|
||||
if (!ocean || !accountId || !dataTokenAddress) return null
|
||||
if (!ocean || !dataTokenAddress) return null
|
||||
|
||||
const tokenPools = await ocean.pool.searchPoolforDT(
|
||||
accountId,
|
||||
dataTokenAddress
|
||||
)
|
||||
const tokenPools = await ocean.pool.searchPoolforDT(dataTokenAddress)
|
||||
|
||||
if (tokenPools === undefined || tokenPools.length === 0) {
|
||||
return {
|
||||
@ -27,11 +23,7 @@ export async function getCheapestPool(
|
||||
|
||||
if (tokenPools) {
|
||||
for (let i = 0; i < tokenPools.length; i++) {
|
||||
const poolPrice = await ocean.pool.getOceanNeeded(
|
||||
accountId,
|
||||
tokenPools[i],
|
||||
'1'
|
||||
)
|
||||
const poolPrice = await ocean.pool.getOceanNeeded(tokenPools[i], '1')
|
||||
const decimalPoolPrice = new Decimal(poolPrice)
|
||||
|
||||
if (decimalPoolPrice < cheapestPoolPrice) {
|
||||
@ -94,7 +86,7 @@ export async function getBestDataTokenPrice(
|
||||
dataTokenAddress: string,
|
||||
accountId: string
|
||||
): Promise<BestPrice> {
|
||||
const cheapestPool = await getCheapestPool(ocean, accountId, dataTokenAddress)
|
||||
const cheapestPool = await getCheapestPool(ocean, dataTokenAddress)
|
||||
const cheapestExchange = await getCheapestExchange(ocean, dataTokenAddress)
|
||||
Decimal.set({ precision: 5 })
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user