metaplex-foundation / solita

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

Support instruction discriminator #103

Open guibescos opened 1 year ago

guibescos commented 1 year ago

I've been trying to use solita on the IDL for the Pyth oracle program. We use 8 byte discriminators, but they're not anchor discriminators. Our idl looks like this :

    "instructions": [
      {
        "name": "initMapping",
        "discriminant": {"value":[
          2,
          0,
          0,
          0,
          0,
          0,
          0,
          1
        ], "type": { "array": ["u8", 8] }},
        "accounts": [
          {
            "name": "fundingAccount",
            "isMut": true,
            "isSigner": true
          },
          {
            "name": "freshMappingAccount",
            "isMut": true,
            "isSigner": true
          }
        ],
        "args": []
      }
    ],

Right now, solita only supports custom discriminators if they are have a beet primitive type. This PR extends to the case where it's a fixed size array of 8 bytes.