oasis_runtime_sdk/
sender.rs

1//! Transaction sender metadata.
2use crate::types::address::Address;
3
4/// Transaction sender metadata.
5#[derive(Clone, Debug, Eq, PartialEq, Default)]
6pub struct SenderMeta {
7    /// Sender address.
8    pub address: Address,
9    /// Sender nonce contained in the transaction.
10    pub tx_nonce: u64,
11    /// Sender nonce contained in runtime state.
12    pub state_nonce: u64,
13}
14
15impl SenderMeta {
16    /// Unique identifier of the sender, currently derived from the sender address.
17    pub fn id(&self) -> Vec<u8> {
18        if self.address == Default::default() {
19            // Use an empty value for the default address as that signals to the host that the
20            // sender should be ignored.
21            vec![]
22        } else {
23            self.address.into_bytes().to_vec()
24        }
25    }
26}