Skip to content
This repository has been archived by the owner on Aug 3, 2021. It is now read-only.

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
mihaisc committed Oct 1, 2020
1 parent 7de06e7 commit 6c2353f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 23 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 6 additions & 3 deletions src/hooks/usePublish/usePublish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -178,7 +180,8 @@ function usePublish(): UsePublish {
undefined,
dataTokenOptions?.cap,
dataTokenOptions?.name,
dataTokenOptions?.symbol
dataTokenOptions?.symbol,
providerUri
)
.next(setStep)
Logger.log('ddo created', ddo)
Expand Down
16 changes: 4 additions & 12 deletions src/utils/dtUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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) {
Expand Down Expand Up @@ -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 })

Expand Down

0 comments on commit 6c2353f

Please sign in to comment.