Skip to content

Commit

Permalink
fix: update sdk-ui-ts typings to import from sdk-ts indexer instead o…
Browse files Browse the repository at this point in the history
…f exchange
  • Loading branch information
ThomasRalee committed Aug 12, 2022
1 parent 89de4c9 commit 950079e
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,9 @@ export class ExchangeGrpcDerivativesApi extends BaseConsumer {
typeof InjectiveDerivativeExchangeRPC.SubaccountTradesList
>(request, InjectiveDerivativeExchangeRPC.SubaccountTradesList)

return ExchangeGrpcDerivativeTransformer.tradesResponseToTrades(response)
return ExchangeGrpcDerivativeTransformer.subaccountTradesListResponseToTrades(
response,
)
} catch (e: any) {
throw new Error(e.message)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,9 @@ export class ExchangeGrpcSpotApi extends BaseConsumer {
typeof InjectiveSpotExchangeRPC.SubaccountTradesList
>(request, InjectiveSpotExchangeRPC.SubaccountTradesList)

return ExchangeGrpcSpotTransformer.tradesResponseToTrades(response)
return ExchangeGrpcSpotTransformer.subaccountTradesListResponseToTrades(
response,
)
} catch (e: any) {
throw new Error(e.message)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export class ExchangeGrpcTransactionApi extends BaseConsumer {
feeDenom = DEFAULT_BRIDGE_FEE_DENOM,
feePrice = DEFAULT_BRIDGE_FEE_PRICE,
timeoutHeight,
useCorrectEIP712Hash,
}: {
address: AccountAddress
chainId: EthereumChainId
Expand All @@ -40,7 +39,6 @@ export class ExchangeGrpcTransactionApi extends BaseConsumer {
timeoutHeight?: number
feeDenom?: string
feePrice?: string
useCorrectEIP712Hash?: boolean
}) {
const txFeeAmount = new Coin()
txFeeAmount.setDenom(feeDenom)
Expand Down Expand Up @@ -71,10 +69,6 @@ export class ExchangeGrpcTransactionApi extends BaseConsumer {
prepareTxRequest.setMemo(memo)
}

if (useCorrectEIP712Hash !== undefined) {
prepareTxRequest.setUseCorrectHash(useCorrectEIP712Hash)
}

try {
const response = await this.request<
PrepareTxRequest,
Expand All @@ -99,7 +93,6 @@ export class ExchangeGrpcTransactionApi extends BaseConsumer {
feePrice = DEFAULT_BRIDGE_FEE_PRICE,
timeoutHeight,
delegatedFee,
useCorrectEIP712Hash,
}: {
address: AccountAddress
chainId: EthereumChainId
Expand All @@ -111,7 +104,6 @@ export class ExchangeGrpcTransactionApi extends BaseConsumer {
feePrice?: string
timeoutHeight?: number
delegatedFee?: boolean
useCorrectEIP712Hash?: boolean
}) {
const txFeeAmount = new Coin()
txFeeAmount.setDenom(feeDenom)
Expand Down Expand Up @@ -146,10 +138,6 @@ export class ExchangeGrpcTransactionApi extends BaseConsumer {
prepareTxRequest.setMemo(memo)
}

if (useCorrectEIP712Hash !== undefined) {
prepareTxRequest.setUseCorrectHash(useCorrectEIP712Hash)
}

try {
const response = await this.request<
PrepareTxRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
TradesResponse as DerivativeTradesResponse,
PositionsResponse as DerivativePositionsResponse,
OrderbooksResponse as DerivativeOrderbooksResponse,
SubaccountTradesListResponse as DerivativeSubaccountTradesListResponse,
} from '@injectivelabs/exchange-api/injective_derivative_exchange_rpc_pb'
import {
BinaryOptionsMarketsResponse as BinaryOptionsMarketsResponse,
Expand Down Expand Up @@ -147,6 +148,14 @@ export class ExchangeGrpcDerivativeTransformer {
return ExchangeGrpcDerivativeTransformer.grpcTradesToTrades(trades)
}

static subaccountTradesListResponseToTrades(
response: DerivativeSubaccountTradesListResponse,
) {
const trades = response.getTradesList()

return ExchangeGrpcDerivativeTransformer.grpcTradesToTrades(trades)
}

static fundingPaymentsResponseToFundingPayments(
response: FundingPaymentsResponse,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
OrdersResponse as SpotOrdersResponse,
TradesResponse as SpotTradesResponse,
OrderbooksResponse as SpotOrderbooksResponse,
SubaccountTradesListResponse as SpotSubaccountTradesListResponse,
} from '@injectivelabs/exchange-api/injective_spot_exchange_rpc_pb'

const zeroPriceLevel = () => ({
Expand Down Expand Up @@ -75,6 +76,14 @@ export class ExchangeGrpcSpotTransformer {
return ExchangeGrpcSpotTransformer.grpcTradesToTrades(trades)
}

static subaccountTradesListResponseToTrades(
response: SpotSubaccountTradesListResponse,
) {
const trades = response.getTradesList()

return ExchangeGrpcSpotTransformer.grpcTradesToTrades(trades)
}

static orderbookResponseToOrderbook(response: SpotOrderbookResponse) {
const orderbook = response.getOrderbook()!

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
SubaccountBalance,
SubaccountTransfer,
} from '@injectivelabs/sdk-ts/dist/client/exchange/types/account'
} from '@injectivelabs/sdk-ts/dist/client/indexer/types/account'
import { UiSubaccountBalance } from '../types/account'

export class UiAccountTransformer {
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-ui-ts/src/client/types/account.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SubaccountTransfer } from '@injectivelabs/sdk-ts/dist/client/exchange/types/account'
import { SubaccountTransfer } from '@injectivelabs/sdk-ts/dist/client/indexer/types/account'
import { Token } from '@injectivelabs/token-metadata'

export interface UiSubaccountBalance {
Expand Down
6 changes: 3 additions & 3 deletions packages/sdk-ui-ts/src/client/types/derivatives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import {
Position as UiPosition,
DerivativeLimitOrder as UiDerivativeLimitOrder,
DerivativeOrderSide,
} from '@injectivelabs/sdk-ts/dist/client/exchange/types/derivatives'
import { Orderbook as UiDerivativeOrderbook } from '@injectivelabs/sdk-ts/dist/client/exchange/types/exchange'
} from '@injectivelabs/sdk-ts/dist/client/indexer/types/derivatives'
import { Orderbook as UiDerivativeOrderbook } from '@injectivelabs/sdk-ts/dist/client/indexer/types/exchange'
import {
ChronosDerivativeMarketSummary,
AllChronosDerivativeMarketSummary,
} from '@injectivelabs/sdk-ts/dist/client/exchange/types/derivatives-rest'
} from '@injectivelabs/sdk-ts/dist/client/indexer/types/derivatives-rest'
import { Token } from '@injectivelabs/token-metadata'
import { Change, MarketBase, MarketType } from './common'

Expand Down
6 changes: 3 additions & 3 deletions packages/sdk-ui-ts/src/client/types/spot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import {
SpotTrade,
SpotLimitOrder as UiSpotLimitOrder,
SpotOrderSide,
} from '@injectivelabs/sdk-ts/dist/client/exchange/types/spot'
import { Orderbook as UiSpotOrderbook } from '@injectivelabs/sdk-ts/dist/client/exchange/types/exchange'
} from '@injectivelabs/sdk-ts/dist/client/indexer/types/spot'
import { Orderbook as UiSpotOrderbook } from '@injectivelabs/sdk-ts/dist/client/indexer/types/exchange'
import {
ChronosSpotMarketSummary,
AllChronosSpotMarketSummary,
} from '@injectivelabs/sdk-ts/dist/client/exchange/types/spot-rest'
} from '@injectivelabs/sdk-ts/dist/client/indexer/types/spot-rest'
import { Token } from '@injectivelabs/token-metadata'
import { Change, MarketBase, MarketType } from './common'

Expand Down

0 comments on commit 950079e

Please sign in to comment.