From 8896e776b3537e24c312579f703c33e3d962cdee Mon Sep 17 00:00:00 2001 From: alexcos20 Date: Wed, 14 Oct 2020 05:05:45 -0700 Subject: [PATCH] fix lint --- src/hooks/usePricing/usePricing.ts | 50 ++++++++++--------- src/providers/OceanProvider/OceanProvider.tsx | 2 +- tsconfig.json | 2 +- 3 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/hooks/usePricing/usePricing.ts b/src/hooks/usePricing/usePricing.ts index ea438a3..888f5d8 100644 --- a/src/hooks/usePricing/usePricing.ts +++ b/src/hooks/usePricing/usePricing.ts @@ -16,15 +16,15 @@ import { Decimal } from 'decimal.js' interface UsePricing { createPricing: ( dataTokenAddress: string, - priceOptions: PriceOptions, + priceOptions: PriceOptions ) => Promise buyDT: ( dataTokenAddress: string, - dtAmount: number | string, + dtAmount: number | string ) => Promise sellDT: ( dataTokenAddress: string, - dtAmount: number | string, + dtAmount: number | string ) => Promise pricingStep?: number pricingStepText?: string @@ -35,19 +35,19 @@ interface UsePricing { export const buyDTFeedback: { [key in number]: string } = { 0: '1/3 Approving OCEAN ...', 1: '2/3 Buying DT ...', - 2: '3/3 DT Bought' + 2: '3/3 DT Bought' } export const sellDTFeedback: { [key in number]: string } = { 0: '1/3 Approving DT ...', 1: '2/3 Selling DT ...', - 2: '3/3 DT sold' + 2: '3/3 DT sold' } -export const createPricingFeedback:{ [key in number]: string } = { +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 { @@ -76,11 +76,11 @@ function usePricing(): UsePricing { ): Promise { setStepCreatePricing(0) let response = null - try{ + try { switch (priceOptions.type) { case 'dynamic': { setStepCreatePricing(2) - response=await ocean.pool.createDTPool( + response = await ocean.pool.createDTPool( accountId, dataTokenAddress, priceOptions.dtAmount.toString(), @@ -96,7 +96,7 @@ function usePricing(): UsePricing { return null } setStepCreatePricing(2) - response=await ocean.fixedRateExchange.create( + response = await ocean.fixedRateExchange.create( dataTokenAddress, priceOptions.price.toString(), accountId @@ -112,20 +112,19 @@ function usePricing(): UsePricing { return response } } - } - catch (error) { + } catch (error) { setPricingError(error.message) Logger.error(error) } finally { setPricingStep(undefined) setPricingStepText(undefined) setIsLoading(false) + } } -} async function buyDT( dataTokenAddress: string, - dtAmount: number | string, + dtAmount: number | string ): Promise { 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 { if (!ocean || !account || !accountId) return @@ -200,16 +204,16 @@ function usePricing(): UsePricing { setStepSellDT(0) try { - const pool=await getFirstPool(ocean, dataTokenAddress) + const pool = await getFirstPool(ocean, dataTokenAddress) const price = new Decimal(pool.value).times(0.95).toString() setStepSellDT(1) Logger.log('Selling token to pool', pool, account.getId(), price) const sellResponse = await ocean.pool.sellDT( - account.getId(), - pool.address, - String(dtAmount), - price - ) + account.getId(), + pool.address, + String(dtAmount), + price + ) setStepSellDT(2) Logger.log('DT sell response', sellResponse) return sellResponse @@ -222,7 +226,7 @@ function usePricing(): UsePricing { setIsLoading(false) } } - + return { createPricing, buyDT, diff --git a/src/providers/OceanProvider/OceanProvider.tsx b/src/providers/OceanProvider/OceanProvider.tsx index 871c60f..5d3f0a6 100644 --- a/src/providers/OceanProvider/OceanProvider.tsx +++ b/src/providers/OceanProvider/OceanProvider.tsx @@ -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 diff --git a/tsconfig.json b/tsconfig.json index f3c9f7c..9ca5a13 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,5 +14,5 @@ "importHelpers": true, "strict": true }, - "include": ["./src/@types", "./src/index.ts"] + "include": ["./src/@types", "./src/hooks", "./src/index.ts"] }