Skip to content

Commit

Permalink
refactor(experimental): add ClusterUrl types
Browse files Browse the repository at this point in the history
As per @lorisleiva's suggestion, here's some types for cluster URLs!
Straight from [this comment](#2053 (comment))
  • Loading branch information
buffalojoec committed Feb 2, 2024
1 parent e9c1b10 commit 61f7ba0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/rpc-types/src/cluster-url.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export type MainnetUrl = string & { '~cluster': 'mainnet' };
export type DevnetUrl = string & { '~cluster': 'devnet' };
export type TestnetUrl = string & { '~cluster': 'testnet' };
export type ClusterUrl = string | MainnetUrl | DevnetUrl | TestnetUrl;

export function mainnet(putativeString: string): MainnetUrl {
return putativeString as MainnetUrl;
}
export function devnet(putativeString: string): DevnetUrl {
return putativeString as DevnetUrl;
}
export function testnet(putativeString: string): TestnetUrl {
return putativeString as TestnetUrl;
}
1 change: 1 addition & 0 deletions packages/rpc-types/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './blockhash';
export * from './cluster-url';
export * from './commitment';
export * from './encoded-bytes';
export * from './lamports';
Expand Down

0 comments on commit 61f7ba0

Please sign in to comment.