From 4cf234618e74ab5e1a800b84265144f41d7f265a Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Fri, 10 May 2019 20:28:39 -0700 Subject: [PATCH] fix: support v0.14 GetRecentBlockhash too --- web3.js/src/connection.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/web3.js/src/connection.js b/web3.js/src/connection.js index da06416b39..83509bc2f2 100644 --- a/web3.js/src/connection.js +++ b/web3.js/src/connection.js @@ -174,6 +174,7 @@ const GetTransactionCountRpcResult = jsonRpcResult('number'); * Expected JSON RPC response for the "getRecentBlockhash" message */ const GetRecentBlockhash = jsonRpcResult(['string', 'object']); +const GetRecentBlockhash_014 = jsonRpcResult('string'); // Legacy v0.14 response. TODO: Remove in July 2019 /** * Expected JSON RPC response for the "requestAirdrop" message @@ -430,6 +431,14 @@ export class Connection { */ async getRecentBlockhash(): Promise { 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) { + return res_014.result; + } + // End Legacy v0.14 response + const res = GetRecentBlockhash(unsafeRes); if (res.error) { throw new Error(res.error.message);