Doc reference

Class: WSClient

This class includes all the functionality related to interacting with a Mesh JSON RPC websocket endpoint.

Hierarchy

  • WSClient

Index

Constructors

Methods

Constructors

constructor

+ new WSClient(url: string, wsOpts?: WSOpts): WSClient

Defined in ws_client.ts:222

Instantiates a new WSClient instance

Parameters:

Name

Type

Description

url

string

WS server endpoint

wsOpts?

WSOpts

WebSocket options

Returns: WSClient

An instance of WSClient

Methods

addOrdersAsync

addOrdersAsync(signedOrders: SignedOrder[], pinned: boolean): Promise<ValidationResults>

Defined in ws_client.ts:251

Adds an array of 0x signed orders to the Mesh node.

Parameters:

Name

Type

Default

Description

signedOrders

SignedOrder[]

-

signedOrders to add

pinned

boolean

true

Whether or not the orders should be pinned. Pinned orders will not be affected by any DDoS prevention or incentive mechanisms and will always stay in storage until they are no longer fillable.

Returns: Promise<ValidationResults>

validation results

destroy

destroy(): void

Defined in ws_client.ts:366

destroy unsubscribes all active subscriptions, closes the websocket connection and stops the internal heartbeat connection liveness check.

Returns: void

getOrdersAsync

getOrdersAsync(perPage: number): Promise<OrderInfo[]>

Defined in ws_client.ts:281

Get all 0x signed orders currently stored in the Mesh node

Parameters:

Name

Type

Default

Description

perPage

number

200

number of signedOrders to fetch per paginated request

Returns: Promise<OrderInfo[]>

all orders, their hash and their fillableTakerAssetAmount

getStatsAsync

getStatsAsync(): Promise<GetStatsResponse>

Defined in ws_client.ts:272

Returns: Promise<GetStatsResponse>

onClose

onClose(cb: function): void

Defined in ws_client.ts:348

Get notified when the underlying WS connection closes normally. If it closes with an error, WSClient automatically attempts to re-connect without emitting a close event.

Parameters:

cb: function

callback to call when WS connection closes

▸ (): void

Returns: void

onReconnected

onReconnected(cb: function): void

Defined in ws_client.ts:357

Get notified when a connection to the underlying WS connection is re-established

Parameters:

cb: function

callback to call with the error when it occurs

▸ (): void

Returns: void

subscribeToOrdersAsync

subscribeToOrdersAsync(cb: function): Promise<string>

Defined in ws_client.ts:309

Subscribe to the 'orders' topic and receive order events from Mesh. This method returns a subscriptionId that can be used to unsubscribe() from this subscription.

Parameters:

cb: function

callback function where you'd like to get notified about order events

▸ (orderEvents: OrderEvent[]): void

Parameters:

Name

Type

orderEvents

OrderEvent[]

Returns: Promise<string>

subscriptionId

unsubscribeAsync

unsubscribeAsync(subscriptionId: string): Promise<void>

Defined in ws_client.ts:338

Unsubscribe from a subscription

Parameters:

Name

Type

Description

subscriptionId

string

identifier of the subscription to cancel

Returns: Promise<void>

Enumeration: ContractEventKind

Index

Enumeration members

Enumeration members

ERC1155ApprovalForAllEvent

ERC1155ApprovalForAllEvent: = "ERC1155ApprovalForAllEvent"

Defined in types.ts:220

ERC1155TransferBatchEvent

ERC1155TransferBatchEvent: = "ERC1155TransferBatchEvent"

Defined in types.ts:222

ERC1155TransferSingleEvent

ERC1155TransferSingleEvent: = "ERC1155TransferSingleEvent"

Defined in types.ts:221

ERC20ApprovalEvent

ERC20ApprovalEvent: = "ERC20ApprovalEvent"

Defined in types.ts:216

ERC20TransferEvent

ERC20TransferEvent: = "ERC20TransferEvent"

Defined in types.ts:215

ERC721ApprovalEvent

ERC721ApprovalEvent: = "ERC721ApprovalEvent"

Defined in types.ts:218

ERC721ApprovalForAllEvent

ERC721ApprovalForAllEvent: = "ERC721ApprovalForAllEvent"

Defined in types.ts:219

ERC721TransferEvent

ERC721TransferEvent: = "ERC721TransferEvent"

Defined in types.ts:217

ExchangeCancelEvent

ExchangeCancelEvent: = "ExchangeCancelEvent"

Defined in types.ts:224

ExchangeCancelUpToEvent

ExchangeCancelUpToEvent: = "ExchangeCancelUpToEvent"

Defined in types.ts:225

ExchangeFillEvent

ExchangeFillEvent: = "ExchangeFillEvent"

Defined in types.ts:223

WethDepositEvent

WethDepositEvent: = "WethDepositEvent"

Defined in types.ts:226

WethWithdrawalEvent

WethWithdrawalEvent: = "WethWithdrawalEvent"

Defined in types.ts:227

Enumeration: OrderEventEndState

Index

Enumeration members

Enumeration members

Added

Added: = "ADDED"

Defined in types.ts:284

Cancelled

Cancelled: = "CANCELLED"

Defined in types.ts:287

Expired

Expired: = "EXPIRED"

Defined in types.ts:288

FillabilityIncreased

FillabilityIncreased: = "FILLABILITY_INCREASED"

Defined in types.ts:290

Filled

Filled: = "FILLED"

Defined in types.ts:285

FullyFilled

FullyFilled: = "FULLY_FILLED"

Defined in types.ts:286

Invalid

Invalid: = "INVALID"

Defined in types.ts:283

Unfunded

Unfunded: = "UNFUNDED"

Defined in types.ts:289

Enumeration: RejectedCode

Index

Enumeration members

Enumeration members

InternalError

InternalError: = "InternalError"

Defined in types.ts:352

MaxOrderSizeExceeded

MaxOrderSizeExceeded: = "MaxOrderSizeExceeded"

Defined in types.ts:353

NetworkRequestFailed

NetworkRequestFailed: = "NetworkRequestFailed"

Defined in types.ts:356

OrderAlreadyStored

OrderAlreadyStored: = "OrderAlreadyStored"

Defined in types.ts:354

OrderCancelled

OrderCancelled: = "OrderCancelled"

Defined in types.ts:361

OrderExpired

OrderExpired: = "OrderExpired"

Defined in types.ts:359

OrderForIncorrectChain

OrderForIncorrectChain: = "OrderForIncorrectChain"

Defined in types.ts:355

OrderFullyFilled

OrderFullyFilled: = "OrderFullyFilled"

Defined in types.ts:360

OrderHasInvalidMakerAssetAmount

OrderHasInvalidMakerAssetAmount: = "OrderHasInvalidMakerAssetAmount"

Defined in types.ts:357

OrderHasInvalidMakerAssetData

OrderHasInvalidMakerAssetData: = "OrderHasInvalidMakerAssetData"

Defined in types.ts:363

OrderHasInvalidSignature

OrderHasInvalidSignature: = "OrderHasInvalidSignature"

Defined in types.ts:365

OrderHasInvalidTakerAssetAmount

OrderHasInvalidTakerAssetAmount: = "OrderHasInvalidTakerAssetAmount"

Defined in types.ts:358

OrderHasInvalidTakerAssetData

OrderHasInvalidTakerAssetData: = "OrderHasInvalidTakerAssetData"

Defined in types.ts:364

OrderUnfunded

OrderUnfunded: = "OrderUnfunded"

Defined in types.ts:362

Enumeration: RejectedKind

Index

Enumeration members

Enumeration members

MeshError

MeshError: = "MESH_ERROR"

Defined in types.ts:347

MeshValidation

MeshValidation: = "MESH_VALIDATION"

Defined in types.ts:348

ZeroexValidation

ZeroexValidation: = "ZEROEX_VALIDATION"

Defined in types.ts:346

Interface: AcceptedOrderInfo

Hierarchy

  • AcceptedOrderInfo

Index

Properties

Properties

fillableTakerAssetAmount

fillableTakerAssetAmount: BigNumber

Defined in types.ts:329

isNew

isNew: boolean

Defined in types.ts:330

orderHash

orderHash: string

Defined in types.ts:327

signedOrder

signedOrder: SignedOrder

Defined in types.ts:328

Interface: ClientConfig

WebSocketClient configs Source: https://github.com/theturtle32/WebSocket-Node/blob/master/docs/WebSocketClient.md#client-config-options

Hierarchy

  • ClientConfig

Index

Properties

Properties

Optional assembleFragments

assembleFragments? : undefined | false | true

Defined in types.ts:14

Optional closeTimeout

closeTimeout? : undefined | number

Defined in types.ts:15

Optional fragmentOutgoingMessages

fragmentOutgoingMessages? : undefined | false | true

Defined in types.ts:12

Optional fragmentationThreshold

fragmentationThreshold? : undefined | number

Defined in types.ts:13

Optional maxReceivedFrameSize

maxReceivedFrameSize? : undefined | number

Defined in types.ts:10

Optional maxReceivedMessageSize

maxReceivedMessageSize? : undefined | number

Defined in types.ts:11

Optional tlsOptions

tlsOptions? : any

Defined in types.ts:16

Optional webSocketVersion

webSocketVersion? : undefined | number

Defined in types.ts:9

Interface: ContractEvent

Hierarchy

  • ContractEvent

Index

Properties

Properties

address

address: string

Defined in types.ts:277

blockHash

blockHash: string

Defined in types.ts:272

isRemoved

isRemoved: string

Defined in types.ts:276

kind

kind: ContractEventKind

Defined in types.ts:278

logIndex

logIndex: number

Defined in types.ts:275

parameters

parameters: ContractEventParameters

Defined in types.ts:279

txHash

txHash: string

Defined in types.ts:273

txIndex

txIndex: number

Defined in types.ts:274

Interface: ERC1155ApprovalForAllEvent

Hierarchy

  • ERC1155ApprovalForAllEvent

Index

Properties

Properties

approved

approved: boolean

Defined in types.ts:142

operator

operator: string

Defined in types.ts:141

owner

owner: string

Defined in types.ts:140

Interface: ERC1155TransferBatchEvent

Hierarchy

  • ERC1155TransferBatchEvent

Index

Properties

Properties

from

from: string

Defined in types.ts:125

ids

ids: BigNumber[]

Defined in types.ts:127

operator

operator: string

Defined in types.ts:124

to

to: string

Defined in types.ts:126

values

values: BigNumber[]

Defined in types.ts:128

Interface: ERC1155TransferSingleEvent

Hierarchy

  • ERC1155TransferSingleEvent

Index

Properties

Properties

from

from: string

Defined in types.ts:109

id

id: BigNumber

Defined in types.ts:111

operator

operator: string

Defined in types.ts:108

to

to: string

Defined in types.ts:110

value

value: BigNumber

Defined in types.ts:112

Interface: ERC20ApprovalEvent

Hierarchy

  • ERC20ApprovalEvent

Index

Properties

Properties

owner

owner: string

Defined in types.ts:66

spender

spender: string

Defined in types.ts:67

value

value: BigNumber

Defined in types.ts:68

Interface: ERC20TransferEvent

Hierarchy

  • ERC20TransferEvent

Index

Properties

Properties

from

from: string

Defined in types.ts:54

to

to: string

Defined in types.ts:55

value

value: BigNumber

Defined in types.ts:56

Interface: ERC721ApprovalEvent

Hierarchy

  • ERC721ApprovalEvent

Index

Properties

Properties

approved

approved: string

Defined in types.ts:91

owner

owner: string

Defined in types.ts:90

tokenId

tokenId: BigNumber

Defined in types.ts:92

Interface: ERC721ApprovalForAllEvent

Hierarchy

  • ERC721ApprovalForAllEvent

Index

Properties

Properties

approved

approved: boolean

Defined in types.ts:104

operator

operator: string

Defined in types.ts:103

owner

owner: string

Defined in types.ts:102

Interface: ERC721TransferEvent

Hierarchy

  • ERC721TransferEvent

Index

Properties

Properties

from

from: string

Defined in types.ts:78

to

to: string

Defined in types.ts:79

tokenId

tokenId: BigNumber

Defined in types.ts:80

Interface: ExchangeCancelEvent

Hierarchy

  • ExchangeCancelEvent

Index

Properties

Properties

feeRecipientAddress

feeRecipientAddress: string

Defined in types.ts:176

makerAddress

makerAddress: string

Defined in types.ts:174

makerAssetData

makerAssetData: string

Defined in types.ts:178

orderHash

orderHash: string

Defined in types.ts:177

senderAddress

senderAddress: string

Defined in types.ts:175

takerAssetData

takerAssetData: string

Defined in types.ts:179

Interface: ExchangeCancelUpToEvent

Hierarchy

  • ExchangeCancelUpToEvent

Index

Properties

Properties

makerAddress

makerAddress: string

Defined in types.ts:183

orderEpoch

orderEpoch: BigNumber

Defined in types.ts:185

senderAddress

senderAddress: string

Defined in types.ts:184

Interface: ExchangeFillEvent

Hierarchy

  • ExchangeFillEvent

Index

Properties

Properties

feeRecipientAddress

feeRecipientAddress: string

Defined in types.ts:149

makerAddress

makerAddress: string

Defined in types.ts:146

makerAssetData

makerAssetData: string

Defined in types.ts:155

makerAssetFilledAmount

makerAssetFilledAmount: BigNumber

Defined in types.ts:150

makerFeePaid

makerFeePaid: BigNumber

Defined in types.ts:152

orderHash

orderHash: string

Defined in types.ts:154

senderAddress

senderAddress: string

Defined in types.ts:148

takerAddress

takerAddress: string

Defined in types.ts:147

takerAssetData

takerAssetData: string

Defined in types.ts:156

takerAssetFilledAmount

takerAssetFilledAmount: BigNumber

Defined in types.ts:151

takerFeePaid

takerFeePaid: BigNumber

Defined in types.ts:153

Interface: GetOrdersResponse

Hierarchy

  • GetOrdersResponse

Index

Properties

Properties

ordersInfos

ordersInfos: RawAcceptedOrderInfo[]

Defined in types.ts:399

snapshotID

snapshotID: string

Defined in types.ts:398

Interface: GetStatsResponse

Hierarchy

  • GetStatsResponse

Index

Properties

Properties

ethRPCRateLimitExpiredRequests

ethRPCRateLimitExpiredRequests: number

Defined in types.ts:426

ethRPCRequestsSentInCurrentUTCDay

ethRPCRequestsSentInCurrentUTCDay: number

Defined in types.ts:425

ethereumChainID

ethereumChainID: number

Defined in types.ts:417

latestBlock

latestBlock: LatestBlock

Defined in types.ts:418

maxExpirationTime

maxExpirationTime: string

Defined in types.ts:423

numOrders

numOrders: number

Defined in types.ts:420

numOrdersIncludingRemoved

numOrdersIncludingRemoved: number

Defined in types.ts:421

numPeers

numPeers: number

Defined in types.ts:419

numPinnedOrders

numPinnedOrders: number

Defined in types.ts:422

peerID

peerID: string

Defined in types.ts:416

pubSubTopic

pubSubTopic: string

Defined in types.ts:414

rendezvous

rendezvous: string

Defined in types.ts:415

startOfCurrentUTCDay

startOfCurrentUTCDay: string

Defined in types.ts:424

version

version: string

Defined in types.ts:413

Interface: HeartbeatEventPayload

Hierarchy

  • HeartbeatEventPayload

Index

Properties

Properties

result

result: string

Defined in types.ts:300

subscription

subscription: string

Defined in types.ts:299

Interface: LatestBlock

Hierarchy

  • LatestBlock

Index

Properties

Properties

hash

hash: string

Defined in types.ts:409

number

number: number

Defined in types.ts:408

Interface: OrderEvent

Hierarchy

  • OrderEvent

Index

Properties

Properties

contractEvents

contractEvents: ContractEvent[]

Defined in types.ts:316

endState

endState: OrderEventEndState

Defined in types.ts:314

fillableTakerAssetAmount

fillableTakerAssetAmount: BigNumber

Defined in types.ts:315

orderHash

orderHash: string

Defined in types.ts:312

signedOrder

signedOrder: SignedOrder

Defined in types.ts:313

Interface: OrderEventPayload

Hierarchy

  • OrderEventPayload

Index

Properties

Properties

result

result: RawOrderEvent[]

Defined in types.ts:295

subscription

subscription: string

Defined in types.ts:294

Interface: OrderInfo

Hierarchy

  • OrderInfo

Index

Properties

Properties

fillableTakerAssetAmount

fillableTakerAssetAmount: BigNumber

Defined in types.ts:342

orderHash

orderHash: string

Defined in types.ts:340

signedOrder

signedOrder: SignedOrder

Defined in types.ts:341

Interface: RawAcceptedOrderInfo

Hierarchy

  • RawAcceptedOrderInfo

Index

Properties

Properties

fillableTakerAssetAmount

fillableTakerAssetAmount: string

Defined in types.ts:322

isNew

isNew: boolean

Defined in types.ts:323

orderHash

orderHash: string

Defined in types.ts:320

signedOrder

signedOrder: StringifiedSignedOrder

Defined in types.ts:321

Interface: RawOrderEvent

Hierarchy

  • RawOrderEvent

Index

Properties

Properties

contractEvents

contractEvents: StringifiedContractEvent[]

Defined in types.ts:308

endState

endState: OrderEventEndState

Defined in types.ts:306

fillableTakerAssetAmount

fillableTakerAssetAmount: string

Defined in types.ts:307

orderHash

orderHash: string

Defined in types.ts:304

signedOrder

signedOrder: StringifiedSignedOrder

Defined in types.ts:305

Interface: RawOrderInfo

Hierarchy

  • RawOrderInfo

Index

Properties

Properties

fillableTakerAssetAmount

fillableTakerAssetAmount: string

Defined in types.ts:336

orderHash

orderHash: string

Defined in types.ts:334

signedOrder

signedOrder: StringifiedSignedOrder

Defined in types.ts:335

Interface: RawRejectedOrderInfo

Hierarchy

  • RawRejectedOrderInfo

Index

Properties

Properties

kind

kind: RejectedKind

Defined in types.ts:376

orderHash

orderHash: string

Defined in types.ts:374

signedOrder

signedOrder: StringifiedSignedOrder

Defined in types.ts:375

status

status: RejectedStatus

Defined in types.ts:377

Interface: RawValidationResults

Hierarchy

  • RawValidationResults

Index

Properties

Properties

accepted

accepted: RawAcceptedOrderInfo[]

Defined in types.ts:388

rejected

rejected: RawRejectedOrderInfo[]

Defined in types.ts:389

Interface: RejectedOrderInfo

Hierarchy

  • RejectedOrderInfo

Index

Properties

Properties

kind

kind: RejectedKind

Defined in types.ts:383

orderHash

orderHash: string

Defined in types.ts:381

signedOrder

signedOrder: SignedOrder

Defined in types.ts:382

status

status: RejectedStatus

Defined in types.ts:384

Interface: RejectedStatus

Hierarchy

  • RejectedStatus

Index

Properties

Properties

code

code: RejectedCode

Defined in types.ts:369

message

message: string

Defined in types.ts:370

Interface: StringifiedContractEvent

Hierarchy

  • StringifiedContractEvent

Index

Properties

Properties

address

address: string

Defined in types.ts:251

blockHash

blockHash: string

Defined in types.ts:246

isRemoved

isRemoved: string

Defined in types.ts:250

kind

kind: string

Defined in types.ts:252

logIndex

logIndex: number

Defined in types.ts:249

parameters

parameters: StringifiedContractEventParameters

Defined in types.ts:253

txHash

txHash: string

Defined in types.ts:247

txIndex

txIndex: number

Defined in types.ts:248

Interface: StringifiedERC1155TransferBatchEvent

Hierarchy

  • StringifiedERC1155TransferBatchEvent

Index

Properties

Properties

from

from: string

Defined in types.ts:133

ids

ids: string[]

Defined in types.ts:135

operator

operator: string

Defined in types.ts:132

to

to: string

Defined in types.ts:134

values

values: string[]

Defined in types.ts:136

Interface: StringifiedERC1155TransferSingleEvent

Hierarchy

  • StringifiedERC1155TransferSingleEvent

Index

Properties

Properties

from

from: string

Defined in types.ts:117

id

id: string

Defined in types.ts:119

operator

operator: string

Defined in types.ts:116

to

to: string

Defined in types.ts:118

value

value: string

Defined in types.ts:120

Interface: StringifiedERC20ApprovalEvent

Hierarchy

  • StringifiedERC20ApprovalEvent

Index

Properties

Properties

owner

owner: string

Defined in types.ts:72

spender

spender: string

Defined in types.ts:73

value

value: string

Defined in types.ts:74

Interface: StringifiedERC20TransferEvent

Hierarchy

  • StringifiedERC20TransferEvent

Index

Properties

Properties

from

from: string

Defined in types.ts:60

to

to: string