autoFill static method

Future<void> autoFill(
  1. XRPLRpc client,
  2. XRPTransaction transaction, {
  3. bool calculateFee = true,
  4. bool setupNetworkId = true,
  5. bool setupAccountSequence = true,
  6. bool setupLedgerSequence = true,
  7. int defaultLedgerOffset = 20,
})

This asynchronous function automates various aspects of preparing an XRPL transaction. It can calculate fees, set the network ID, account sequence, and last ledger sequence.

Implementation

static Future<void> autoFill(
  XRPLRpc client,
  XRPTransaction transaction, {
  bool calculateFee = true,
  bool setupNetworkId = true,
  bool setupAccountSequence = true,
  bool setupLedgerSequence = true,
  int defaultLedgerOffset = 20,
}) async {
  /// Set the network ID if requested.
  if (setupNetworkId) {
    transaction.setNetworkId(await client.getTransactionNetworkId());
  }

  /// Calculate transaction fees if requested.
  if (calculateFee) {
    await calculateFees(client, transaction);
  }

  /// Set the account sequence if requested.
  if (setupAccountSequence) {
    final int sequence =
        await getAccountSequence(client, transaction.account);
    transaction.setSequence(sequence);
  }

  /// Set the last ledger sequence if requested.
  if (setupLedgerSequence) {
    final int ledgerIndex = await getLedgerIndex(client,
        defaultLedgerOffset: defaultLedgerOffset);
    transaction.setLastLedgerSequence(ledgerIndex);
  }
}