Skip to content

AbiEvent.assertArgs

Asserts that the provided arguments match the decoded log arguments.

Imports

Named
import { AbiEvent } from 'ox'

Examples

import { AbiEvent } from 'ox'
 
const abiEvent = AbiEvent.from('event Transfer(address indexed from, address indexed to, uint256 value)')
 
const args = AbiEvent.decode(abiEvent, {
  data: '0x0000000000000000000000000000000000000000000000000000000000000001',
  topics: [
    '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
    '0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac',
    '0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac',
  ],
})
 
AbiEvent.assertArgs(abiEvent, args, {
  from: '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ad',
  to: '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ac',
  value: 1n,
})
 
AbiEvent.ArgsMismatchError: Given arguments to not match the arguments decoded from the log.
Event: event Transfer(address indexed from, address indexed to, uint256 value)
from: 0xa5cc3c03994db5b0d9a5eedd10cabab0813678ac
to: 0xa5cc3c03994db5b0d9a5eedd10cabab0813678ad
value: 1
Given Arguments:
from: 0xa5cc3c03994db5b0d9a5eedd10cabab0813678ad
to: 0xa5cc3c03994db5b0d9a5eedd10cabab0813678ac
value: 1

Definition

function assertArgs<abiEvent>(
  abiEvent: abiEvent | AbiEvent,
  args: unknown,
  matchArgs: IsNarrowable<abiEvent, AbiEvent> extends true ? abiEvent['inputs'] extends readonly [] ? never : internal.ParametersToPrimitiveTypes<abiEvent['inputs'], {
    EnableUnion: true;
    IndexedOnly: false;
    Required: false;
}> : unknown,
): void

Source: src/AbiEvent.ts

Parameters

abiEvent

  • Type: abiEvent | AbiEvent

ABI Event to check.

args

  • Type: unknown

Decoded arguments.

matchArgs

  • Type: IsNarrowable<abiEvent, AbiEvent> extends true ? abiEvent['inputs'] extends readonly [] ? never : internal.ParametersToPrimitiveTypes<abiEvent['inputs'], { EnableUnion: true; IndexedOnly: false; Required: false; }> : unknown

The arguments to check.

Return Type

void

Error Type

AbiEvent.assertArgs.ErrorType