-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
runtime-sdk: Add support for reporting sender metadata
- Loading branch information
Showing
5 changed files
with
77 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//! Transaction sender metadata. | ||
use crate::types::address::Address; | ||
|
||
/// Transaction sender metadata. | ||
#[derive(Clone, Debug, Eq, PartialEq, Default)] | ||
pub struct SenderMeta { | ||
/// Sender address. | ||
pub address: Address, | ||
/// Sender nonce contained in the transaction. | ||
pub tx_nonce: u64, | ||
/// Sender nonce contained in runtime state. | ||
pub state_nonce: u64, | ||
} | ||
|
||
impl SenderMeta { | ||
/// Unique identifier of the sender, currently derived from the sender address. | ||
pub fn id(&self) -> Vec<u8> { | ||
if self.address == Default::default() { | ||
// Use an empty value for the default address as that signals to the host that the | ||
// sender should be ignored. | ||
vec![] | ||
} else { | ||
self.address.into_bytes().to_vec() | ||
} | ||
} | ||
} |