holochain_zome_types/
info.rs

1use crate::prelude::*;
2use holo_hash::ActionHash;
3use holo_hash::AgentPubKey;
4use holochain_serialized_bytes::prelude::*;
5
6pub use holochain_integrity_types::info::*;
7
8/// The struct containing all information about the executing agent's identity.
9#[allow(missing_docs)]
10#[derive(Clone, Debug, Serialize, Deserialize, SerializedBytes, PartialEq)]
11pub struct AgentInfo {
12    /// The current agent's pubkey at genesis.
13    /// Always found at index 2 in the source chain.
14    pub agent_initial_pubkey: AgentPubKey,
15    #[cfg(feature = "unstable-dpki")]
16    /// The current agent's current pubkey.
17    /// Same as the initial pubkey if it has never been changed.
18    /// The agent can revoke an old key and replace it with a new one, the latest appears here.
19    pub agent_latest_pubkey: AgentPubKey,
20    pub chain_head: (ActionHash, u32, Timestamp),
21}
22
23impl AgentInfo {
24    pub fn new(
25        agent_initial_pubkey: AgentPubKey,
26        #[cfg(feature = "unstable-dpki")] agent_latest_pubkey: AgentPubKey,
27        chain_head: (ActionHash, u32, Timestamp),
28    ) -> Self {
29        Self {
30            agent_initial_pubkey,
31            #[cfg(feature = "unstable-dpki")]
32            agent_latest_pubkey,
33            chain_head,
34        }
35    }
36}
37
38#[derive(Debug, Serialize, Deserialize)]
39pub struct CallInfo {
40    /// The provenance identifies the agent who made the call.
41    /// This is the author of the chain for local calls, and the assignee of a capability for remote calls.
42    pub provenance: AgentPubKey,
43    /// The function name that was the entrypoint into the wasm.
44    pub function_name: FunctionName,
45    /// Chain head as at the call start.
46    /// This will not change within a call even if the chain is written to.
47    pub as_at: (ActionHash, u32, Timestamp),
48    /// The capability grant used to authorize the call.
49    pub cap_grant: CapGrant,
50}