coral-xyz / anchor

⚓ Solana Sealevel Framework
https://anchor-lang.com
Apache License 2.0
3.59k stars 1.32k forks source link

idl: Store deployment addresses for other clusters #2892

Closed acheroncrypto closed 6 months ago

acheroncrypto commented 6 months ago

Problem

It's currently not possible to store program address information for other clusters.

Solution

Initially, I thought of making the top-level address field an enum:

pub enum IdlAddress {
    Multiple {
        mainnet: Option<String>,
        testnet: Option<String>,
        devnet: Option<String>,
        localnet: Option<String>,
    },
    #[untagged]
    Single(String),
}

This way, we could support both string address as a default and an object type for more detailed (cluster based) information. However, the program's IDL may also exist in other clusters, which makes the current IDL (the one we got the other deployment addresses from) useless (because the IDL in the cluster should be fetched). For this reason, it made more sense to store this information in the metadata field compared to the top-level address field:

pub struct IdlDeployments {
    pub mainnet: Option<String>,
    pub testnet: Option<String>,
    pub devnet: Option<String>,
    pub localnet: Option<String>,
}

Summary of changes

Add metadata.deployments field that optionally stores deployment addresses in mainnet, testnet, devnet and localnet.

vercel[bot] commented 6 months ago

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

A member of the Team first needs to authorize it.