Skip to content

Commit e25564f

Browse files
committed
change remote call from economic resource to resource specification to local call
1 parent e612eae commit e25564f

File tree

2 files changed

+18
-6
lines changed
  • zomes/rea_economic_resource

2 files changed

+18
-6
lines changed

zomes/rea_economic_resource/storage/src/lib.rs

+17-6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use hdk_records::{
1515
generate_record_entry,
1616
record_interface::Updateable,
1717
rpc::call_zome_method,
18+
rpc::call_local_zome_method,
1819
};
1920

2021
use vf_measurement::*;
@@ -38,6 +39,8 @@ use hc_zome_rea_economic_event_rpc::{
3839
ResourceInventoryType,
3940
};
4041

42+
pub use hc_zome_rea_economic_resource_storage_consts::*;
43+
4144
// :SHONK: needed as re-export in zome logic to allow validation logic to parse entries
4245
pub use hdk_records::record_interface::Identified;
4346

@@ -225,34 +228,42 @@ fn get_units_for_resource(
225228
},
226229
None => (None, None),
227230
};
231+
228232
let resource_unit = if let MaybeUndefined::Some(resource_quantity) = event_resource_quantity {
229233
if resource_quantity.get_unit().is_some() { resource_quantity.get_unit() }
230234
else { default_resource_unit }
231235
} else {
232236
default_resource_unit
233237
};
238+
234239
let effort_unit = if let MaybeUndefined::Some(effort_quantity) = event_effort_quantity {
235240
if effort_quantity.get_unit().is_some() { effort_quantity.get_unit() }
236241
else { default_effort_unit }
237242
} else {
238243
default_effort_unit
239244
};
245+
240246
Ok((resource_unit, effort_unit))
241247
}
242248
}
243249
}
244250

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;
245257
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,
249261
GetSpecificationRequest { address: specification_id.to_owned() },
250-
LinkTypes::AvailableCapability
251262
);
252-
263+
253264
match spec_data {
254265
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))),
256267
}
257268
}
258269

zomes/rea_economic_resource/storage_consts/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
* @package hREA
77
*/
88
pub const RESOURCE_ENTRY_TYPE: &str = "economic_resource";
9+
pub const RESOURCE_SPECIFICATION_READ_METHOD: &str = "get_resource_specification";

0 commit comments

Comments
 (0)