@@ -15,6 +15,7 @@ use hdk_records::{
15
15
generate_record_entry,
16
16
record_interface:: Updateable ,
17
17
rpc:: call_zome_method,
18
+ rpc:: call_local_zome_method,
18
19
} ;
19
20
20
21
use vf_measurement:: * ;
@@ -38,6 +39,8 @@ use hc_zome_rea_economic_event_rpc::{
38
39
ResourceInventoryType ,
39
40
} ;
40
41
42
+ pub use hc_zome_rea_economic_resource_storage_consts:: * ;
43
+
41
44
// :SHONK: needed as re-export in zome logic to allow validation logic to parse entries
42
45
pub use hdk_records:: record_interface:: Identified ;
43
46
@@ -225,34 +228,42 @@ fn get_units_for_resource(
225
228
} ,
226
229
None => ( None , None ) ,
227
230
} ;
231
+
228
232
let resource_unit = if let MaybeUndefined :: Some ( resource_quantity) = event_resource_quantity {
229
233
if resource_quantity. get_unit ( ) . is_some ( ) { resource_quantity. get_unit ( ) }
230
234
else { default_resource_unit }
231
235
} else {
232
236
default_resource_unit
233
237
} ;
238
+
234
239
let effort_unit = if let MaybeUndefined :: Some ( effort_quantity) = event_effort_quantity {
235
240
if effort_quantity. get_unit ( ) . is_some ( ) { effort_quantity. get_unit ( ) }
236
241
else { default_effort_unit }
237
242
} else {
238
243
default_effort_unit
239
244
} ;
245
+
240
246
Ok ( ( resource_unit, effort_unit) )
241
247
}
242
248
}
243
249
}
244
250
251
+ fn resource_specification_zome ( conf : DnaConfigSlice ) -> Option < String > {
252
+ // TODO: get this from the zome config
253
+ return Some ( "resource_specification" . to_string ( ) ) ;
254
+ }
255
+
256
+ use hdk_records:: CrossCellError ;
245
257
fn get_resource_specification ( specification_id : ResourceSpecificationAddress ) -> RecordAPIResult < ResourceSpecificationResponse > {
246
- let spec_data: OtherCellResult < ResourceSpecificationResponseData > = call_zome_method :: < EntryDefinitions , _ , _ , _ , _ , _ , _ , _ > (
247
- & specification_id ,
248
- & String :: from ( "read_resource_specification" ) ,
258
+ let spec_data: Result < ResourceSpecificationResponseData , CrossCellError > = call_local_zome_method (
259
+ resource_specification_zome ,
260
+ RESOURCE_SPECIFICATION_READ_METHOD ,
249
261
GetSpecificationRequest { address : specification_id. to_owned ( ) } ,
250
- LinkTypes :: AvailableCapability
251
262
) ;
252
-
263
+
253
264
match spec_data {
254
265
Ok ( spec_response) => Ok ( spec_response. resource_specification ) ,
255
- Err ( e ) => Err ( e . into ( ) ) ,
266
+ Err ( _ ) => Err ( DataIntegrityError :: LocalIndexNotConfigured ( specification_id . to_string ( ) , format ! ( "Failed to call local zome method for {}" , specification_id ) ) ) ,
256
267
}
257
268
}
258
269
0 commit comments