getEventsByCreationNumber method

Future<Response<BuiltList<VersionedEvent>>> getEventsByCreationNumber({
  1. required String address,
  2. required String creationNumber,
  3. String? start,
  4. int? limit,
  5. CancelToken? cancelToken,
  6. Map<String, dynamic>? headers,
  7. Map<String, dynamic>? extra,
  8. ValidateStatus? validateStatus,
  9. ProgressCallback? onSendProgress,
  10. ProgressCallback? onReceiveProgress,
})

Get events by creation number Event types are globally identifiable by an account `address` and monotonically increasing `creation_number`, one per event type emitted to the given account. This API returns events corresponding to that that event type.

Parameters:

  • address - Hex-encoded 32 byte Aptos account, with or without a 0x prefix, for which events are queried. This refers to the account that events were emitted to, not the account hosting the move module that emits that event type.
  • creationNumber - Creation number corresponding to the event stream originating from the given account.
  • start - Starting sequence number of events. If unspecified, by default will retrieve the most recent events
  • limit - Max number of events to retrieve. If unspecified, defaults to default page size
  • cancelToken - A CancelToken that can be used to cancel the operation
  • headers - Can be used to add additional headers to the request
  • extras - Can be used to add flags to the request
  • validateStatus - A ValidateStatus callback that can be used to determine request success based on the HTTP status of the response
  • onSendProgress - A ProgressCallback that can be used to get the send progress
  • onReceiveProgress - A ProgressCallback that can be used to get the receive progress

Returns a Future containing a Response with a BuiltList<VersionedEvent> as data Throws DioError if API call or serialization fails

Implementation

Future<Response<BuiltList<VersionedEvent>>> getEventsByCreationNumber({
  required String address,
  required String creationNumber,
  String? start,
  int? limit,
  CancelToken? cancelToken,
  Map<String, dynamic>? headers,
  Map<String, dynamic>? extra,
  ValidateStatus? validateStatus,
  ProgressCallback? onSendProgress,
  ProgressCallback? onReceiveProgress,
}) async {
  final _path = r'/accounts/{address}/events/{creation_number}'
      .replaceAll('{' r'address' '}', address.toString())
      .replaceAll('{' r'creation_number' '}', creationNumber.toString());
  final _options = Options(
    method: r'GET',
    headers: <String, dynamic>{
      ...?headers,
    },
    extra: <String, dynamic>{
      'secure': <Map<String, String>>[],
      ...?extra,
    },
    validateStatus: validateStatus,
  );

  final _queryParameters = <String, dynamic>{
    if (start != null)
      r'start':
          encodeQueryParameter(_serializers, start, const FullType(String)),
    if (limit != null)
      r'limit':
          encodeQueryParameter(_serializers, limit, const FullType(int)),
  };

  final _response = await _dio.request<Object>(
    _path,
    options: _options,
    queryParameters: _queryParameters,
    cancelToken: cancelToken,
    onSendProgress: onSendProgress,
    onReceiveProgress: onReceiveProgress,
  );

  BuiltList<VersionedEvent>? _responseData;

  try {
    final rawResponse = _response.data;
    _responseData = rawResponse == null
        ? null
        : _serializers.deserialize(
            rawResponse,
            specifiedType:
                const FullType(BuiltList, [FullType(VersionedEvent)]),
          ) as BuiltList<VersionedEvent>;
  } catch (error, stackTrace) {
    throw DioError(
      requestOptions: _response.requestOptions,
      response: _response,
      type: DioErrorType.unknown,
      error: error,
      stackTrace: stackTrace,
    );
  }

  return Response<BuiltList<VersionedEvent>>(
    data: _responseData,
    headers: _response.headers,
    isRedirect: _response.isRedirect,
    requestOptions: _response.requestOptions,
    redirects: _response.redirects,
    statusCode: _response.statusCode,
    statusMessage: _response.statusMessage,
    extra: _response.extra,
  );
}