Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] Namespaced Instructions #2786

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

ngundotra
Copy link
Contributor

The goal of this PR is to add namespaces to instructions and optionally allow method names to be overridden in the IDL.

Methods can now be optionally overriden in 1 of 2 ways.

// 1. Instruction discriminator is result of sighash("my-interface", "my_func")
#[ix(namespace="my-interface")]
pub fn my_func(...) -> Result<()> {
}

// 2. Instruction discriminator is result of sighash("my-interface", "other_func")
// In this case, this instruction will have name `other-func` in the IDL
#[ix(namespace="my-interface", name="other-func")]
pub fn my_func(...) -> Result<()> {
}

In order to call namespaced methods in typescript, a new field has been added to the Program object in the anchor TS package.

// 1. Explicit namespace "myInterface"
program
  .namespace
  .myInterface
  .myFunc(...args)
  ....

// 2. Overridden instruction name "other-func"
program
  .namespace
  .myInterface
  .otherFunc(...args)
  ....

Copy link

vercel bot commented Jan 24, 2024

@ngundotra is attempting to deploy a commit to the coral-xyz Team on Vercel.

A member of the Team first needs to authorize it.

@acheroncrypto acheroncrypto added lang ts idl related to the IDL, either program or client side labels Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idl related to the IDL, either program or client side lang ts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants