aftermath-ts-sdk - v3.3.3
    Preparing search index...

    Queries, paginates, and locally casts Sui events.

    Most methods coordinate a caller-provided page fetcher and do not choose a transport. fetchCastEventsWithCursor is the exception: it performs network I/O through the optional JSON-RPC client because the gRPC client has no equivalent for suix_queryEvents.

    Index
    • Fetches every event page until the callback returns an empty page or a null cursor.

      This method does not perform I/O itself. fetchEventsFunc receives the current EventId cursor and a page limit and may use any supported source. The default limit is 256 events per call. The method preserves page order and does not deduplicate events.

      Type Parameters

      • T

      Parameters

      • inputs: {
            fetchEventsFunc: (
                eventsInputs: EventsInputs,
            ) => Promise<EventsWithCursor<T>>;
            limitStepSize?: number;
        }

        The page fetcher and optional per-page limit.

      Returns Promise<T[]>

      All events returned by the callback.

      Errors from fetchEventsFunc or its event caster.

    • Fetches and casts one page of events with the legacy JSON-RPC client.

      Type Parameters

      • EventOnChainType
      • EventType

      Parameters

      • inputs: {
            eventFromEventOnChain: (eventOnChain: EventOnChainType) => EventType;
            query: SuiEventFilter;
        } & EventsInputs

        A JSON-RPC event filter, an optional EventId cursor and page limit, and a caster for the raw event shape. The cursor's eventSeq value is sent as a string, as required by JSON-RPC.

      Returns Promise<EventsWithCursor<EventType>>

      The cast events from this page and nextCursor. The cursor is null when JSON-RPC reports no later page.

      Remaining JSON-RPC surface — see AftermathApi.jsonRpcClient. suix_queryEvents has no SuiGrpcClient equivalent: the only gRPC path is the raw ledgerService.ListEvents, whose filter model and cursor differ from SuiEventFilter / EventId, and whose events carry BCS bytes instead of the parsedJson that every eventFromEventOnChain caster reads. Porting it would change this helper's semantics, so it still goes through JSON-RPC and will stop working when that is removed from fullnodes (scheduled for mid-October 2026).

      If no jsonRpcClient was passed to AftermathApi, since it is optional there.

      If the optional JSON-RPC client is absent, the request fails, or the caster throws.

    • Fetches pages until events fall outside a millisecond time window.

      This method does not perform I/O itself. It calls fetchEventsFunc with an EventId cursor and a page limit, so the callback determines the transport and query. It keeps events in page order, stops before the first event whose timestamp is more than timeMs milliseconds older than Date.now(), and stops after 20 pages even when the callback keeps returning a cursor. Events without a timestamp are not treated as stale.

      Type Parameters

      Parameters

      • inputs: {
            fetchEventsFunc: (
                eventsInputs: EventsInputs,
            ) => Promise<EventsWithCursor<T>>;
            limitStepSize?: number;
            timeMs: number;
        }

        The page fetcher, time window in milliseconds, and optional per-page limit. The limit defaults to 256 events.

      Returns Promise<T[]>

      Events collected within the time window.

      Errors from fetchEventsFunc or its event caster.

    • Always throws because event subscriptions are not implemented by this helper.

      Parameters

      • _inputs: { address: string; onEvent: (event: SuiEvent) => void }

        The wallet address and event callback that the removed subscription API would have used. Neither value is read.

      Returns Promise<never>

      Not implemented. gRPC's SubscriptionService.SubscribeEvents is the replacement — reach it via AftermathApi["client"].subscriptionService — or poll EventsApiHelpers.fetchCastEventsWithCursor.

      Error on every call because this method is not implemented.

    • Casts one event when its type matches the requested Move type.

      This is a local operation. By default it uses substring matching; set exactMatch to true to require the event type to equal the resolved type. The caster runs only for a matching event.

      Type Parameters

      • EventTypeOnChain
      • EventType

      Parameters

      • event: SuiEvent

        The raw Sui event to inspect.

      • eventType: string | (() => string)

        A Move type string or a callback that returns one.

      • castFunction: (eventOnChain: EventTypeOnChain) => EventType

        Converts the raw event into the caller's event type.

      • OptionalexactMatch: boolean

        Whether to require exact type equality. Defaults to false.

      Returns EventType | undefined

      The cast event for a match, otherwise undefined.

      Errors from castFunction.

    • Builds a fully qualified Move event type string.

      This is a local string operation and performs no network I/O. When wrapperType is provided, the result is wrapperType<package::module::event>. The method does not validate the individual type segments.

      Parameters

      • packageAddress: string

        The published package address, such as 0x2.

      • packageName: string

        The Move module name.

      • eventType: string

        The event struct name or inner type expression.

      • OptionalwrapperType: string

        Optional outer Move type, such as SomeWrapper.

      Returns string

      The assembled Move type string.

    • Finds and casts the first matching event in one transaction response.

      This is a local operation with no network I/O. A transaction without an events array is treated as having no matching events.

      Type Parameters

      • EventTypeOnChain
      • EventType

      Parameters

      • transaction: SuiTransactionBlockResponse

        The transaction response to inspect.

      • eventType: string | (() => string)

        A Move type string or a callback that returns one.

      • castFunction: (eventOnChain: EventTypeOnChain) => EventType

        Converts the raw matching event.

      Returns EventType | undefined

      The first cast match, or undefined when the transaction has no matching event.

      Errors from castFunction.

    • Finds and casts the first matching event across transaction responses.

      This is a local operation with no network I/O. Transactions and their events are searched in array order, and the method stops after the first match.

      Type Parameters

      • EventTypeOnChain
      • EventType

      Parameters

      • transactions: SuiTransactionBlockResponse[]

        The transaction responses to inspect.

      • eventType: string | (() => string)

        A Move type string or a callback that returns one.

      • castFunction: (eventOnChain: EventTypeOnChain) => EventType

        Converts the raw matching event.

      Returns EventType | undefined

      The first cast match, or undefined when no transaction matches.

      Errors from castFunction.

    • Finds and casts the first event whose type contains the requested Move type.

      This is a local operation with no network I/O. The event array remains in caller order, and the caster runs only for the first matching event.

      Type Parameters

      • EventTypeOnChain
      • EventType

      Parameters

      • inputs: {
            castFunction: (eventOnChain: EventTypeOnChain) => EventType;
            events: SuiEvent[];
            eventType: string | (() => string);
        }

        The event array, Move type string or resolver, and caster.

      Returns EventType | undefined

      The first cast match, or undefined when no event matches.

      Errors from castFunction.

    • Finds and casts every event whose type contains the requested Move type.

      This is a local operation with no network I/O. The result is an array in the same order as events; no match produces an empty array.

      Type Parameters

      • EventTypeOnChain
      • EventType

      Parameters

      • inputs: {
            castFunction: (eventOnChain: EventTypeOnChain) => EventType;
            events: SuiEvent[];
            eventType: string | (() => string);
        }

        The event array, Move type string or resolver, and caster.

      Returns EventType[]

      All cast matches, or an empty array when no event matches.

      Errors from castFunction.

    • Returns an event when its type contains the requested Move type.

      This is a local check and performs no network I/O. A callback event type is resolved when the method runs. Matching is substring-based, so a wrapped event type also matches its inner type.

      Parameters

      • event: SuiEvent

        The event to inspect.

      • eventType: string | (() => string)

        A Move type string or a callback that returns one.

      Returns SuiEvent | undefined

      The original event when it matches, otherwise undefined.