From 3face237fb8e5b22d3311cc20c94d12c8c30a018 Mon Sep 17 00:00:00 2001 From: Paul Date: Wed, 16 Mar 2022 14:38:07 -0400 Subject: [PATCH] cli: make ts idl equal json idl (#1609) --- CHANGELOG.md | 1 + cli/src/template.rs | 11 +++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f85d1bdc0..848741f36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ incremented for features. * spl: Update `spl/governance` to use new errors ([#1582](https://github.com/project-serum/anchor/pull/1582)). * client: Fix `Cluster`'s `FromStr` implementation ([#1362](https://github.com/project-serum/anchor/pull/1362)). * lang: implement `Key` for `Pubkey` again, so `associated_token::*` constraints can use pubkey targets again ([#1601](https://github.com/project-serum/anchor/pull/1601)). +* cli/ts: generated `IDL` variable in `types/` should equal the `.json` idl file ([#1609](https://github.com/project-serum/anchor/pull/1609)) ### Breaking diff --git a/cli/src/template.rs b/cli/src/template.rs index 78ae2f523..db4f4c130 100644 --- a/cli/src/template.rs +++ b/cli/src/template.rs @@ -29,20 +29,19 @@ token = "{}" } pub fn idl_ts(idl: &Idl) -> Result { - let mut idl = idl.clone(); - for acc in idl.accounts.iter_mut() { + let mut idl_types = idl.clone(); + for acc in idl_types.accounts.iter_mut() { acc.name = acc.name.to_mixed_case(); } - let idl_json = serde_json::to_string_pretty(&idl)?; Ok(format!( r#"export type {} = {}; export const IDL: {} = {}; "#, + idl_types.name.to_camel_case(), + serde_json::to_string_pretty(&idl_types)?, idl.name.to_camel_case(), - idl_json, - idl.name.to_camel_case(), - idl_json + serde_json::to_string_pretty(&idl)? )) }