cli: Fix IDL json generation

This commit is contained in:
armaniferrante 2021-10-25 12:38:18 -07:00
parent d10413fc70
commit 32ffede2ec
No known key found for this signature in database
GPG Key ID: 58BEF301E91F7828
1 changed files with 4 additions and 3 deletions

View File

@ -29,8 +29,8 @@ token = "{}"
} }
pub fn idl_ts(idl: &Idl) -> Result<String> { pub fn idl_ts(idl: &Idl) -> Result<String> {
let mut idl = idl.clone(); let mut idl_type = idl.clone();
idl.accounts = idl idl_type.accounts = idl_type
.accounts .accounts
.into_iter() .into_iter()
.map(|acc| { .map(|acc| {
@ -39,6 +39,7 @@ pub fn idl_ts(idl: &Idl) -> Result<String> {
acc acc
}) })
.collect(); .collect();
let idl_type = serde_json::to_string_pretty(&idl_type)?;
let idl_json = serde_json::to_string_pretty(&idl)?; let idl_json = serde_json::to_string_pretty(&idl)?;
Ok(format!( Ok(format!(
r#"export type {} = {}; r#"export type {} = {};
@ -46,7 +47,7 @@ pub fn idl_ts(idl: &Idl) -> Result<String> {
export const IDL: {} = {}; export const IDL: {} = {};
"#, "#,
idl.name.to_camel_case(), idl.name.to_camel_case(),
idl_json, idl_type,
idl.name.to_camel_case(), idl.name.to_camel_case(),
idl_json idl_json
)) ))