compile method
Compiles instruction according to the instruction format.
Implementation
CompiledInstruction compile(
Map<Ed25519HDPublicKey, int> accountIndexesMap,
) {
if (!accountIndexesMap.containsKey(programId)) {
throw const FormatException('programId not found in accountIndexesMap');
}
final accountIndexes = accounts.map((a) {
if (!accountIndexesMap.containsKey(a.pubKey)) {
throw const FormatException(
'one of the supplied accounts was not found in the accountIndexesMap',
);
}
return accountIndexesMap[a.pubKey]!;
});
return CompiledInstruction(
programIdIndex: accountIndexesMap[programId]!,
accountKeyIndexes: accountIndexes.toList(),
data: data,
);
}