Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PolyProgrammist committed Dec 28, 2024
1 parent 8e16e83 commit 916e81d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
20 changes: 11 additions & 9 deletions near-sdk/src/environment/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -877,32 +877,34 @@ pub fn promise_and(promise_indices: &[PromiseIndex]) -> PromiseIndex {
}

/// # Examples
/// ```
/// ```no_run
///
/// use near_sdk::env;
/// use near_sdk::AccountId;
/// use std::str::FromStr;
///
/// let promise = promise_batch_create(
/// let promise = env::promise_batch_create(
/// &AccountId::from_str("receiver.near").unwrap()
/// );
/// ```
/// Create a NEAR promise which will have multiple promise actions inside.
///
/// Example:
/// ```no_run
/// use near_sdk::env;
/// use near_sdk::{env, NearToken, NearGas};
///
/// let target_account = "example.near".to_string();
/// let promise_index = env::promise_batch_create(&target_account);
/// let promise_index = env::promise_batch_create(
/// &AccountId::from_str("example.near").unwrap()
/// );
///
/// // Adding actions to the promise
/// env::promise_batch_action_transfer(promise_index, 10u128); // Transfer 10 NEAR
/// env::promise_batch_action_transfer(promise_index, NearToken::fromNear(10u128)); // Transfer 10 NEAR
/// env::promise_batch_action_function_call(
/// promise_index,
/// "method_name".to_string(), // Target method
/// b"{}".to_vec(), // Arguments
/// "method_name", // Target method
/// b"{}", // Arguments
/// 0, // Attached deposit
/// 5_000_000_000_000 // Gas for execution
/// NearGas::from_tgas(5) // Gas for execution
/// );
/// ```
/// All actions in a batch are executed in the order they were added.
Expand Down
12 changes: 9 additions & 3 deletions near-sdk/src/types/vm_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@ pub use near_vm_runner::logic::types::{PromiseResult as VmPromiseResult, ReturnD
/// Returned by [`promise_create`](crate::env::promise_create) and can be used to refer this promise in `promise_then`, `promise_batch_create`, and other functions.
/// Example:
/// ```no_run
/// use near_sdk::env;
/// use near_sdk::{env, NearGas};
///
/// let promise_id = env::promise_create("a.near", "new", b"{}", 0, 1_000_000_000_000);
/// env::promise_then(promise_id, "b.near", "callback", b"{}", 0, 1_000_000_000_000);
/// let promise_id = env::promise_create(
/// &AccountId::from_str("a.near").unwrap(), "new", b"{}", 0,
/// NearGas::from_tgas(1)
/// );
/// env::promise_then(
/// promise_id, &AccountId::from_str("b.near").unwrap(), "callback", b"{}", 0,
/// NearGas::from_tgas(1)
/// );
/// ```
#[derive(Debug, Eq, PartialEq, PartialOrd, Ord, Hash, Copy, Clone)]
pub struct PromiseIndex(pub(crate) u64);
Expand Down

0 comments on commit 916e81d

Please sign in to comment.