codama-idl / codama

Generate clients, CLIs, documentation and more from your Solana programs
MIT License
73 stars 16 forks source link

[renderers-js-umi] Missing 'eddsa' context at instruction render with pdaValueNode #155

Closed myx0m0p closed 2 months ago

myx0m0p commented 2 months ago

While generating client with js-umi rendered, eddsa context isn't picked for context arg.

Kinobi IDL:

|   |   instructionNode [setPauseV1]
|   |   |   instructionAccountNode [fusionData.writable]
|   |   |   |   pdaValueNode
|   |   |   |   |   pdaNode [fusionData]
|   |   |   |   |   |   constantPdaSeedNode
|   |   |   |   |   |   |   bytesTypeNode
|   |   |   |   |   |   |   bytesValueNode [base16.667573696f6e5f64617461]
|   |   |   instructionAccountNode [authority.writable.signer]
|   |   |   |   identityValueNode
|   |   |   instructionArgumentNode [discriminator]
|   |   |   |   fixedSizeTypeNode [8]
|   |   |   |   |   bytesTypeNode
|   |   |   |   bytesValueNode [base16.48aed1c673030480]
|   |   |   instructionArgumentNode [paused]
|   |   |   |   booleanTypeNode
|   |   |   |   |   numberTypeNode [u8]
|   |   |   fieldDiscriminatorNode [discriminator]

Generated instruction signature:

// Instruction.
export function setPauseV1(
  context: Pick<Context, 'identity' | 'programs'>,
  input: SetPauseV1InstructionAccounts & SetPauseV1InstructionArgs
): TransactionBuilder

Defaults from pda node:

  // Default values.
  if (!resolvedAccounts.fusionData.value) {
    resolvedAccounts.fusionData.value = context.eddsa.findPda(programId, [
      bytes().serialize(
        new Uint8Array([102, 117, 115, 105, 111, 110, 95, 100, 97, 116, 97])
      ),
    ]);
  }

This leads to typescript compilation error.

Related part of the code:

https://github.com/kinobi-so/kinobi/blob/8b80c38d4d918e09e7a0fb7bd9e23d2ab28983d3/packages/renderers-js-umi/src/renderInstructionDefaults.ts#L78-L125

I'm not sure adding interfaces.add('eddsa'); before return would be good.

lorisleiva commented 2 months ago

Hey, thanks for reporting this! I will fix asap. 🙏

lorisleiva commented 2 months ago

This is currently publishing as @kinobi-so/renderers-js-umi@0.21.1. Thanks again for your help reporting this. 🍺