ethers.js icon indicating copy to clipboard operation
ethers.js copied to clipboard

`signTransaction` mutates the given transaction

Open KillariDev opened this issue 1 year ago • 2 comments

Ethers Version

6.13.1

Search Terms

No response

Describe the Problem

when signTransaction is given a transaction object, it mutates the object by removing from field

Code Snippet

const test = async () => {
	const wallet = new ethers.Wallet('0x0000000000000000000000000000000000000000000000000000000000000001', new JsonRpcProvider('https://holesky.drpc.org'))
	const tx = { from: '0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf' }
	await wallet.populateTransaction(tx)
	console.log(tx.from)
	await wallet.signTransaction(tx)
	console.log(tx.from)
}
test()

this prints:

0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf
undefined

It should print:

0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf
0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf

KillariDev avatar Jul 19 '24 06:07 KillariDev

Confirmed this is a bug. Looking into it now.

ricmoo avatar Jul 25 '24 21:07 ricmoo

Fixed in v6.13.2. Please give it a try and let me know if there are any more issues.

Thanks!: )

ricmoo avatar Jul 25 '24 22:07 ricmoo