From 1448963fcf3fe24e2a3ddd46d4e2611b536ab443 Mon Sep 17 00:00:00 2001 From: lightyear15 Date: Tue, 8 Jun 2021 10:02:43 +0200 Subject: [PATCH] adding TransactionInfo trait and default implementation (#43) adding TransactionInfo trait and default implementation --- src/external/transaction.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/external/transaction.rs b/src/external/transaction.rs index 0412ccd..a54a5d1 100644 --- a/src/external/transaction.rs +++ b/src/external/transaction.rs @@ -94,6 +94,31 @@ pub fn sender() -> Vec { } } +pub trait TransactionInfo { + fn arguments(&self) -> Vec; + fn ret(&self, _values: &[u8]); + fn sender(&self) -> Vec; +} + +#[derive(Clone)] +pub struct TransactionInfoImpl {} +impl TransactionInfo for TransactionInfoImpl { + fn arguments(&self) -> Vec { + arguments() + } + fn ret(&self, values: &[u8]) { + ret(values.to_vec()) + } + fn sender(&self) -> Vec { + sender() + } +} +impl Default for TransactionInfoImpl { + fn default() -> Self { + Self {} + } +} + #[cfg(test)] #[cfg(feature = "host-mock")] mod tests {