Skip to content

waitForOrderClose

The waitForOrderClose waits for an order to be in a terminal state (closed, filled or rejected) on a SolverNet inbox contract.

Usage

import { waitForOrderClose } from '@omni-network/core'

import { waitForOrderClose } from '@omni-network/core'
 
const orderStatus = await waitForOrderClose({
  // ... params
});

Parameters

PropTypeRequiredDescription
clientClientYesThe viem client used to read from the blockchain.
inboxAddressAddressYesThe address of the inbox contract, retrieved using the getContracts function.
orderIdHexYesOrder identifier defined on a ResolvedOrder
pollingintervalnumberNoPolling interval in milliseconds, defaults to the client polling interval.
signalAbortSignalNoOptional AbortSignal that can be used to stop waiting.

Return

waitForOrderClose returns the Promise of a TerminalStatus string.

TerminalStatus

type TerminalStatus = 'closed' | 'filled' | 'rejected'

Example

import { sendOrder, waitForOrderClose, waitForOrderOpen } from '@omni-network/core'
 
const txHash = await sendOrder({
  client: viemClient,
  inboxAddress: contracts.inbox,
  order: orderParams
})
const resolvedOrder = await waitForOrderOpen({
  client: viemClient,
  txHash: txHash,
})
const orderStatus = await waitForOrderClose({
  client: viemClient,
  inboxAddress: contracts.inbox,
  orderId: resolvedOrder.orderId,
})