send method
Future<void>
send({
- required Transaction transaction,
- Duration timeout = const Duration(seconds: 60),
- required TransactionConfirmationHandler onConfirmation,
- required TransactionErrorHandler onError,
override
Sends a transaction and listens to confirmations.
Sender auto-closes in the following situations : - when transaction is fully confirmed - when timeout is reached - when transaction fails
Implementation
@override
Future<void> send({
required Transaction transaction,
Duration timeout = const Duration(seconds: 60),
required TransactionConfirmationHandler onConfirmation,
required TransactionErrorHandler onError,
}) async {
_timer = Timer(
timeout,
() {
onError(const TransactionError.timeout());
close();
},
);
await _connect(
phoenixHttpEndpoint,
websocketEndpoint,
);
_listenTransactionConfirmed(
transaction.address!.address!,
onConfirmation,
onError,
);
_listenTransactionError(
transaction.address!.address!,
onError,
);
await _sendTransaction(
transaction: transaction,
onError: onError,
);
}