Skip to content

Conversation

@mcintyre94
Copy link
Contributor

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.

@mcintyre94 mcintyre94 requested a review from lorisleiva October 1, 2024 16:16
@changeset-bot
Copy link

changeset-bot bot commented Oct 1, 2024

🦋 Changeset detected

Latest commit: c60e5ba

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

@mcintyre94 mcintyre94 marked this pull request as draft October 1, 2024 16:37
@mcintyre94 mcintyre94 force-pushed the config-program-address branch from c43c559 to 4b0a650 Compare October 1, 2024 17:02
@mcintyre94 mcintyre94 marked this pull request as ready for review October 1, 2024 17:02
@lorisleiva lorisleiva changed the title [renderers-js] Add an optional programAddress override to instruction builders [0.21] Add an optional programAddress override to instruction builders of JS renderer Oct 1, 2024
Copy link
Member

@lorisleiva lorisleiva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect. Thank you! 🍺

@mcintyre94 mcintyre94 merged commit 345a145 into main Oct 1, 2024
3 checks passed
@mcintyre94 mcintyre94 deleted the config-program-address branch October 1, 2024 21:36
@github-actions github-actions bot mentioned this pull request Oct 1, 2024
lorisleiva pushed a commit that referenced this pull request Oct 2, 2024
…s of JS renderer (#224)

* Add an optional config parameter to override programAddress when creating an instruction

* Add a test to check the program address config works as expected

* Add changeset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants