fix: support v0.14 GetRecentBlockhash too
This commit is contained in:
@ -174,6 +174,7 @@ const GetTransactionCountRpcResult = jsonRpcResult('number');
|
|||||||
* Expected JSON RPC response for the "getRecentBlockhash" message
|
* Expected JSON RPC response for the "getRecentBlockhash" message
|
||||||
*/
|
*/
|
||||||
const GetRecentBlockhash = jsonRpcResult(['string', 'object']);
|
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
|
* Expected JSON RPC response for the "requestAirdrop" message
|
||||||
@ -430,6 +431,14 @@ export class Connection {
|
|||||||
*/
|
*/
|
||||||
async getRecentBlockhash(): Promise<Blockhash> {
|
async getRecentBlockhash(): Promise<Blockhash> {
|
||||||
const unsafeRes = await this._rpcRequest('getRecentBlockhash', []);
|
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);
|
const res = GetRecentBlockhash(unsafeRes);
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
throw new Error(res.error.message);
|
throw new Error(res.error.message);
|
||||||
|
Reference in New Issue
Block a user