feat: support rpc method getSignaturesByAddres
This commit is contained in:
committed by
Michael Vines
parent
3362ac06b5
commit
db3475bcdf
@ -127,6 +127,21 @@ export type ConfirmedSignaturesForAddress2Options = {
|
||||
limit?: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* Options for getSignaturesForAddress
|
||||
*/
|
||||
export type SignaturesForAddressOptions = {
|
||||
/**
|
||||
* Start searching backwards from this transaction signature.
|
||||
* @remark If not provided the search starts from the highest max confirmed block.
|
||||
*/
|
||||
before?: TransactionSignature;
|
||||
/** Search until this transaction signature is reached, if found before `limit`. */
|
||||
until?: TransactionSignature;
|
||||
/** Maximum transaction signatures to return (between 1 and 1,000, default: 1,000). */
|
||||
limit?: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* RPC Response with extra contextual information
|
||||
*/
|
||||
@ -1060,6 +1075,21 @@ const GetConfirmedSignaturesForAddress2RpcResult = jsonRpcResult(
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Expected JSON RPC response for the "getSignaturesForAddress" message
|
||||
*/
|
||||
const GetSignaturesForAddressRpcResult = jsonRpcResult(
|
||||
array(
|
||||
pick({
|
||||
signature: string(),
|
||||
slot: number(),
|
||||
err: TransactionErrorResult,
|
||||
memo: nullable(string()),
|
||||
blockTime: optional(nullable(number())),
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
/***
|
||||
* Expected JSON RPC response for the "accountNotification" message
|
||||
*/
|
||||
@ -3205,6 +3235,35 @@ export class Connection {
|
||||
return res.result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns confirmed signatures for transactions involving an
|
||||
* address backwards in time from the provided signature or most recent confirmed block
|
||||
*
|
||||
*
|
||||
* @param address queried address
|
||||
* @param options
|
||||
*/
|
||||
async getSignaturesForAddress(
|
||||
address: PublicKey,
|
||||
options?: SignaturesForAddressOptions,
|
||||
commitment?: Finality,
|
||||
): Promise<Array<ConfirmedSignatureInfo>> {
|
||||
const args = this._buildArgsAtLeastConfirmed(
|
||||
[address.toBase58()],
|
||||
commitment,
|
||||
undefined,
|
||||
options,
|
||||
);
|
||||
const unsafeRes = await this._rpcRequest('getSignaturesForAddress', args);
|
||||
const res = create(unsafeRes, GetSignaturesForAddressRpcResult);
|
||||
if ('error' in res) {
|
||||
throw new Error(
|
||||
'failed to get signatures for address: ' + res.error.message,
|
||||
);
|
||||
}
|
||||
return res.result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the contents of a Nonce account from the cluster, return with context
|
||||
*/
|
||||
|
Reference in New Issue
Block a user