mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-04-22 10:17:56 +00:00
6f4aa731ab
* Add support for wrapper types * Move `FilesWithExtensionIterator` to `core::common` * Remove unneeded use of two `HashMap`s * Make metadata structs more typed * Impl new_from for wrapper types * Implement the new input handling logic * Fix edge-case in input handling * Ignore macro doc comment tests * Correct comment * Fix edge-case in deployment order * Handle calldata better * Allow for the use of function signatures * Add support for exceptions * Cached nonce allocator * Fix tests * Add support for address replacement * Cleanup implementation * Cleanup mutability * Wire up address replacement with rest of code * Implement caller replacement * Switch to callframe trace for exceptions * Add a way to skip tests if they don't match the target * Handle values from the metadata files * Remove address replacement * Correct the arguments * Remove empty impl * Remove address replacement * Correct the arguments * Remove empty impl * Fix size_requirement underflow * Add support for wildcards in exceptions * Fix calldata construction of single calldata * Better handling for length in equivalency checks * Make initial balance a constant * Fix size_requirement underflow * Add support for wildcards in exceptions * Fix calldata construction of single calldata * Better handling for length in equivalency checks * Fix tests
79 lines
2.2 KiB
Rust
79 lines
2.2 KiB
Rust
use alloy::{
|
||
network::{Network, TransactionBuilder},
|
||
providers::{
|
||
Provider, SendableTx,
|
||
fillers::{GasFiller, TxFiller},
|
||
},
|
||
transports::TransportResult,
|
||
};
|
||
|
||
#[derive(Clone, Debug)]
|
||
pub struct FallbackGasFiller {
|
||
inner: GasFiller,
|
||
default_gas_limit: u64,
|
||
default_max_fee_per_gas: u128,
|
||
default_priority_fee: u128,
|
||
}
|
||
|
||
impl FallbackGasFiller {
|
||
pub fn new(
|
||
default_gas_limit: u64,
|
||
default_max_fee_per_gas: u128,
|
||
default_priority_fee: u128,
|
||
) -> Self {
|
||
Self {
|
||
inner: GasFiller,
|
||
default_gas_limit,
|
||
default_max_fee_per_gas,
|
||
default_priority_fee,
|
||
}
|
||
}
|
||
}
|
||
|
||
impl<N> TxFiller<N> for FallbackGasFiller
|
||
where
|
||
N: Network,
|
||
{
|
||
type Fillable = Option<<GasFiller as TxFiller<N>>::Fillable>;
|
||
|
||
fn status(
|
||
&self,
|
||
tx: &<N as Network>::TransactionRequest,
|
||
) -> alloy::providers::fillers::FillerControlFlow {
|
||
<GasFiller as TxFiller<N>>::status(&self.inner, tx)
|
||
}
|
||
|
||
fn fill_sync(&self, _: &mut alloy::providers::SendableTx<N>) {}
|
||
|
||
async fn prepare<P: Provider<N>>(
|
||
&self,
|
||
provider: &P,
|
||
tx: &<N as Network>::TransactionRequest,
|
||
) -> TransportResult<Self::Fillable> {
|
||
// Try to fetch GasFiller’s “fillable” (gas_price, base_fee, estimate_gas, …)
|
||
// If it errors (i.e. tx would revert under eth_estimateGas), swallow it.
|
||
match self.inner.prepare(provider, tx).await {
|
||
Ok(fill) => Ok(Some(fill)),
|
||
Err(_) => Ok(None),
|
||
}
|
||
}
|
||
|
||
async fn fill(
|
||
&self,
|
||
fillable: Self::Fillable,
|
||
mut tx: alloy::providers::SendableTx<N>,
|
||
) -> TransportResult<SendableTx<N>> {
|
||
if let Some(fill) = fillable {
|
||
// our inner GasFiller succeeded — use it
|
||
self.inner.fill(fill, tx).await
|
||
} else {
|
||
if let Some(builder) = tx.as_mut_builder() {
|
||
builder.set_gas_limit(self.default_gas_limit);
|
||
builder.set_max_fee_per_gas(self.default_max_fee_per_gas);
|
||
builder.set_max_priority_fee_per_gas(self.default_priority_fee);
|
||
}
|
||
Ok(tx)
|
||
}
|
||
}
|
||
}
|