diff options
author | Fabio Berger <me@fabioberger.com> | 2018-08-23 06:46:45 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-08-23 06:46:45 +0800 |
commit | 61255309d2f7e2724d29f58f1c1493a1a87a182c (patch) | |
tree | 33eabfcf58f782fa2ccb070e05a6cd711af2ab29 /packages/connect/src/types.ts | |
parent | 27d329ff2559c643b54489d0796bb2c2fcda264f (diff) | |
parent | cb19623a3aaf22a386bd4a7d6477048a604be9a2 (diff) | |
download | dexon-sol-tools-61255309d2f7e2724d29f58f1c1493a1a87a182c.tar dexon-sol-tools-61255309d2f7e2724d29f58f1c1493a1a87a182c.tar.gz dexon-sol-tools-61255309d2f7e2724d29f58f1c1493a1a87a182c.tar.bz2 dexon-sol-tools-61255309d2f7e2724d29f58f1c1493a1a87a182c.tar.lz dexon-sol-tools-61255309d2f7e2724d29f58f1c1493a1a87a182c.tar.xz dexon-sol-tools-61255309d2f7e2724d29f58f1c1493a1a87a182c.tar.zst dexon-sol-tools-61255309d2f7e2724d29f58f1c1493a1a87a182c.zip |
merge development
Diffstat (limited to 'packages/connect/src/types.ts')
-rw-r--r-- | packages/connect/src/types.ts | 168 |
1 files changed, 88 insertions, 80 deletions
diff --git a/packages/connect/src/types.ts b/packages/connect/src/types.ts index fc7a4b24d..06ae732a5 100644 --- a/packages/connect/src/types.ts +++ b/packages/connect/src/types.ts @@ -2,73 +2,55 @@ import { SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; export interface Client { - getTokenPairsAsync: (requestOpts?: TokenPairsRequestOpts & PagedRequestOpts) => Promise<TokenPairsItem[]>; - getOrdersAsync: (requestOpts?: OrdersRequestOpts & PagedRequestOpts) => Promise<SignedOrder[]>; - getOrderAsync: (orderHash: string) => Promise<SignedOrder>; + getAssetPairsAsync: ( + requestOpts?: AssetPairsRequestOpts & PagedRequestOpts, + ) => Promise<PaginatedCollection<AssetPairsItem>>; + getOrdersAsync: (requestOpts?: OrdersRequestOpts & PagedRequestOpts) => Promise<PaginatedCollection<APIOrder>>; + getOrderAsync: (orderHash: string) => Promise<APIOrder>; getOrderbookAsync: (request: OrderbookRequest, requestOpts?: PagedRequestOpts) => Promise<OrderbookResponse>; - getFeesAsync: (request: FeesRequest) => Promise<FeesResponse>; + getOrderConfigAsync: (request: OrderConfigRequest) => Promise<OrderConfigResponse>; + getFeeRecipientsAsync: (requestOpts?: PagedRequestOpts) => Promise<FeeRecipientsResponse>; submitOrderAsync: (signedOrder: SignedOrder) => Promise<void>; } -export interface OrderbookChannel { - subscribe: (subscriptionOpts: OrderbookChannelSubscriptionOpts) => void; +export interface OrdersChannel { + subscribe: (subscriptionOpts: OrdersChannelSubscriptionOpts) => void; close: () => void; } /** - * baseTokenAddress: The address of token designated as the baseToken in the currency pair calculation of price - * quoteTokenAddress: The address of token designated as the quoteToken in the currency pair calculation of price - * snapshot: If true, a snapshot of the orderbook will be sent before the updates to the orderbook + * baseAssetData: The address of assetData designated as the baseToken in the currency pair calculation of price + * quoteAssetData: The address of assetData designated as the quoteToken in the currency pair calculation of price * limit: Maximum number of bids and asks in orderbook snapshot */ -export interface OrderbookChannelSubscriptionOpts { - baseTokenAddress: string; - quoteTokenAddress: string; - snapshot: boolean; +export interface OrdersChannelSubscriptionOpts { + baseAssetData: string; + quoteAssetData: string; limit: number; } -export interface OrderbookChannelHandler { - onSnapshot: ( - channel: OrderbookChannel, - subscriptionOpts: OrderbookChannelSubscriptionOpts, - snapshot: OrderbookResponse, - ) => void; - onUpdate: ( - channel: OrderbookChannel, - subscriptionOpts: OrderbookChannelSubscriptionOpts, - order: SignedOrder, - ) => void; - onError: (channel: OrderbookChannel, err: Error, subscriptionOpts?: OrderbookChannelSubscriptionOpts) => void; - onClose: (channel: OrderbookChannel) => void; -} - -export type OrderbookChannelMessage = - | SnapshotOrderbookChannelMessage - | UpdateOrderbookChannelMessage - | UnknownOrderbookChannelMessage; - -export enum OrderbookChannelMessageTypes { - Snapshot = 'snapshot', - Update = 'update', - Unknown = 'unknown', +export interface OrdersChannelHandler { + onUpdate: (channel: OrdersChannel, subscriptionOpts: OrdersChannelSubscriptionOpts, orders: APIOrder[]) => void; + onError: (channel: OrdersChannel, err: Error, subscriptionOpts?: OrdersChannelSubscriptionOpts) => void; + onClose: (channel: OrdersChannel) => void; } -export interface SnapshotOrderbookChannelMessage { - type: OrderbookChannelMessageTypes.Snapshot; - requestId: number; - payload: OrderbookResponse; +export type OrdersChannelMessage = UpdateOrdersChannelMessage | UnknownOrdersChannelMessage; + +export enum OrdersChannelMessageTypes { + Update = 'update', + Unknown = 'unknown', } -export interface UpdateOrderbookChannelMessage { - type: OrderbookChannelMessageTypes.Update; - requestId: number; - payload: SignedOrder; +export interface UpdateOrdersChannelMessage { + type: OrdersChannelMessageTypes.Update; + requestId: string; + payload: APIOrder[]; } -export interface UnknownOrderbookChannelMessage { - type: OrderbookChannelMessageTypes.Unknown; - requestId: number; +export interface UnknownOrdersChannelMessage { + type: OrdersChannelMessageTypes.Unknown; + requestId: string; payload: undefined; } @@ -83,60 +65,86 @@ export enum WebsocketClientEventType { ConnectFailed = 'connectFailed', } -export interface TokenPairsRequestOpts { - tokenA?: string; - tokenB?: string; +export type OrdersResponse = PaginatedCollection<APIOrder>; + +export interface APIOrder { + order: SignedOrder; + metaData: object; +} + +export interface AssetPairsRequestOpts { + assetDataA?: string; + assetDataB?: string; } -export interface TokenPairsItem { - tokenA: TokenTradeInfo; - tokenB: TokenTradeInfo; +export type AssetPairsResponse = PaginatedCollection<AssetPairsItem>; + +export interface AssetPairsItem { + assetDataA: Asset; + assetDataB: Asset; } -export interface TokenTradeInfo { - address: string; +export interface Asset { + assetData: string; minAmount: BigNumber; maxAmount: BigNumber; precision: number; } export interface OrdersRequestOpts { - exchangeContractAddress?: string; - tokenAddress?: string; - makerTokenAddress?: string; - takerTokenAddress?: string; - maker?: string; - taker?: string; - trader?: string; - feeRecipient?: string; + makerAssetProxyId?: string; + takerAssetProxyId?: string; + makerAssetAddress?: string; + takerAssetAddress?: string; + exchangeAddress?: string; + senderAddress?: string; + makerAssetData?: string; + takerAssetData?: string; + makerAddress?: string; + takerAddress?: string; + traderAddress?: string; + feeRecipientAddress?: string; } export interface OrderbookRequest { - baseTokenAddress: string; - quoteTokenAddress: string; + baseAssetData: string; + quoteAssetData: string; } export interface OrderbookResponse { - bids: SignedOrder[]; - asks: SignedOrder[]; + bids: PaginatedCollection<APIOrder>; + asks: PaginatedCollection<APIOrder>; +} + +export interface PaginatedCollection<T> { + total: number; + page: number; + perPage: number; + records: T[]; } -export interface FeesRequest { - exchangeContractAddress: string; - maker: string; - taker: string; - makerTokenAddress: string; - takerTokenAddress: string; - makerTokenAmount: BigNumber; - takerTokenAmount: BigNumber; - expirationUnixTimestampSec: BigNumber; - salt: BigNumber; +export interface OrderConfigRequest { + makerAddress: string; + takerAddress: string; + makerAssetAmount: string; + takerAssetAmount: string; + makerAssetData: string; + takerAssetData: string; + exchangeAddress: string; + expirationTimeSeconds: string; } -export interface FeesResponse { - feeRecipient: string; +export interface OrderConfigResponse { makerFee: BigNumber; takerFee: BigNumber; + feeRecipientAddress: string; + senderAddress: string; +} + +export type FeeRecipientsResponse = PaginatedCollection<string>; + +export interface RequestOpts { + networkId?: number; } export interface PagedRequestOpts { |