Skip to content

Commit

Permalink
adding TransactionInfo trait and default implementation (#43)
Browse files Browse the repository at this point in the history
adding TransactionInfo trait and default implementation
  • Loading branch information
lightyear15 authored Jun 8, 2021
1 parent f23a113 commit 1448963
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/external/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,31 @@ pub fn sender() -> Vec<u8> {
}
}

pub trait TransactionInfo {
fn arguments(&self) -> Vec<u8>;
fn ret(&self, _values: &[u8]);
fn sender(&self) -> Vec<u8>;
}

#[derive(Clone)]
pub struct TransactionInfoImpl {}
impl TransactionInfo for TransactionInfoImpl {
fn arguments(&self) -> Vec<u8> {
arguments()
}
fn ret(&self, values: &[u8]) {
ret(values.to_vec())
}
fn sender(&self) -> Vec<u8> {
sender()
}
}
impl Default for TransactionInfoImpl {
fn default() -> Self {
Self {}
}
}

#[cfg(test)]
#[cfg(feature = "host-mock")]
mod tests {
Expand Down

0 comments on commit 1448963

Please sign in to comment.