Skip to content

Conversation

@acheroncrypto
Copy link
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
Copy link

vercel bot commented Mar 21, 2024

@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 solana-foundation:master Mar 22, 2024
@beeman
Copy link

beeman commented Apr 22, 2024

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
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
Copy link

beeman commented Apr 22, 2024

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