send method

  1. @override
Future<void> send({
  1. required Transaction transaction,
  2. Duration timeout = const Duration(seconds: 60),
  3. required TransactionConfirmationHandler onConfirmation,
  4. 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,
  );
}