Skip to content

watchDidFill

The watchDidFill waits for an order to be filled on the destination chain. This involves waiting for a Filled event to be emitted on the destination outbox contract, and returns the destination transaction hash.

Usage

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

import { watchDidFill } from '@omni-network/core'
 
const { unwatch, status, destTxHash } = await watchDidFill({
  // ... params
});

Parameters

PropTypeRequiredDescription
clientClientYesThe viem client used to send the transaction. This client must have an account attached to it.
outboxAddressHexYesThe address of the outbox contract, retrieved using the getContracts function.
orderIdHexYesOrder identifier defined on a ResolvedOrder
onFill(txHash: Hex) => voidYesCallback that'll be invoked with the destination tx hash that emitted the Filled event.
pollingIntervalnumberNoPolling interval in milliseconds, defaults to the client polling interval.
onError(error: Error) => voidNoOptional callback that'll be invoked when an error occurs.

Return

unwatch

Terminates watching of contract events.

() => void

Example

import { watchDidFill } from '@omni-network/core'
 
const { unwatch, status, destTxHash } = await watchDidFill({
  client: viemWalletClient,
  outboxAddress: contracts.outbox,
  orderId: resolvedOrder.orderId,
  onFill: (txHash) => {
    console.log('Fill tx hash found:', txHash)
  },
})
 
// Stop watching for the Filled event
unwatch()