I have a VersionedTransaction
, which has a message with some instructions of type MessageCompiledInstruction
. I'm trying to decode the ComputeBudgetInstruction
with the following code:
const msg = versionedTransaction.message
for (const ix of msg.compiledInstructions) {
if (msg.staticAccountKeys[ix.programIdIndex].toBase58() == "ComputeBudget111111111111111111111111111111") {
console.log(ix)
// e.g.
//{
// programIdIndex: 19,
// accountKeyIndexes: [],
// data: <Buffer 02 ae 02 04 00>
//}
ComputeBudgetInstruction.decodeInstructionType(ix)
}
}
I want to decode the compute budget instructions, however decodeInstructionType
takes in input a TransactionInstruction
, which can be instantiated with the following constructor:
type TransactionInstructionCtorFields = {
keys: Array<AccountMeta>;
programId: PublicKey;
data?: Buffer;
};
I'm not sure where to get the AccountMeta
objects. So in short my question is how to convert a MessageCompiledInstruction
to TransactionInstruction
?