Incompatibility in AbstractSigner: sendTransaction Passes Transaction with Private Properties to signTransaction Expecting TransactionRequest with Unresolved Properties #4575
taylorjdawson
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
In upgrading from v5 to v6, I had to override
sendTransactiondue to a nuanced type issue betweenAbstractSignerandTransaction.The core of the issue is that
sendTransactiongenerates aTransactioninstance viaTransaction.from(), which is then passed tosignTransaction.Although
signTransactionis designed to accept aTransactionRequest, the structural similarities betweenTransactionRequestandTransactionmean TypeScript doesn't identify this as an error, despite a crucial difference:Transaction's properties are private.This distinction becomes problematic when
resolvePropertiesis invoked on theTransactionRequestwithinsignTransaction, leading to an empty object becauseObject.keys()cannot accessTransaction's private properties.Importantly,
TransactionRequestmay contain properties as promises, necessitating the use ofresolvePropertiesto ensure proper handling.This subtlety in how
Transactioninstances andTransactionRequestobjects are treated, especially regarding promise properties and the need forresolveProperties, indicates a potential area for improvement in ethers library's type system.Either the
AbstractSigner'ssendTransactionimplementation needs to pass in the appropriate type tosignTransactionorsignTransaction's param type needs to be updated such that the developer implementing a customer signer is aware that an instance ofTransactionmay be passed to it.My current solution is to override the
sendTransactionmethod but this came after hours of trying to figure out why the signature was different between callingsignTransactionand the signature produced after callingsendTransaction.Beta Was this translation helpful? Give feedback.
All reactions