From 6ce085bdf9d24995f7a159ea61d427a7226b1768 Mon Sep 17 00:00:00 2001 From: Muhammad Altabba <24407834+Muhammad-Altabba@users.noreply.github.com> Date: Tue, 11 Apr 2023 13:45:42 +0200 Subject: [PATCH] Fix error: "n.data.substring is not a function" (#6000) * Fix error: "n.data.substring is not a function" * update CHANGELOG.md --- CHANGELOG.md | 2 +- packages/web3-core-method/src/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e337e548cee..7312641c81a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -666,7 +666,7 @@ Released with 1.0.0-beta.37 code base. ### Fixed - Improved the error propagation in `web3-providers-http` package to effectively propagate useful error infomation about failed HTTP connections (#5955) - + - Fix error: "n.data.substring is not a function", that is raised when there is a revert and `web.eth.handleRevert = true` (#6000) ### Changed - `transaction.type` is now formatted to a hex string before being send to provider (#5979) diff --git a/packages/web3-core-method/src/index.js b/packages/web3-core-method/src/index.js index 53646183321..7747460b2cf 100644 --- a/packages/web3-core-method/src/index.js +++ b/packages/web3-core-method/src/index.js @@ -653,7 +653,7 @@ Method.prototype.buildCall = function () { if (!err && method.isRevertReasonString(result)){ reasonData = result.substring(10); } else if (err && err.data){ - reasonData = err.data.substring(10); + reasonData = (err.data.data || err.data).substring(10); } if (reasonData){