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