Преглед изворни кода

idl: Store deployment addresses for other clusters (#2892)

acheron пре 1 година
родитељ
комит
da2d9a4045
4 измењених фајлова са 20 додато и 0 уклоњено
  1. 1 0
      CHANGELOG.md
  2. 10 0
      idl/src/types.rs
  3. 1 0
      lang/syn/src/idl/program.rs
  4. 8 0
      ts/packages/anchor/src/idl.ts

+ 1 - 0
CHANGELOG.md

@@ -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
 

+ 10 - 0
idl/src/types.rs

@@ -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)]
@@ -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,

+ 1 - 0
lang/syn/src/idl/program.rs

@@ -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),*],

+ 8 - 0
ts/packages/anchor/src/idl.ts

@@ -23,6 +23,7 @@ export type IdlMetadata = {
   repository?: string;
   dependencies?: IdlDependency[];
   contact?: string;
+  deployments?: IdlDeployments;
 };
 
 export type IdlDependency = {
@@ -30,6 +31,13 @@ export type IdlDependency = {
   version: string;
 };
 
+export type IdlDeployments = {
+  mainnet?: string;
+  testnet?: string;
+  devnet?: string;
+  localnet?: string;
+};
+
 export type IdlInstruction = {
   name: string;
   docs?: string[];