Skip to content

Commit

Permalink
fix: signer fills from if unset (alloy-rs#555)
Browse files Browse the repository at this point in the history
  • Loading branch information
prestwich authored and ben186 committed Jul 27, 2024
1 parent 36805d8 commit a983849
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 1 addition & 2 deletions crates/provider/src/fillers/nonce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ mod tests {

#[tokio::test]
async fn no_nonce_if_sender_unset() {
let (provider, _anvil) =
ProviderBuilder::new().with_nonce_management().on_anvil_with_signer();
let (provider, _anvil) = ProviderBuilder::new().with_nonce_management().on_anvil();

let tx = TransactionRequest {
value: Some(U256::from(100)),
Expand Down
13 changes: 12 additions & 1 deletion crates/provider/src/fillers/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ where
type Fillable = ();

fn status(&self, tx: &<N as Network>::TransactionRequest) -> FillerControlFlow {
if tx.from().is_none() {
return FillerControlFlow::Ready;
}

if tx.can_build() {
FillerControlFlow::Ready
} else {
Expand All @@ -72,11 +76,18 @@ where
_fillable: Self::Fillable,
tx: SendableTx<N>,
) -> TransportResult<SendableTx<N>> {
let builder = match tx {
let mut builder = match tx {
SendableTx::Builder(builder) => builder,
_ => return Ok(tx),
};

if builder.from().is_none() {
builder.set_from(self.signer.default_signer());
if !builder.can_build() {
return Ok(SendableTx::Builder(builder));
}
}

let envelope = builder.build(&self.signer).await.map_err(RpcError::local_usage)?;

Ok(SendableTx::Envelope(envelope))
Expand Down

0 comments on commit a983849

Please sign in to comment.