getEventsByCreationNumber method
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 a0x
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 eventslimit
- Max number of events to retrieve. If unspecified, defaults to default page sizecancelToken
- ACancelToken
that can be used to cancel the operationheaders
- Can be used to add additional headers to the requestextras
- Can be used to add flags to the requestvalidateStatus
- AValidateStatus
callback that can be used to determine request success based on the HTTP status of the responseonSendProgress
- AProgressCallback
that can be used to get the send progressonReceiveProgress
- AProgressCallback
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,
);
}