fromRelayMessage static method

NostrEventOkCommand fromRelayMessage(
  1. String data
)

Implementation

static NostrEventOkCommand fromRelayMessage(String data) {
  assert(canBeDeserialized(data));

  final decoded = jsonDecode(data) as List;
  final eventId = decoded[1] as String;

  final isEventAccepted = decoded.length > 2
      ? decoded[2] is bool
          ? decoded[2] as bool
          : decoded[2] is String
              ? (decoded[2] as String).toLowerCase() == 'true'
              : null
      : null;

  final message = decoded.length > 3 ? decoded[3] as String? : null;

  return NostrEventOkCommand(
    eventId: eventId,
    isEventAccepted: isEventAccepted,
    message: message,
  );
}