2
0
mirror of synced 2025-02-23 03:28:22 +00:00

Fixed LedgerSigner sendTransaction (#936).

This commit is contained in:
Richard Moore 2020-09-05 04:37:47 -04:00
parent 72385c2287
commit cadb28d6b3
No known key found for this signature in database
GPG Key ID: 665176BE8E9DC651

View File

@ -94,13 +94,22 @@ export class LedgerSigner extends ethers.Signer {
}
async signTransaction(transaction: ethers.providers.TransactionRequest): Promise<string> {
const tx = transaction = await ethers.utils.resolveProperties(transaction);
const unsignedTx = ethers.utils.serializeTransaction(<ethers.utils.UnsignedTransaction>tx).substring(2);
const tx = await ethers.utils.resolveProperties(transaction);
const baseTx: ethers.utils.UnsignedTransaction = {
chainId: (tx.chainId || undefined),
data: (tx.data || undefined),
gasLimit: (tx.gasLimit || undefined),
gasPrice: (tx.gasPrice || undefined),
nonce: (tx.nonce ? ethers.BigNumber.from(tx.nonce).toNumber(): undefined),
to: (tx.to || undefined),
value: (tx.value || undefined),
};
const unsignedTx = ethers.utils.serializeTransaction(baseTx).substring(2);
const sig = await this._retry((eth) => eth.signTransaction(this.path, unsignedTx));
return ethers.utils.serializeTransaction(<ethers.utils.UnsignedTransaction>tx, {
v: sig.v,
return ethers.utils.serializeTransaction(baseTx, {
v: ethers.BigNumber.from("0x" + sig.v).toNumber(),
r: ("0x" + sig.r),
s: ("0x" + sig.s),
});