diff --git a/src/block.rs b/src/block.rs index 574f90cd..2a2f9489 100644 --- a/src/block.rs +++ b/src/block.rs @@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize}; use crate::core::{ContractAddress, GlobalRoot}; use crate::hash::StarkHash; use crate::serde_utils::{BytesAsHex, PrefixedBytesAsHex}; -use crate::transaction::{Transaction, TransactionOutput}; +use crate::transaction::{Fee, Transaction, TransactionOutput}; /// A block. #[derive(Debug, Default, Clone, Eq, PartialEq, Hash, Deserialize, Serialize, PartialOrd, Ord)] @@ -128,6 +128,12 @@ impl From for PrefixedBytesAsHex<16_usize> { } } +impl GasPrice { + pub fn calculate_fee_by_gas_usage(&self, gas_usage: f64) -> Fee { + Fee((gas_usage.ceil() as u128) * self.0) + } +} + /// The timestamp of a [Block](`crate::block::Block`). #[derive( Debug, Default, Copy, Clone, Eq, PartialEq, Hash, Deserialize, Serialize, PartialOrd, Ord,