Skip to content

idl: Store deployment addresses for other clusters #2892

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ The minor version will be incremented upon a breaking change and the patch versi
- lang: Add `declare_program!` macro ([#2857](https://github.com/coral-xyz/anchor/pull/2857)).
- cli: Add `deactivate_feature` flag to `solana-test-validator` config in Anchor.toml ([#2872](https://github.com/coral-xyz/anchor/pull/2872)).
- idl: Add `docs` field for constants ([#2887](https://github.com/coral-xyz/anchor/pull/2887)).
- idl: Store deployment addresses for other clusters ([#2892](https://github.com/coral-xyz/anchor/pull/2892)).

### Fixes

Expand Down
10 changes: 10 additions & 0 deletions idl/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ pub struct IdlMetadata {
pub dependencies: Vec<IdlDependency>,
#[serde(skip_serializing_if = "is_default")]
pub contact: Option<String>,
#[serde(skip_serializing_if = "is_default")]
pub deployments: Option<IdlDeployments>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
Expand All @@ -46,6 +48,14 @@ pub struct IdlDependency {
pub version: String,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct IdlDeployments {
pub mainnet: Option<String>,
pub testnet: Option<String>,
pub devnet: Option<String>,
pub localnet: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct IdlInstruction {
pub name: String,
Expand Down
1 change: 1 addition & 0 deletions lang/syn/src/idl/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ pub fn gen_idl_print_fn_program(program: &Program) -> TokenStream {
.map(|r| r.into()),
dependencies: Default::default(),
contact: Default::default(),
deployments: Default::default(),
},
docs: #docs,
instructions: vec![#(#instructions),*],
Expand Down
8 changes: 8 additions & 0 deletions ts/packages/anchor/src/idl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,21 @@ export type IdlMetadata = {
repository?: string;
dependencies?: IdlDependency[];
contact?: string;
deployments?: IdlDeployments;
};

export type IdlDependency = {
name: string;
version: string;
};

export type IdlDeployments = {
mainnet?: string;
testnet?: string;
devnet?: string;
localnet?: string;
};

export type IdlInstruction = {
name: string;
docs?: string[];
Expand Down
Loading