Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion book/src/contract-keywords/refers-to-lookup.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ WHERE saltedDomainHash = -- findBy
`constraints` (holding `minimumAgeBlocks` and [`chooseFirst`](#choosing-the-first-commitment-choosefirst)) and `consume` sit on the `refersTo`, beside `findBy`: they describe the document `findBy` finds when the referring document is created, so the reference must be judged on the create alone. A function in `findBy` makes it so, and so does a referring type whose documents are never replaced (`documentsMutable: false`): a replace is the one write that checks a reference again. Any other `findBy` declaring either is refused at registration (10231), and so is either beside [`inList`](refers-to-list-element.md), which checks that a list holds the value rather than finding a document by a key.

- **`constraints.minimumAgeBlocks`**: the commitment's `$createdAtBlockHeight` is at least that many blocks below the create's height. The commitment type must list `$createdAtBlockHeight` in `required`.
- **`consume: true`**: the create deletes the commitment, its storage refunded to its owner. Only on a `deletableDocument` reference with the `where` entry `"$ownerId": "$ownerId"`, into a type of the same contract whose owner may delete its documents (`canBeDeleted: true`) or whose documents only a consume deletes (`canBeDeleted: "onlyWhenConsumed"`, see [Deletion](deletion.md#canbedeleted)), that declares no delete token cost or delete action fee and no [`deleteConstraints`](deletion.md#deleteconstraints) (no delete transition charges or judges them), and that requires no stricter signature security level than the revealing type. A contract-bound key signing the create must be allowed to act on the consumed type too (`ContractBoundedKeyOutOfBoundsError`, 20014). From protocol version 15 the delete uses the commitment `findBy` read, so the create pays for one read of it; before, the delete read it again by id and that read was charged too.
- **`consume: true`**: the create deletes the commitment, its storage refunded to its owner. Only on a `deletableDocument` reference with the `where` entry `"$ownerId": "$ownerId"`, into a type of the same contract whose owner may delete its documents (`canBeDeleted: true`) or whose documents only a consume deletes (`canBeDeleted: "onlyWhenConsumed"`, see [Deletion](deletion.md#canbedeleted)), that declares no delete token cost or delete action fee and no [`deleteConstraints`](deletion.md#deleteconstraints) (no delete transition charges or judges them), and that requires no stricter signature security level than the revealing type. A contract-bound key signing the create must be allowed to act on the consumed type too (`ContractBoundedKeyOutOfBoundsError`, 20014). From protocol version 15 the delete uses the commitment `findBy` read instead of reading it again by id, so the create pays for one read of it fewer than before.

A create missing a param, or with a value holding its separator, is refused before any read (`DocumentReferencePreimageInvalidError`, 10423). No commitment is `ReferencedEntityNotFoundError` (40120), another identity's `ReferencedDocumentPropertyMismatchError` (40127), and one too young `ReferencedDocumentRequirementNotMetError` (40142). The [Documents chapter](../data-model/documents.md#commit-and-reveal-a-findby-function) has the full rules.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -973,10 +973,10 @@ struct RevealedValue<'a> {
/// The recursion is as deep as the expression, which registration keeps
/// within `SystemLimits::max_reference_expression_depth`.
///
/// In place in generation 0, which every table selects: its callers, the
/// document create and replace state validations, reach it from protocol
/// version 14 only, and only that version's parser produces an expression, so
/// every earlier write goes straight to the leaf check it always ran.
/// In place in generation 0: its callers, the document create and replace
/// state validations, reach it from protocol version 14 only, and only that
/// version's parser produces an expression, so every earlier write goes
/// straight to the leaf check it always ran.
#[allow(clippy::too_many_arguments)]
fn validate_reference_v0(
contract: &DataContract,
Expand Down Expand Up @@ -1577,10 +1577,10 @@ fn validate_reference_target_v0(
// differing value would be.
(Some(_), None) | (None, Some(_)) => return Ok(mismatch()),
};
// In place in generation 0, which every table selects: a
// `where` only parses from protocol version
// 14 (`apply_property_reference` 0), so before it no
// document type carries a pair to reach this comparison
// In place in generation 0: a `where` only parses from
// protocol version 14 (`apply_property_reference` 0), so
// before it no document type carries a pair to reach this
// comparison
if !referring_value.same_scalar_data(&referenced_value) {
return Ok(mismatch());
}
Expand Down Expand Up @@ -2527,10 +2527,10 @@ fn validate_key_id_reference_v0(
// may add a property carrying this reference to such a type, so a
// replace setting the key id of an old document names no identity,
// and is refused as a key id set while its identity property is not.
// In place in generation 0, which every table selects: its callers,
// the document create and replace state validations, reach it from
// protocol version 14 only, the only version whose parser produces a
// key reference, so no earlier write gets here
// In place in generation 0: its callers, the document create and
// replace state validations, reach it from protocol version 14 only,
// the only version whose parser produces a key reference, so no
// earlier write gets here
KeyReferenceIdentityProperty::CreatorId => match creator_id {
Some(creator_id) => creator_id,
None => {
Expand Down

This file was deleted.

Loading
Loading