Skip to content

Commit

Permalink
refactor: client type names (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickfrosty authored Feb 27, 2025
1 parent 3439498 commit 7c997f7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changeset/bright-moles-remain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"gill": patch
---

refactored client type names
12 changes: 6 additions & 6 deletions packages/gill/src/core/create-solana-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import type { DevnetUrl, MainnetUrl, TestnetUrl } from "@solana/rpc-types";

import type {
LocalnetUrl,
SolanaClient,
ModifiedClusterUrl,
CreateSolanaClientArgs,
CreateSolanaClientResult,
} from "../types/rpc";
import { sendAndConfirmTransactionFactory } from "../kit";
import { getPublicSolanaRpcUrl } from "./rpc";
Expand All @@ -18,25 +18,25 @@ export function createSolanaClient(
props: Omit<CreateSolanaClientArgs<MainnetUrl | "mainnet">, "urlOrMoniker"> & {
urlOrMoniker: "mainnet";
},
): CreateSolanaClientResult<MainnetUrl>;
): SolanaClient<MainnetUrl>;
export function createSolanaClient(
props: Omit<CreateSolanaClientArgs<DevnetUrl | "devnet">, "urlOrMoniker"> & {
urlOrMoniker: "devnet";
},
): CreateSolanaClientResult<DevnetUrl>;
): SolanaClient<DevnetUrl>;
export function createSolanaClient(
props: Omit<CreateSolanaClientArgs<TestnetUrl | "testnet">, "urlOrMoniker"> & {
urlOrMoniker: "testnet";
},
): CreateSolanaClientResult<TestnetUrl>;
): SolanaClient<TestnetUrl>;
export function createSolanaClient(
props: Omit<CreateSolanaClientArgs<LocalnetUrl | "localnet">, "urlOrMoniker"> & {
urlOrMoniker: "localnet";
},
): CreateSolanaClientResult<LocalnetUrl>;
): SolanaClient<LocalnetUrl>;
export function createSolanaClient<TClusterUrl extends ModifiedClusterUrl>(
props: CreateSolanaClientArgs<TClusterUrl>,
): CreateSolanaClientResult<TClusterUrl>;
): SolanaClient<TClusterUrl>;
export function createSolanaClient<TCluster extends ModifiedClusterUrl>({
urlOrMoniker,
rpcConfig,
Expand Down
10 changes: 5 additions & 5 deletions packages/gill/src/types/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ export type GenericUrl = string & {};

export type ModifiedClusterUrl = MainnetUrl | DevnetUrl | TestnetUrl | LocalnetUrl | GenericUrl;

export type CreateSolanaClientArgs<
TClusterUrl extends ModifiedClusterUrl | SolanaClusterMoniker = GenericUrl,
> = {
export type SolanaClientUrlOrMoniker = SolanaClusterMoniker | URL | ModifiedClusterUrl;

export type CreateSolanaClientArgs<TClusterUrl extends SolanaClientUrlOrMoniker = GenericUrl> = {
/** Full RPC URL (for a private RPC endpoint) or the Solana moniker (for a public RPC endpoint) */
urlOrMoniker: SolanaClusterMoniker | TClusterUrl | URL | ModifiedClusterUrl;
urlOrMoniker: SolanaClientUrlOrMoniker | TClusterUrl;
/** Configuration used to create the `rpc` client */
rpcConfig?: Parameters<typeof createSolanaRpc>[1] & { port?: number };
/** Configuration used to create the `rpcSubscriptions` client */
rpcSubscriptionsConfig?: Parameters<typeof createSolanaRpcSubscriptions>[1] & { port?: number };
};

export type CreateSolanaClientResult<TClusterUrl extends ModifiedClusterUrl | string = string> = {
export type SolanaClient<TClusterUrl extends ModifiedClusterUrl | string = string> = {
/** Used to make RPC calls to your RPC provider */
rpc: RpcFromTransport<
SolanaRpcApiFromTransport<RpcTransportFromClusterUrl<TClusterUrl>>,
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/types/providers.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// import {} from "react";

import { CreateSolanaClientResult } from "gill";
import { SolanaClient } from "gill";

/**
* Initial configuration settings for utilizing gill hooks
*/
export type GillConfig = CreateSolanaClientResult;
export type GillConfig = SolanaClient;

0 comments on commit 7c997f7

Please sign in to comment.