CompiledKeys.compile constructor
CompiledKeys.compile(
- List<
TransactionInstruction> instructions, - SolAddress payer
Implementation
factory CompiledKeys.compile(
List<TransactionInstruction> instructions, SolAddress payer) {
final keyMetaMap = <String, _KeyMeta>{};
keyMetaMap[payer.address] ??= _KeyMeta.defaultKey();
keyMetaMap[payer.address] =
keyMetaMap[payer.address]!.copyWith(isSigner: true, isWritable: true);
for (final ix in instructions) {
final String programIdAddress = ix.programId.address;
keyMetaMap[programIdAddress] ??= _KeyMeta.defaultKey();
keyMetaMap[programIdAddress] =
keyMetaMap[programIdAddress]!.copyWith(isInvoked: true);
for (final accountMeta in ix.keys) {
final addr = accountMeta.publicKey.address;
keyMetaMap[addr] ??= _KeyMeta.defaultKey();
final bool isSigner = keyMetaMap[addr]!.isSigner;
final bool isWritable = keyMetaMap[addr]!.isWritable;
if (!isSigner) {
keyMetaMap[addr] =
keyMetaMap[addr]!.copyWith(isSigner: accountMeta.isSigner);
}
if (!isWritable) {
keyMetaMap[addr] =
keyMetaMap[addr]!.copyWith(isWritable: accountMeta.isWritable);
}
}
}
return CompiledKeys._(payer: payer, keyMetaMap: keyMetaMap);
}