Add getSignatureStatus()
This commit is contained in:
@ -83,6 +83,21 @@ const ConfirmTransactionRpcResult = struct({
|
||||
result: 'boolean?',
|
||||
});
|
||||
|
||||
/**
|
||||
* Expected JSON RPC response for the "getSignatureStatus" message
|
||||
*/
|
||||
const GetSignatureStatusRpcResult = struct({
|
||||
jsonrpc: struct.literal('2.0'),
|
||||
id: 'string',
|
||||
error: 'any?',
|
||||
result: struct.optional(struct.enum([
|
||||
'Confirmed',
|
||||
'SignatureNotFound',
|
||||
'ProgramRuntimeError',
|
||||
'GenericFailure',
|
||||
])),
|
||||
});
|
||||
|
||||
/**
|
||||
* Expected JSON RPC response for the "getTransactionCount" message
|
||||
*/
|
||||
@ -147,6 +162,13 @@ type AccountInfo = {
|
||||
userdata: Buffer | null,
|
||||
}
|
||||
|
||||
/**
|
||||
* Possible signature status values
|
||||
*
|
||||
* @typedef {string} SignatureStatus
|
||||
*/
|
||||
type SignatureStatus = 'Confirmed' | 'SignatureNotFound' | 'ProgramRuntimeError' | 'GenericFailure';
|
||||
|
||||
/**
|
||||
* A connection to a fullnode JSON RPC endpoint
|
||||
*/
|
||||
@ -224,6 +246,20 @@ export class Connection {
|
||||
return res.result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the current transaction count of the network
|
||||
*/
|
||||
async getSignatureStatus(signature: TransactionSignature): Promise<SignatureStatus> {
|
||||
const unsafeRes = await this._rpcRequest('getSignatureStatus', [signature]);
|
||||
const res = GetSignatureStatusRpcResult(unsafeRes);
|
||||
if (res.error) {
|
||||
throw new Error(res.error.message);
|
||||
}
|
||||
assert(typeof res.result !== 'undefined');
|
||||
return res.result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch the current transaction count of the network
|
||||
*/
|
||||
|
Reference in New Issue
Block a user