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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703
//! Helper types for working with [`Op`]s
use crate::prelude::*;
#[cfg(test)]
mod test;
/// This trait provides a conversion to a convenience type [`FlatOp`]
/// for use in the validation call back.
///
/// Not all data is available in the [`FlatOp`]. This is why the [`Op`]
/// is not taken by value and can still be used after this conversion.
///
/// There is data that is common to all ops and can be accessed via helpers on
/// the op.
/// - Get the [`Op::author()`] of the op.
/// - Get the [`Op::timestamp()`] for when the op was created.
/// - Get the [`Op::action_seq()`] of the op.
/// - Get the [`Op::prev_action()`] of the op.
/// - Get the [`Op::action_type()`] of the op.
pub trait OpHelper {
/// Converts an [`Op`] to a [`FlatOp`] without consuming it.
/// This will clone the required internal data.
fn flattened<ET, LT>(&self) -> Result<FlatOp<ET, LT>, WasmError>
where
ET: EntryTypesHelper + UnitEnum,
<ET as UnitEnum>::Unit: Into<ZomeEntryTypesKey>,
LT: LinkTypesHelper,
WasmError: From<<ET as EntryTypesHelper>::Error>,
WasmError: From<<LT as LinkTypesHelper>::Error>;
/// Alias for `flattened`, for backward compatibility
#[deprecated = "`to_type` has been renamed to `flattened`, please use that name instead"]
fn to_type<ET, LT>(&self) -> Result<FlatOp<ET, LT>, WasmError>
where
ET: EntryTypesHelper + UnitEnum,
<ET as UnitEnum>::Unit: Into<ZomeEntryTypesKey>,
LT: LinkTypesHelper,
WasmError: From<<ET as EntryTypesHelper>::Error>,
WasmError: From<<LT as LinkTypesHelper>::Error>,
{
self.flattened()
}
}
/// All possible variants that an [`RegisterAgentActivity`]
/// with an [`Action`] that has an [`EntryType`] can produce.
#[derive(Debug)]
enum ActivityEntry<Unit> {
App { entry_type: Option<Unit> },
PrivateApp { entry_type: Option<Unit> },
Agent(AgentPubKey),
CapClaim(EntryHash),
CapGrant(EntryHash),
}
impl OpHelper for Op {
fn flattened<ET, LT>(&self) -> Result<FlatOp<ET, LT>, WasmError>
where
ET: EntryTypesHelper + UnitEnum,
<ET as UnitEnum>::Unit: Into<ZomeEntryTypesKey>,
LT: LinkTypesHelper,
WasmError: From<<ET as EntryTypesHelper>::Error>,
WasmError: From<<LT as LinkTypesHelper>::Error>,
{
match self {
Op::StoreRecord(StoreRecord { record }) => {
let r = match record.action() {
Action::Dna(action) => OpRecord::Dna {
dna_hash: action.hash.clone(),
action: action.clone(),
},
Action::AgentValidationPkg(action) => {
let AgentValidationPkg { membrane_proof, .. } = action;
OpRecord::AgentValidationPkg {
membrane_proof: membrane_proof.clone(),
action: action.clone(),
}
}
Action::InitZomesComplete(action) => OpRecord::InitZomesComplete {
action: action.clone(),
},
Action::CreateLink(action) => {
let CreateLink {
zome_index,
link_type,
base_address,
target_address,
tag,
..
} = action;
let link_type = in_scope_link_type(*zome_index, *link_type)?;
OpRecord::CreateLink {
base_address: base_address.clone(),
target_address: target_address.clone(),
tag: tag.clone(),
link_type,
action: action.clone(),
}
}
Action::DeleteLink(action) => {
let DeleteLink {
base_address,
link_add_address,
..
} = action;
OpRecord::DeleteLink {
original_action_hash: link_add_address.clone(),
base_address: base_address.clone(),
action: action.clone(),
}
}
Action::OpenChain(action) => {
let OpenChain { prev_dna_hash, .. } = action;
OpRecord::OpenChain {
previous_dna_hash: prev_dna_hash.clone(),
action: action.clone(),
}
}
Action::CloseChain(action) => {
let CloseChain { new_dna_hash, .. } = action;
OpRecord::CloseChain {
new_dna_hash: new_dna_hash.clone(),
action: action.clone(),
}
}
Action::Create(action) => {
let Create {
entry_type,
entry_hash,
..
} = action;
match entry_type {
EntryType::AgentPubKey => OpRecord::CreateAgent {
agent: entry_hash.clone().into(),
action: action.clone(),
},
EntryType::App(entry_def) => {
match get_app_entry_type_for_record_authority(
entry_def,
record.entry.as_option(),
)? {
UnitEnumEither::Enum(app_entry) => OpRecord::CreateEntry {
app_entry,
action: action.clone(),
},
UnitEnumEither::Unit(app_entry_type) => {
OpRecord::CreatePrivateEntry {
app_entry_type,
action: action.clone(),
}
}
}
}
EntryType::CapClaim => OpRecord::CreateCapClaim {
action: action.clone(),
},
EntryType::CapGrant => OpRecord::CreateCapGrant {
action: action.clone(),
},
}
}
Action::Update(action) => {
let Update {
entry_type,
entry_hash,
original_action_address: original_action_hash,
original_entry_address: original_entry_hash,
..
} = action;
match entry_type {
EntryType::AgentPubKey => OpRecord::UpdateAgent {
original_key: original_entry_hash.clone().into(),
original_action_hash: original_action_hash.clone(),
new_key: entry_hash.clone().into(),
action: action.clone(),
},
EntryType::App(entry_def) => {
match get_app_entry_type_for_record_authority(
entry_def,
record.entry.as_option(),
)? {
UnitEnumEither::Enum(app_entry) => OpRecord::UpdateEntry {
original_action_hash: original_action_hash.clone(),
original_entry_hash: original_entry_hash.clone(),
app_entry,
action: action.clone(),
},
UnitEnumEither::Unit(app_entry_type) => {
OpRecord::UpdatePrivateEntry {
original_action_hash: original_action_hash.clone(),
original_entry_hash: original_entry_hash.clone(),
app_entry_type,
action: action.clone(),
}
}
}
}
EntryType::CapClaim => OpRecord::UpdateCapClaim {
original_action_hash: original_action_hash.clone(),
original_entry_hash: original_entry_hash.clone(),
action: action.clone(),
},
EntryType::CapGrant => OpRecord::UpdateCapGrant {
original_action_hash: original_action_hash.clone(),
original_entry_hash: original_entry_hash.clone(),
action: action.clone(),
},
}
}
Action::Delete(action) => {
let Delete {
deletes_address,
deletes_entry_address,
..
} = action;
OpRecord::DeleteEntry {
original_action_hash: deletes_address.clone(),
original_entry_hash: deletes_entry_address.clone(),
action: action.clone(),
}
}
};
Ok(FlatOp::StoreRecord(r))
}
Op::StoreEntry(StoreEntry { action, entry }) => {
let r = match &action.hashed.content {
EntryCreationAction::Create(action) => {
let Create {
entry_type,
entry_hash,
..
} = action;
match entry_type {
EntryType::AgentPubKey => OpEntry::CreateAgent {
agent: entry_hash.clone().into(),
action: action.clone(),
},
EntryType::App(app_entry) => OpEntry::CreateEntry {
app_entry: get_app_entry_type_for_store_entry_authority(app_entry, entry)?,
action: action.clone(),
},
EntryType::CapClaim => OpEntry::CreateCapClaim {
entry: match entry {
Entry::CapClaim(entry) => entry.clone(),
_ => return Err(wasm_error!(WasmErrorInner::Guest(format!("Entry type does not match. CapClaim expected but got: {:?}", entry))))
},
action: action.clone(),
},
EntryType::CapGrant => OpEntry::CreateCapGrant {
entry: match entry {
Entry::CapGrant(entry) => entry.clone(),
_ => return Err(wasm_error!(WasmErrorInner::Guest(format!("Entry type does not match. CapGrant expected but got: {:?}", entry))))
},
action: action.clone(),
},
}
}
EntryCreationAction::Update(action) => {
let Update {
original_action_address: original_action_hash,
original_entry_address: original_entry_hash,
entry_type,
entry_hash,
..
} = action;
match entry_type {
EntryType::AgentPubKey => OpEntry::UpdateAgent {
original_key: original_entry_hash.clone().into(),
original_action_hash: original_action_hash.clone(),
new_key: entry_hash.clone().into(),
action: action.clone(),
},
EntryType::App(entry_def) => {
let app_entry = get_app_entry_type_for_store_entry_authority(entry_def, entry)?;
OpEntry::UpdateEntry {
original_action_hash: original_action_hash.clone(),
original_entry_hash: original_entry_hash.clone(),
app_entry,
action: action.clone(),
}
}
EntryType::CapClaim => OpEntry::UpdateCapClaim {
original_action_hash: original_action_hash.clone(),
original_entry_hash: original_entry_hash.clone(),
entry: match entry {
Entry::CapClaim(entry) => entry.clone(),
_ => return Err(wasm_error!(WasmErrorInner::Guest(format!("Entry type does not match. CapClaim expected but got: {:?}", entry))))
},
action: action.clone(),
},
EntryType::CapGrant => OpEntry::UpdateCapGrant {
original_action_hash: original_action_hash.clone(),
original_entry_hash: original_entry_hash.clone(),
entry: match entry {
Entry::CapGrant(entry) => entry.clone(),
_ => return Err(wasm_error!(WasmErrorInner::Guest(format!("Entry type does not match. CapGrant expected but got: {:?}", entry))))
},
action: action.clone(),
},
}
}
};
Ok(FlatOp::StoreEntry(r))
}
Op::RegisterUpdate(RegisterUpdate { update, new_entry }) => {
let Update {
original_action_address: original_action_hash,
original_entry_address: original_entry_hash,
entry_type,
entry_hash,
..
} = &update.hashed.content;
let update = match entry_type {
EntryType::AgentPubKey => OpUpdate::Agent {
original_key: original_entry_hash.clone().into(),
original_action_hash: original_action_hash.clone(),
new_key: entry_hash.clone().into(),
action: update.hashed.content.clone(),
},
EntryType::App(entry_def) => {
let new_entry = get_app_entry_type_for_record_authority::<ET>(
entry_def,
new_entry.as_ref(),
)?;
match new_entry {
UnitEnumEither::Enum(new) => OpUpdate::Entry {
app_entry: new,
action: update.hashed.content.clone(),
},
UnitEnumEither::Unit(new) => OpUpdate::PrivateEntry {
original_action_hash: original_action_hash.clone(),
app_entry_type: new,
action: update.hashed.content.clone(),
},
}
}
EntryType::CapClaim => OpUpdate::CapClaim {
original_action_hash: original_action_hash.clone(),
action: update.hashed.content.clone(),
},
EntryType::CapGrant => OpUpdate::CapGrant {
original_action_hash: original_action_hash.clone(),
action: update.hashed.content.clone(),
},
};
Ok(FlatOp::RegisterUpdate(update))
}
Op::RegisterAgentActivity(RegisterAgentActivity { action, .. }) => {
let r = match &action.hashed.content {
Action::Dna(action) => {
let Dna { hash, .. } = action;
OpActivity::Dna {
dna_hash: hash.clone(),
action: action.clone(),
}
}
Action::AgentValidationPkg(action) => {
let AgentValidationPkg { membrane_proof, .. } = action;
OpActivity::AgentValidationPkg {
membrane_proof: membrane_proof.clone(),
action: action.clone(),
}
}
Action::InitZomesComplete(action) => OpActivity::InitZomesComplete {
action: action.clone(),
},
Action::OpenChain(action) => {
let OpenChain { prev_dna_hash, .. } = action;
OpActivity::OpenChain {
previous_dna_hash: prev_dna_hash.clone(),
action: action.clone(),
}
}
Action::CloseChain(action) => {
let CloseChain { new_dna_hash, .. } = action;
OpActivity::CloseChain {
new_dna_hash: new_dna_hash.clone(),
action: action.clone(),
}
}
Action::CreateLink(action) => {
let CreateLink {
base_address,
target_address,
zome_index,
link_type,
tag,
..
} = action;
let link_type = activity_link_type(*zome_index, *link_type)?;
OpActivity::CreateLink {
base_address: base_address.clone(),
target_address: target_address.clone(),
tag: tag.clone(),
link_type,
action: action.clone(),
}
}
Action::DeleteLink(action) => {
let DeleteLink {
link_add_address,
base_address,
..
} = action;
OpActivity::DeleteLink {
original_action_hash: link_add_address.clone(),
base_address: base_address.clone(),
action: action.clone(),
}
}
Action::Create(action) => {
let Create {
entry_type,
entry_hash,
..
} = action;
match activity_entry::<ET>(entry_type, entry_hash)? {
ActivityEntry::App { entry_type, .. } => OpActivity::CreateEntry {
app_entry_type: entry_type,
action: action.clone(),
},
ActivityEntry::PrivateApp { entry_type, .. } => {
OpActivity::CreatePrivateEntry {
app_entry_type: entry_type,
action: action.clone(),
}
}
ActivityEntry::Agent(agent) => OpActivity::CreateAgent {
agent,
action: action.clone(),
},
ActivityEntry::CapClaim(_hash) => OpActivity::CreateCapClaim {
action: action.clone(),
},
ActivityEntry::CapGrant(_hash) => OpActivity::CreateCapGrant {
action: action.clone(),
},
}
}
Action::Update(action) => {
let Update {
original_action_address,
original_entry_address,
entry_type,
entry_hash,
..
} = action;
match activity_entry::<ET>(entry_type, entry_hash)? {
ActivityEntry::App { entry_type, .. } => OpActivity::UpdateEntry {
original_action_hash: original_action_address.clone(),
original_entry_hash: original_entry_address.clone(),
app_entry_type: entry_type,
action: action.clone(),
},
ActivityEntry::PrivateApp { entry_type, .. } => {
OpActivity::UpdatePrivateEntry {
original_action_hash: original_action_address.clone(),
original_entry_hash: original_entry_address.clone(),
app_entry_type: entry_type,
action: action.clone(),
}
}
ActivityEntry::Agent(new_key) => OpActivity::UpdateAgent {
original_action_hash: original_action_address.clone(),
original_key: original_entry_address.clone().into(),
new_key,
action: action.clone(),
},
ActivityEntry::CapClaim(_entry_hash) => OpActivity::UpdateCapClaim {
original_action_hash: original_action_address.clone(),
original_entry_hash: original_entry_address.clone(),
action: action.clone(),
},
ActivityEntry::CapGrant(_entry_hash) => OpActivity::UpdateCapGrant {
original_action_hash: original_action_address.clone(),
original_entry_hash: original_entry_address.clone(),
action: action.clone(),
},
}
}
Action::Delete(action) => {
let Delete {
deletes_address,
deletes_entry_address,
..
} = action;
OpActivity::DeleteEntry {
original_action_hash: deletes_address.clone(),
original_entry_hash: deletes_entry_address.clone(),
action: action.clone(),
}
}
};
Ok(FlatOp::RegisterAgentActivity(r))
}
Op::RegisterCreateLink(RegisterCreateLink { create_link }) => {
let CreateLink {
base_address,
target_address,
zome_index,
link_type,
tag,
..
} = &create_link.hashed.content;
let link_type = in_scope_link_type(*zome_index, *link_type)?;
Ok(FlatOp::RegisterCreateLink {
base_address: base_address.clone(),
target_address: target_address.clone(),
tag: tag.clone(),
link_type,
action: create_link.hashed.content.clone(),
})
}
Op::RegisterDeleteLink(RegisterDeleteLink {
delete_link,
create_link,
}) => {
let CreateLink {
base_address,
target_address,
zome_index,
link_type,
tag,
..
} = create_link;
let link_type = in_scope_link_type(*zome_index, *link_type)?;
Ok(FlatOp::RegisterDeleteLink {
original_action: create_link.clone(),
base_address: base_address.clone(),
target_address: target_address.clone(),
tag: tag.clone(),
link_type,
action: delete_link.hashed.content.clone(),
})
}
Op::RegisterDelete(RegisterDelete { delete }) => Ok(FlatOp::RegisterDelete(OpDelete {
action: delete.hashed.content.clone(),
})),
}
}
}
/// Produces the user-defined entry type enum. Even if the entry is private, this will succeed.
/// To be used only in the context of a StoreEntry authority.
fn get_app_entry_type_for_store_entry_authority<ET>(
entry_def: &AppEntryDef,
entry: &Entry,
) -> Result<ET, WasmError>
where
ET: EntryTypesHelper + UnitEnum,
<ET as UnitEnum>::Unit: Into<ZomeEntryTypesKey>,
WasmError: From<<ET as EntryTypesHelper>::Error>,
{
let entry_type = <ET as EntryTypesHelper>::deserialize_from_type(
entry_def.zome_index,
entry_def.entry_index,
entry,
)?;
match entry_type {
Some(entry_type) => Ok(entry_type),
None => Err(deny_other_zome()),
}
}
/// Produces the user-defined entry type enum or the unit enum if entry is not present.
/// To be used only in the context of a StoreRecord or AgentActivity authority.
/// If the entry's availability does not match the defined visibility, an error will result.
fn get_app_entry_type_for_record_authority<ET>(
entry_def: &AppEntryDef,
entry: Option<&Entry>,
) -> Result<UnitEnumEither<ET>, WasmError>
where
ET: EntryTypesHelper + UnitEnum,
<ET as UnitEnum>::Unit: Into<ZomeEntryTypesKey>,
WasmError: From<<ET as EntryTypesHelper>::Error>,
{
let AppEntryDef {
zome_index,
entry_index: entry_def_index,
visibility,
..
} = entry_def;
match (entry, visibility) {
(Some(entry), EntryVisibility::Public) => {
get_app_entry_type_for_store_entry_authority(entry_def, entry).map(UnitEnumEither::Enum)
}
(None, EntryVisibility::Private) => {
match get_unit_entry_type::<ET>(*zome_index, *entry_def_index)? {
Some(unit) => Ok(UnitEnumEither::Unit(unit)),
None => Err(deny_other_zome()),
}
}
(Some(_), EntryVisibility::Private) => Err(wasm_error!(WasmErrorInner::Guest(format!(
"Entry visibility is private but an entry was provided! entry_def: {entry_def:?}"
)))),
(None, EntryVisibility::Public) => Err(wasm_error!(WasmErrorInner::Guest(format!(
"Entry visibility is public but no entry is available. entry_def: {entry_def:?}"
)))),
}
}
/// Maps [`RegisterAgentActivity`] ops to their
/// entries. The entry type will be [`None`] if
/// the zome id is not a dependency of this zome.
fn activity_entry<ET>(
entry_type: &EntryType,
entry_hash: &EntryHash,
) -> Result<ActivityEntry<<ET as UnitEnum>::Unit>, WasmError>
where
ET: UnitEnum,
<ET as UnitEnum>::Unit: Into<ZomeEntryTypesKey>,
{
match entry_type {
EntryType::App(AppEntryDef {
zome_index,
entry_index: entry_def_index,
visibility,
}) => {
let unit = get_unit_entry_type::<ET>(*zome_index, *entry_def_index)?;
match visibility {
EntryVisibility::Public => Ok(ActivityEntry::App { entry_type: unit }),
EntryVisibility::Private => Ok(ActivityEntry::PrivateApp { entry_type: unit }),
}
}
EntryType::AgentPubKey => Ok(ActivityEntry::Agent(entry_hash.clone().into())),
EntryType::CapClaim => Ok(ActivityEntry::CapClaim(entry_hash.clone())),
EntryType::CapGrant => Ok(ActivityEntry::CapGrant(entry_hash.clone())),
}
}
/// Get the app defined link type from a [`ZomeIndex`] and [`LinkType`].
/// If the [`ZomeIndex`] is not a dependency of this zome then return a host error.
fn in_scope_link_type<LT>(zome_index: ZomeIndex, link_type: LinkType) -> Result<LT, WasmError>
where
LT: LinkTypesHelper,
WasmError: From<<LT as LinkTypesHelper>::Error>,
{
match <LT as LinkTypesHelper>::from_type(*zome_index, *link_type)? {
Some(link_type) => Ok(link_type),
None => Err(deny_other_zome()),
}
}
/// Get the app defined link type from a [`ZomeIndex`] and [`LinkType`].
/// If the [`ZomeIndex`] is not a dependency of this zome then return a host error.
fn activity_link_type<LT>(
zome_index: ZomeIndex,
link_type: LinkType,
) -> Result<Option<LT>, WasmError>
where
LT: LinkTypesHelper,
WasmError: From<<LT as LinkTypesHelper>::Error>,
{
Ok(<LT as LinkTypesHelper>::from_type(*zome_index, *link_type)?)
}
/// Produce the unit variant given a zome id and entry def index.
/// Returns [`None`] if the zome id is not a dependency of this zome.
/// Returns a [`WasmErrorInner::Guest`] error if the zome id is a
/// dependency but the [`EntryDefIndex`] is out of range.
fn get_unit_entry_type<ET>(
zome_index: ZomeIndex,
entry_def_index: EntryDefIndex,
) -> Result<Option<<ET as UnitEnum>::Unit>, WasmError>
where
ET: UnitEnum,
<ET as UnitEnum>::Unit: Into<ZomeEntryTypesKey>,
{
let entries = zome_info()?.zome_types.entries;
let unit = entries.find(
<ET as UnitEnum>::unit_iter(),
ScopedEntryDefIndex {
zome_index,
zome_type: entry_def_index,
},
);
let unit = match unit {
Some(unit) => Some(unit),
None => {
if entries.dependencies().any(|z| z == zome_index) {
return Err(wasm_error!(WasmErrorInner::Guest(format!(
"Entry type: {:?} is out of range for this zome.",
entry_def_index
))));
} else {
None
}
}
};
Ok(unit)
}
/// Produce an error because this zome
/// should never be called with a zome id
/// that is not a dependency.
fn deny_other_zome() -> WasmError {
wasm_error!(WasmErrorInner::Host(
"Op called for zome it was not defined in. This is a Holochain bug".to_string()
))
}