fix: add missing getSlot API
This commit is contained in:
@ -160,6 +160,11 @@ const GetProgramAccountsRpcResult = jsonRpcResult(
|
||||
*/
|
||||
const ConfirmTransactionRpcResult = jsonRpcResult('boolean');
|
||||
|
||||
/**
|
||||
* Expected JSON RPC response for the "getSlot" message
|
||||
*/
|
||||
const GetSlot = jsonRpcResult('number');
|
||||
|
||||
/**
|
||||
* Expected JSON RPC response for the "getSlotLeader" message
|
||||
*/
|
||||
@ -535,6 +540,20 @@ export class Connection {
|
||||
return res.result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the current slot that the node is processing
|
||||
*/
|
||||
async getSlot(): Promise<number> {
|
||||
const unsafeRes = await this._rpcRequest('getSlot', []);
|
||||
const res = GetSlot(unsafeRes);
|
||||
if (res.error) {
|
||||
throw new Error(res.error.message);
|
||||
}
|
||||
assert(typeof res.result !== 'undefined');
|
||||
return res.result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch the current slot leader of the cluster
|
||||
*/
|
||||
|
Reference in New Issue
Block a user