Struct TransactionList

Source
pub struct TransactionList { /* private fields */ }
Expand description

A list contains a series of transactions and appropriate indexers.

This structure exposes a virtual merkle-tree in the following form:

0: event_hashes 1: offset 3: user_indexer 4: contract_indexer 5: token_indexer

      ROOT
     /    \
    /      \
   V        V
  /  \     /  \
 0    1   3    V
              / \
             4   5

Implementations§

Source§

impl TransactionList

Source

pub fn new(contract: Principal, offset: u64) -> TransactionList

Create a new list with the given global offset.

Source

pub fn contract_id(&self) -> &Principal

Return the principal id of the contract we’re storing transactions for.

Source

pub fn size(&self) -> u64

Return the total number of transactions.

Source

pub fn len(&self) -> usize

Return the total number of items in this list.

Source

pub fn is_empty(&self) -> bool

Returns tru if there are no events in this list.

Source

pub fn insert(&mut self, event: Event) -> u64

Try to insert an event into the list.

Source

pub fn get_transactions_for_user( &self, principal: &Principal, page: u32, ) -> Vec<&Event>

Return the transactions associated with a user’s principal id at the given page.

Source

pub fn last_page_for_user(&self, principal: &Principal) -> u32

Return the last page number associated with the given user.

Source

pub fn get_transactions_for_contract( &self, principal: &Principal, page: u32, ) -> Vec<&Event>

Return the transactions associated with a token’s principal id at the given page.

Source

pub fn last_page_for_contract(&self, principal: &Principal) -> u32

Return the last page number associated with the given token contract.

Source

pub fn get_transactions_for_token( &self, token_id: &u64, page: u32, ) -> Vec<&Event>

Return the transactions for a specific token.

Source

pub fn last_page_for_token(&self, token_id: &u64) -> u32

Source

pub fn witness_transactions_for_user( &self, principal: &Principal, page: u32, ) -> HashTree<'_>

Return the witness that can be used to prove the response from get_transactions_for_user.

Source

pub fn witness_transactions_for_contract( &self, principal: &Principal, page: u32, ) -> HashTree<'_>

Return the witness that can be used to prove the response from get_transactions_for_token.

Source

pub fn witness_transactions_for_token( &self, token_id: &u64, page: u32, ) -> HashTree<'_>

Return the witness that can be used to prove the response from get_transactions_for_token.

Source

pub fn get_transaction(&self, id: u64) -> Option<&Event>

Return a transaction by its global id.

Source

pub fn witness_transaction(&self, id: u64) -> HashTree<'_>

Return a witness which proves the response returned by get_transaction.

Trait Implementations§

Source§

impl AsHashTree for TransactionList

Source§

fn root_hash(&self) -> [u8; 32]

This method should return the root hash of this hash tree. Must be equivalent to as_hash_tree().reconstruct(). Read more
Source§

fn as_hash_tree(&self) -> HashTree<'_>

Constructs a hash tree corresponding to the data.
Source§

impl CandidType for TransactionList

Source§

fn _ty() -> Type

Source§

fn idl_serialize<S>( &self, serializer: S, ) -> Result<(), <S as Serializer>::Error>
where S: Serializer,

Source§

fn ty() -> Type

Source§

fn id() -> TypeId

Source§

impl<'de> Deserialize<'de> for TransactionList

Source§

fn deserialize<D>( deserializer: D, ) -> Result<TransactionList, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Drop for TransactionList

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Serialize for TransactionList

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> GroupLeaf for T
where T: Any + AsHashTree,