Skip to content

Commit

Permalink
Use pallet::getter syntax (paritytech#742)
Browse files Browse the repository at this point in the history
* Use `pallet::getter` syntax

* Leave `current_block_hash`
  • Loading branch information
tgmichel authored Jun 23, 2022
1 parent 28c4bce commit 3b67d14
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions frame/ethereum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,23 +320,28 @@ pub mod pallet {

/// Current building block's transactions and receipts.
#[pallet::storage]
#[pallet::getter(fn pending)]
pub(super) type Pending<T: Config> =
StorageValue<_, Vec<(Transaction, TransactionStatus, Receipt)>, ValueQuery>;

/// The current Ethereum block.
#[pallet::storage]
#[pallet::getter(fn current_block)]
pub(super) type CurrentBlock<T: Config> = StorageValue<_, ethereum::BlockV2>;

/// The current Ethereum receipts.
#[pallet::storage]
#[pallet::getter(fn current_receipts)]
pub(super) type CurrentReceipts<T: Config> = StorageValue<_, Vec<Receipt>>;

/// The current transaction statuses.
#[pallet::storage]
#[pallet::getter(fn current_transaction_statuses)]
pub(super) type CurrentTransactionStatuses<T: Config> = StorageValue<_, Vec<TransactionStatus>>;

// Mapping for block number and hashes.
#[pallet::storage]
#[pallet::getter(fn block_hash)]
pub(super) type BlockHash<T: Config> = StorageMap<_, Twox64Concat, U256, H256, ValueQuery>;

#[pallet::genesis_config]
Expand Down Expand Up @@ -676,26 +681,11 @@ impl<T: Config> Pallet<T> {
})
}

/// Get the transaction status with given index.
pub fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {
CurrentTransactionStatuses::<T>::get()
}

/// Get current block.
pub fn current_block() -> Option<ethereum::BlockV2> {
CurrentBlock::<T>::get()
}

/// Get current block hash
pub fn current_block_hash() -> Option<H256> {
Self::current_block().map(|block| block.header.hash())
}

/// Get receipts by number.
pub fn current_receipts() -> Option<Vec<Receipt>> {
CurrentReceipts::<T>::get()
}

/// Execute an Ethereum transaction.
pub fn execute(
from: H160,
Expand Down

0 comments on commit 3b67d14

Please sign in to comment.