Currently, the generated instruction helpers make a lot of assumptions about account metas (as defined in the Codama IDL) that is impossible for the end-user to override. For instance, right now you cannot change the writable status of your instruction account.
Say I wanted to do this:
const ix = getTransferSolInstruction(tx, {
source: createNoopSigner(address('1234')),
destination: address('5678'),
});
But for some reason, I wanted to override the destination account to be a readonly account. Right now, I would need to deep copy the instruction in order to change that. However, if Codama accepted something like a asReadonly wrapper, it could become something like this:
const ix = getTransferSolInstruction(tx, {
source: createNoopSigner(address('1234')),
destination: asReadonly(address('5678')),
});
We can then take it one step further and have wrappers like asLookupMeta for accounts linked to LUTs.
const ix = getTransferSolInstruction(tx, {
source: createNoopSigner(address('1234')),
destination: asLookupMeta(
address('5678'), /* real address */
address('9999'), /* lookup address */
7, /* lookup index */
),
});
Offering these extra building blocks could be interesting in the context of generated clients and would allow client users a lot more flexibility.
Under the hood, these wrapper functions could simply construct IAccountMeta type or equivalent. The Codama generated function would need to accept these types and treat them accordingly.
Currently, the generated instruction helpers make a lot of assumptions about account metas (as defined in the Codama IDL) that is impossible for the end-user to override. For instance, right now you cannot change the writable status of your instruction account.
Say I wanted to do this:
But for some reason, I wanted to override the
destination
account to be a readonly account. Right now, I would need to deep copy the instruction in order to change that. However, if Codama accepted something like aasReadonly
wrapper, it could become something like this:We can then take it one step further and have wrappers like
asLookupMeta
for accounts linked to LUTs.Offering these extra building blocks could be interesting in the context of generated clients and would allow client users a lot more flexibility.
Under the hood, these wrapper functions could simply construct
IAccountMeta
type or equivalent. The Codama generated function would need to accept these types and treat them accordingly.