sendTransactionNotification method
Future<void>
sendTransactionNotification({
- required TransactionNotification notification,
- required KeyPair senderKeyPair,
- required String notifBackendBaseUrl,
- required Map<
String, PushNotification> pushNotification, - required String transactionType,
- 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',
},
);
}
}