Skip to content

Commit 83f4346

Browse files
authored
feat(connector): allow to set default fees (#2181)
1 parent 1bbc0d7 commit 83f4346

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

crates/chain-connector/src/connector.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use alloy_primitives::hex::ToHexExt;
2-
use alloy_primitives::{uint, FixedBytes, U256};
2+
use alloy_primitives::{uint, FixedBytes, Uint, U256};
33
use alloy_sol_types::sol_data::Array;
44
use alloy_sol_types::{SolCall, SolType};
55
use std::collections::HashMap;
@@ -106,6 +106,10 @@ impl ChainConnector {
106106
}
107107

108108
async fn get_base_fee_per_gas(&self) -> Result<U256, ConnectorError> {
109+
if let Some(fee) = self.config.default_base_fee {
110+
return Ok(Uint::from(fee));
111+
}
112+
109113
let block: Value = process_response(
110114
self.client
111115
.request("eth_getBlockByNumber", rpc_params!["pending", false])
@@ -138,6 +142,10 @@ impl ChainConnector {
138142
}
139143

140144
async fn max_priority_fee_per_gas(&self) -> Result<U256, ConnectorError> {
145+
if let Some(fee) = self.config.default_priority_fee {
146+
return Ok(Uint::from(fee));
147+
}
148+
141149
let resp: String = process_response(
142150
self.client
143151
.request("eth_maxPriorityFeePerGas", rpc_params![])
@@ -568,6 +576,8 @@ mod tests {
568576
"0x97a2456e78c4894c62eef6031972d1ca296ed40bf311ab54c231f13db59fc428",
569577
)
570578
.unwrap(),
579+
default_base_fee: None,
580+
default_priority_fee: None,
571581
},
572582
peer_id_from_hex("0x6497db93b32e4cdd979ada46a23249f444da1efb186cd74b9666bd03f710028b")
573583
.unwrap(),

crates/chain-listener/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ serde_json = { workspace = true }
2323
tokio = { workspace = true, features = ["rt"] }
2424
server-config = { workspace = true }
2525
types = { workspace = true }
26-
libipld = "0.16.0"
26+
libipld = { workspace = true }
2727

2828
alloy-sol-types = { workspace = true }
2929
alloy-primitives = { workspace = true }

crates/cid-utils/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2021"
77

88
[dependencies]
99
serde = { workspace = true }
10-
libipld = "0.16.0"
10+
libipld = { workspace = true }
1111
bytes = "1.5.0"
1212
quick-protobuf = "0.8.1"
1313
eyre = { workspace = true }

crates/server-config/src/node_config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,10 @@ pub struct ChainConfig {
567567
pub market_contract_address: String,
568568
pub network_id: u64,
569569
pub wallet_key: PrivateKey,
570+
/// If none, comes from the chain
571+
pub default_base_fee: Option<u64>,
572+
/// If none, comes from the chain
573+
pub default_priority_fee: Option<u64>,
570574
}
571575

572576
#[derive(Clone, Deserialize, Serialize, Derivative)]

0 commit comments

Comments
 (0)