@midnight-ntwrk/testkit-js 3.0.0-alpha.0
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.
- package/README.md +256 -0
- package/dist/assertions.d.ts +15 -0
- package/dist/assertions.d.ts.map +1 -0
- package/dist/client/faucet-client.d.ts +30 -0
- package/dist/client/faucet-client.d.ts.map +1 -0
- package/dist/client/index.d.ts +5 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/indexer-client.d.ts +18 -0
- package/dist/client/indexer-client.d.ts.map +1 -0
- package/dist/client/node-client.d.ts +66 -0
- package/dist/client/node-client.d.ts.map +1 -0
- package/dist/client/proof-server-client.d.ts +25 -0
- package/dist/client/proof-server-client.d.ts.map +1 -0
- package/dist/configuration-types.d.ts +68 -0
- package/dist/configuration-types.d.ts.map +1 -0
- package/dist/configuration.d.ts +6 -0
- package/dist/configuration.d.ts.map +1 -0
- package/dist/contract/contract-types.d.ts +16 -0
- package/dist/contract/contract-types.d.ts.map +1 -0
- package/dist/contract/in-memory-private-state-provider.d.ts +10 -0
- package/dist/contract/in-memory-private-state-provider.d.ts.map +1 -0
- package/dist/contract/index.d.ts +4 -0
- package/dist/contract/index.d.ts.map +1 -0
- package/dist/contract/providers.d.ts +24 -0
- package/dist/contract/providers.d.ts.map +1 -0
- package/dist/env-vars.d.ts +10 -0
- package/dist/env-vars.d.ts.map +1 -0
- package/dist/errors.d.ts +11 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/index.cjs +2067 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +789 -0
- package/dist/index.d.mts +789 -0
- package/dist/index.d.ts +789 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +1993 -0
- package/dist/index.mjs.map +1 -0
- package/dist/logger.d.ts +5 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/proof-server-container.d.ts +83 -0
- package/dist/proof-server-container.d.ts.map +1 -0
- package/dist/test-environment/environment-configuration.d.ts +23 -0
- package/dist/test-environment/environment-configuration.d.ts.map +1 -0
- package/dist/test-environment/environment-provider.d.ts +9 -0
- package/dist/test-environment/environment-provider.d.ts.map +1 -0
- package/dist/test-environment/index.d.ts +4 -0
- package/dist/test-environment/index.d.ts.map +1 -0
- package/dist/test-environment/test-environments/env-var-remote-test-environment.d.ts +22 -0
- package/dist/test-environment/test-environments/env-var-remote-test-environment.d.ts.map +1 -0
- package/dist/test-environment/test-environments/index.d.ts +7 -0
- package/dist/test-environment/test-environments/index.d.ts.map +1 -0
- package/dist/test-environment/test-environments/local-test-environment.d.ts +96 -0
- package/dist/test-environment/test-environments/local-test-environment.d.ts.map +1 -0
- package/dist/test-environment/test-environments/qanet-test-environment.d.ts +19 -0
- package/dist/test-environment/test-environments/qanet-test-environment.d.ts.map +1 -0
- package/dist/test-environment/test-environments/remote-test-environment.d.ts +40 -0
- package/dist/test-environment/test-environments/remote-test-environment.d.ts.map +1 -0
- package/dist/test-environment/test-environments/test-environment.d.ts +50 -0
- package/dist/test-environment/test-environments/test-environment.d.ts.map +1 -0
- package/dist/test-environment/test-environments/testnet2-test-environment.d.ts +19 -0
- package/dist/test-environment/test-environments/testnet2-test-environment.d.ts.map +1 -0
- package/dist/utils.d.ts +19 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/wallet/bigint-serialization.d.ts +7 -0
- package/dist/wallet/bigint-serialization.d.ts.map +1 -0
- package/dist/wallet/fluent-wallet-builder.d.ts +23 -0
- package/dist/wallet/fluent-wallet-builder.d.ts.map +1 -0
- package/dist/wallet/gzip-file.d.ts +29 -0
- package/dist/wallet/gzip-file.d.ts.map +1 -0
- package/dist/wallet/index.d.ts +9 -0
- package/dist/wallet/index.d.ts.map +1 -0
- package/dist/wallet/midnight-wallet-provider.d.ts +28 -0
- package/dist/wallet/midnight-wallet-provider.d.ts.map +1 -0
- package/dist/wallet/wallet-configuration-mapper.d.ts +10 -0
- package/dist/wallet/wallet-configuration-mapper.d.ts.map +1 -0
- package/dist/wallet/wallet-factory.d.ts +21 -0
- package/dist/wallet/wallet-factory.d.ts.map +1 -0
- package/dist/wallet/wallet-seed.d.ts +13 -0
- package/dist/wallet/wallet-seed.d.ts.map +1 -0
- package/dist/wallet/wallet-state-provider.d.ts +43 -0
- package/dist/wallet/wallet-state-provider.d.ts.map +1 -0
- package/dist/wallet/wallet-utils.d.ts +11 -0
- package/dist/wallet/wallet-utils.d.ts.map +1 -0
- package/package.json +70 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,789 @@
|
|
|
1
|
+
import { Contract } from '@midnight-ntwrk/compact-js';
|
|
2
|
+
import { StateValue, ContractAddress } from '@midnight-ntwrk/compact-runtime';
|
|
3
|
+
import { Signaturish, Proofish, Bindingish, Transaction, ContractState, LedgerState, ZswapSecretKeys, DustSecretKey, CoinPublicKey, EncPublicKey, ShieldedCoinInfo, FinalizedTransaction, TokenType, LedgerParameters } from '@midnight-ntwrk/ledger-v7';
|
|
4
|
+
import { FinalizedDeployTxData, FinalizedDeployTxDataBase, DeployContractOptions, DeployTxOptions, FinalizedCallTxData, CallTxOptions } from '@midnight-ntwrk/midnight-js-contracts';
|
|
5
|
+
import { MidnightProviders, PrivateStateId, FinalizedTxData, BlockHash, PrivateStateProvider, MidnightProvider, WalletProvider, UnboundTransaction } from '@midnight-ntwrk/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 { EnvironmentConfiguration as EnvironmentConfiguration$1 } from '@/test-environment';
|
|
11
|
+
import { MidnightWalletProvider as MidnightWalletProvider$1 } from '@/wallet';
|
|
12
|
+
import { NetworkId } from '@midnight-ntwrk/wallet-sdk-abstractions';
|
|
13
|
+
import { TestEnvironment as TestEnvironment$1 } from '@/test-environment/test-environments/test-environment';
|
|
14
|
+
import { ProofServerContainer as ProofServerContainer$1 } from '@/proof-server-container';
|
|
15
|
+
import * as _midnight_ntwrk_wallet_sdk_facade from '@midnight-ntwrk/wallet-sdk-facade';
|
|
16
|
+
import { WalletFacade } from '@midnight-ntwrk/wallet-sdk-facade';
|
|
17
|
+
import { UnshieldedKeystore, UnshieldedWallet, UnshieldedWalletState } from '@midnight-ntwrk/wallet-sdk-unshielded-wallet';
|
|
18
|
+
import { EnvironmentConfiguration as EnvironmentConfiguration$2 } from '@/test-environment/environment-configuration';
|
|
19
|
+
import { DustWalletOptions as DustWalletOptions$1 } from '@/wallet/wallet-factory';
|
|
20
|
+
import { WalletSeeds as WalletSeeds$1 } from '@/wallet/wallet-seed';
|
|
21
|
+
import { EnvironmentConfiguration as EnvironmentConfiguration$3 } from '@/index';
|
|
22
|
+
import { DustWallet } from '@midnight-ntwrk/wallet-sdk-dust-wallet';
|
|
23
|
+
import { ShieldedWallet, ShieldedWalletState } from '@midnight-ntwrk/wallet-sdk-shielded';
|
|
24
|
+
import { DefaultV1Configuration } from '@midnight-ntwrk/wallet-sdk-shielded/v1';
|
|
25
|
+
|
|
26
|
+
declare const stateValueEqual: (a: StateValue, b: StateValue) => boolean;
|
|
27
|
+
declare const txsEqual: <S extends Signaturish, P extends Proofish, B extends Bindingish>(a: Transaction<S, P, B>, b: Transaction<S, P, B>) => boolean;
|
|
28
|
+
declare const expectFoundAndDeployedTxPublicDataEqual: <C extends Contract.Any>(deployTxData: FinalizedDeployTxData<C>, foundDeployTxData: FinalizedDeployTxDataBase<C>) => void;
|
|
29
|
+
declare const expectFoundAndDeployedTxPrivateDataEqual: <C extends Contract.Any>(deployTxData: FinalizedDeployTxData<C>, foundDeployTxData: FinalizedDeployTxDataBase<C>) => void;
|
|
30
|
+
declare const expectFoundAndDeployedTxDataEqual: <C extends Contract.Any>(deployTxData: FinalizedDeployTxData<C>, foundDeployTxData: FinalizedDeployTxDataBase<C>) => void;
|
|
31
|
+
declare const expectFoundAndDeployedStatesEqual: <C extends Contract.Any>(providers: MidnightProviders<Contract.ImpureCircuitId<C>, PrivateStateId, Contract.PrivateState<C> | unknown>, deployTxData: FinalizedDeployTxData<C>, foundDeployTxData: FinalizedDeployTxDataBase<C>, privateStateId?: PrivateStateId, initialPrivateState?: Contract.PrivateState<C>) => Promise<void>;
|
|
32
|
+
declare const expectSuccessfulTxData: (finalizedTxData: FinalizedTxData) => void;
|
|
33
|
+
declare const expectSuccessfulDeployTx: <C extends Contract.Any>(providers: MidnightProviders<Contract.ImpureCircuitId<C>, PrivateStateId, Contract.PrivateState<C> | unknown>, deployTxData: FinalizedDeployTxData<C>, deployTxOptions?: DeployContractOptions<C> | DeployTxOptions<C>) => Promise<void>;
|
|
34
|
+
declare const expectSuccessfulCallTx: <C extends Contract.Any, ICK extends Contract.ImpureCircuitId<C>>(providers: MidnightProviders<Contract.ImpureCircuitId<C>, PrivateStateId, Contract.PrivateState<C> | unknown>, callTxData: FinalizedCallTxData<C, ICK>, callTxOptions?: CallTxOptions<C, ICK>, nextPrivateState?: Contract.PrivateState<C>) => Promise<void>;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Client for interacting with the Midnight faucet service.
|
|
38
|
+
* Provides functionality to request test tokens for wallet addresses.
|
|
39
|
+
*/
|
|
40
|
+
declare class FaucetClient {
|
|
41
|
+
readonly faucetUrl: string;
|
|
42
|
+
private logger;
|
|
43
|
+
/**
|
|
44
|
+
* Creates a new FaucetClient instance.
|
|
45
|
+
* @param {string} faucetUrl - The URL of the faucet service endpoint
|
|
46
|
+
* @param {Logger} logger - Logger instance for recording operations
|
|
47
|
+
*/
|
|
48
|
+
constructor(faucetUrl: string, logger: Logger);
|
|
49
|
+
/**
|
|
50
|
+
* Checks the health status of the faucet service.
|
|
51
|
+
* Makes a GET request to the health endpoint of the faucet service.
|
|
52
|
+
* @returns {Promise<AxiosResponse | void>} A promise that resolves to the response of the health check or logs an error if the request fails
|
|
53
|
+
*/
|
|
54
|
+
health(): Promise<void | axios.AxiosResponse<any, any, {}>>;
|
|
55
|
+
/**
|
|
56
|
+
* Requests test tokens from the faucet for a specified wallet address.
|
|
57
|
+
* Makes a POST request to the faucet service with the wallet address.
|
|
58
|
+
* @param {string} walletAddress - The address to receive the test tokens
|
|
59
|
+
* @returns {Promise<void>} A promise that resolves when the request is complete
|
|
60
|
+
* @throws Will log but not throw if the request fails
|
|
61
|
+
*/
|
|
62
|
+
requestTokens(walletAddress: string): Promise<void>;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
declare class IndexerClient {
|
|
66
|
+
readonly indexerUrl: string;
|
|
67
|
+
private logger;
|
|
68
|
+
/**
|
|
69
|
+
* Creates an instance of IndexerClient.
|
|
70
|
+
* @param {string} indexerUrl - The URL of the indexer service.
|
|
71
|
+
* @param {Logger} logger - The logger instance for logging information.
|
|
72
|
+
*/
|
|
73
|
+
constructor(indexerUrl: string, logger: Logger);
|
|
74
|
+
/**
|
|
75
|
+
* Checks the health status of the indexer service.
|
|
76
|
+
* Makes a GET request to the status endpoint of the indexer service.
|
|
77
|
+
* @returns {Promise<AxiosResponse | void>} A promise that resolves to the response of the health check or logs an error if the request fails.
|
|
78
|
+
*/
|
|
79
|
+
health(): Promise<void | axios.AxiosResponse<any, any, {}>>;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Client for interacting with a Midnight node's JSON-RPC API
|
|
84
|
+
*/
|
|
85
|
+
declare class NodeClient {
|
|
86
|
+
readonly nodeURL: string;
|
|
87
|
+
private logger;
|
|
88
|
+
/**
|
|
89
|
+
* Creates a new NodeClient instance
|
|
90
|
+
* @param {string} nodeURL - URL of the Midnight node
|
|
91
|
+
* @param {Logger} logger - Logger instance for recording operations
|
|
92
|
+
*/
|
|
93
|
+
constructor(nodeURL: string, logger: Logger);
|
|
94
|
+
/**
|
|
95
|
+
* Checks the health status of the node.
|
|
96
|
+
* Makes a GET request to the health endpoint of the node.
|
|
97
|
+
* @returns {Promise<AxiosResponse | void>} A promise that resolves to the response of the health check or logs an error if the request fails.
|
|
98
|
+
*/
|
|
99
|
+
health(): Promise<void | AxiosResponse<any, any, {}>>;
|
|
100
|
+
/**
|
|
101
|
+
* Validates response format and throws if unexpected
|
|
102
|
+
* @param {AxiosResponse} response - Response from node API
|
|
103
|
+
* @throws {Error} If response format is unexpected
|
|
104
|
+
* @private
|
|
105
|
+
*/
|
|
106
|
+
private static throwOnUnexpected;
|
|
107
|
+
/**
|
|
108
|
+
* Makes a JSON-RPC request to the node
|
|
109
|
+
* @param {string} method - RPC method name
|
|
110
|
+
* @param {any[]} params - RPC method parameters
|
|
111
|
+
* @returns {Promise<string>} Response result as string
|
|
112
|
+
* @private
|
|
113
|
+
*/
|
|
114
|
+
private jsonRPC;
|
|
115
|
+
/**
|
|
116
|
+
* Fetches the state of a contract
|
|
117
|
+
* @param {ContractAddress} contractAddress - Address of the contract
|
|
118
|
+
* @returns {Promise<ContractState | null>} Contract state or null if not found
|
|
119
|
+
*/
|
|
120
|
+
contractState(contractAddress: ContractAddress): Promise<ContractState | null>;
|
|
121
|
+
/**
|
|
122
|
+
* Fetches the ledger state at a given block
|
|
123
|
+
* @param {BlockHash} blockHash - Hash of the block
|
|
124
|
+
* @returns {Promise<LedgerState>} Ledger state
|
|
125
|
+
*/
|
|
126
|
+
ledgerState(blockHash: BlockHash): Promise<LedgerState>;
|
|
127
|
+
/**
|
|
128
|
+
* Fetches the raw ledger state blob at a given block
|
|
129
|
+
* @param {BlockHash} blockHash - Hash of the block
|
|
130
|
+
* @returns {Promise<Uint8Array>} Raw ledger state data
|
|
131
|
+
* @throws {Error} If no ledger state is found
|
|
132
|
+
*/
|
|
133
|
+
ledgerStateBlob(blockHash: BlockHash): Promise<Uint8Array>;
|
|
134
|
+
/**
|
|
135
|
+
* Fetches the ledger version at a given block
|
|
136
|
+
* @param {BlockHash} blockHash - Hash of the block
|
|
137
|
+
* @returns {Promise<string>} Ledger version
|
|
138
|
+
* @throws {Error} If no ledger version is found
|
|
139
|
+
*/
|
|
140
|
+
ledgerVersion(blockHash: BlockHash): Promise<string>;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
declare class ProofServerClient {
|
|
144
|
+
readonly proofServer: string;
|
|
145
|
+
private logger;
|
|
146
|
+
/**
|
|
147
|
+
* Creates an instance of ProofServerClient.
|
|
148
|
+
* @param {string} proofServer - The URL of the proof server service.
|
|
149
|
+
* @param {Logger} logger - The logger instance for logging information.
|
|
150
|
+
*/
|
|
151
|
+
constructor(proofServer: string, logger: Logger);
|
|
152
|
+
/**
|
|
153
|
+
* Checks the health status of the indexer service.
|
|
154
|
+
* Makes a GET request to the status endpoint of the indexer service.
|
|
155
|
+
* @returns {Promise<AxiosResponse | void>} A promise that resolves to the response of the health check or logs an error if the request fails.
|
|
156
|
+
*/
|
|
157
|
+
health(): Promise<void | axios.AxiosResponse<any, any, {}>>;
|
|
158
|
+
/**
|
|
159
|
+
* Proves a transaction by sending a POST request to the proof server.
|
|
160
|
+
* @param data serialized transaction data
|
|
161
|
+
* @param config Axios request configuration
|
|
162
|
+
*/
|
|
163
|
+
proveTx(data?: ArrayBuffer, config?: AxiosRequestConfig): Promise<void | axios.AxiosResponse<any, any, {}>>;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Configuration for a proof server container instance
|
|
168
|
+
*/
|
|
169
|
+
interface ProofServerContainerConfiguration {
|
|
170
|
+
/** Directory path where container configuration is located */
|
|
171
|
+
path: string;
|
|
172
|
+
/** Name of the container configuration file */
|
|
173
|
+
fileName: string;
|
|
174
|
+
/** Network endpoint configuration for the container */
|
|
175
|
+
container: ContainerEndpoints;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Network endpoint configuration for a container
|
|
179
|
+
*/
|
|
180
|
+
interface ContainerEndpoints {
|
|
181
|
+
/** Name of the container */
|
|
182
|
+
name: string;
|
|
183
|
+
/** Port number the container listens on */
|
|
184
|
+
port: number;
|
|
185
|
+
/** TestContainers WaitStrategy to use for container start */
|
|
186
|
+
waitStrategy: WaitStrategy;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Container endpoint configurations for standalone mode services
|
|
190
|
+
*/
|
|
191
|
+
interface StandaloneContainerNames {
|
|
192
|
+
/** Proof server container configuration */
|
|
193
|
+
proofServer: ContainerEndpoints;
|
|
194
|
+
/** Blockchain node container configuration */
|
|
195
|
+
node: ContainerEndpoints;
|
|
196
|
+
/** Indexer service container configuration */
|
|
197
|
+
indexer: ContainerEndpoints;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Configuration for standalone mode containers
|
|
201
|
+
*/
|
|
202
|
+
interface StandaloneContainersConfiguration {
|
|
203
|
+
/** Directory path where container configuration is located */
|
|
204
|
+
path: string;
|
|
205
|
+
/** Name of the container configuration file */
|
|
206
|
+
fileName: string;
|
|
207
|
+
/** Container endpoint configurations */
|
|
208
|
+
container: StandaloneContainerNames;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Configuration for test logging
|
|
212
|
+
*/
|
|
213
|
+
interface LogConfiguration {
|
|
214
|
+
/** Directory path where log files will be written */
|
|
215
|
+
path: string;
|
|
216
|
+
/** Name of the log file */
|
|
217
|
+
fileName: string;
|
|
218
|
+
/** Log level (e.g. 'info', 'debug', etc) */
|
|
219
|
+
level: string;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Top-level configuration for all test containers
|
|
223
|
+
*/
|
|
224
|
+
interface ContainersConfiguration {
|
|
225
|
+
/** Proof server container configuration */
|
|
226
|
+
proofServer: ProofServerContainerConfiguration;
|
|
227
|
+
/** Standalone mode containers configuration */
|
|
228
|
+
standalone: StandaloneContainersConfiguration;
|
|
229
|
+
/** Logging configuration */
|
|
230
|
+
log: LogConfiguration;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
declare const defaultContainersConfiguration: ContainersConfiguration;
|
|
234
|
+
declare const latestContainersConfiguration: ContainersConfiguration;
|
|
235
|
+
declare const getContainersConfiguration: () => ContainersConfiguration;
|
|
236
|
+
declare const setContainersConfiguration: (containersConfig: ContainersConfiguration) => void;
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Configuration interface for Midnight contracts.
|
|
240
|
+
*/
|
|
241
|
+
interface ContractConfiguration {
|
|
242
|
+
/**
|
|
243
|
+
* Name of the store used for persisting private state data.
|
|
244
|
+
* This is used as a base name - a signing key store will also be created with "-signing-keys" appended.
|
|
245
|
+
*/
|
|
246
|
+
readonly privateStateStoreName: string;
|
|
247
|
+
/**
|
|
248
|
+
* File system path to the zero-knowledge proof configuration files.
|
|
249
|
+
* This should point to the directory containing the circuit verification keys and other ZK artifacts.
|
|
250
|
+
*/
|
|
251
|
+
readonly zkConfigPath: string;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* A simple in-memory implementation of private state provider. Makes it easy to capture and rewrite private state from deploy.
|
|
256
|
+
* @template PSI - Type of the private state identifier.
|
|
257
|
+
* @template PS - Type of the private state.
|
|
258
|
+
* @returns {PrivateStateProvider<PSI, PS>} An in-memory private state provider.
|
|
259
|
+
*/
|
|
260
|
+
declare const inMemoryPrivateStateProvider: <PSI extends PrivateStateId, PS extends Contract.PrivateState<Contract.Any>>() => PrivateStateProvider<PSI, PS>;
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Configures and returns the required providers for a Midnight contract.
|
|
264
|
+
*
|
|
265
|
+
* @template ICK - Type parameter for the input circuit key string
|
|
266
|
+
* @template PS - Type parameter for the private state
|
|
267
|
+
*
|
|
268
|
+
* @param {MidnightWalletProvider} midnightWalletProvider - The midnightWalletProvider provider instance to use for transactions
|
|
269
|
+
* @param {EnvironmentConfiguration} environmentConfiguration - Configuration for the environment including indexer and proof server details
|
|
270
|
+
* @param {ContractConfiguration} contractConfiguration - Configuration specific to the contract including storage names and ZK config path
|
|
271
|
+
*
|
|
272
|
+
* @returns {MidnightProviders} An object containing all configured providers:
|
|
273
|
+
* - privateStateProvider: For managing private contract state
|
|
274
|
+
* - publicDataProvider: For accessing public blockchain data
|
|
275
|
+
* - zkConfigProvider: For zero-knowledge proof configurations
|
|
276
|
+
* - proofProvider: For generating and verifying proofs
|
|
277
|
+
* - walletProvider: For midnightWalletProvider operations
|
|
278
|
+
* - midnightProvider: For Midnight-specific operations
|
|
279
|
+
*/
|
|
280
|
+
declare const initializeMidnightProviders: <ICK extends string, PS>(midnightWalletProvider: MidnightWalletProvider$1, environmentConfiguration: EnvironmentConfiguration$1, contractConfiguration: ContractConfiguration) => MidnightProviders<ICK, PrivateStateId, PS>;
|
|
281
|
+
|
|
282
|
+
declare function createLogger(fileName: string, dir?: string): pino.Logger<never, boolean>;
|
|
283
|
+
declare function createDefaultTestLogger(): pino.Logger<never, boolean>;
|
|
284
|
+
declare const logger: pino.Logger<never, boolean>;
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Interface representing a proof server container that can be started and stopped.
|
|
288
|
+
*/
|
|
289
|
+
interface ProofServerContainer {
|
|
290
|
+
/**
|
|
291
|
+
* Stops the proof server container.
|
|
292
|
+
* @returns {Promise<void>} A promise that resolves when the container is stopped
|
|
293
|
+
*/
|
|
294
|
+
stop(): Promise<void>;
|
|
295
|
+
/**
|
|
296
|
+
* Gets the URL where the proof server can be accessed.
|
|
297
|
+
* @returns {string} The URL of the proof server
|
|
298
|
+
*/
|
|
299
|
+
getUrl(): string;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* A proof server container that is started and stopped dynamically by the test
|
|
303
|
+
* suite on random port.
|
|
304
|
+
*/
|
|
305
|
+
declare class DynamicProofServerContainer implements ProofServerContainer {
|
|
306
|
+
/** The Docker Compose environment running the container */
|
|
307
|
+
dockerEnv: StartedDockerComposeEnvironment;
|
|
308
|
+
/** Unique identifier for the container instance */
|
|
309
|
+
private uid;
|
|
310
|
+
/** Configuration for the proof server container */
|
|
311
|
+
private config;
|
|
312
|
+
/**
|
|
313
|
+
* Creates a new DynamicProofServerContainer instance.
|
|
314
|
+
* @param {StartedDockerComposeEnvironment} dockerEnv - The started Docker Compose environment
|
|
315
|
+
* @param {string} uid - Unique identifier for the container
|
|
316
|
+
* @private
|
|
317
|
+
*/
|
|
318
|
+
private constructor();
|
|
319
|
+
/**
|
|
320
|
+
* Starts a new proof server container.
|
|
321
|
+
* @param {Logger} logger - Logger instance for recording operations
|
|
322
|
+
* @param {string} [maybeUID] - Optional unique identifier for the container
|
|
323
|
+
* @param {string} [maybeNetworkId] - Optional network ID for the container
|
|
324
|
+
* @returns {Promise<DynamicProofServerContainer>} A promise that resolves to the new container instance
|
|
325
|
+
*/
|
|
326
|
+
static start(logger: Logger, maybeUID?: string, maybeNetworkId?: string): Promise<DynamicProofServerContainer>;
|
|
327
|
+
/**
|
|
328
|
+
* Stops the proof server container.
|
|
329
|
+
* @returns {Promise<void>} A promise that resolves when the container is stopped
|
|
330
|
+
*/
|
|
331
|
+
stop(): Promise<void>;
|
|
332
|
+
/**
|
|
333
|
+
* Gets the mapped port number for the container.
|
|
334
|
+
* @returns {number} The mapped port number
|
|
335
|
+
*/
|
|
336
|
+
getMappedPort(): number;
|
|
337
|
+
/**
|
|
338
|
+
* Gets the URL where the proof server can be accessed.
|
|
339
|
+
* @returns {string} The URL of the proof server
|
|
340
|
+
*/
|
|
341
|
+
getUrl(): string;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* A proof server that is currently running on a specific port.
|
|
345
|
+
* Used for connecting to an existing proof server instance.
|
|
346
|
+
*/
|
|
347
|
+
declare class StaticProofServerContainer implements ProofServerContainer {
|
|
348
|
+
/** The port number where the proof server is running */
|
|
349
|
+
port: number;
|
|
350
|
+
/**
|
|
351
|
+
* Creates a new StaticProofServerContainer instance.
|
|
352
|
+
* @param {number} port - The port number where the proof server is running (default: 6300)
|
|
353
|
+
*/
|
|
354
|
+
constructor(port?: number);
|
|
355
|
+
/**
|
|
356
|
+
* Gets the URL where the proof server can be accessed.
|
|
357
|
+
* @returns {string} The URL of the proof server
|
|
358
|
+
*/
|
|
359
|
+
getUrl(): string;
|
|
360
|
+
/**
|
|
361
|
+
* No-op stop method since this represents an external proof server.
|
|
362
|
+
* @returns {Promise<void>} A resolved promise
|
|
363
|
+
*/
|
|
364
|
+
stop(): Promise<void>;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Configuration interface for the test environment services
|
|
369
|
+
*/
|
|
370
|
+
interface EnvironmentConfiguration {
|
|
371
|
+
/** Wallet Network identifier */
|
|
372
|
+
readonly walletNetworkId: NetworkId.NetworkId;
|
|
373
|
+
/** Network identifier */
|
|
374
|
+
readonly networkId: string;
|
|
375
|
+
/** URL of the indexer HTTP endpoint */
|
|
376
|
+
readonly indexer: string;
|
|
377
|
+
/** WebSocket URL for the indexer service */
|
|
378
|
+
readonly indexerWS: string;
|
|
379
|
+
/** URL of the blockchain node */
|
|
380
|
+
readonly node: string;
|
|
381
|
+
/** WebSocket URL for the blockchain node */
|
|
382
|
+
readonly nodeWS: string;
|
|
383
|
+
/** URL of the proof generation server */
|
|
384
|
+
readonly proofServer: string;
|
|
385
|
+
/** Optional URL for the faucet service to obtain test tokens */
|
|
386
|
+
readonly faucet: string | undefined;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Returns the appropriate test environment based on the MN_TEST_ENVIRONMENT variable.
|
|
391
|
+
* @param {Logger} logger - The logger instance to be used by the test environment.
|
|
392
|
+
* @returns { TestEnvironment} The selected test environment instance.
|
|
393
|
+
*/
|
|
394
|
+
declare const getTestEnvironment: (logger: Logger) => TestEnvironment$1;
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Abstract base class for test environments.
|
|
398
|
+
* Provides common functionality for managing test wallets and environments.
|
|
399
|
+
*/
|
|
400
|
+
declare abstract class TestEnvironment {
|
|
401
|
+
/** Logger instance for recording operations */
|
|
402
|
+
protected readonly logger: Logger;
|
|
403
|
+
/** Unique identifier for this test environment instance */
|
|
404
|
+
protected readonly uid: string;
|
|
405
|
+
protected readonly envConfiguration: EnvironmentConfiguration;
|
|
406
|
+
/**
|
|
407
|
+
* Creates a new TestEnvironment instance.
|
|
408
|
+
* @param {Logger} logger - Logger instance for recording operations
|
|
409
|
+
*/
|
|
410
|
+
constructor(logger: Logger);
|
|
411
|
+
/**
|
|
412
|
+
* Starts a single wallet instance.
|
|
413
|
+
* @returns {Promise<MidnightWalletProvider>} A promise that resolves to the started wallet
|
|
414
|
+
* @throws {Error} If no wallet could be started
|
|
415
|
+
*/
|
|
416
|
+
getMidnightWalletProvider: () => Promise<MidnightWalletProvider$1>;
|
|
417
|
+
/**
|
|
418
|
+
* Shuts down the test environment and cleans up resources.
|
|
419
|
+
* @param {boolean} [saveWalletState] - Optional flag to save the wallet state before shutdown
|
|
420
|
+
* @returns {Promise<void>} A promise that resolves when shutdown is complete
|
|
421
|
+
*/
|
|
422
|
+
abstract shutdown(saveWalletState?: boolean): Promise<void>;
|
|
423
|
+
/**
|
|
424
|
+
* Start the test environment.
|
|
425
|
+
*
|
|
426
|
+
* @param maybeProofServerContainer If defined, a container representing an already
|
|
427
|
+
* running proof server. If undefined, a proof server
|
|
428
|
+
* will be started automatically.
|
|
429
|
+
* @returns {Promise<EnvironmentConfiguration>} A promise that resolves to the environment configuration
|
|
430
|
+
*/
|
|
431
|
+
abstract start(maybeProofServerContainer?: ProofServerContainer$1): Promise<EnvironmentConfiguration>;
|
|
432
|
+
/**
|
|
433
|
+
* Starts multiple wallet instances.
|
|
434
|
+
* @param {number} [amount] - Optional number of wallet instances to start
|
|
435
|
+
* @param {string[]} [seeds] - Optional array of seeds for the wallets
|
|
436
|
+
* @returns {Promise<MidnightWalletProvider[]>} A promise that resolves to an array of started wallets
|
|
437
|
+
*/
|
|
438
|
+
abstract startMidnightWalletProviders(amount?: number, seeds?: string[]): Promise<MidnightWalletProvider$1[]>;
|
|
439
|
+
abstract getEnvironmentConfiguration(): EnvironmentConfiguration;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Base class for remote test environments that connect to external network services.
|
|
444
|
+
* Provides functionality for managing walletProviders and a proof server container.
|
|
445
|
+
*/
|
|
446
|
+
declare abstract class RemoteTestEnvironment extends TestEnvironment {
|
|
447
|
+
protected proofServerContainer: ProofServerContainer$1;
|
|
448
|
+
private environmentConfiguration;
|
|
449
|
+
private walletProviders;
|
|
450
|
+
/**
|
|
451
|
+
* Abstract method that must be implemented by subclasses to provide environment configuration.
|
|
452
|
+
* @returns {EnvironmentConfiguration} Configuration object containing service URLs and endpoints
|
|
453
|
+
*/
|
|
454
|
+
abstract getEnvironmentConfiguration(): EnvironmentConfiguration$1;
|
|
455
|
+
/**
|
|
456
|
+
* Creates and starts the specified number of wallet providers.
|
|
457
|
+
* @returns {Promise<MidnightWalletProvider[]>} Array of started wallet providers
|
|
458
|
+
*/
|
|
459
|
+
startMidnightWalletProviders: (amount?: number, seeds?: string[] | undefined) => Promise<MidnightWalletProvider$1[]>;
|
|
460
|
+
/**
|
|
461
|
+
* Shuts down the test environment by closing all walletProviders and stopping the proof server.
|
|
462
|
+
*/
|
|
463
|
+
shutdown: (saveWalletState?: boolean) => Promise<void>;
|
|
464
|
+
/**
|
|
465
|
+
* Performs a health check for the environment.
|
|
466
|
+
* Checks the health of the node, indexer, and optionally the faucet services.
|
|
467
|
+
* @returns {Promise<void>} A promise that resolves when the health check is complete.
|
|
468
|
+
*/
|
|
469
|
+
healthCheck: () => Promise<void>;
|
|
470
|
+
/**
|
|
471
|
+
* Starts the test environment by initializing the proof server and environment configuration.
|
|
472
|
+
* @param {ProofServerContainer} maybeProofServerContainer Optional proof server container to use instead of creating a new one
|
|
473
|
+
* @returns {Promise<EnvironmentConfiguration>} The environment configuration
|
|
474
|
+
*/
|
|
475
|
+
start: (maybeProofServerContainer?: ProofServerContainer$1) => Promise<EnvironmentConfiguration$1>;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Test environment that configures services using environment variables.
|
|
480
|
+
* Allows specifying custom endpoints through environment variables.
|
|
481
|
+
*/
|
|
482
|
+
declare class EnvVarRemoteTestEnvironment extends RemoteTestEnvironment {
|
|
483
|
+
/**
|
|
484
|
+
* Returns the configuration for environment services based on environment variables.
|
|
485
|
+
* Required environment variables:
|
|
486
|
+
* - MN_TEST_NETWORK_ID: Network identifier (e.g., 'testnet', 'devnet')
|
|
487
|
+
* - MN_TEST_INDEXER: GraphQL API endpoint for the indexer
|
|
488
|
+
* - MN_TEST_INDEXER_WS: WebSocket endpoint for the indexer
|
|
489
|
+
* - MN_TEST_NODE: RPC endpoint for the blockchain node
|
|
490
|
+
* Optional environment variables:
|
|
491
|
+
* - MN_TEST_FAUCET: API endpoint for requesting test tokens
|
|
492
|
+
* @returns {EnvironmentConfiguration} Object containing service URLs from environment variables
|
|
493
|
+
* @throws {MissingEnvironmentVariable} If any required environment variable is not set
|
|
494
|
+
*/
|
|
495
|
+
getEnvironmentConfiguration(): EnvironmentConfiguration$1;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Configuration for component ports in the local test environment
|
|
500
|
+
*/
|
|
501
|
+
type ComponentPortsConfiguration = {
|
|
502
|
+
indexer: number;
|
|
503
|
+
node: number;
|
|
504
|
+
proofServer: number;
|
|
505
|
+
};
|
|
506
|
+
/**
|
|
507
|
+
* Configuration class for local test environment implementing EnvironmentConfiguration
|
|
508
|
+
*/
|
|
509
|
+
declare class LocalTestConfiguration implements EnvironmentConfiguration$1 {
|
|
510
|
+
readonly walletNetworkId: NetworkId.NetworkId;
|
|
511
|
+
readonly networkId: string;
|
|
512
|
+
readonly indexer: string;
|
|
513
|
+
readonly indexerWS: string;
|
|
514
|
+
readonly node: string;
|
|
515
|
+
readonly nodeWS: string;
|
|
516
|
+
readonly proofServer: string;
|
|
517
|
+
readonly faucet: string | undefined;
|
|
518
|
+
/**
|
|
519
|
+
* Creates a new LocalTestConfiguration instance
|
|
520
|
+
* @param {ComponentPortsConfiguration} ports - Object containing port numbers for each component
|
|
521
|
+
*/
|
|
522
|
+
constructor({ indexer, node, proofServer }: ComponentPortsConfiguration);
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Test environment for local development using Docker containers
|
|
526
|
+
* Manages containers for node, indexer and proof server components
|
|
527
|
+
*/
|
|
528
|
+
declare class LocalTestEnvironment extends TestEnvironment {
|
|
529
|
+
static readonly MAX_NUMBER_OF_WALLETS = 4;
|
|
530
|
+
readonly genesisMintWalletSeed: string[];
|
|
531
|
+
private config;
|
|
532
|
+
private environmentConfiguration;
|
|
533
|
+
dockerEnv: StartedDockerComposeEnvironment;
|
|
534
|
+
private walletProviders;
|
|
535
|
+
/**
|
|
536
|
+
* Creates a new LocalTestEnvironment instance
|
|
537
|
+
* @param {Logger} logger - Logger instance for recording operations
|
|
538
|
+
*/
|
|
539
|
+
constructor(logger: Logger);
|
|
540
|
+
/**
|
|
541
|
+
* Returns the configuration for the testnet environment services.
|
|
542
|
+
* @returns {EnvironmentConfiguration} Object containing URLs for testnet services:
|
|
543
|
+
* - indexer: GraphQL API endpoint for the indexer
|
|
544
|
+
* - indexerWS: WebSocket endpoint for the indexer
|
|
545
|
+
* - node: RPC endpoint for the blockchain node
|
|
546
|
+
* - faucet: API endpoint for requesting test tokens
|
|
547
|
+
* - proofServer: URL for the proof generation server
|
|
548
|
+
*/
|
|
549
|
+
getEnvironmentConfiguration(): EnvironmentConfiguration$1;
|
|
550
|
+
/**
|
|
551
|
+
* Gets the mapped ports for all containers in the environment
|
|
552
|
+
* @returns {ComponentPortsConfiguration} Object containing mapped port numbers
|
|
553
|
+
* @private
|
|
554
|
+
*/
|
|
555
|
+
private getMappedPorts;
|
|
556
|
+
/**
|
|
557
|
+
* Instead of starting the test environment by building the docker containers
|
|
558
|
+
* from the default configuration files in this package, start the test environment
|
|
559
|
+
* by passing an existing {@link StartedDockerComposeEnvironment} along with the
|
|
560
|
+
* ports for the containers in the environment.
|
|
561
|
+
*
|
|
562
|
+
* @param {StartedDockerComposeEnvironment} dockerEnv - A started docker compose environment
|
|
563
|
+
* @param {ComponentPortsConfiguration} ports - The ports of the containers in the given environment
|
|
564
|
+
* @returns {Promise<EnvironmentConfiguration>} The environment configuration
|
|
565
|
+
*/
|
|
566
|
+
startWithInjectedEnvironment: (dockerEnv: StartedDockerComposeEnvironment, ports: ComponentPortsConfiguration) => Promise<EnvironmentConfiguration$1>;
|
|
567
|
+
/**
|
|
568
|
+
* Starts the test environment by creating and configuring Docker containers
|
|
569
|
+
* @param {ProofServerContainer} maybeProofServerContainer - Optional proof server container
|
|
570
|
+
* @returns {Promise<EnvironmentConfiguration>} The environment configuration
|
|
571
|
+
* @throws {Error} If trying to inject proof server container when starting new environment
|
|
572
|
+
*/
|
|
573
|
+
start: (maybeProofServerContainer?: ProofServerContainer$1) => Promise<EnvironmentConfiguration$1>;
|
|
574
|
+
/**
|
|
575
|
+
* Shuts down the test environment, closing walletProviders and stopping containers
|
|
576
|
+
* @returns {Promise<void>}
|
|
577
|
+
*/
|
|
578
|
+
shutdown: (saveWalletState?: boolean) => Promise<void>;
|
|
579
|
+
/**
|
|
580
|
+
* Creates and starts the specified number of wallet providers
|
|
581
|
+
* @throws {Error} If requested amount exceeds maximum supported walletProviders
|
|
582
|
+
* @returns {Promise<MidnightWalletProvider[]>} A promise that resolves to an array of started wallets
|
|
583
|
+
*/
|
|
584
|
+
startMidnightWalletProviders: (amount?: number, seeds?: string[] | undefined) => Promise<MidnightWalletProvider$1[]>;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* Test environment configuration for the Midnight QA network.
|
|
589
|
+
* Provides URLs and endpoints for QA network services.
|
|
590
|
+
*/
|
|
591
|
+
declare class QanetTestEnvironment extends RemoteTestEnvironment {
|
|
592
|
+
/**
|
|
593
|
+
* Returns the configuration for the QA network environment services.
|
|
594
|
+
* @returns {EnvironmentConfiguration} Object containing URLs for QA network services:
|
|
595
|
+
* - indexer: GraphQL API endpoint for the indexer
|
|
596
|
+
* - indexerWS: WebSocket endpoint for the indexer
|
|
597
|
+
* - node: RPC endpoint for the blockchain node
|
|
598
|
+
* - faucet: API endpoint for requesting test tokens
|
|
599
|
+
* - proofServer: URL for the proof generation server
|
|
600
|
+
*/
|
|
601
|
+
getEnvironmentConfiguration(): EnvironmentConfiguration$1;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* Test environment configuration for the Midnight testnet network.
|
|
606
|
+
* Provides URLs and endpoints for testnet services.
|
|
607
|
+
*/
|
|
608
|
+
declare class Testnet2TestEnvironment extends RemoteTestEnvironment {
|
|
609
|
+
/**
|
|
610
|
+
* Returns the configuration for the testnet environment services.
|
|
611
|
+
* @returns {EnvironmentConfiguration} Object containing URLs for testnet services:
|
|
612
|
+
* - indexer: GraphQL API endpoint for the indexer
|
|
613
|
+
* - indexerWS: WebSocket endpoint for the indexer
|
|
614
|
+
* - node: RPC endpoint for the blockchain node
|
|
615
|
+
* - faucet: API endpoint for requesting test tokens
|
|
616
|
+
* - proofServer: URL for the proof generation server
|
|
617
|
+
*/
|
|
618
|
+
getEnvironmentConfiguration(): EnvironmentConfiguration$1;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
declare const MINUTE = 60000;
|
|
622
|
+
/**
|
|
623
|
+
* Creates a Promise that resolves after a specified delay.
|
|
624
|
+
* @param ms The delay duration in milliseconds.
|
|
625
|
+
* @returns A Promise that resolves after the specified delay.
|
|
626
|
+
* @example
|
|
627
|
+
* // Wait for 1 second
|
|
628
|
+
* await delay(1000);
|
|
629
|
+
*/
|
|
630
|
+
declare const delay: (ms: number) => Promise<unknown>;
|
|
631
|
+
/**
|
|
632
|
+
* Deletes a directory and its contents recursively.
|
|
633
|
+
* @param {string} dirPath - The path to the directory to delete
|
|
634
|
+
* @returns {Promise<void>} A promise that resolves when the directory is deleted
|
|
635
|
+
* @private
|
|
636
|
+
*/
|
|
637
|
+
declare const deleteDirectory: (dirPath: string) => Promise<void>;
|
|
638
|
+
declare const extractHostnameAndPort: (url: string) => string;
|
|
639
|
+
|
|
640
|
+
declare global {
|
|
641
|
+
interface BigInt {
|
|
642
|
+
toJSON(): number;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
declare class FluentWalletBuilder {
|
|
647
|
+
private readonly config;
|
|
648
|
+
private readonly networkId;
|
|
649
|
+
private seeds?;
|
|
650
|
+
private dustOptions;
|
|
651
|
+
private constructor();
|
|
652
|
+
static forEnvironment(envConfig: EnvironmentConfiguration$2): FluentWalletBuilder;
|
|
653
|
+
withSeed(seed: string): FluentWalletBuilder;
|
|
654
|
+
withRandomSeed(): FluentWalletBuilder;
|
|
655
|
+
withDustOptions(options: DustWalletOptions$1): FluentWalletBuilder;
|
|
656
|
+
build(): Promise<WalletFacade>;
|
|
657
|
+
buildWithoutStarting(): Promise<{
|
|
658
|
+
wallet: WalletFacade;
|
|
659
|
+
seeds: WalletSeeds$1;
|
|
660
|
+
keystore: UnshieldedKeystore;
|
|
661
|
+
}>;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
/**
|
|
665
|
+
* A class for compressing and decompressing files using gzip.
|
|
666
|
+
*/
|
|
667
|
+
declare class GzipFile {
|
|
668
|
+
/** The path to the input file */
|
|
669
|
+
inputFile: string;
|
|
670
|
+
/** The path to the output file */
|
|
671
|
+
outputFile: string;
|
|
672
|
+
/**
|
|
673
|
+
* Creates a new GzipFile instance.
|
|
674
|
+
* @param inputFile - The path to the input file to compress/decompress
|
|
675
|
+
* @param outputFile - The path where the compressed file will be saved
|
|
676
|
+
*/
|
|
677
|
+
constructor(inputFile: string, outputFile: string);
|
|
678
|
+
/**
|
|
679
|
+
* Compresses the input file using gzip compression.
|
|
680
|
+
* @returns A promise that resolves when compression is complete
|
|
681
|
+
* @throws If there is an error during compression
|
|
682
|
+
*/
|
|
683
|
+
compress: () => Promise<void>;
|
|
684
|
+
/**
|
|
685
|
+
* Decompresses the input gzip file and returns its contents as a string.
|
|
686
|
+
* @returns A promise that resolves with the decompressed file contents as a string
|
|
687
|
+
* @throws If there is an error during decompression
|
|
688
|
+
*/
|
|
689
|
+
decompress: () => Promise<string>;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
/**
|
|
693
|
+
* Provider class that implements wallet functionality for the Midnight network.
|
|
694
|
+
* Handles transaction balancing, submission, and wallet state management.
|
|
695
|
+
*/
|
|
696
|
+
declare class MidnightWalletProvider implements MidnightProvider, WalletProvider {
|
|
697
|
+
logger: Logger;
|
|
698
|
+
readonly env: EnvironmentConfiguration$3;
|
|
699
|
+
readonly wallet: WalletFacade;
|
|
700
|
+
readonly unshieldedKeystore: UnshieldedKeystore;
|
|
701
|
+
readonly zswapSecretKeys: ZswapSecretKeys;
|
|
702
|
+
readonly dustSecretKey: DustSecretKey;
|
|
703
|
+
private constructor();
|
|
704
|
+
getCoinPublicKey(): CoinPublicKey;
|
|
705
|
+
getEncryptionPublicKey(): EncPublicKey;
|
|
706
|
+
balanceTx(tx: UnboundTransaction, _newCoins: ShieldedCoinInfo[], ttl?: Date): Promise<FinalizedTransaction>;
|
|
707
|
+
submitTx(tx: FinalizedTransaction): Promise<string>;
|
|
708
|
+
start(waitForFundsInWallet?: boolean, tokenType?: TokenType): Promise<void>;
|
|
709
|
+
stop(): Promise<void>;
|
|
710
|
+
static build(logger: Logger, env: EnvironmentConfiguration$3, seed?: string | undefined): Promise<MidnightWalletProvider>;
|
|
711
|
+
static withWallet(logger: Logger, env: EnvironmentConfiguration$3, wallet: WalletFacade, zswapSecretKeys: ZswapSecretKeys, dustSecretKey: DustSecretKey, unshieldedKeystore: UnshieldedKeystore): Promise<MidnightWalletProvider>;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
interface DustWalletOptions {
|
|
715
|
+
ledgerParams: LedgerParameters;
|
|
716
|
+
additionalFeeOverhead: bigint;
|
|
717
|
+
feeBlocksMargin: number;
|
|
718
|
+
}
|
|
719
|
+
declare const DEFAULT_DUST_OPTIONS: DustWalletOptions;
|
|
720
|
+
declare class WalletFactory {
|
|
721
|
+
static createShieldedWallet(config: DefaultV1Configuration, seed: Uint8Array): ShieldedWallet;
|
|
722
|
+
static createUnshieldedWallet(config: DefaultV1Configuration, unshieldedKeystore: UnshieldedKeystore): UnshieldedWallet;
|
|
723
|
+
static createDustWallet(config: DefaultV1Configuration, seed: Uint8Array, dustOptions?: DustWalletOptions): DustWallet;
|
|
724
|
+
static createWalletFacade(shieldedWallet: ShieldedWallet, unshieldedWallet: UnshieldedWallet, dustWallet: DustWallet): WalletFacade;
|
|
725
|
+
static startWalletFacade(wallet: WalletFacade, shieldedSeed: Uint8Array, dustSeed: Uint8Array): Promise<WalletFacade>;
|
|
726
|
+
static restoreShieldedWallet(config: DefaultV1Configuration, serializedState: string): Promise<ShieldedWallet>;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
declare const getShieldedSeed: (seed: string) => Uint8Array;
|
|
730
|
+
declare const getUnshieldedSeed: (seed: string) => Uint8Array;
|
|
731
|
+
declare const getDustSeed: (seed: string) => Uint8Array;
|
|
732
|
+
declare class WalletSeeds {
|
|
733
|
+
readonly masterSeed: string;
|
|
734
|
+
readonly shielded: Uint8Array;
|
|
735
|
+
readonly unshielded: Uint8Array;
|
|
736
|
+
readonly dust: Uint8Array;
|
|
737
|
+
private constructor();
|
|
738
|
+
static fromMasterSeed(seed: string): WalletSeeds;
|
|
739
|
+
static generateRandom(): WalletSeeds;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
/** Default directory path for storing wallet state files */
|
|
743
|
+
declare const DEFAULT_WALLET_STATE_DIRECTORY = "./.states";
|
|
744
|
+
/**
|
|
745
|
+
* Generates a filename for the wallet state file based on environment and optional seed
|
|
746
|
+
* @returns {string} Generated filename for the wallet state
|
|
747
|
+
* @param seed
|
|
748
|
+
*/
|
|
749
|
+
declare const getWalletStateFilename: (seed: string | undefined) => string;
|
|
750
|
+
/**
|
|
751
|
+
* Provider class for saving and loading wallet state to/from compressed files
|
|
752
|
+
*/
|
|
753
|
+
declare class WalletSaveStateProvider {
|
|
754
|
+
/** Logger instance for recording operations */
|
|
755
|
+
logger: Logger;
|
|
756
|
+
/** Absolute path to the directory containing wallet state files */
|
|
757
|
+
directoryPath: string;
|
|
758
|
+
/** Full path including filename for the wallet state file */
|
|
759
|
+
filePath: string;
|
|
760
|
+
/**
|
|
761
|
+
* Creates a new WalletSaveStateProvider instance
|
|
762
|
+
* @param {Logger} logger - Logger instance for recording operations
|
|
763
|
+
* @param seed
|
|
764
|
+
* @param {string} [directoryPath=DEFAULT_WALLET_STATE_DIRECTORY] - Directory path for wallet state files
|
|
765
|
+
* @param {string} [filename] - Filename for the wallet state file
|
|
766
|
+
*/
|
|
767
|
+
constructor(logger: Logger, seed: string, directoryPath?: string, filename?: string);
|
|
768
|
+
/**
|
|
769
|
+
* Saves the wallet state to a compressed file
|
|
770
|
+
* @param {ShieldedWallet | UnshieldedWallet} wallet - The wallet instance to save state from
|
|
771
|
+
* @returns {Promise<void>} A promise that resolves when the save is complete
|
|
772
|
+
*/
|
|
773
|
+
save(wallet: ShieldedWallet | UnshieldedWallet): Promise<void>;
|
|
774
|
+
/**
|
|
775
|
+
* Loads and decompresses the wallet state from a file
|
|
776
|
+
* @returns {Promise<string>} A promise that resolves with the decompressed wallet state as a string
|
|
777
|
+
* @throws {Error} If there is an error reading or decompressing the file
|
|
778
|
+
*/
|
|
779
|
+
load(): Promise<string>;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
declare const getInitialState: (wallet: ShieldedWallet | UnshieldedWallet) => Promise<ShieldedWalletState | UnshieldedWalletState>;
|
|
783
|
+
declare const getInitialShieldedState: (wallet: ShieldedWallet) => Promise<ShieldedWalletState>;
|
|
784
|
+
declare const getInitialUnshieldedState: (wallet: UnshieldedWallet) => Promise<UnshieldedWalletState>;
|
|
785
|
+
declare const syncWallet: (wallet: WalletFacade, throttleTime?: number, timeout?: number) => Promise<_midnight_ntwrk_wallet_sdk_facade.FacadeState>;
|
|
786
|
+
declare const waitForFunds: (wallet: WalletFacade, env: EnvironmentConfiguration$3, tokenType?: TokenType, fundFromFaucet?: boolean) => Promise<bigint | _midnight_ntwrk_wallet_sdk_facade.FacadeState>;
|
|
787
|
+
|
|
788
|
+
export { DEFAULT_DUST_OPTIONS, DEFAULT_WALLET_STATE_DIRECTORY, DynamicProofServerContainer, EnvVarRemoteTestEnvironment, FaucetClient, FluentWalletBuilder, GzipFile, IndexerClient, LocalTestConfiguration, LocalTestEnvironment, MINUTE, MidnightWalletProvider, NodeClient, ProofServerClient, QanetTestEnvironment, RemoteTestEnvironment, StaticProofServerContainer, TestEnvironment, Testnet2TestEnvironment, WalletFactory, WalletSaveStateProvider, WalletSeeds, createDefaultTestLogger, createLogger, defaultContainersConfiguration, delay, deleteDirectory, expectFoundAndDeployedStatesEqual, expectFoundAndDeployedTxDataEqual, expectFoundAndDeployedTxPrivateDataEqual, expectFoundAndDeployedTxPublicDataEqual, expectSuccessfulCallTx, expectSuccessfulDeployTx, expectSuccessfulTxData, extractHostnameAndPort, getContainersConfiguration, getDustSeed, getInitialShieldedState, getInitialState, getInitialUnshieldedState, getShieldedSeed, getTestEnvironment, getUnshieldedSeed, getWalletStateFilename, inMemoryPrivateStateProvider, initializeMidnightProviders, latestContainersConfiguration, logger, setContainersConfiguration, stateValueEqual, syncWallet, txsEqual, waitForFunds };
|
|
789
|
+
export type { ComponentPortsConfiguration, ContainerEndpoints, ContainersConfiguration, ContractConfiguration, DustWalletOptions, EnvironmentConfiguration, LogConfiguration, ProofServerContainer, ProofServerContainerConfiguration, StandaloneContainerNames, StandaloneContainersConfiguration };
|