Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

fix(middleware): use signer chain when tx is None #1377

Merged
merged 1 commit into from
Jun 14, 2022

Conversation

Rjected
Copy link
Contributor

@Rjected Rjected commented Jun 14, 2022

Motivation

The previous behavior never changes the tx chain id if it is None, since the tx is cloned inside the match statement.

Solution

Move the tx clone outside the match statement.

Adds a test setting the tx chain id to None, with a 1337 chain id on the signer, ensuring that the transaction encoding and signature are changed properly.

PR Checklist

  • Added Tests
  • Added Documentation
  • Updated the changelog

@@ -131,12 +131,12 @@ where
// compare chain_id and use signer's chain_id if the tranasaction's chain_id is None,
// return an error if they are not consistent
let chain_id = self.signer.chain_id();
let mut tx = tx.clone();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to clone? let's just make mut tx instead in the function declaration?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right, yeah we can do that, that makes more sense

@@ -382,6 +382,42 @@ mod tests {
assert_eq!(tx, expected_rlp);
}

#[tokio::test]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great!

@Rjected Rjected force-pushed the fix-tx-chainid-scope branch from 2cadbad to 7d03827 Compare June 14, 2022 20:13
@gakonst gakonst merged commit c0a5962 into gakonst:master Jun 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants