Skip to content

Commit 1bbcee3

Browse files
authored
Make ResolvedHeliusRpcApi Type Explicit (#218)
1 parent 81fdd9b commit 1bbcee3

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

src/rpc/heliusRpcApi.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
1-
import type { createSolanaRpcApi, Rpc, RpcPlan } from "@solana/kit";
1+
import type { Rpc, SolanaRpcApi } from "@solana/kit";
22
import { AutoSent } from "./wrapAutoSend";
33

4-
// To resolve TS async type issues
5-
type UnwrapRpcPlan<T> = T extends RpcPlan<infer U> ? U : T;
6-
7-
type UnwrappedRpc<T> = {
8-
[K in keyof T]: T[K] extends (...args: infer A) => Promise<infer P>
9-
? (...args: A) => Promise<UnwrapRpcPlan<P>>
10-
: T[K];
11-
};
12-
13-
export type ResolvedHeliusRpcApi = UnwrappedRpc<
14-
AutoSent<Rpc<ReturnType<typeof createSolanaRpcApi>>>
15-
>;
4+
// Concrete type: Matches createSolanaRpcApi(DEFAULT_RPC_CONFIG) → Rpc → AutoSent (unwrapped Promises)
5+
export type ResolvedHeliusRpcApi = AutoSent<Rpc<SolanaRpcApi>>;

src/rpc/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export const createHelius = ({
105105
const transport = createDefaultRpcTransport({ url });
106106

107107
const baseRpc = createRpc({ api: solanaApi, transport });
108-
const raw = wrapAutoSend(baseRpc) as unknown as ResolvedHeliusRpcApi;
108+
const raw: ResolvedHeliusRpcApi = wrapAutoSend(baseRpc);
109109

110110
const wsUrl = new URL(url);
111111
wsUrl.protocol = "wss:";

0 commit comments

Comments
 (0)