compileV0 static method
MessageV0
compileV0({
- required List<
TransactionInstruction> transactionInstructions, - required SolAddress payer,
- required SolAddress recentBlockhash,
- List<
AddressLookupTableAccount> lookupTableAccounts = const [],
compile V0 Message
Implementation
static MessageV0 compileV0(
{required List<TransactionInstruction> transactionInstructions,
required SolAddress payer,
required SolAddress recentBlockhash,
List<AddressLookupTableAccount> lookupTableAccounts = const []}) {
final compiledKeys = CompiledKeys.compile(transactionInstructions, payer);
final addressTableLookups = <AddressTableLookup>[];
final List<SolAddress> writable = List.empty(growable: true);
final List<SolAddress> readonly = List.empty(growable: true);
for (final lookupTable in lookupTableAccounts) {
final extractResult = compiledKeys.extractTableLookup(lookupTable);
if (extractResult != null) {
final addressTableLookup = extractResult.lookup;
addressTableLookups.add(addressTableLookup);
writable.addAll(extractResult.writable);
readonly.addAll(extractResult.readable);
}
}
final componets = compiledKeys.getMessageComponents();
final header = componets.item1;
final staticAccountKeys = componets.item2;
final accountKeys = MessageAccountKeys(staticAccountKeys,
AccountLookupKeys(readonly: readonly, writable: writable));
final compiledInstructions =
accountKeys.compileInstructions(transactionInstructions);
return MessageV0(
header: header,
accountKeys: staticAccountKeys,
recentBlockhash: recentBlockhash,
compiledInstructions: compiledInstructions,
addressTableLookups: addressTableLookups,
);
}