sendTransactionNotification method

Future<void> sendTransactionNotification({
  1. required TransactionNotification notification,
  2. required KeyPair senderKeyPair,
  3. required String notifBackendBaseUrl,
  4. required Map<String, PushNotification> pushNotification,
  5. required String transactionType,
  6. dynamic extra,
})

Implementation

Future<void> sendTransactionNotification({
  required TransactionNotification notification,
  required KeyPair senderKeyPair,
  required String notifBackendBaseUrl,
  required Map<String, PushNotification> pushNotification,
  required String transactionType,
  dynamic extra,
}) async {
  for (final listenAddress in notification.listenAddresses) {
    final signature = uint8ListToHex(
      await signTransactionNotification(
        notificationRecipientAddress:
            notification.notificationRecipientAddress,
        listenAddress: listenAddress,
        senderKeyPair: senderKeyPair,
      ),
    );

    final body = jsonEncode(
      {
        'txAddress': notification.notificationRecipientAddress,
        'txChainGenesisAddress': listenAddress,
        'payloadSignature': signature,
        'pushNotification': pushNotification,
        'type': transactionType,
        'extra': extra,
      },
    );
    log('Sending notification. $body');
    await http.post(
      Uri.parse('$notifBackendBaseUrl/transactionSent'),
      body: body,
      headers: <String, String>{
        'Content-type': 'application/json',
        'Accept': 'application/json',
      },
    );
  }
}