espresso-cash / espresso-cash-public

Dart and Flutter apps and libraries maintained by Espresso Cash team for Solana.
https://espressocash.com
263 stars 89 forks source link

Deserialize a BinaryAccountData from an IDL specification #202

Open mugveiga opened 2 years ago

mugveiga commented 2 years ago

Is your feature request related to a problem? Please describe. Im trying to fetch account data from my candy machine v2. Ex:

var accountInfo = await _solanaClient.rpcClient.getAccountInfo("CQvEEpwKVhmBevmdUxjSAaFWjbVrqiumdaupNa8pFCuW", encoding: Encoding.base64);
List<int> candyMachineBinary = (accountInfo!.data! as BinaryAccountData).data;

Is this the right way of retrieving my candyMachine account data? i mean, im aiming to retrieve this portion of the IDL: image

but i get this huge byte array that i cannot decode manually (i tried the same strategy as on metadata.fromBinary without success.

A nice feature to have would be to pass as a parameter the IDL specs and the binary.. and receive a nice json.

the IDL spec for this byte array, for example, is here: https://github.com/metaplex-foundation/metaplex-program-library/blob/master/candy-machine/js/idl/candy_machine.json

Describe the solution you'd like a new parameter on getAccountInfo passing the IDL spec.

ookami-kb commented 2 years ago

Hi, not sure if we will have time to implement it in the near future, so feel free to create a PR in the meantime :)