cli: Fix IDL json generation
This commit is contained in:
parent
d10413fc70
commit
32ffede2ec
|
@ -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
|
||||||
))
|
))
|
||||||
|
|
Loading…
Reference in New Issue