metaplex-foundation / solita

Genrates an SDK API from solana contract IDL.
Apache License 2.0
142 stars 33 forks source link

Exceptional case where the IDL type definition is not met #78

Closed ricardocr987 closed 2 years ago

ricardocr987 commented 2 years ago

I have encountered a bug, trying to use solita for the Jupiter and Jet Protocol programs:

The bug is as follows:

Screenshot 2022-08-29 at 10 48 24

When I try to display the requireds variable of the renderIxAccountKeys function of render-instructions I get this:

Screenshot 2022-08-29 at 09 52 22

Looking at the Jet code (which is open source), I noticed this:

This is the context of the instruction that cause the problem on Jet, seems like they created different custom collections of accounts to reuse that definition on the same instruction (source_market, target_market):

This is the instruction causing the bug on the IDL: https://github.com/jet-lab/jet-v1/blob/master/app/public/idl/mainnet-beta/jet.json#L901 if you look inside the vector accounts of the instruction it has several vectors of accounts that do not comply with the type definition in solita, this is the case that gives problems that's why I get the Objects in the console

thlorenz commented 2 years ago

Thanks for reporting. From a quick look it seems that the IDL incorrectly nests accounts for the mockLiquidateDex instruction. It's first account sourceMarket has itself an accounts property which is currently not supported (and I'm not sure it makes no sense either).

A instruction should just have a list of accounts, each of type AccountMetadata (not arrays or anything else).

Therefore I think that the tool that generated the IDL might not support your setup properly.