NostrRequest.deserialized constructor
NostrRequest.deserialized(
- dynamic input
Deserialize a request
Implementation
factory NostrRequest.deserialized(input) {
final haveThreeElements = input is List && input.length >= 3;
assert(
haveThreeElements,
'Invalid request, must have at least 3 elements',
);
assert(
input[0] == NostrConstants.request,
'Invalid request, must start with ${NostrConstants.request}',
);
final subscriptionId = input[1] as String;
return NostrRequest(
subscriptionId: subscriptionId,
filters: List.generate(
input.length - 2,
(index) => NostrFilter.fromJson(
input[index + 2],
),
),
);
}