Skip to content

ts: Remove programId parameter of the Program constructor#2864

Merged
acheroncrypto merged 7 commits into
otter-sec:masterfrom
acheroncrypto:ts-remove-program-id-parameter
Mar 22, 2024
Merged

ts: Remove programId parameter of the Program constructor#2864
acheroncrypto merged 7 commits into
otter-sec:masterfrom
acheroncrypto:ts-remove-program-id-parameter

Conversation

@acheroncrypto

Copy link
Copy Markdown
Collaborator

Problem

address field is now a required field for the IDL, making the programId parameter of Program constructor redundant.

Solution

Remove the programId parameter of the Program constructor and use the program id from the IDL.

@vercel

vercel Bot commented Mar 21, 2024

Copy link
Copy Markdown

@acheroncrypto 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 merged commit 7c424ee into otter-sec:master Mar 22, 2024
@beeman

beeman commented Apr 22, 2024

Copy link
Copy Markdown

While working on Anchor v0.30.0 I realized this is no longer needed.

One use case I had for passing the programId as a parameter is when a program is deployed on a different account depending on the cluster.

In the new setup, this means we would need to generate a new IDL with that different programId - or merge it, or is there another way to achieve this?

From looking at the PR, I see I'm not the only one with this use case.

It might be good to give an option to still override it, as this feels like a step back in usability.

image
image

@acheroncrypto

Copy link
Copy Markdown
Collaborator Author

In the new setup, this means we would need to generate a new IDL with that different programId, or is there another way to achieve this?

I think you can just idl.address = programId if you want to override the address in the IDL.

From looking at the PR, I see I'm not the only one with this use case.

It might be good to give an option to still override it, as this feels like a step back in usability.

There is also a new idl.metadata.deployments field (#2892), to specify program deployment addresses on other clusters. We'll probably use that (based on Anchor.toml entries) going forward, but it's not yet included in the generation.

@beeman

beeman commented Apr 22, 2024

Copy link
Copy Markdown

In the new setup, this means we would need to generate a new IDL with that different programId, or is there another way to achieve this?

I think you can just idl.address = programId if you want to override the address in the IDL.

From looking at the PR, I see I'm not the only one with this use case.
It might be good to give an option to still override it, as this feels like a step back in usability.

There is also a new idl.metadata.deployments field (#2892), to specify program deployment addresses on other clusters. We'll probably use that (based on Anchor.toml entries) going forward, but it's not yet included in the generation.

Got it, thanks.

Honestly still feels kinda hacky compared to having a proper (optional) parameter where you just control it.

The deployments object is nice, but it still means I'd need to update that when I run it locally with a new generated keypair.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants