Skip to content

Commit

Permalink
fix Promise in Accounts.signTransaction() throwing errors that cannot…
Browse files Browse the repository at this point in the history
… be caught web3#4724
  • Loading branch information
andreistefanwork committed Jun 16, 2022
1 parent 739217c commit 67958f7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ Released with 1.0.0-beta.37 code base.
- Fix static tuple encoding (#4673) (#4884)
- Fix bug in handleRevert logic for eth_sendRawTransaction (#4902)
- Fix resolve type of getBlock function (#4911)
- Fix Promise in Accounts.signTransaction() throwing errors that cannot be caught (#4724)

### Changed
- Replace deprecated String.prototype.substr() (#4855)
Expand Down
4 changes: 3 additions & 1 deletion packages/web3-eth-accounts/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,9 @@ function _handleTxPricing(_this, tx) {
throw Error("Network doesn't support eip-1559")
resolve({ gasPrice });
}
})
}).catch((error) => {
reject(error);
});
}
} catch (error) {
reject(error)
Expand Down
26 changes: 25 additions & 1 deletion test/eth.accounts.signTransaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,30 @@ var tests = [
transactionHash: "0x82c19b39a6b7eaa0492863a8b236fad5018f267b4977c270ddd5228c4cbda60e",
messageHash: "0xe3beea0918f445c21eb2f42e3cbc3c5d54321ec642f47d12c473b2765df97f2b"
},
{
// test #31
address: '0x2c7536E3605D9C16a7a3D7b1898e529396a65c23',
iban: 'XE0556YCRTEZ9JALZBSCXOK4UJ5F3HN03DV',
privateKey: '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318',
transaction: {
chainId: 1,
nonce: 0,
gas: 27200,
maxPriorityFeePerGas: '0x3B9ACA00',
gasLimit: '0x6A40',
to: '0xF0109fC8DF283027b6285cc889F5aA624EaC1F55',
toIban: 'XE04S1IRT2PR8A8422TPBL9SR6U0HODDCUT', // will be switched to "to" in the test
value: "1000000000",
data: "",
common: commonBerlin
},
error: true,
// signature from eth_signTransaction
rawTransaction: "0x02f86e0180843b9aca00843b9aca0e826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080c080a0eb8ca6017e6926503ce11c404ba9b61f30d53ea934857e4f4489f43a6c189cf8a03655ba42b2fdcabdb3363cb39e7f672baa91455632e02bab27f92e1a275ca833",
oldSignature: "0x02f86e0180843b9aca00843b9aca0e826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080c080a0eb8ca6017e6926503ce11c404ba9b61f30d53ea934857e4f4489f43a6c189cf8a03655ba42b2fdcabdb3363cb39e7f672baa91455632e02bab27f92e1a275ca833",
transactionHash: "0x488a813f2286f7c015947aa13133bdae49ec75ae1c8f5eba80034d71a038dca8",
messageHash: "0xcd6d6dee80ecc38f1b22f2d128bf6043dc41079fc913183a8995b5b3e187df61"
}
];

describe("eth", function () {
Expand Down Expand Up @@ -900,7 +924,7 @@ describe("eth", function () {
done(e);
});
});


it("signTransaction should not call for chainId if common.customChain.chainId provided", function(done) {
var provider = new FakeHttpProvider();
Expand Down

0 comments on commit 67958f7

Please sign in to comment.