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
-
In upgrading from v5 to v6, I had to override
sendTransaction
due to a nuanced type issue betweenAbstractSigner
andTransaction
.The core of the issue is that
sendTransaction
generates aTransaction
instance viaTransaction.from()
, which is then passed tosignTransaction
.Although
signTransaction
is designed to accept aTransactionRequest
, the structural similarities betweenTransactionRequest
andTransaction
mean TypeScript doesn't identify this as an error, despite a crucial difference:Transaction
's properties are private.This distinction becomes problematic when
resolveProperties
is invoked on theTransactionRequest
withinsignTransaction
, leading to an empty object becauseObject.keys()
cannot accessTransaction
's private properties.Importantly,
TransactionRequest
may contain properties as promises, necessitating the use ofresolveProperties
to ensure proper handling.This subtlety in how
Transaction
instances andTransactionRequest
objects 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
'ssendTransaction
implementation needs to pass in the appropriate type tosignTransaction
orsignTransaction
's param type needs to be updated such that the developer implementing a customer signer is aware that an instance ofTransaction
may be passed to it.My current solution is to override the
sendTransaction
method but this came after hours of trying to figure out why the signature was different between callingsignTransaction
and the signature produced after callingsendTransaction
.Beta Was this translation helpful? Give feedback.
All reactions