autoFill static method
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);
}
}