cli: make ts idl equal json idl (#1609)
This commit is contained in:
parent
acb4e7119b
commit
3face237fb
|
@ -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/<project-name.ts>` should equal the `<project-name>.json` idl file ([#1609](https://github.com/project-serum/anchor/pull/1609))
|
||||
|
||||
### Breaking
|
||||
|
||||
|
|
|
@ -29,20 +29,19 @@ token = "{}"
|
|||
}
|
||||
|
||||
pub fn idl_ts(idl: &Idl) -> Result<String> {
|
||||
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)?
|
||||
))
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue