Skip to content

Commit

Permalink
doc: NEAR SDK Descriptions (#782)
Browse files Browse the repository at this point in the history
Co-authored-by: NinoLipartiia4ire <[email protected]>
Co-authored-by: Austin Abell <[email protected]>
  • Loading branch information
3 people authored Apr 15, 2022
1 parent c2492e7 commit 3f11bc4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
17 changes: 17 additions & 0 deletions near-sdk/src/promise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,23 @@ impl borsh::BorshSerialize for Promise {
}
}

/// When the method can return either a promise or a value, it can be called with `PromiseOrValue::Promise`
/// or `PromiseOrValue::Value` to specify which one should be returned.
/// # Example
/// ```no_run
/// # use near_sdk::{ext_contract, near_bindgen, Gas, PromiseOrValue};
/// #[ext_contract]
/// pub trait ContractA {
/// fn a(&mut self);
/// }
///
/// let value = Some(true);
/// let val: PromiseOrValue<bool> = if let Some(value) = value {
/// PromiseOrValue::Value(value)
/// } else {
/// contract_a::a("bob_near".parse().unwrap(), 0, Gas(1_000)).into()
/// };
/// ```
#[derive(serde::Serialize)]
#[serde(untagged)]
pub enum PromiseOrValue<T> {
Expand Down
2 changes: 2 additions & 0 deletions near-sdk/src/test_utils/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Testing blockchain utilities. These can only be used inside tests and are not available for
//! a wasm32 target.
#[allow(dead_code)]
pub mod test_env;

Expand Down
2 changes: 2 additions & 0 deletions near-sdk/src/types/vm_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
pub use near_vm_logic::types::{PromiseResult as VmPromiseResult, ReturnData};

//* Types from near_vm_logic
/// Promise index that is computed only once.
pub type PromiseIndex = u64;
/// An index of Receipt to append an action
pub type ReceiptIndex = u64;
pub type IteratorIndex = u64;

Expand Down
2 changes: 2 additions & 0 deletions near-sdk/src/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Helper methods that often used in smart contracts.

pub(crate) mod storage_key_impl;

#[cfg(feature = "unstable")]
Expand Down

0 comments on commit 3f11bc4

Please sign in to comment.