1
0
mirror of https://github.com/oceanprotocol/react.git synced 2024-11-22 01:37:03 +01:00
This commit is contained in:
alexcos20 2020-10-14 05:05:45 -07:00
parent ad270f8a39
commit 8896e776b3
3 changed files with 29 additions and 25 deletions

View File

@ -16,15 +16,15 @@ import { Decimal } from 'decimal.js'
interface UsePricing {
createPricing: (
dataTokenAddress: string,
priceOptions: PriceOptions,
priceOptions: PriceOptions
) => Promise<TransactionReceipt | null>
buyDT: (
dataTokenAddress: string,
dtAmount: number | string,
dtAmount: number | string
) => Promise<TransactionReceipt | null>
sellDT: (
dataTokenAddress: string,
dtAmount: number | string,
dtAmount: number | string
) => Promise<TransactionReceipt | null>
pricingStep?: number
pricingStepText?: string
@ -47,7 +47,7 @@ export const createPricingFeedback:{ [key in number]: string } = {
0: '1/4 Approving DT ...',
1: '2/4 Approving Ocean ...',
2: '3/4 Creating ....',
3: '4/4 Pricing created',
3: '4/4 Pricing created'
}
function usePricing(): UsePricing {
@ -112,8 +112,7 @@ function usePricing(): UsePricing {
return response
}
}
}
catch (error) {
} catch (error) {
setPricingError(error.message)
Logger.error(error)
} finally {
@ -125,7 +124,7 @@ function usePricing(): UsePricing {
async function buyDT(
dataTokenAddress: string,
dtAmount: number | string,
dtAmount: number | string
): Promise<TransactionReceipt | null> {
if (!ocean || !account || !accountId) return
@ -140,7 +139,12 @@ function usePricing(): UsePricing {
const price = new Decimal(bestPrice.value).times(1.05).toString()
const maxPrice = new Decimal(bestPrice.value).times(2).toString()
setStepBuyDT(1)
Logger.log('Buying token from pool', bestPrice, account.getId(), price)
Logger.log(
'Buying token from pool',
bestPrice,
account.getId(),
price
)
const buyResponse = await ocean.pool.buyDT(
account.getId(),
bestPrice.address,
@ -191,7 +195,7 @@ function usePricing(): UsePricing {
async function sellDT(
dataTokenAddress: string,
dtAmount: number | string,
dtAmount: number | string
): Promise<TransactionReceipt | null> {
if (!ocean || !account || !accountId) return

View File

@ -137,7 +137,7 @@ function OceanProvider({
}
async function logout() {
// TODO: #67 check how is the proper way to logout
web3Modal?.clearCachedProvider()
if (web3Modal) web3Modal.clearCachedProvider()
}
// TODO: #68 Refetch balance periodically, or figure out some event to subscribe to

View File

@ -14,5 +14,5 @@
"importHelpers": true,
"strict": true
},
"include": ["./src/@types", "./src/index.ts"]
"include": ["./src/@types", "./src/hooks", "./src/index.ts"]
}