diff --git a/src/abi/full_program.rs b/src/abi/full_program.rs index 72cb5cf..d3a531b 100644 --- a/src/abi/full_program.rs +++ b/src/abi/full_program.rs @@ -39,7 +39,7 @@ impl FullProgramABI { let lookup: HashMap<_, _> = program_abi .types .iter() - .map(|ttype| (ttype.type_id, ttype.clone())) + .map(|ttype| (ttype.type_id.clone(), ttype.clone())) .collect(); let types = program_abi @@ -137,7 +137,7 @@ impl FullABIFunction { pub fn from_counterpart( abi_function: &ABIFunction, - types: &HashMap, + types: &HashMap, ) -> Result { let inputs = abi_function .inputs @@ -168,7 +168,7 @@ pub struct FullTypeDeclaration { impl FullTypeDeclaration { pub fn from_counterpart( type_decl: &TypeDeclaration, - types: &HashMap, + types: &HashMap, ) -> FullTypeDeclaration { let components = type_decl .components @@ -210,7 +210,7 @@ pub struct FullTypeApplication { impl FullTypeApplication { pub fn from_counterpart( type_application: &TypeApplication, - types: &HashMap, + types: &HashMap, ) -> FullTypeApplication { let type_arguments = type_application .type_arguments @@ -242,7 +242,7 @@ pub struct FullLoggedType { impl FullLoggedType { fn from_counterpart( logged_type: &LoggedType, - types: &HashMap, + types: &HashMap, ) -> FullLoggedType { FullLoggedType { log_id: logged_type.log_id.clone(), @@ -261,7 +261,7 @@ pub struct FullConfigurable { impl FullConfigurable { pub fn from_counterpart( configurable: &Configurable, - types: &HashMap, + types: &HashMap, ) -> FullConfigurable { FullConfigurable { name: configurable.name.clone(), @@ -312,29 +312,33 @@ mod tests { fn can_convert_into_full_type_decl() { // given let type_0 = TypeDeclaration { - type_id: 0, + type_id: "9da470e78078ef5bf7aabdd59e465abbd0b288fb01443a5777c8bcf6488a747b".to_string(), type_field: "type_0".to_string(), components: Some(vec![TypeApplication { name: "type_0_component_a".to_string(), - type_id: 1, + type_id: "0bb3a6b090834070f46e91d3e25184ec5d701976dc5cebe3d1fc121948231fb0" + .to_string(), type_arguments: Some(vec![TypeApplication { name: "type_0_type_arg_0".to_string(), - type_id: 2, + type_id: "00b4c853d51a6da239f08800898a6513eaa6950018fb89def110627830eb323f" + .to_string(), type_arguments: None, }]), }]), - type_parameters: Some(vec![2]), + type_parameters: Some(vec![ + "00b4c853d51a6da239f08800898a6513eaa6950018fb89def110627830eb323f".to_string(), + ]), }; let type_1 = TypeDeclaration { - type_id: 1, + type_id: "0bb3a6b090834070f46e91d3e25184ec5d701976dc5cebe3d1fc121948231fb0".to_string(), type_field: "type_1".to_string(), components: None, type_parameters: None, }; let type_2 = TypeDeclaration { - type_id: 2, + type_id: "00b4c853d51a6da239f08800898a6513eaa6950018fb89def110627830eb323f".to_string(), type_field: "type_2".to_string(), components: None, type_parameters: None, @@ -342,7 +346,7 @@ mod tests { let types = [&type_0, &type_1, &type_2] .iter() - .map(|&ttype| (ttype.type_id, ttype.clone())) + .map(|&ttype| (ttype.type_id.clone(), ttype.clone())) .collect::>(); // when @@ -380,23 +384,24 @@ mod tests { fn can_convert_into_full_type_appl() { let application = TypeApplication { name: "ta_0".to_string(), - type_id: 0, + type_id: "9da470e78078ef5bf7aabdd59e465abbd0b288fb01443a5777c8bcf6488a747b".to_string(), type_arguments: Some(vec![TypeApplication { name: "ta_1".to_string(), - type_id: 1, + type_id: "0bb3a6b090834070f46e91d3e25184ec5d701976dc5cebe3d1fc121948231fb0" + .to_string(), type_arguments: None, }]), }; let type_0 = TypeDeclaration { - type_id: 0, + type_id: "9da470e78078ef5bf7aabdd59e465abbd0b288fb01443a5777c8bcf6488a747b".to_string(), type_field: "type_0".to_string(), components: None, type_parameters: None, }; let type_1 = TypeDeclaration { - type_id: 1, + type_id: "0bb3a6b090834070f46e91d3e25184ec5d701976dc5cebe3d1fc121948231fb0".to_string(), type_field: "type_1".to_string(), components: None, type_parameters: None, @@ -404,7 +409,7 @@ mod tests { let types = [&type_0, &type_1] .into_iter() - .map(|ttype| (ttype.type_id, ttype.clone())) + .map(|ttype| (ttype.type_id.clone(), ttype.clone())) .collect::>(); // given diff --git a/src/abi/program.rs b/src/abi/program.rs index 5bc3b0e..b74a9e8 100644 --- a/src/abi/program.rs +++ b/src/abi/program.rs @@ -10,6 +10,9 @@ use serde::{Deserialize, Serialize}; #[derive(Default, Debug, Clone, Eq, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct ProgramABI { + pub program_type: String, + pub spec_version: Version, + pub abi_version: Version, #[serde(skip_serializing_if = "Option::is_none")] pub encoding: Option, pub types: Vec, @@ -67,11 +70,11 @@ impl ABIFunction { #[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct TypeDeclaration { - pub type_id: usize, + pub type_id: String, #[serde(rename = "type")] pub type_field: String, pub components: Option>, // Used for custom types - pub type_parameters: Option>, + pub type_parameters: Option>, } #[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] @@ -79,7 +82,7 @@ pub struct TypeDeclaration { pub struct TypeApplication { pub name: String, #[serde(rename = "type")] - pub type_id: usize, + pub type_id: String, pub type_arguments: Option>, }