Skip to content

Commit

Permalink
idl: Store deployment addresses for other clusters (#2892)
Browse files Browse the repository at this point in the history
  • Loading branch information
acheroncrypto authored Apr 6, 2024
1 parent 2dd79da commit da2d9a4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
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

0 comments on commit da2d9a4

Please sign in to comment.