-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Oracle data type generation * update template * fix oracle decoding issue * Update templates/basic-template/generate-types/Cargo.toml Co-authored-by: Hernando Castano <[email protected]> * Update examples/oracle-example/src/lib.rs Co-authored-by: Hernando Castano <[email protected]> * comments * put back to master * fix scale codec version --------- Co-authored-by: Hernando Castano <[email protected]>
- Loading branch information
1 parent
de27c61
commit c351230
Showing
6 changed files
with
45 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,35 @@ | ||
use schemars::schema_for; | ||
use std::fs; | ||
use program::{UserConfig, AuxData}; | ||
use program::{UserConfig, AuxData, ORACLE_DATA}; | ||
use codec::Encode; | ||
|
||
pub fn generate_types() { | ||
let schema_config = schema_for!(UserConfig); | ||
fs::write( | ||
"./{{project-name}}_serialized_config_type.txt", | ||
"./tests_serialized_config_type.txt", | ||
format!( | ||
"{:?}", | ||
serde_json::to_vec(&schema_config) | ||
.expect("error converting user config for device key proxy") | ||
.expect("error converting user config") | ||
), | ||
) | ||
.expect("Failed to write to device key proxy config"); | ||
.expect("Failed to write to config"); | ||
|
||
let schema_aux_data = schema_for!(AuxData); | ||
fs::write( | ||
"./{{project-name}}_serialized_aux_data_type.txt", | ||
"./tests_serialized_aux_data_type.txt", | ||
format!( | ||
"{:?}", | ||
serde_json::to_vec(&schema_aux_data) | ||
.expect("error converting user aux_data for device key proxy") | ||
.expect("error converting user aux_data") | ||
), | ||
) | ||
.expect("Failed to write to device key proxy aux_data"); | ||
} | ||
.expect("Failed to write to proxy aux_data"); | ||
|
||
let oracle_data = ORACLE_DATA.iter().map(|x| x.encode()).collect::<Vec<_>>(); | ||
fs::write( | ||
"./tests_serialized_oracle_data_type.txt", | ||
oracle_data.encode() | ||
) | ||
.expect("Failed to write oracle_data"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters