@midnightntwrk/testkit-js 0.0.0-stage → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +409 -2
  2. package/dist/fixtures/hf/README.md +781 -0
  3. package/dist/fixtures/hf/coin-receiver-016/coin-receiver.compact +24 -0
  4. package/dist/fixtures/hf/coin-receiver-016/compiled/compiler/contract-info.json +104 -0
  5. package/dist/fixtures/hf/coin-receiver-016/compiled/contract/index.d.ts +47 -0
  6. package/dist/fixtures/hf/coin-receiver-016/compiled/contract/index.js +412 -0
  7. package/dist/fixtures/hf/coin-receiver-016/receive-coin-transcript.recording.json +668 -0
  8. package/dist/fixtures/hf/coin-receiver-016/state-v6-envelope.hex +1 -0
  9. package/dist/fixtures/hf/coin-receiver-016/state-v9.hex +1 -0
  10. package/dist/fixtures/hf/counter-016/compiled/compiler/contract-info.json +31 -0
  11. package/dist/fixtures/hf/counter-016/compiled/contract/index.d.ts +39 -0
  12. package/dist/fixtures/hf/counter-016/compiled/contract/index.js +189 -0
  13. package/dist/fixtures/hf/counter-016/compiled/keys/increment.prover +0 -0
  14. package/dist/fixtures/hf/counter-016/compiled/keys/increment.verifier +0 -0
  15. package/dist/fixtures/hf/counter-016/compiled/zkir/increment.bzkir +0 -0
  16. package/dist/fixtures/hf/counter-016/compiled/zkir/increment.zkir +22 -0
  17. package/dist/fixtures/hf/counter-016/increment-transcript.golden.json +23 -0
  18. package/dist/fixtures/hf/fixtures.json +69 -0
  19. package/dist/fixtures/hf/pre-fork-private-state-store/.gitattributes +8 -0
  20. package/dist/fixtures/hf/pre-fork-private-state-store/ENVELOPE.md +70 -0
  21. package/dist/fixtures/hf/pre-fork-private-state-store/store/000005.ldb +0 -0
  22. package/dist/fixtures/hf/pre-fork-private-state-store/store/000006.log +0 -0
  23. package/dist/fixtures/hf/pre-fork-private-state-store/store/CURRENT +1 -0
  24. package/dist/fixtures/hf/pre-fork-private-state-store/store/MANIFEST-000004 +0 -0
  25. package/dist/fixtures/hf/private-counter-016/README.md +13 -0
  26. package/dist/fixtures/hf/private-counter-016/compiled/compiler/contract-info.json +40 -0
  27. package/dist/fixtures/hf/private-counter-016/compiled/contract/index.d.ts +40 -0
  28. package/dist/fixtures/hf/private-counter-016/compiled/contract/index.js +211 -0
  29. package/dist/fixtures/hf/private-counter-twin/compiled/compiler/contract-info.json +41 -0
  30. package/dist/fixtures/hf/private-counter-twin/compiled/contract/index.js +271 -0
  31. package/dist/fixtures/hf/private-counter-twin/private-counter.compact +27 -0
  32. package/dist/fixtures/hf/state-both-keys.hex +1 -0
  33. package/dist/fixtures/hf/state-co-v2-only-foreign.hex +1 -0
  34. package/dist/fixtures/hf/state-migrated-v9-merkle.hex +1 -0
  35. package/dist/fixtures/hf/state-migrated-v9.hex +1 -0
  36. package/dist/fixtures/hf/state-tampered-bytes.hex +1 -0
  37. package/dist/fixtures/hf/state-tampered-keyset-v8to9.hex +1 -0
  38. package/dist/fixtures/hf/state-tampered-keyset-v9to8.hex +1 -0
  39. package/dist/fixtures/hf/state-v8-v6-envelope.hex +1 -0
  40. package/dist/fixtures/hf/state-v8.hex +1 -0
  41. package/dist/fixtures/hf/twin-contract/compiled/compiler/contract-info.json +31 -0
  42. package/dist/fixtures/hf/twin-contract/compiled/compiler/contract-manifest.json +58 -0
  43. package/dist/fixtures/hf/twin-contract/compiled/contract/index.d.ts +40 -0
  44. package/dist/fixtures/hf/twin-contract/compiled/contract/index.js +196 -0
  45. package/dist/fixtures/hf/twin-contract/compiled/keys/increment.prover +0 -0
  46. package/dist/fixtures/hf/twin-contract/compiled/keys/increment.verifier +0 -0
  47. package/dist/fixtures/hf/twin-contract/compiled/zkir/increment.bzkir +0 -0
  48. package/dist/fixtures/hf/twin-contract/compiled/zkir/increment.zkir +22 -0
  49. package/dist/fixtures/hf/twin-contract/counter.compact +15 -0
  50. package/dist/fixtures-hf.d.ts +70 -0
  51. package/dist/fixtures-hf.js +161 -0
  52. package/dist/fixtures-hf.js.map +1 -0
  53. package/dist/index.d.ts +1067 -0
  54. package/dist/index.js +3459 -0
  55. package/dist/index.js.map +1 -0
  56. package/package.json +82 -3
@@ -0,0 +1,1067 @@
1
+ import { Ledger9FinalizedDeployTxData, Ledger9FoundDeployTxData, Ledger9FinalizedCallTxData, Ledger9CallTxOptions, Ledger9DeployContractOptions, Ledger9DeployTxOptions } from '@midnightntwrk/midnight-js-contracts';
2
+ import { Signaturish, Proofish, Bindingish, Transaction, ContractState, LedgerState, ZswapSecretKeys, DustSecretKey, CoinPublicKey, EncPublicKey, LedgerParameters } from '@midnightntwrk/midnight-js-protocol/v9';
3
+ import { Contract } from '@midnightntwrk/midnight-js-protocol/v9/compact-js';
4
+ import { StateValue, ContractAddress } from '@midnightntwrk/midnight-js-protocol/v9/compact-runtime';
5
+ import { MidnightProviders, PrivateStateId, Ledger9FinalizedTxData, NetworkId, BlockHash, PrivateStateProvider, MidnightProvider, WalletProvider, UnboundTx, FinalizedTx } from '@midnightntwrk/midnight-js-types';
6
+ import * as axios from 'axios';
7
+ import { AxiosResponse, AxiosRequestConfig } from 'axios';
8
+ import pino, { Logger } from 'pino';
9
+ import { WaitStrategy, StartedDockerComposeEnvironment } from 'testcontainers';
10
+ import { ZkConfigIntegrityOptions } from '@midnightntwrk/midnight-js-utils';
11
+ import { NetworkId as NetworkId$1, WalletFacade, UnshieldedKeystore, WalletSeeds as WalletSeeds$1, DefaultShieldedConfiguration, ShieldedWalletAPI, ShieldedKeysByEpoch, DefaultUnshieldedConfiguration, UnshieldedWalletAPI, DefaultDustConfiguration, DustWalletAPI, DustKeysByEpoch, DefaultConfiguration, ShieldedWallet, ShieldedWalletState, UnshieldedWalletState } from '@midnightntwrk/wallet-sdk';
12
+ import { LedgerEra } from '@midnightntwrk/midnight-js-protocol/version';
13
+ import { InitialAPI, ConnectedAPI, TokenType, SignDataOptions, Signature, KeyMaterialProvider, ProvingProvider, Configuration, ConnectionStatus, WalletConnectedAPI, DesiredOutput, DesiredInput, HistoryEntry } from '@midnightntwrk/dapp-connector-api';
14
+ import * as _midnightntwrk_wallet_sdk_facade from '@midnightntwrk/wallet-sdk-facade';
15
+
16
+ declare const stateValueEqual: (a: StateValue, b: StateValue) => boolean;
17
+ declare const txsEqual: <S extends Signaturish, P extends Proofish, B extends Bindingish>(a: Transaction<S, P, B>, b: Transaction<S, P, B>) => boolean;
18
+ declare const expectFoundAndDeployedTxPublicDataEqual: <C extends Contract.Any>(deployTxData: Ledger9FinalizedDeployTxData<C>, foundDeployTxData: Ledger9FoundDeployTxData<C>) => void;
19
+ declare const expectFoundAndDeployedTxPrivateDataEqual: <C extends Contract.Any>(deployTxData: Ledger9FinalizedDeployTxData<C>, foundDeployTxData: Ledger9FoundDeployTxData<C>) => void;
20
+ declare const expectFoundAndDeployedTxDataEqual: <C extends Contract.Any>(deployTxData: Ledger9FinalizedDeployTxData<C>, foundDeployTxData: Ledger9FoundDeployTxData<C>) => void;
21
+ declare const expectFoundAndDeployedStatesEqual: <C extends Contract.Any>(providers: MidnightProviders<Contract.ProvableCircuitId<C>, PrivateStateId, Contract.PrivateState<C> | unknown>, deployTxData: Ledger9FinalizedDeployTxData<C>, foundDeployTxData: Ledger9FoundDeployTxData<C>, privateStateId?: PrivateStateId, initialPrivateState?: Contract.PrivateState<C>) => Promise<void>;
22
+ declare const expectSuccessfulTxData: (finalizedTxData: Ledger9FinalizedTxData) => void;
23
+ declare const expectSuccessfulDeployTx: <C extends Contract.Any>(providers: MidnightProviders<Contract.ProvableCircuitId<C>, PrivateStateId, Contract.PrivateState<C> | unknown>, deployTxData: Ledger9FinalizedDeployTxData<C>, deployTxOptions?: Ledger9DeployContractOptions<C> | Ledger9DeployTxOptions<C>) => Promise<void>;
24
+ declare const expectSuccessfulCallTx: <C extends Contract.Any, PCK extends Contract.ProvableCircuitId<C>>(providers: MidnightProviders<Contract.ProvableCircuitId<C>, PrivateStateId, Contract.PrivateState<C> | unknown>, callTxData: Ledger9FinalizedCallTxData<C, PCK>, callTxOptions?: Ledger9CallTxOptions<C, PCK>, nextPrivateState?: Contract.PrivateState<C>) => Promise<void>;
25
+
26
+ /**
27
+ * Client for interacting with the Midnight faucet service.
28
+ * Provides functionality to request test tokens for wallet addresses.
29
+ */
30
+ declare class FaucetClient {
31
+ readonly faucetUrl: string;
32
+ private logger;
33
+ /**
34
+ * Creates a new FaucetClient instance.
35
+ * @param {string} faucetUrl - The URL of the faucet service endpoint
36
+ * @param {Logger} logger - Logger instance for recording operations
37
+ */
38
+ constructor(faucetUrl: string, logger: Logger);
39
+ /**
40
+ * Checks the health status of the faucet service.
41
+ * Makes a GET request to the health endpoint of the faucet service.
42
+ * @returns {Promise<AxiosResponse | void>} A promise that resolves to the response of the health check or logs an error if the request fails
43
+ */
44
+ health(): Promise<axios.AxiosResponse<any, any, {}, any>>;
45
+ /**
46
+ * Requests test tokens from the faucet for a specified wallet address.
47
+ * Makes a POST request to the faucet service with the wallet address.
48
+ * @param {string} walletAddress - The address to receive the test tokens
49
+ * @returns {Promise<void>} A promise that resolves when the request is complete
50
+ * @throws Will log but not throw if the request fails
51
+ */
52
+ requestTokens(walletAddress: string): Promise<void>;
53
+ }
54
+
55
+ declare class IndexerClient {
56
+ readonly indexerUrl: string;
57
+ private logger;
58
+ /**
59
+ * Creates an instance of IndexerClient.
60
+ * @param {string} indexerUrl - The URL of the indexer service.
61
+ * @param {Logger} logger - The logger instance for logging information.
62
+ */
63
+ constructor(indexerUrl: string, logger: Logger);
64
+ /**
65
+ * Checks the health status of the indexer service.
66
+ * Makes a GET request to the status endpoint of the indexer service.
67
+ * @returns {Promise<AxiosResponse | void>} A promise that resolves to the response of the health check or logs an error if the request fails.
68
+ */
69
+ health(): Promise<axios.AxiosResponse<any, any, {}, any>>;
70
+ }
71
+
72
+ /**
73
+ * Client for interacting with a Midnight node's JSON-RPC API
74
+ */
75
+ declare class NodeClient {
76
+ readonly nodeURL: string;
77
+ private logger;
78
+ private readonly networkId;
79
+ /**
80
+ * Creates a new NodeClient instance
81
+ * @param {string} nodeURL - URL of the Midnight node
82
+ * @param {Logger} logger - Logger instance for recording operations
83
+ * @param {NetworkId} networkId - Network the node serves, used to address contract state
84
+ */
85
+ constructor(nodeURL: string, logger: Logger, networkId: NetworkId);
86
+ /**
87
+ * Checks the health status of the node.
88
+ * Makes a GET request to the health endpoint of the node.
89
+ * @returns {Promise<AxiosResponse | void>} A promise that resolves to the response of the health check or logs an error if the request fails.
90
+ */
91
+ health(): Promise<AxiosResponse<any, any, {}, any>>;
92
+ /**
93
+ * Validates response format and throws if unexpected
94
+ * @param {AxiosResponse} response - Response from node API
95
+ * @throws {Error} If response format is unexpected
96
+ * @private
97
+ */
98
+ private static throwOnUnexpected;
99
+ /**
100
+ * Makes a JSON-RPC request to the node
101
+ * @param {string} method - RPC method name
102
+ * @param {any[]} params - RPC method parameters
103
+ * @returns {Promise<string>} Response result as string
104
+ * @private
105
+ */
106
+ private jsonRPC;
107
+ /**
108
+ * Fetches the state of a contract
109
+ * @param {ContractAddress} contractAddress - Address of the contract
110
+ * @returns {Promise<ContractState | null>} Contract state or null if not found
111
+ */
112
+ contractState(contractAddress: ContractAddress): Promise<ContractState | null>;
113
+ /**
114
+ * Fetches the ledger state at a given block
115
+ * @param {BlockHash} blockHash - Hash of the block
116
+ * @returns {Promise<LedgerState>} Ledger state
117
+ */
118
+ ledgerState(blockHash: BlockHash): Promise<LedgerState>;
119
+ /**
120
+ * Fetches the raw ledger state blob at a given block
121
+ * @param {BlockHash} blockHash - Hash of the block
122
+ * @returns {Promise<Uint8Array>} Raw ledger state data
123
+ * @throws {Error} If no ledger state is found
124
+ */
125
+ ledgerStateBlob(blockHash: BlockHash): Promise<Uint8Array>;
126
+ /**
127
+ * Fetches the ledger version at a given block
128
+ * @param {BlockHash} blockHash - Hash of the block
129
+ * @returns {Promise<string>} Ledger version
130
+ * @throws {Error} If no ledger version is found
131
+ */
132
+ ledgerVersion(blockHash: BlockHash): Promise<string>;
133
+ }
134
+
135
+ declare class ProofServerClient {
136
+ readonly proofServer: string;
137
+ private logger;
138
+ /**
139
+ * Creates an instance of ProofServerClient.
140
+ * @param {string} proofServer - The URL of the proof server service.
141
+ * @param {Logger} logger - The logger instance for logging information.
142
+ */
143
+ constructor(proofServer: string, logger: Logger);
144
+ /**
145
+ * Checks the health status of the indexer service.
146
+ * Makes a GET request to the status endpoint of the indexer service.
147
+ * @returns {Promise<AxiosResponse | void>} A promise that resolves to the response of the health check or logs an error if the request fails.
148
+ */
149
+ health(): Promise<axios.AxiosResponse<any, any, {}, any>>;
150
+ /**
151
+ * Proves a transaction by sending a POST request to the proof server.
152
+ * @param data serialized transaction data
153
+ * @param config Axios request configuration
154
+ */
155
+ proveTx(data?: ArrayBuffer, config?: AxiosRequestConfig): Promise<axios.AxiosResponse<any, any, {}, any>>;
156
+ }
157
+
158
+ /**
159
+ * Configuration for a proof server container instance
160
+ */
161
+ interface ProofServerContainerConfiguration {
162
+ /** Directory path where container configuration is located */
163
+ path: string;
164
+ /** Name of the container configuration file */
165
+ fileName: string;
166
+ /** Network endpoint configuration for the container */
167
+ container: ContainerEndpoints;
168
+ }
169
+ /**
170
+ * Network endpoint configuration for a container
171
+ */
172
+ interface ContainerEndpoints {
173
+ /** Name of the container */
174
+ name: string;
175
+ /** Port number the container listens on */
176
+ port: number;
177
+ /** TestContainers WaitStrategy to use for container start */
178
+ waitStrategy: WaitStrategy;
179
+ }
180
+ /**
181
+ * Container endpoint configurations for standalone mode services
182
+ */
183
+ interface StandaloneContainerNames {
184
+ /** Proof server container configuration */
185
+ proofServer: ContainerEndpoints;
186
+ /** Blockchain node container configuration */
187
+ node: ContainerEndpoints;
188
+ /** Indexer service container configuration */
189
+ indexer: ContainerEndpoints;
190
+ }
191
+ /**
192
+ * Configuration for standalone mode containers
193
+ */
194
+ interface StandaloneContainersConfiguration {
195
+ /** Directory path where container configuration is located */
196
+ path: string;
197
+ /** Name of the container configuration file */
198
+ fileName: string;
199
+ /** Container endpoint configurations */
200
+ container: StandaloneContainerNames;
201
+ }
202
+ /**
203
+ * Configuration for test logging
204
+ */
205
+ interface LogConfiguration {
206
+ /** Directory path where log files will be written */
207
+ path: string;
208
+ /** Name of the log file */
209
+ fileName: string;
210
+ /** Log level (e.g. 'info', 'debug', etc) */
211
+ level: string;
212
+ }
213
+ /**
214
+ * Top-level configuration for all test containers
215
+ */
216
+ interface ContainersConfiguration {
217
+ /** Proof server container configuration */
218
+ proofServer: ProofServerContainerConfiguration;
219
+ /** Standalone mode containers configuration */
220
+ standalone: StandaloneContainersConfiguration;
221
+ /** Logging configuration */
222
+ log: LogConfiguration;
223
+ }
224
+
225
+ declare const HEALTH_CHECK_TIMEOUT_MS = 10000;
226
+ declare const defaultContainersConfiguration: ContainersConfiguration;
227
+ declare const latestContainersConfiguration: ContainersConfiguration;
228
+ declare const getContainersConfiguration: () => ContainersConfiguration;
229
+ declare const setContainersConfiguration: (containersConfig: ContainersConfiguration) => void;
230
+
231
+ /**
232
+ * Configuration interface for Midnight contracts.
233
+ */
234
+ interface ContractConfiguration {
235
+ /**
236
+ * Name of the store used for persisting private state data.
237
+ * This is used as a base name - a signing key store will also be created with "-signing-keys" appended.
238
+ */
239
+ readonly privateStateStoreName: string;
240
+ /**
241
+ * File system path to the zero-knowledge proof configuration files.
242
+ * This should point to the directory containing the circuit verification keys and other ZK artifacts.
243
+ */
244
+ readonly zkConfigPath: string;
245
+ /**
246
+ * Integrity-verification options for the ZK artifacts, passed straight to the
247
+ * config provider. Omitted means the provider's own default, `require`.
248
+ *
249
+ * Needed because retained-era artifacts cannot satisfy `require`: `compactc`
250
+ * 0.31.1 emits `compiler/contract-info.json` and no
251
+ * `compiler/contract-manifest.json`, and the manifest is what verification
252
+ * reads. A pre-fork contract therefore has nothing to verify against, however
253
+ * intact its artifacts are.
254
+ */
255
+ readonly zkConfigIntegrity?: ZkConfigIntegrityOptions;
256
+ }
257
+
258
+ /**
259
+ * A simple in-memory implementation of private state provider. Makes it easy to capture and rewrite private state from deploy.
260
+ *
261
+ * Note: Unlike `levelPrivateStateProvider`, this provider has no storage password configured.
262
+ * Therefore, export/import operations always require an explicit password in the options.
263
+ *
264
+ * @template PSI - Type of the private state identifier.
265
+ * @template PS - Type of the private state.
266
+ * @returns {PrivateStateProvider<PSI, PS>} An in-memory private state provider.
267
+ */
268
+ declare const inMemoryPrivateStateProvider: <PSI extends PrivateStateId, PS extends Contract.PrivateState<Contract.Any>>() => PrivateStateProvider<PSI, PS>;
269
+
270
+ /**
271
+ * Configuration interface for the test environment services
272
+ */
273
+ interface EnvironmentConfiguration {
274
+ /** Wallet Network identifier */
275
+ readonly walletNetworkId: NetworkId$1.NetworkId;
276
+ /** Network identifier */
277
+ readonly networkId: string;
278
+ /** URL of the indexer HTTP endpoint */
279
+ readonly indexer: string;
280
+ /** WebSocket URL for the indexer service */
281
+ readonly indexerWS: string;
282
+ /** URL of the blockchain node */
283
+ readonly node: string;
284
+ /** WebSocket URL for the blockchain node */
285
+ readonly nodeWS: string;
286
+ /** URL of the proof generation server */
287
+ readonly proofServer: string;
288
+ /** Optional URL for the faucet service to obtain test tokens */
289
+ readonly faucet: string | undefined;
290
+ }
291
+
292
+ /**
293
+ * Interface representing a proof server container that can be started and stopped.
294
+ */
295
+ interface ProofServerContainer {
296
+ /**
297
+ * Stops the proof server container.
298
+ * @returns {Promise<void>} A promise that resolves when the container is stopped
299
+ */
300
+ stop(): Promise<void>;
301
+ /**
302
+ * Gets the URL where the proof server can be accessed.
303
+ * @returns {string} The URL of the proof server
304
+ */
305
+ getUrl(): string;
306
+ }
307
+ /**
308
+ * A proof server container that is started and stopped dynamically by the test
309
+ * suite on random port.
310
+ */
311
+ declare class DynamicProofServerContainer implements ProofServerContainer {
312
+ /** The Docker Compose environment running the container */
313
+ dockerEnv: StartedDockerComposeEnvironment;
314
+ /** Unique identifier for the container instance */
315
+ private uid;
316
+ /** Configuration for the proof server container */
317
+ private config;
318
+ /**
319
+ * Creates a new DynamicProofServerContainer instance.
320
+ * @param {StartedDockerComposeEnvironment} dockerEnv - The started Docker Compose environment
321
+ * @param {string} uid - Unique identifier for the container
322
+ * @private
323
+ */
324
+ private constructor();
325
+ /**
326
+ * Starts a new proof server container.
327
+ * @param {Logger} logger - Logger instance for recording operations
328
+ * @param {string} [maybeUID] - Optional unique identifier for the container
329
+ * @param {string} [maybeNetworkId] - Optional network ID for the container
330
+ * @returns {Promise<DynamicProofServerContainer>} A promise that resolves to the new container instance
331
+ */
332
+ static start(logger: Logger, maybeUID?: string, maybeNetworkId?: string): Promise<DynamicProofServerContainer>;
333
+ /**
334
+ * Stops the proof server container.
335
+ * @returns {Promise<void>} A promise that resolves when the container is stopped
336
+ */
337
+ stop(): Promise<void>;
338
+ /**
339
+ * Gets the mapped port number for the container.
340
+ * @returns {number} The mapped port number
341
+ */
342
+ getMappedPort(): number;
343
+ /**
344
+ * Gets the URL where the proof server can be accessed.
345
+ * @returns {string} The URL of the proof server
346
+ */
347
+ getUrl(): string;
348
+ }
349
+ /**
350
+ * A proof server that is currently running on a specific port.
351
+ * Used for connecting to an existing proof server instance.
352
+ */
353
+ declare class StaticProofServerContainer implements ProofServerContainer {
354
+ /** The port number where the proof server is running */
355
+ port: number;
356
+ /**
357
+ * Creates a new StaticProofServerContainer instance.
358
+ * @param {number} port - The port number where the proof server is running (default: 6300)
359
+ */
360
+ constructor(port?: number);
361
+ /**
362
+ * Gets the URL where the proof server can be accessed.
363
+ * @returns {string} The URL of the proof server
364
+ */
365
+ getUrl(): string;
366
+ /**
367
+ * No-op stop method since this represents an external proof server.
368
+ * @returns {Promise<void>} A resolved promise
369
+ */
370
+ stop(): Promise<void>;
371
+ }
372
+
373
+ declare global {
374
+ interface BigInt {
375
+ toJSON(): string;
376
+ }
377
+ }
378
+
379
+ declare class DAppConnectorInitialAPI implements InitialAPI {
380
+ readonly rdns: string;
381
+ readonly name: string;
382
+ readonly icon: string;
383
+ readonly apiVersion: string;
384
+ private readonly connectedWallet;
385
+ private readonly expectedNetworkId;
386
+ constructor(connectedWallet: ConnectedAPI, networkId: string, options?: {
387
+ rdns?: string;
388
+ name?: string;
389
+ icon?: string;
390
+ apiVersion?: string;
391
+ });
392
+ connect(networkId: string): Promise<ConnectedAPI>;
393
+ }
394
+
395
+ /**
396
+ * Provider class that implements wallet functionality for the Midnight network.
397
+ * Handles transaction balancing, submission, and wallet state management.
398
+ */
399
+ declare class MidnightWalletProvider implements MidnightProvider, WalletProvider {
400
+ /** Both eras, on both providers this class implements. */
401
+ readonly supportedEras: readonly LedgerEra[];
402
+ private readonly balancer;
403
+ private readonly submitter;
404
+ logger: Logger;
405
+ readonly env: EnvironmentConfiguration;
406
+ readonly wallet: WalletFacade;
407
+ readonly unshieldedKeystore: UnshieldedKeystore;
408
+ readonly zswapSecretKeys: ZswapSecretKeys;
409
+ readonly dustSecretKey: DustSecretKey;
410
+ readonly seeds: WalletSeeds$1;
411
+ private constructor();
412
+ getCoinPublicKey(): CoinPublicKey;
413
+ getEncryptionPublicKey(): EncPublicKey;
414
+ balanceTx(tx: UnboundTx, ttl?: Date): Promise<FinalizedTx>;
415
+ submitTx(tx: FinalizedTx): Promise<string>;
416
+ private balance;
417
+ private submit;
418
+ start(waitForFundsInWallet?: boolean): Promise<void>;
419
+ stop(): Promise<void>;
420
+ static build(logger: Logger, env: EnvironmentConfiguration, seed?: string | undefined): Promise<MidnightWalletProvider>;
421
+ static withWallet(logger: Logger, env: EnvironmentConfiguration, wallet: WalletFacade, seeds: WalletSeeds$1, unshieldedKeystore: UnshieldedKeystore): Promise<MidnightWalletProvider>;
422
+ }
423
+
424
+ declare class DAppConnectorWalletAdapter implements ConnectedAPI {
425
+ private readonly walletProvider;
426
+ private readonly environmentConfiguration;
427
+ private cachedDefaultKeyMaterialProvider?;
428
+ constructor(walletProvider: Pick<MidnightWalletProvider, 'wallet' | 'unshieldedKeystore' | 'dustSecretKey'>, environmentConfiguration: EnvironmentConfiguration);
429
+ getShieldedAddresses(): Promise<{
430
+ shieldedAddress: string;
431
+ shieldedCoinPublicKey: string;
432
+ shieldedEncryptionPublicKey: string;
433
+ }>;
434
+ getUnshieldedAddress(): Promise<{
435
+ unshieldedAddress: string;
436
+ }>;
437
+ getDustAddress(): Promise<{
438
+ dustAddress: string;
439
+ }>;
440
+ getShieldedBalances(): Promise<Record<TokenType, bigint>>;
441
+ getUnshieldedBalances(): Promise<Record<TokenType, bigint>>;
442
+ getDustBalance(): Promise<{
443
+ cap: bigint;
444
+ balance: bigint;
445
+ }>;
446
+ balanceUnsealedTransaction(tx: string, options?: {
447
+ payFees?: boolean;
448
+ }): Promise<{
449
+ tx: string;
450
+ }>;
451
+ balanceSealedTransaction(tx: string, options?: {
452
+ payFees?: boolean;
453
+ }): Promise<{
454
+ tx: string;
455
+ }>;
456
+ submitTransaction(tx: string): Promise<void>;
457
+ signData(data: string, options: SignDataOptions): Promise<Signature>;
458
+ getProvingProvider(keyMaterialProvider: KeyMaterialProvider): Promise<ProvingProvider>;
459
+ getConfiguration(): Promise<Configuration>;
460
+ getConnectionStatus(): Promise<ConnectionStatus>;
461
+ hintUsage(_methodNames: (keyof WalletConnectedAPI)[]): Promise<void>;
462
+ makeTransfer(_desiredOutputs: DesiredOutput[], _options?: {
463
+ payFees?: boolean;
464
+ }): Promise<{
465
+ tx: string;
466
+ }>;
467
+ makeIntent(_desiredInputs: DesiredInput[], _desiredOutputs: DesiredOutput[], _options: {
468
+ intentId: number | 'random';
469
+ payFees: boolean;
470
+ }): Promise<{
471
+ tx: string;
472
+ }>;
473
+ getTxHistory(_pageNumber: number, _pageSize: number): Promise<HistoryEntry[]>;
474
+ /**
475
+ * Reads a transaction a dApp handed over, at the protocol version the wallet is acting at.
476
+ *
477
+ * A refusal here says the dApp's bytes are unreadable -- authored against the other side of a protocol boundary,
478
+ * or at another stage -- not that the wallet failed. That is the connector's `InvalidRequest`, so it reaches the
479
+ * caller in the connector's own vocabulary rather than the wallet SDK's, with the refusal kept as the cause.
480
+ */
481
+ private adopt;
482
+ private signAndFinalize;
483
+ private getDefaultKeyMaterialProvider;
484
+ }
485
+
486
+ interface DustWalletOptions {
487
+ ledgerParams: LedgerParameters;
488
+ additionalFeeOverhead: bigint;
489
+ feeBlocksMargin: number;
490
+ }
491
+ declare const DEFAULT_DUST_OPTIONS: DustWalletOptions;
492
+ declare class WalletFactory {
493
+ static createShieldedWallet(config: DefaultShieldedConfiguration, seed: Uint8Array): Promise<ShieldedWalletAPI<ShieldedKeysByEpoch>>;
494
+ static createUnshieldedWallet(config: DefaultUnshieldedConfiguration, unshieldedKeystore: UnshieldedKeystore): Promise<UnshieldedWalletAPI>;
495
+ static createDustWallet(config: DefaultDustConfiguration, seed: Uint8Array, dustOptions?: DustWalletOptions): Promise<DustWalletAPI<DustKeysByEpoch>>;
496
+ static createWalletFacade(config: DefaultConfiguration, shieldedWallet: ShieldedWalletAPI<ShieldedKeysByEpoch>, unshieldedWallet: UnshieldedWalletAPI, dustWallet: DustWalletAPI<DustKeysByEpoch>): Promise<WalletFacade>;
497
+ static startWalletFacade(wallet: WalletFacade, seeds: WalletSeeds$1): Promise<WalletFacade>;
498
+ static restoreShieldedWallet(config: DefaultShieldedConfiguration, serializedState: string): Promise<ShieldedWallet>;
499
+ }
500
+
501
+ declare const TEST_MNEMONIC = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon diesel";
502
+ declare const getShieldedSeed: (seed: string) => Uint8Array;
503
+ declare const getUnshieldedSeed: (seed: string) => Uint8Array;
504
+ declare const getDustSeed: (seed: string) => Uint8Array;
505
+ declare class WalletSeeds {
506
+ readonly masterSeed: string;
507
+ readonly shielded: Uint8Array;
508
+ readonly unshielded: Uint8Array;
509
+ readonly dust: Uint8Array;
510
+ private constructor();
511
+ static fromMasterSeed(seed: string): WalletSeeds;
512
+ static generateRandom(): WalletSeeds;
513
+ static fromMnemonic(mnemonic: string): WalletSeeds;
514
+ static testWallet(): WalletSeeds;
515
+ }
516
+
517
+ declare class FluentWalletBuilder {
518
+ private readonly config;
519
+ private readonly networkId;
520
+ private seeds?;
521
+ private dustOptions;
522
+ private constructor();
523
+ static forEnvironment(envConfig: EnvironmentConfiguration): FluentWalletBuilder;
524
+ withSeed(seed: string): FluentWalletBuilder;
525
+ withRandomSeed(): FluentWalletBuilder;
526
+ withMnemonic(mnemonic: string): FluentWalletBuilder;
527
+ withTestWallet(): FluentWalletBuilder;
528
+ withDustOptions(options: DustWalletOptions): FluentWalletBuilder;
529
+ build(): Promise<WalletFacade>;
530
+ buildWithoutStarting(): Promise<{
531
+ wallet: WalletFacade;
532
+ seeds: WalletSeeds;
533
+ keystore: UnshieldedKeystore;
534
+ }>;
535
+ }
536
+
537
+ /**
538
+ * A class for compressing and decompressing files using gzip.
539
+ */
540
+ declare class GzipFile {
541
+ /** The path to the input file */
542
+ inputFile: string;
543
+ /** The path to the output file */
544
+ outputFile: string;
545
+ /**
546
+ * Creates a new GzipFile instance.
547
+ * @param inputFile - The path to the input file to compress/decompress
548
+ * @param outputFile - The path where the compressed file will be saved
549
+ */
550
+ constructor(inputFile: string, outputFile: string);
551
+ /**
552
+ * Compresses the input file using gzip compression.
553
+ * @returns A promise that resolves when compression is complete
554
+ * @throws If there is an error during compression
555
+ */
556
+ compress: () => Promise<void>;
557
+ /**
558
+ * Decompresses the input gzip file and returns its contents as a string.
559
+ * @returns A promise that resolves with the decompressed file contents as a string
560
+ * @throws If there is an error during decompression
561
+ */
562
+ decompress: () => Promise<string>;
563
+ }
564
+
565
+ /** Default directory path for storing wallet state files */
566
+ declare const DEFAULT_WALLET_STATE_DIRECTORY = "./.states";
567
+ /**
568
+ * Generates a filename for the wallet state file based on environment and optional seed
569
+ * @returns {string} Generated filename for the wallet state
570
+ * @param seed
571
+ */
572
+ declare const getWalletStateFilename: (seed: string | undefined) => string;
573
+ /**
574
+ * Provider class for saving and loading wallet state to/from compressed files
575
+ */
576
+ declare class WalletSaveStateProvider {
577
+ /** Logger instance for recording operations */
578
+ logger: Logger;
579
+ /** Absolute path to the directory containing wallet state files */
580
+ directoryPath: string;
581
+ /** Full path including filename for the wallet state file */
582
+ filePath: string;
583
+ /**
584
+ * Creates a new WalletSaveStateProvider instance
585
+ * @param {Logger} logger - Logger instance for recording operations
586
+ * @param seed
587
+ * @param {string} [directoryPath=DEFAULT_WALLET_STATE_DIRECTORY] - Directory path for wallet state files
588
+ * @param {string} [filename] - Filename for the wallet state file
589
+ */
590
+ constructor(logger: Logger, seed: string, directoryPath?: string, filename?: string);
591
+ /**
592
+ * Saves the wallet state to a compressed file
593
+ * @param {ShieldedWalletAPI | UnshieldedWalletAPI} wallet - The wallet instance to save state from
594
+ * @returns {Promise<void>} A promise that resolves when the save is complete
595
+ */
596
+ save(wallet: ShieldedWalletAPI | UnshieldedWalletAPI): Promise<void>;
597
+ /**
598
+ * Loads and decompresses the wallet state from a file
599
+ * @returns {Promise<string>} A promise that resolves with the decompressed wallet state as a string
600
+ * @throws {Error} If there is an error reading or decompressing the file
601
+ */
602
+ load(): Promise<string>;
603
+ }
604
+
605
+ declare const getInitialState: (wallet: ShieldedWalletAPI | UnshieldedWalletAPI) => Promise<ShieldedWalletState | UnshieldedWalletState>;
606
+ declare const getInitialShieldedState: (wallet: ShieldedWalletAPI) => Promise<ShieldedWalletState>;
607
+ declare const getInitialUnshieldedState: (wallet: UnshieldedWalletAPI) => Promise<UnshieldedWalletState>;
608
+ declare const syncWallet: (wallet: WalletFacade, throttleTime?: number, timeout?: number) => Promise<_midnightntwrk_wallet_sdk_facade.FacadeState>;
609
+ declare const waitForFunds: (wallet: WalletFacade, env: EnvironmentConfiguration, fundFromFaucet: boolean | undefined, unshieldedKeystore: UnshieldedKeystore) => Promise<bigint>;
610
+
611
+ /**
612
+ * Abstract base class for test environments.
613
+ * Provides common functionality for managing test wallets and environments.
614
+ */
615
+ declare abstract class TestEnvironment {
616
+ /** Logger instance for recording operations */
617
+ protected readonly logger: Logger;
618
+ /** Unique identifier for this test environment instance */
619
+ protected readonly uid: string;
620
+ /**
621
+ * Creates a new TestEnvironment instance.
622
+ * @param {Logger} logger - Logger instance for recording operations
623
+ */
624
+ constructor(logger: Logger);
625
+ /**
626
+ * Starts a single wallet instance.
627
+ * @returns {Promise<MidnightWalletProvider>} A promise that resolves to the started wallet
628
+ * @throws {Error} If no wallet could be started
629
+ */
630
+ getMidnightWalletProvider: () => Promise<MidnightWalletProvider>;
631
+ /**
632
+ * Shuts down the test environment and cleans up resources.
633
+ * @param {boolean} [saveWalletState] - Optional flag to save the wallet state before shutdown
634
+ * @returns {Promise<void>} A promise that resolves when shutdown is complete
635
+ */
636
+ abstract shutdown(saveWalletState?: boolean): Promise<void>;
637
+ /**
638
+ * Start the test environment.
639
+ *
640
+ * @param maybeProofServerContainer If defined, a container representing an already
641
+ * running proof server. If undefined, a proof server
642
+ * will be started automatically.
643
+ * @returns {Promise<EnvironmentConfiguration>} A promise that resolves to the environment configuration
644
+ */
645
+ abstract start(maybeProofServerContainer?: ProofServerContainer): Promise<EnvironmentConfiguration>;
646
+ /**
647
+ * Starts multiple wallet instances.
648
+ * @param {number} [amount] - Optional number of wallet instances to start
649
+ * @param {string[]} [seeds] - Optional array of seeds for the wallets
650
+ * @returns {Promise<MidnightWalletProvider[]>} A promise that resolves to an array of started wallets
651
+ */
652
+ abstract startMidnightWalletProviders(amount?: number, seeds?: string[]): Promise<MidnightWalletProvider[]>;
653
+ abstract getEnvironmentConfiguration(): EnvironmentConfiguration;
654
+ }
655
+
656
+ /**
657
+ * Returns the appropriate test environment based on the MN_TEST_ENVIRONMENT variable.
658
+ * @param {Logger} logger - The logger instance to be used by the test environment.
659
+ * @returns { TestEnvironment} The selected test environment instance.
660
+ */
661
+ declare const getTestEnvironment: (logger: Logger) => TestEnvironment;
662
+
663
+ /**
664
+ * Base class for remote test environments that connect to external network services.
665
+ * Provides functionality for managing walletProviders and a proof server container.
666
+ */
667
+ declare abstract class RemoteTestEnvironment extends TestEnvironment {
668
+ protected proofServerContainer: ProofServerContainer;
669
+ private environmentConfiguration;
670
+ private walletProviders;
671
+ /**
672
+ * Abstract method that must be implemented by subclasses to provide environment configuration.
673
+ * @returns {EnvironmentConfiguration} Configuration object containing service URLs and endpoints
674
+ */
675
+ abstract getEnvironmentConfiguration(): EnvironmentConfiguration;
676
+ /**
677
+ * Creates and starts the specified number of wallet providers.
678
+ * @returns {Promise<MidnightWalletProvider[]>} Array of started wallet providers
679
+ */
680
+ startMidnightWalletProviders: (amount?: number, seeds?: string[] | undefined) => Promise<MidnightWalletProvider[]>;
681
+ /**
682
+ * Shuts down the test environment by closing all walletProviders and stopping the proof server.
683
+ */
684
+ shutdown: (saveWalletState?: boolean) => Promise<void>;
685
+ /**
686
+ * Performs a health check for the environment.
687
+ * Checks the health of the node, indexer, and optionally the faucet services.
688
+ * @returns {Promise<void>} A promise that resolves when the health check is complete.
689
+ */
690
+ healthCheck: () => Promise<void>;
691
+ /**
692
+ * Starts the test environment by initializing the proof server and environment configuration.
693
+ * @param {ProofServerContainer} maybeProofServerContainer Optional proof server container to use instead of creating a new one
694
+ * @returns {Promise<EnvironmentConfiguration>} The environment configuration
695
+ */
696
+ start: (maybeProofServerContainer?: ProofServerContainer) => Promise<EnvironmentConfiguration>;
697
+ }
698
+
699
+ /**
700
+ * Test environment that configures services using environment variables.
701
+ * Allows specifying custom endpoints through environment variables.
702
+ */
703
+ declare class EnvVarRemoteTestEnvironment extends RemoteTestEnvironment {
704
+ /**
705
+ * Returns the configuration for environment services based on environment variables.
706
+ * Required environment variables:
707
+ * - MN_TEST_NETWORK_ID: Network identifier (e.g., 'testnet', 'devnet')
708
+ * - MN_TEST_INDEXER: GraphQL API endpoint for the indexer
709
+ * - MN_TEST_INDEXER_WS: WebSocket endpoint for the indexer
710
+ * - MN_TEST_NODE: RPC endpoint for the blockchain node
711
+ * Optional environment variables:
712
+ * - MN_TEST_FAUCET: API endpoint for requesting test tokens
713
+ * @returns {EnvironmentConfiguration} Object containing service URLs from environment variables
714
+ * @throws {MissingEnvironmentVariable} If any required environment variable is not set
715
+ */
716
+ getEnvironmentConfiguration(): EnvironmentConfiguration;
717
+ }
718
+
719
+ interface ForkEnactment {
720
+ /** The runtime spec version at block #1, i.e. the one genesis brought up. */
721
+ readonly oldSpecVersion: number;
722
+ /**
723
+ * The runtime spec version reported from the applying block's state onwards. Guaranteed to be
724
+ * greater than {@link ForkEnactment.oldSpecVersion}.
725
+ */
726
+ readonly newSpecVersion: number;
727
+ /** The height of the block that applied the new code; the new runtime first executes at `appliedAt + 1`. */
728
+ readonly appliedAtBlockHeight: number;
729
+ }
730
+ /**
731
+ * A chain whose genesis carries the ledger-v8 runtime, running on the ledger-v9 node binary, plus
732
+ * the governance call that moves it across the boundary.
733
+ *
734
+ * A test that wants the fork constructs this class directly -- `getTestEnvironment` never returns
735
+ * it. Why it is a sibling of the other environments rather than a mode of one, and why it runs two
736
+ * proof servers, is recorded in `docs/architecture/fork-e2e-environment.md`.
737
+ *
738
+ * Wallets are not supported here; {@link ForkTestEnvironment.startMidnightWalletProviders} refuses.
739
+ *
740
+ * @example
741
+ * ```ts
742
+ * const environment = new ForkTestEnvironment(logger);
743
+ * const preFork = await environment.start(); // chain is on the ledger-v8 runtime
744
+ * const { appliedAtBlockHeight } = await environment.enactFork(); // governance set_code, finalized past
745
+ * const postFork = environment.getEnvironmentConfiguration(); // now points at the v9 proof server
746
+ * ```
747
+ */
748
+ declare class ForkTestEnvironment extends TestEnvironment {
749
+ private dockerEnv;
750
+ private environmentConfiguration;
751
+ private forkEnactment;
752
+ private readonly composeDirectory;
753
+ private readonly composeFile;
754
+ private readonly projectName;
755
+ private readonly composeEnvironment;
756
+ constructor(logger: Logger);
757
+ /**
758
+ * The compose project this stack runs under.
759
+ *
760
+ * Exposed so a caller can drive the same project itself -- `compose run
761
+ * --profile tools toolkit ...` for a node-side reading, say -- and reach the
762
+ * node under its service name rather than through a mapped port.
763
+ */
764
+ get composeProject(): string;
765
+ /** Whether {@link ForkTestEnvironment.enactFork} has already moved this chain across the boundary. */
766
+ get hasForked(): boolean;
767
+ /**
768
+ * The current environment configuration. Its `proofServer` names the pre-fork server until
769
+ * {@link ForkTestEnvironment.enactFork} runs and the post-fork one afterwards; every other field
770
+ * is fixed for the life of the stack.
771
+ *
772
+ * @returns {EnvironmentConfiguration} The configuration for the side of the boundary the chain is on.
773
+ * @throws {Error} If the environment has not been started, or has already been shut down.
774
+ */
775
+ getEnvironmentConfiguration(): EnvironmentConfiguration;
776
+ /**
777
+ * The proof server that proves transactions built below the boundary.
778
+ *
779
+ * @returns {string} The pre-fork (ledger-8) proof server's URL.
780
+ */
781
+ getPreForkProofServer(): string;
782
+ /**
783
+ * The proof server that proves transactions built above the boundary.
784
+ *
785
+ * @returns {string} The post-fork (ledger-9) proof server's URL.
786
+ */
787
+ getPostForkProofServer(): string;
788
+ /**
789
+ * The runtime spec version at the chain's finalized head, read from the node rather than from any
790
+ * state this class holds. Lets a caller check the era against the chain itself.
791
+ *
792
+ * @returns {Promise<number>} The spec version in force at the finalized head.
793
+ */
794
+ specVersionAtFinalizedHead(): Promise<number>;
795
+ /**
796
+ * Starts the fork stack and returns its configuration on the pre-fork side of the boundary.
797
+ *
798
+ * @param {ProofServerContainer} maybeProofServerContainer - Must be nullish; present only to satisfy the base-class signature.
799
+ * @returns {Promise<EnvironmentConfiguration>} The pre-fork environment configuration.
800
+ * @throws {Error} If a proof server container is injected, since neither of this stack's two can be replaced.
801
+ * @throws {Error} If the stack has already been started, since a second start would orphan the first.
802
+ */
803
+ start: (maybeProofServerContainer?: ProofServerContainer) => Promise<EnvironmentConfiguration>;
804
+ /**
805
+ * Enacts the ledger-8 to ledger-9 fork on the running chain and waits for it to finalize past the
806
+ * applying block. From here on {@link ForkTestEnvironment.getEnvironmentConfiguration} reports the
807
+ * post-fork proof server.
808
+ *
809
+ * The toolkit runs through `docker compose run` rather than as a testcontainer so that it joins
810
+ * the project network and reaches the node under its service name.
811
+ *
812
+ * @returns {Promise<ForkEnactment>} The spec versions either side of the boundary and the applying height.
813
+ * @throws {Error} If the fork has already been enacted on this chain.
814
+ * @throws {Error} If the governance call fails, or if no finalized block reports a higher spec version in time.
815
+ * @throws {Error} If the chain does not reach or finalize past the applying block in time.
816
+ */
817
+ enactFork: () => Promise<ForkEnactment>;
818
+ /**
819
+ * Not supported on this stack. A wallet cannot sync a chain whose history spans the boundary, so
820
+ * there is nothing here for a wallet-driven test to build on and refusing beats handing back a
821
+ * provider that cannot see its own funds.
822
+ *
823
+ * @returns {Promise<MidnightWalletProvider[]>} Never resolves.
824
+ * @throws {Error} Always.
825
+ */
826
+ startMidnightWalletProviders: () => Promise<MidnightWalletProvider[]>;
827
+ /**
828
+ * Tears the stack down, volumes included, and forgets the configuration it was reporting.
829
+ *
830
+ * @returns {Promise<void>} Resolves once the stack is down.
831
+ */
832
+ /**
833
+ * Writes each stack container's logs into `directory`, one file per service, and answers with the
834
+ * paths written.
835
+ *
836
+ * For the failures the framework's own errors cannot explain. A submission the NODE rejects
837
+ * surfaces as `SubmissionError: Transaction submission error` with no reason on it, and the error
838
+ * that wraps it redacts the provider's message deliberately -- so the only account of WHY the
839
+ * chain refused is in the node's log.
840
+ *
841
+ * `docker compose logs` WITHOUT `-f`, and that is the load-bearing detail. The obvious route --
842
+ * `getContainer(...).logs()` and drain the stream to `'end'` -- FOLLOWS a running container, so
843
+ * `'end'` never arrives; awaiting it leaves the process with a pending promise, and a pending
844
+ * promise under the driver's top-level `await` ends the run with `Detected unsettled top-level
845
+ * await` and exit 13, taking the failure report with it. That was measured twice, and bounding the
846
+ * drain with a timer only traded one hang for another. A command that terminates by itself removes
847
+ * the condition instead of racing it.
848
+ *
849
+ * Must be called BEFORE {@link shutdown}, which removes the containers and their logs with them.
850
+ * Never throws: it runs on a failure path, where losing the original error to a logging problem
851
+ * would be the worse outcome. A service whose log cannot be read is reported by its absence from
852
+ * the returned list.
853
+ *
854
+ * @param directory The directory the log files are written into; created if absent.
855
+ * @returns {Promise<string[]>} The paths written, one per service whose log could be read.
856
+ */
857
+ captureContainerLogs: (directory: string) => Promise<string[]>;
858
+ shutdown: () => Promise<void>;
859
+ /** The node's JSON-RPC endpoint over HTTP, which is how this environment reads the chain. */
860
+ private getNodeHttpUrl;
861
+ private configurationFor;
862
+ private mappedPort;
863
+ /**
864
+ * Runs one node-toolkit command against this stack and returns its combined output.
865
+ *
866
+ * Through `compose run` rather than as a testcontainer, so it joins the project
867
+ * network and reaches the node under its service name. Exposed because a caller
868
+ * may need the NODE's own answer about the chain: the indexer serves the latest
869
+ * contract action at or before a block, so on questions about migrated state
870
+ * the two sources can legitimately differ and the difference is the finding.
871
+ *
872
+ * @param args The toolkit subcommand and its arguments.
873
+ * @returns stdout and stderr, concatenated.
874
+ * @throws Error, with the toolkit's stderr on `cause`, if the command fails.
875
+ */
876
+ runToolkit: (args: readonly string[]) => Promise<string>;
877
+ private runToolkitUpgrade;
878
+ }
879
+
880
+ /**
881
+ * Configuration for component ports in the local test environment
882
+ */
883
+ type ComponentPortsConfiguration = {
884
+ indexer: number;
885
+ node: number;
886
+ proofServer: number;
887
+ };
888
+ declare class LocalTestConfiguration implements EnvironmentConfiguration {
889
+ readonly walletNetworkId: NetworkId$1.NetworkId;
890
+ readonly networkId: string;
891
+ readonly indexer: string;
892
+ readonly indexerWS: string;
893
+ readonly node: string;
894
+ readonly nodeWS: string;
895
+ readonly proofServer: string;
896
+ readonly faucet: string | undefined;
897
+ /**
898
+ * Creates a new LocalTestConfiguration instance
899
+ * @param {ComponentPortsConfiguration} ports - Object containing port numbers for each component
900
+ */
901
+ constructor({ indexer, node, proofServer }: ComponentPortsConfiguration);
902
+ }
903
+ /**
904
+ * Test environment for local development using Docker containers
905
+ * Manages containers for node, indexer and proof server components
906
+ */
907
+ declare class LocalTestEnvironment extends TestEnvironment {
908
+ static readonly MAX_NUMBER_OF_WALLETS = 4;
909
+ readonly genesisMintWalletSeed: string[];
910
+ private config;
911
+ private environmentConfiguration;
912
+ dockerEnv: StartedDockerComposeEnvironment;
913
+ private walletProviders;
914
+ /**
915
+ * Creates a new LocalTestEnvironment instance
916
+ * @param {Logger} logger - Logger instance for recording operations
917
+ */
918
+ constructor(logger: Logger);
919
+ /**
920
+ * Returns the configuration for the testnet environment services.
921
+ * @returns {EnvironmentConfiguration} Object containing URLs for testnet services:
922
+ * - indexer: GraphQL API endpoint for the indexer
923
+ * - indexerWS: WebSocket endpoint for the indexer
924
+ * - node: RPC endpoint for the blockchain node
925
+ * - faucet: API endpoint for requesting test tokens
926
+ * - proofServer: URL for the proof generation server
927
+ */
928
+ getEnvironmentConfiguration(): EnvironmentConfiguration;
929
+ /**
930
+ * Gets the mapped ports for all containers in the environment
931
+ * @returns {ComponentPortsConfiguration} Object containing mapped port numbers
932
+ * @private
933
+ */
934
+ private getMappedPorts;
935
+ /**
936
+ * Instead of starting the test environment by building the docker containers
937
+ * from the default configuration files in this package, start the test environment
938
+ * by passing an existing {@link StartedDockerComposeEnvironment} along with the
939
+ * ports for the containers in the environment.
940
+ *
941
+ * @param {StartedDockerComposeEnvironment} dockerEnv - A started docker compose environment
942
+ * @param {ComponentPortsConfiguration} ports - The ports of the containers in the given environment
943
+ * @returns {Promise<EnvironmentConfiguration>} The environment configuration
944
+ */
945
+ startWithInjectedEnvironment: (dockerEnv: StartedDockerComposeEnvironment, ports: ComponentPortsConfiguration) => Promise<EnvironmentConfiguration>;
946
+ /**
947
+ * Starts the test environment by creating and configuring Docker containers
948
+ * @param {ProofServerContainer} maybeProofServerContainer - Optional proof server container
949
+ * @returns {Promise<EnvironmentConfiguration>} The environment configuration
950
+ * @throws {Error} If trying to inject proof server container when starting new environment
951
+ */
952
+ start: (maybeProofServerContainer?: ProofServerContainer) => Promise<EnvironmentConfiguration>;
953
+ /**
954
+ * Shuts down the test environment, closing walletProviders and stopping containers
955
+ * @returns {Promise<void>}
956
+ */
957
+ shutdown: (saveWalletState?: boolean) => Promise<void>;
958
+ /**
959
+ * Creates and starts the specified number of wallet providers
960
+ * @throws {Error} If requested amount exceeds maximum supported walletProviders
961
+ * @returns {Promise<MidnightWalletProvider[]>} A promise that resolves to an array of started wallets
962
+ */
963
+ startMidnightWalletProviders: (amount?: number, seeds?: string[] | undefined) => Promise<MidnightWalletProvider[]>;
964
+ }
965
+
966
+ /**
967
+ * Test environment configuration for the Midnight preprod network.
968
+ * Provides URLs and endpoints for preprod network services.
969
+ */
970
+ declare class PreprodTestEnvironment extends RemoteTestEnvironment {
971
+ /**
972
+ * Returns the configuration for the preprod environment services.
973
+ * @returns {EnvironmentConfiguration} Object containing URLs for preprod services:
974
+ * - indexer: GraphQL API endpoint for the indexer
975
+ * - indexerWS: WebSocket endpoint for the indexer
976
+ * - node: RPC endpoint for the blockchain node
977
+ * - faucet: API endpoint for requesting test tokens
978
+ * - proofServer: URL for the proof generation server
979
+ */
980
+ getEnvironmentConfiguration(): EnvironmentConfiguration;
981
+ }
982
+
983
+ /**
984
+ * Test environment configuration for the Midnight preview network.
985
+ * Provides URLs and endpoints for preview network services.
986
+ */
987
+ declare class PreviewTestEnvironment extends RemoteTestEnvironment {
988
+ /**
989
+ * Returns the configuration for the preview environment services.
990
+ * @returns {EnvironmentConfiguration} Object containing URLs for preview services:
991
+ * - indexer: GraphQL API endpoint for the indexer
992
+ * - indexerWS: WebSocket endpoint for the indexer
993
+ * - node: RPC endpoint for the blockchain node
994
+ * - faucet: API endpoint for requesting test tokens
995
+ * - proofServer: URL for the proof generation server
996
+ */
997
+ getEnvironmentConfiguration(): EnvironmentConfiguration;
998
+ }
999
+
1000
+ /**
1001
+ * Test environment configuration for the Midnight QA network.
1002
+ * Provides URLs and endpoints for QA network services.
1003
+ */
1004
+ declare class QanetTestEnvironment extends RemoteTestEnvironment {
1005
+ /**
1006
+ * Returns the configuration for the QA network environment services.
1007
+ * @returns {EnvironmentConfiguration} Object containing URLs for QA network services:
1008
+ * - indexer: GraphQL API endpoint for the indexer
1009
+ * - indexerWS: WebSocket endpoint for the indexer
1010
+ * - node: RPC endpoint for the blockchain node
1011
+ * - faucet: API endpoint for requesting test tokens
1012
+ * - proofServer: URL for the proof generation server
1013
+ */
1014
+ getEnvironmentConfiguration(): EnvironmentConfiguration;
1015
+ }
1016
+
1017
+ /**
1018
+ * Configures and returns the required providers for a Midnight contract.
1019
+ *
1020
+ * @template PCK - Type parameter for the input circuit key string
1021
+ * @template PS - Type parameter for the private state
1022
+ *
1023
+ * @param {MidnightWalletProvider} midnightWalletProvider - The midnightWalletProvider provider instance to use for transactions
1024
+ * @param {EnvironmentConfiguration} environmentConfiguration - Configuration for the environment including indexer and proof server details
1025
+ * @param {ContractConfiguration} contractConfiguration - Configuration specific to the contract including storage names and ZK config path
1026
+ *
1027
+ * @returns {MidnightProviders} An object containing all configured providers:
1028
+ * - privateStateProvider: For managing private contract state
1029
+ * - publicDataProvider: For accessing public blockchain data
1030
+ * - zkConfigProvider: For zero-knowledge proof configurations
1031
+ * - proofProvider: For generating and verifying proofs
1032
+ * - walletProvider: For midnightWalletProvider operations
1033
+ * - midnightProvider: For Midnight-specific operations
1034
+ * - config: The environment's network id and a one-hour TTL
1035
+ *
1036
+ * @throws InvalidArgumentError If `environmentConfiguration.networkId` is not a non-empty string without surrounding whitespace,
1037
+ * reported by {@link createMidnightProviders} as `providers.config.networkId`.
1038
+ */
1039
+ declare const initializeMidnightProviders: <PCK extends string, PS>(midnightWalletProvider: MidnightWalletProvider, environmentConfiguration: EnvironmentConfiguration, contractConfiguration: ContractConfiguration) => MidnightProviders<PCK, PrivateStateId, PS>;
1040
+
1041
+ declare function createLogger(fileName: string, dir?: string): pino.Logger<never, boolean>;
1042
+ declare function createDefaultTestLogger(): pino.Logger<never, boolean>;
1043
+ declare const logger: pino.Logger<never, boolean>;
1044
+
1045
+ declare const MINUTE = 60000;
1046
+ /**
1047
+ * Creates a Promise that resolves after a specified delay.
1048
+ * @param ms The delay duration in milliseconds.
1049
+ * @returns A Promise that resolves after the specified delay.
1050
+ * @example
1051
+ * // Wait for 1 second
1052
+ * await delay(1000);
1053
+ */
1054
+ declare const delay: (ms: number) => Promise<unknown>;
1055
+ /**
1056
+ * Deletes a directory and its contents recursively.
1057
+ * @param {string} dirPath - The path to the directory to delete
1058
+ * @returns {Promise<void>} A promise that resolves when the directory is deleted
1059
+ * @private
1060
+ */
1061
+ declare const tryDeleteDirectory: (dirPath: string) => Promise<void>;
1062
+ declare const buildUrlWithPath: (baseUrl: string, urlPath: string) => string;
1063
+ declare const redactUrl: (value: string) => string;
1064
+ declare const redactedJson: (value: unknown) => string;
1065
+
1066
+ export { DAppConnectorInitialAPI, DAppConnectorWalletAdapter, DEFAULT_DUST_OPTIONS, DEFAULT_WALLET_STATE_DIRECTORY, DynamicProofServerContainer, EnvVarRemoteTestEnvironment, FaucetClient, FluentWalletBuilder, ForkTestEnvironment, GzipFile, HEALTH_CHECK_TIMEOUT_MS, IndexerClient, LocalTestConfiguration, LocalTestEnvironment, MINUTE, MidnightWalletProvider, NodeClient, PreprodTestEnvironment, PreviewTestEnvironment, ProofServerClient, QanetTestEnvironment, RemoteTestEnvironment, StaticProofServerContainer, TEST_MNEMONIC, TestEnvironment, WalletFactory, WalletSaveStateProvider, WalletSeeds, buildUrlWithPath, createDefaultTestLogger, createLogger, defaultContainersConfiguration, delay, expectFoundAndDeployedStatesEqual, expectFoundAndDeployedTxDataEqual, expectFoundAndDeployedTxPrivateDataEqual, expectFoundAndDeployedTxPublicDataEqual, expectSuccessfulCallTx, expectSuccessfulDeployTx, expectSuccessfulTxData, getContainersConfiguration, getDustSeed, getInitialShieldedState, getInitialState, getInitialUnshieldedState, getShieldedSeed, getTestEnvironment, getUnshieldedSeed, getWalletStateFilename, inMemoryPrivateStateProvider, initializeMidnightProviders, latestContainersConfiguration, logger, redactUrl, redactedJson, setContainersConfiguration, stateValueEqual, syncWallet, tryDeleteDirectory, txsEqual, waitForFunds };
1067
+ export type { ComponentPortsConfiguration, ContainerEndpoints, ContainersConfiguration, ContractConfiguration, DustWalletOptions, EnvironmentConfiguration, ForkEnactment, LogConfiguration, ProofServerContainer, ProofServerContainerConfiguration, StandaloneContainerNames, StandaloneContainersConfiguration };