codama-idl / codama

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

[0.21] Add an optional programAddress override to instruction builders of JS renderer #224

Closed mcintyre94 closed 1 week ago

mcintyre94 commented 1 week ago

Currently when an instruction creator is called, it hardcodes the programAddress part of the program to the program that the client is being rendered for. This PR adds a new optional config parameter to instruction creators, which can be used to override the programAddress. For example:

import {
    getTransferCheckedInstruction,
} from '@solana-program/token';

const sendTokenInstruction = getTransferCheckedInstruction({
    source,
    destination,
    amount,
    authority,
   decimals,
   mint,
  }, { programAddress: TOKEN_22_PROGRAM_ADDRESS }
);

This is useful when there are multiple programs with compatible instructions, for example in the case of token and token22. In these cases, when dealing with these compatible instructions, you can now re-use the token client and just change the programAddress of the generated instructions.

changeset-bot[bot] commented 1 week ago

🦋 Changeset detected

Latest commit: c60e5ba30f7cea9319f71149705e0d1bf54d06a9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages | Name | Type | | ----------------------- | ----- | | @kinobi-so/renderers-js | Patch | | @kinobi-so/renderers | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR