-
Notifications
You must be signed in to change notification settings - Fork 58
/
main.rs
58 lines (50 loc) · 1.48 KB
/
main.rs
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
53
54
55
56
57
58
use ethers::contract::Abigen;
use std::process;
fn main() {
// Gravity contract
let abigen = match Abigen::new("Gravity", "../gravity_abi/Gravity.json") {
Ok(abigen) => abigen,
Err(e) => {
println!("Could not open Gravity.json: {}", e);
process::exit(1);
}
};
let abi = match abigen
.add_event_derive("serde::Deserialize")
.add_event_derive("serde::Serialize")
.generate()
{
Ok(abi) => abi,
Err(e) => {
println!("Could not generate abi from Gravity.json: {}", e);
process::exit(1);
}
};
match abi.write_to_file("../gravity_abi/src/gravity.rs") {
Ok(_) => (),
Err(e) => println!("Error writing gravity.rs: {}", e),
}
// OpenZeppelin ERC20 contract
let abigen = match Abigen::new("ERC20", "../gravity_abi/ERC20.json") {
Ok(abigen) => abigen,
Err(e) => {
println!("Could not open ERC20.json: {}", e);
process::exit(1);
}
};
let abi = match abigen
.add_event_derive("serde::Deserialize")
.add_event_derive("serde::Serialize")
.generate()
{
Ok(abi) => abi,
Err(e) => {
println!("Could not generate abi from ERC20.json: {}", e);
process::exit(1);
}
};
match abi.write_to_file("../gravity_abi/src/erc20.rs") {
Ok(_) => (),
Err(e) => println!("Error writing erc20.rs: {}", e),
}
}