-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathschema.Makefile.toml
52 lines (43 loc) · 1.28 KB
/
schema.Makefile.toml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
[tasks.generate-all-schemas]
script_runner = "@rust"
script = '''
use std::fs;
use std::process::Command;
fn main() -> std::io::Result<()> {
fs::remove_dir_all("schema");
fs::remove_dir_all("schemas");
fs::create_dir("schemas")?;
println!("Done");
let contracts = vec![
"mars-credit-manager",
"mars-account-nft",
"mars-swapper-base",
"mars-zapper-base",
"mars-mock-red-bank",
"mars-mock-vault",
"mars-mock-oracle",
"mars-mock-credit-manager",
];
for contract in contracts {
println!("{}", contract);
let output = Command::new("cargo")
.arg("run")
.arg("--package")
.arg(contract)
.arg("--example")
.arg("schema")
.output()
.expect("failed to execute process");
println!("status: {}", output.status);
println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
fs::create_dir(format!("schemas/{}", contract))?;
fs::rename(
format!("schema/{}.json", contract),
format!("schemas/{}/{}.json", contract, contract),
)?;
}
fs::remove_dir_all("schema");
Ok(())
}
'''