From 53958a8b1e09bc7f43de5107f784f3e833dea4da Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Thu, 23 May 2019 10:35:57 -0600 Subject: [PATCH] fix: Repair getRecentBlockhash bug in non-legacy formats --- web3.js/src/connection.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/web3.js/src/connection.js b/web3.js/src/connection.js index 83509bc2f2..b80fbd4055 100644 --- a/web3.js/src/connection.js +++ b/web3.js/src/connection.js @@ -433,9 +433,14 @@ export class Connection { const unsafeRes = await this._rpcRequest('getRecentBlockhash', []); // Legacy v0.14 response. TODO: Remove in July 2019 - const res_014 = GetRecentBlockhash_014(unsafeRes); - if (!res_014.error) { + try { + const res_014 = GetRecentBlockhash_014(unsafeRes); + if (res_014.error) { + throw new Error(res_014.error.message); + } return res_014.result; + } catch (e) { + // Not legacy format } // End Legacy v0.14 response