This repository has been archived by the owner on Jan 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 919
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(experimental): add cluster level API for rpc-core
- Loading branch information
1 parent
8b5554c
commit 4d08ea7
Showing
2 changed files
with
47 additions
and
4 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
packages/rpc-core/src/rpc-methods/__typetests__/api-type-test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { IRpcApi, IRpcApiDevnet, IRpcApiMainnet, IRpcApiTestnet } from '@solana/rpc-transport'; | ||
|
||
import { createSolanaRpcApi, SolanaRpcMethods } from '..'; | ||
|
||
const config = null as unknown as Parameters<typeof createSolanaRpcApi>[0]; | ||
|
||
// No cluster specified should be generic `IRpcApi` | ||
createSolanaRpcApi(config) satisfies IRpcApi<SolanaRpcMethods>; | ||
|
||
// When devnet is specified, should be `IRpcApiDevnet` | ||
createSolanaRpcApi<'devnet'>(config) satisfies IRpcApiDevnet<SolanaRpcMethods>; | ||
// @ts-expect-error Should not be a testnet API | ||
createSolanaRpcApi<'devnet'>(config) satisfies IRpcApiTestnet<SolanaRpcMethods>; | ||
// @ts-expect-error Should not be a mainnet API | ||
createSolanaRpcApi<'devnet'>(config) satisfies IRpcApiMainnet<SolanaRpcMethods>; | ||
|
||
// When testnet is specified, should be `IRpcApiTestnet` | ||
createSolanaRpcApi<'testnet'>(config) satisfies IRpcApiTestnet<SolanaRpcMethods>; | ||
// @ts-expect-error Should not be a devnet API | ||
createSolanaRpcApi<'testnet'>(config) satisfies IRpcApiDevnet<SolanaRpcMethods>; | ||
// @ts-expect-error Should not be a mainnet API | ||
createSolanaRpcApi<'testnet'>(config) satisfies IRpcApiMainnet<SolanaRpcMethods>; | ||
|
||
// When mainnet is specified, should be `IRpcApiMainnet` | ||
createSolanaRpcApi<'mainnet'>(config) satisfies IRpcApiMainnet<Omit<SolanaRpcMethods, 'requestAirdrop'>>; | ||
// @ts-expect-error Should not be a devnet API | ||
createSolanaRpcApi<'mainnet'>(config) satisfies IRpcApiDevnet<Omit<SolanaRpcMethods, 'requestAirdrop'>>; | ||
// @ts-expect-error Should not be a testnet API | ||
createSolanaRpcApi<'mainnet'>(config) satisfies IRpcApiTestnet<Omit<SolanaRpcMethods, 'requestAirdrop'>>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters