feat: generic argument for rpc.call (#9)

providing an optional generic for the `rpc.call` function to grant a user the ability to specify the expected return type.
This commit is contained in:
Eulentier
2025-01-20 23:33:23 +01:00
committed by GitHub
parent a43bcd3e4e
commit c9b035b548

2
rpc.ts
View File

@@ -35,7 +35,7 @@ export class RPC implements RPCInterface {
//Network information related
/** The function that sends the RPC POST request */
async call(payload: Record<string, any>): Promise<Record<string, any>> {
async call<T extends Record<string, any>>(payload: Record<string, any>): Promise<T> {
if (this.debug) console.log(JSON.stringify(payload));
const resp = await fetch(this.rpc_url, {
method: "POST",