addSelfFetchFunctions<TData> function
Augments a Decoder with self-fetch methods by wrapping it in a SelfFetchFunctions instance.
This enables a fluent API where you can call methods like .fetch()
directly on the returned object to retrieve and decode accounts in one
step.
Example:
final fetchable = addSelfFetchFunctions(rpc, myDecoder);
// Fetch and decode an account in one step.
final account = await fetchable.fetch(accountAddress);
// Handle accounts that may not exist.
final maybeAccount = await fetchable.fetchMaybe(accountAddress);
if (maybeAccount.exists) {
// Use maybeAccount.
}
// Fetch multiple accounts at once (throws if any are missing).
final accounts = await fetchable.fetchAll([addressA, addressB]);
// Fetch multiple accounts, allowing some to be missing.
final maybeAccounts = await fetchable.fetchAllMaybe([addressA, addressB]);
Implementation
SelfFetchFunctions<TData> addSelfFetchFunctions<TData>(
Rpc rpc,
Decoder<TData> decoder,
) {
return SelfFetchFunctions<TData>(decoder: decoder, rpc: rpc);
}