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

Commit

Permalink
fix: eslint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
dolcalmi committed Jul 7, 2022
1 parent 97f7600 commit eddf9f8
Show file tree
Hide file tree
Showing 29 changed files with 93 additions and 49 deletions.
2 changes: 1 addition & 1 deletion dealer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"dependencies": {
"@apollo/client": "^3.5.8",
"@galoymoney/client": "^0.1.10",
"@galoymoney/client": "^0.1.32",
"@grpc/grpc-js": "^1.5.3",
"@opentelemetry/api": "^1.0.2",
"@opentelemetry/core": "^1.0.0",
Expand Down
1 change: 1 addition & 0 deletions dealer/src/Dealer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pino from "pino"

import { yamlConfig } from "./config"
import { Result } from "./Result"
import { btc2sat, roundBtc } from "./utils"
Expand Down
5 changes: 3 additions & 2 deletions dealer/src/DealerRemoteWallet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { ErrorLevel, Result } from "./Result"
import { GaloyWallet, WalletsBalances } from "./GaloyWalletTypes"
import {
ApolloClient,
NormalizedCacheObject,
Expand All @@ -9,6 +7,9 @@ import {
} from "@apollo/client/core"
import fetch from "node-fetch"
import { pino } from "pino"

import { GaloyWallet, WalletsBalances } from "./GaloyWalletTypes"
import { ErrorLevel, Result } from "./Result"
import { cents2usd, sat2btc } from "./utils"
import {
addAttributesToCurrentSpan,
Expand Down
5 changes: 3 additions & 2 deletions dealer/src/DealerSimulatedWallet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { ErrorLevel, Result } from "./Result"
import { GaloyWallet, WalletsBalances } from "./GaloyWalletTypes"
import {
ApolloClient,
NormalizedCacheObject,
Expand All @@ -9,6 +7,9 @@ import {
} from "@apollo/client/core"
import fetch from "node-fetch"
import { pino } from "pino"

import { GaloyWallet, WalletsBalances } from "./GaloyWalletTypes"
import { ErrorLevel, Result } from "./Result"
import { cents2usd, sat2btc } from "./utils"
import {
addAttributesToCurrentSpan,
Expand Down
11 changes: 7 additions & 4 deletions dealer/src/ExchangeBase.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import ccxt, { ExchangeId } from "ccxt"

import pino from "pino"

import {
FetchDepositAddressResult,
WithdrawParameters,
Expand Down Expand Up @@ -33,9 +37,8 @@ import {
GetFundingRateHistoryResult,
} from "./ExchangeTradingType"
import { ErrorLevel, Result } from "./Result"
import ccxt, { ExchangeId } from "ccxt"
import { ExchangeConfiguration, Headers } from "./ExchangeConfiguration"
import pino from "pino"

import {
addAttributesToCurrentSpan,
asyncRunInSpan,
Expand Down Expand Up @@ -161,7 +164,7 @@ export abstract class ExchangeBase {
}

private async fetchDepositsAllPages(args: FetchDepositsParameters) {
return await asyncRunInSpan(
return asyncRunInSpan(
"app.exchangeBase.fetchDepositsAllPages",
{
[SemanticAttributes.CODE_FUNCTION]: "fetchDepositsAllPages",
Expand Down Expand Up @@ -342,7 +345,7 @@ export abstract class ExchangeBase {
}

private async fetchWithdrawalsAllPages(args: FetchWithdrawalsParameters) {
return await asyncRunInSpan(
return asyncRunInSpan(
"app.exchangeBase.fetchWithdrawalsAllPages",
{
[SemanticAttributes.CODE_FUNCTION]: "fetchWithdrawalsAllPages",
Expand Down
1 change: 1 addition & 0 deletions dealer/src/ExchangeTradingType.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Params } from "ccxt"

import { FundingRate, Transaction } from "./database/models"

export enum TradeCurrency {
Expand Down
7 changes: 5 additions & 2 deletions dealer/src/OkexExchange.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import assert from "assert"

import pino from "pino"

import {
GetAccountAndPositionRiskResult,
GetInstrumentDetailsResult,
Expand All @@ -16,7 +20,6 @@ import {
GetFundingRateHistoryResult,
GetFundingRateHistoryParameters,
} from "./ExchangeTradingType"
import assert from "assert"
import { ExchangeBase } from "./ExchangeBase"
import {
ExchangeConfiguration,
Expand All @@ -25,7 +28,7 @@ import {
} from "./ExchangeConfiguration"
import { OkexExchangeConfiguration } from "./OkexExchangeConfiguration"
import { ErrorLevel, Result } from "./Result"
import pino from "pino"

import { ExchangeNames, FundingRate, Transaction } from "./database/models"
import { sleep } from "./utils"
import {
Expand Down
3 changes: 2 additions & 1 deletion dealer/src/OkexExchangeConfiguration.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import assert from "assert"

import {
FetchDepositAddressResult,
WithdrawParameters,
Expand All @@ -17,7 +19,6 @@ import {
FetchWithdrawalsParameters,
TransferParameters,
} from "./ExchangeTradingType"
import assert from "assert"
import {
ExchangeConfiguration,
SupportedExchange,
Expand Down
15 changes: 10 additions & 5 deletions dealer/src/OkexPerpetualSwapStrategy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import pino from "pino"

import { floorBtc, roundBtc, sleep } from "./utils"
import { yamlConfig } from "./config"
import { ErrorLevel, Result } from "./Result"
Expand Down Expand Up @@ -32,7 +34,6 @@ import {
DestinationAddressType,
} from "./OkexExchangeConfiguration"
import { AccountTypeToId, OkexExchange } from "./OkexExchange"
import pino from "pino"

import {
ExternalTransfer,
Expand Down Expand Up @@ -149,17 +150,17 @@ export class OkexPerpetualSwapStrategy implements HedgingStrategy {
}

public async getDerivativeMarketInfo(): Promise<Result<FetchTickerResult>> {
return await this.exchange.fetchTicker(SupportedInstrument.OKEX_PERPETUAL_SWAP)
return this.exchange.fetchTicker(SupportedInstrument.OKEX_PERPETUAL_SWAP)
}

public async getFundingAccountBalance(): Promise<
Result<FetchFundingAccountBalanceResult>
> {
return await this.exchange.fetchFundingAccountBalance()
return this.exchange.fetchFundingAccountBalance()
}

public async fetchExchangeStatus(): Promise<Result<boolean>> {
return await this.exchange.fetchExchangeStatus()
return this.exchange.fetchExchangeStatus()
}

public async fetchTransactionHistory(
Expand Down Expand Up @@ -573,7 +574,11 @@ export class OkexPerpetualSwapStrategy implements HedgingStrategy {
withdrawArgs.quantity,
)
this.logger.debug(
{ withdrawOnChainAddress, transferSizeInBtc: withdrawArgs.quantity, bookingResult },
{
withdrawOnChainAddress,
transferSizeInBtc: withdrawArgs.quantity,
bookingResult,
},
"withdrawBookKeepingCallback() returned: {bookingResult}",
)
if (!bookingResult.ok) {
Expand Down
3 changes: 2 additions & 1 deletion dealer/src/app/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { wrapAsyncToRunInSpan } from "../services/tracing"

// import * as DealerMod from "../Dealer"
import * as schedulerMod from "./scheduler"
import * as exporterMod from "../servers/exporter/exporter"
import * as priceServiceMod from "../servers/price"

import { baseLogger } from "../services/logger"

import * as schedulerMod from "./scheduler"
const logger = baseLogger.child({ module: "wrapper" })

const allFunctions = {
Expand Down
3 changes: 2 additions & 1 deletion dealer/src/app/scheduler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { baseLogger } from "../services/logger"
import cron from "node-cron"

import { baseLogger } from "../services/logger"
import { Dealer } from "../Dealer"
import { recordExceptionInCurrentSpan, wrapAsyncToRunInSpan } from "../services/tracing"
import { ErrorLevel } from "../Result"
Expand Down
4 changes: 2 additions & 2 deletions dealer/src/app/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import { baseLogger } from "../services/logger"
// import { scheduler } from "./scheduler"
// import { priceService } from "../servers/price"

import { exporter, scheduler, priceService } from "."

import {
addAttributesToCurrentSpan,
SemanticAttributes,
wrapAsyncToRunInSpan,
} from "../services/tracing"

import { exporter, scheduler, priceService } from "."

const logger = baseLogger.child({ module: "cron" })

const options = {
Expand Down
2 changes: 2 additions & 0 deletions dealer/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import fs from "fs"

import yaml from "js-yaml"
import _ from "lodash"

import { baseLogger } from "./services/logger"

const defaultContent = fs.readFileSync("./default.yaml", "utf8")
Expand Down
9 changes: 6 additions & 3 deletions dealer/src/database/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import pgPromise, { IInitOptions, IDatabase, IMain } from "pg-promise"

import humps from "humps"
import dotenv from "dotenv"

import { baseLogger } from "../services/logger"

import {
Extensions,
InFlightTransfersRepository,
Expand All @@ -9,9 +15,6 @@ import {
ExternalTransfersRepository,
FundingRatesRepository,
} from "./repositories"
import { baseLogger } from "../services/logger"
import humps from "humps"
import dotenv from "dotenv"

dotenv.config()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import pino from "pino"
import { IDatabase, IMain } from "pg-promise"

import { Md5 } from "ts-md5/dist/md5"

import { ExternalTransfer } from "../models"
import { externalTransfersQueries as sql } from "../sql"
import { Result } from "../../Result"
import { Md5 } from "ts-md5/dist/md5"

export class ExternalTransfersRepository {
private logger: pino.Logger
Expand Down
1 change: 1 addition & 0 deletions dealer/src/database/repositories/FundingRatesRepository.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pino from "pino"
import { IDatabase, IMain } from "pg-promise"

import { ExchangeNames, FundingRate } from "../models"
import { fundingRatesQueries as sql } from "../sql"
import { Result } from "../../Result"
Expand Down
1 change: 1 addition & 0 deletions dealer/src/database/repositories/GraphqlRepository.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pino from "pino"
import { IDatabase, IMain } from "pg-promise"

import { Wallet, LastOnChainAddress, OnChainPay } from "../models"
import { graphql as sql } from "../sql"
import { Result } from "../../Result"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pino from "pino"
import { IDatabase, IMain } from "pg-promise"
import { IResult } from "pg-promise/typescript/pg-subset"

import { InFlightTransfer, InFlightTransfersMetrics } from "../models"
import { inFlightTransfersQueries as sql } from "../sql"
import { Result } from "../../Result"
Expand Down Expand Up @@ -42,7 +43,7 @@ export class InFlightTransfersRepository {
public async completed(address: string): Promise<Result<number>> {
try {
const rowCount = await this.db.tx("update-completed", async (t) => {
return await t.result(sql.complete, { address }, (r: IResult) => r.rowCount)
return t.result(sql.complete, { address }, (r: IResult) => r.rowCount)
})
if (rowCount !== 1) {
throw new Error(`completedInFlightTransfer({address}) updated ${rowCount} rows.`)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pino from "pino"
import { IDatabase, IMain } from "pg-promise"

import { InternalTransfer, InternalTransfersMetrics } from "../models"
import { internalTransfersQueries as sql } from "../sql"
import { Result } from "../../Result"
Expand Down
1 change: 1 addition & 0 deletions dealer/src/database/repositories/OrdersRepository.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pino from "pino"
import { IDatabase, IMain } from "pg-promise"

import { Order } from "../models"
import { ordersQueries as sql } from "../sql"
import { Result } from "../../Result"
Expand Down
1 change: 1 addition & 0 deletions dealer/src/database/repositories/TransactionsRepository.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pino from "pino"
import { IDatabase, IMain } from "pg-promise"

import { FundingFeesMetrics, TradingFeesMetrics, Transaction } from "../models"
import { transactionsQueries as sql } from "../sql"
import { Result } from "../../Result"
Expand Down
4 changes: 3 additions & 1 deletion dealer/src/database/sql/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { QueryFile, IQueryFileOptions } from "pg-promise"
import { join as joinPath } from "path"

import { QueryFile, IQueryFileOptions } from "pg-promise"

import { baseLogger } from "../../services/logger"

const logger = baseLogger.child({ module: "db/queries" })
Expand Down
1 change: 1 addition & 0 deletions dealer/src/servers/exporter/exporter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import dotenv from "dotenv"
import express from "express"
import client, { register } from "prom-client"

import { baseLogger } from "../../services/logger"
import { Dealer } from "../../Dealer"
import { PositionSide } from "../../ExchangeTradingType"
Expand Down
3 changes: 2 additions & 1 deletion dealer/src/servers/graphql/WalletGraphqlServer.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { AddressInfo } from "net"

import dotenv from "dotenv"
import {
stringLength,
Expand All @@ -16,7 +18,6 @@ import { v4 as uuidv4 } from "uuid"
import { db as database } from "../../database"

import { baseLogger } from "../../services/logger"
import { AddressInfo } from "net"

const graphqlLogger = baseLogger.child({ module: "graphql" })

Expand Down
8 changes: 6 additions & 2 deletions dealer/src/servers/price/client_service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import util from "util"

import { credentials } from "@grpc/grpc-js"
import { UnknownDealerPriceServiceError } from "./errors"

import { baseLogger } from "../../services/logger"

import { toCents, toCentsPerSatsRatio, toSats } from "../../utils"

import { UnknownDealerPriceServiceError } from "./errors"
import { PriceServiceClient } from "./proto/services/price/v1/price_service_grpc_pb"
import {
GetCentsFromSatsForImmediateBuyRequest,
Expand All @@ -23,7 +28,6 @@ import {
GetCentsPerSatsExchangeMidRateRequest,
GetCentsPerSatsExchangeMidRateResponse,
} from "./proto/services/price/v1/price_service_pb"
import { toCents, toCentsPerSatsRatio, toSats } from "../../utils"

const serverPort = process.env.PRICE_SERVER_PORT ?? "50055"
const client = new PriceServiceClient(
Expand Down
Loading

0 comments on commit eddf9f8

Please sign in to comment.