compile method
Compiles a message into the array of bytes that would be interpreted by
solana. The recentBlockhash
is passed here as this is the final step
before sending the Message.
If provided the feePayer
can be added to the accounts if it's not
present.
Returns a CompiledMessage that can be used to sign the transaction, and also verify that the number of signers is correct.
Implementation
CompiledMessage compile({
required String recentBlockhash,
required Ed25519HDPublicKey feePayer,
}) {
final accounts = instructions.getAccounts(feePayer: feePayer);
final accountsIndexesMap = accounts.toIndexesMap();
final header = MessageHeader.fromAccounts(accounts);
final compiledInstructions =
instructions.map((i) => i.compile(accountsIndexesMap));
return CompiledMessage.legacy(
header: header,
accountKeys: accounts.map((e) => e.pubKey).toList(),
recentBlockhash: recentBlockhash,
instructions: compiledInstructions.toList(),
);
}