-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeScript error: ethers.Transaction.from won't accept ethers.TransactionRequest #4659
Comments
The issue is that a Transaction’s operations are all synchronous, while a TransactionRequest allows the If you are certain your transaction has a synchronously accessible Also, if you use the signer.populateTransaction, that should return a TransactionLike, which is safe to pass to Does that make sense? |
This is what I'm trying to do, I am implementing signTransaction, so I have been given a async signTransaction(
txRequest: ethers.TransactionRequest
): Promise<string> {
// TODO Hopefully we can remove the explicit any after this is resolved: https://github.com/ethers-io/ethers.js/issues/4659
let tx = ethers.Transaction.from(txRequest as any);
const unsignedSerializedTx = tx.unsignedSerialized;
const unsignedSerializedTxHash = ethers.keccak256(unsignedSerializedTx);
const signedSerializedTxHash = await signWithEcdsa(
this.thresholdKeyInfo,
ethers.getBytes(unsignedSerializedTxHash)
);
if (this.provider === null) {
throw new Error(`ThresholdWallet: provider must not be null`);
}
const network = await this.provider.getNetwork();
const chainId = Number(network.chainId);
const { r, s, v } = calculateRsvForTEcdsa(
chainId,
await this.getAddress(),
unsignedSerializedTxHash,
signedSerializedTxHash
);
tx.signature = {
r,
s,
v
};
const rawTransaction = tx.serialized;
return rawTransaction;
}
MIT License
// Copyright (c) 2023 AZLE token holders (nlhft-2iaaa-aaaae-qaaua-cai)
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE. |
Ah, are you saying that I can do this? async signTransaction(
txRequest: ethers.TransactionRequest
): Promise<string> {
let txLike = await this.populateTransaction(txRequest);
let tx = ethers.Transaction.from(txLike); |
This isn't working unfortunately:
I haven't specified from, this is failing on this transaction:
|
Oh! That's because you are including a When you create a I just tried your example deleting the The property names |
Quick aside: the reason you cannot "set" the The easiest way to drop it is probably |
The error message now includes quotes around the property name so it doesn't look like an incomplete error message randomly ending in a preposition that makes no sense. :) Thanks! :) |
Sorry I'm confused at your last few comments. There is no |
Ethers Version
6.11.1
Search Terms
No response
Describe the Problem
While implementing
signTransaction
within my own concrete implementation ofethers.AbstractSigner
, I am trying to create a transaction usingethers.Transaction.from
with anethers.TransactionRequest
as the argument. I would think that this could work, but unfortunately there is a TypeScript error. At runtime everything is working fine thus far.Code Snippet
Contract ABI
No response
Errors
Environment
node.js (v12 or newer)
Environment (Other)
VS Code
The text was updated successfully, but these errors were encountered: