near_vm_logic/
types.rs

1use serde::{Deserialize, Serialize};
2
3pub use near_primitives_core::types::*;
4
5pub type PublicKey = Vec<u8>;
6pub type PromiseIndex = u64;
7pub type ReceiptIndex = u64;
8pub type IteratorIndex = u64;
9
10#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
11pub enum ReturnData {
12    /// Method returned some value or data.
13    #[serde(with = "crate::serde_with::bytes_as_str")]
14    Value(Vec<u8>),
15
16    /// The return value of the method should be taken from the return value of another method
17    /// identified through receipt index.
18    ReceiptIndex(ReceiptIndex),
19
20    /// Method hasn't returned any data or promise.
21    None,
22}
23
24impl ReturnData {
25    /// Function to extract value from ReturnData.
26    pub fn as_value(self) -> Option<Vec<u8>> {
27        match self {
28            ReturnData::Value(value) => Some(value),
29            _ => None,
30        }
31    }
32}
33
34/// When there is a callback attached to one or more contract calls the execution results of these
35/// calls are available to the contract invoked through the callback.
36#[derive(Debug, PartialEq, Serialize, Deserialize)]
37pub enum PromiseResult {
38    /// Current version of the protocol never returns `PromiseResult::NotReady`.
39    NotReady,
40    #[serde(with = "crate::serde_with::bytes_as_str")]
41    Successful(Vec<u8>),
42    Failed,
43}