Skip to content

doc: #[near(contract_state)] doc should link to [store] and [collections] modules #1304

Open
@dj8yfo

Description

There should be links from #[near(contract_state)] to modules themselves and to anchors of modules' documentation with all [env] host-functions used in storage implementation.

Links from [store] and [collections] to host-functions in [env] used in storage implementation intersect with scope of #1265


Relates to #1299

Should create links mentioned below in comment #1304 (comment) and also add this sub-heading to #[near(contract_state)] heading:

/// ### FAQ
/// * unlike containers in [`collections`] module, most containers in [`store`] module will cache all changes
///   and loads and only update values that are changed in storage after it’s dropped through it’s [`Drop`](core::ops::Drop) implementation.
///   These changes can be updated in storage before the container variable is dropped by using
///   the container's `flush` method, e.g. [`store::Vector::flush`] ([`store::Vector::drop`] uses this in implementation too).
///
/// ```rust
/// // expanded #[near] macro call on a contract method
/// // ...
/// let mut contract: Contract = ::near_sdk::env::state_read().unwrap_or_default();
/// // call of the original `mutating_method` as defined in source code prior to expansion 
/// Contract::mutating_method(&mut contract, greeting);
/// ::near_sdk::env::state_write(&contract);
/// // Drop on `contract` is implicitly called here
/// // ...
/// ```

Metadata

Assignees

Labels

Type

No type

Projects

  • Status

    NEW❗

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions