Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions src/rpc/heliusRpcApi.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
import type { createSolanaRpcApi, Rpc, RpcPlan } from "@solana/kit";
import type { Rpc, SolanaRpcApi } from "@solana/kit";
import { AutoSent } from "./wrapAutoSend";

// To resolve TS async type issues
type UnwrapRpcPlan<T> = T extends RpcPlan<infer U> ? U : T;

type UnwrappedRpc<T> = {
[K in keyof T]: T[K] extends (...args: infer A) => Promise<infer P>
? (...args: A) => Promise<UnwrapRpcPlan<P>>
: T[K];
};

export type ResolvedHeliusRpcApi = UnwrappedRpc<
AutoSent<Rpc<ReturnType<typeof createSolanaRpcApi>>>
>;
// Concrete type: Matches createSolanaRpcApi(DEFAULT_RPC_CONFIG) → Rpc → AutoSent (unwrapped Promises)
export type ResolvedHeliusRpcApi = AutoSent<Rpc<SolanaRpcApi>>;
2 changes: 1 addition & 1 deletion src/rpc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export const createHelius = ({
const transport = createDefaultRpcTransport({ url });

const baseRpc = createRpc({ api: solanaApi, transport });
const raw = wrapAutoSend(baseRpc) as unknown as ResolvedHeliusRpcApi;
const raw: ResolvedHeliusRpcApi = wrapAutoSend(baseRpc);

const wsUrl = new URL(url);
wsUrl.protocol = "wss:";
Expand Down