-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(provider): modify provider traits for new types, impl alloy prov…
…ider
- Loading branch information
Showing
20 changed files
with
2,001 additions
and
1,718 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// This file is part of Rundler. | ||
// | ||
// Rundler is free software: you can redistribute it and/or modify it under the | ||
// terms of the GNU Lesser General Public License as published by the Free Software | ||
// Foundation, either version 3 of the License, or (at your option) any later version. | ||
// | ||
// Rundler is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
// See the GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License along with Rundler. | ||
// If not, see https://www.gnu.org/licenses/. | ||
|
||
use alloy_primitives::{Address, Bytes}; | ||
use alloy_provider::Provider as AlloyProvider; | ||
use alloy_sol_types::sol; | ||
use alloy_transport::Transport; | ||
|
||
use crate::ProviderResult; | ||
|
||
// From https://github.com/OffchainLabs/nitro-contracts/blob/fbbcef09c95f69decabaced3da683f987902f3e2/src/node-interface/NodeInterface.sol#L112 | ||
sol! { | ||
#[sol(rpc)] | ||
interface NodeInterface { | ||
function gasEstimateL1Component( | ||
address to, | ||
bool contractCreation, | ||
bytes calldata data | ||
) | ||
external | ||
payable | ||
returns ( | ||
uint64 gasEstimateForL1, | ||
uint256 baseFee, | ||
uint256 l1BaseFeeEstimate | ||
); | ||
} | ||
} | ||
|
||
pub(crate) async fn estimate_l1_gas<AP: AlloyProvider<T>, T: Transport + Clone>( | ||
provider: AP, | ||
oracle_address: Address, | ||
to_address: Address, | ||
data: Bytes, | ||
) -> ProviderResult<u128> { | ||
let inst = NodeInterface::NodeInterfaceInstance::new(oracle_address, provider); | ||
|
||
// assume contract creation | ||
let ret = inst | ||
.gasEstimateL1Component(to_address, true, data) | ||
.call() | ||
.await?; | ||
|
||
Ok(ret.gasEstimateForL1 as u128) | ||
} |
Oops, something went wrong.