@@ -10,11 +10,11 @@ export interface NetworkConfig {
1010 fetchFn ?: FetchFn ;
1111}
1212
13- export const StacksNetworks = [ 'mainnet' , 'testnet' ] as const ;
13+ export const StacksNetworks = [ 'mainnet' , 'testnet' , 'devnet' , 'mocknet' ] as const ;
1414export type StacksNetworkName = ( typeof StacksNetworks ) [ number ] ;
1515
1616/**
17- * @related {@link StacksMainnet }, {@link StacksTestnet}, {@link StacksMocknet}
17+ * @related {@link StacksMainnet }, {@link StacksTestnet}, {@link StacksDevnet}, { @link StacksMocknet}
1818 */
1919export class StacksNetwork {
2020 version = TransactionVersion . Mainnet ;
@@ -42,6 +42,10 @@ export class StacksNetwork {
4242 return new StacksMainnet ( ) ;
4343 case 'testnet' :
4444 return new StacksTestnet ( ) ;
45+ case 'devnet' :
46+ return new StacksDevnet ( ) ;
47+ case 'mocknet' :
48+ return new StacksMocknet ( ) ;
4549 default :
4650 throw new Error (
4751 `Invalid network name provided. Must be one of the following: ${ StacksNetworks . join (
@@ -133,7 +137,7 @@ export class StacksNetwork {
133137}
134138
135139/**
136- * A {@link StacksNetwork} with default values for the Stacks mainnet.
140+ * A {@link StacksNetwork} with the parameters for the Stacks mainnet.
137141 * Pass a `url` option to override the default Hiro hosted Stacks node API.
138142 * Pass a `fetchFn` option to customize the default networking functions.
139143 * @example
@@ -157,7 +161,16 @@ export class StacksMainnet extends StacksNetwork {
157161}
158162
159163/**
160- * Same as {@link StacksMainnet} but defaults to values for the Stacks testnet.
164+ * A {@link StacksNetwork} with the parameters for the Stacks testnet.
165+ * Pass a `url` option to override the default Hiro hosted Stacks node API.
166+ * Pass a `fetchFn` option to customize the default networking functions.
167+ * @example
168+ * ```
169+ * const network = new StacksTestnet();
170+ * const network = new StacksTestnet({ url: "https://stacks-node-api.testnet.stacks.co" });
171+ * const network = new StacksTestnet({ fetch: createFetchFn() });
172+ * ```
173+ * @related {@link createFetchFn }, {@link createApiKeyMiddleware}
161174 */
162175export class StacksTestnet extends StacksNetwork {
163176 version = TransactionVersion . Testnet ;
@@ -171,6 +184,9 @@ export class StacksTestnet extends StacksNetwork {
171184 }
172185}
173186
187+ /**
188+ * A {@link StacksNetwork} using the testnet parameters, but `localhost:3999` as the API URL.
189+ */
174190export class StacksMocknet extends StacksNetwork {
175191 version = TransactionVersion . Testnet ;
176192 chainId = ChainID . Testnet ;
@@ -182,3 +198,6 @@ export class StacksMocknet extends StacksNetwork {
182198 } ) ;
183199 }
184200}
201+
202+ /** Alias for {@link StacksMocknet} */
203+ export const StacksDevnet = StacksMocknet ;
0 commit comments