WalletFactory
Midnight.js API Reference v2.0.2
Midnight.js API Reference / @midnight-ntwrk/midnight-js-testing / WalletFactory
Class: WalletFactory
Constructorsβ
Constructorβ
new WalletFactory():
WalletFactory
Returnsβ
WalletFactory
Methodsβ
build()β
staticbuild(env,walletLogLevel?):Promise<MidnightWallet>
Builds a wallet instance based on the provided environment configuration.
Parametersβ
envβ
Configuration for the wallet environment
walletLogLevel?β
LogLevel = DEFAULT_WALLET_LOG_LEVEL
Optional log level for wallet operations
Returnsβ
Promise<MidnightWallet>
A promise that resolves to the new wallet instance
buildFromEnvContext()β
staticbuildFromEnvContext(env,seed?,walletLogLevel?):Promise<MidnightWallet>
Builds a wallet instance based on the provided environment configuration and optional seed.
Parametersβ
envβ
Configuration for the wallet environment
seed?β
string
Optional seed for wallet generation. If not provided, a new random wallet will be created
walletLogLevel?β
LogLevel = DEFAULT_WALLET_LOG_LEVEL
Optional log level for wallet operations
Returnsβ
Promise<MidnightWallet>
A promise that resolves to the new wallet instance
buildFromSeed()β
staticbuildFromSeed(env,seed,walletLogLevel?):Promise<MidnightWallet>
Builds a wallet instance from a seed based on the provided environment configuration.
Parametersβ
envβ
Configuration for the wallet environment
seedβ
string
Seed for wallet generation
walletLogLevel?β
LogLevel = DEFAULT_WALLET_LOG_LEVEL
Optional log level for wallet operations
Returnsβ
Promise<MidnightWallet>
A promise that resolves to the new wallet instance
buildFromSeedAndTryToRestoreState()β
staticbuildFromSeedAndTryToRestoreState(env,seed,directoryPath?,filename?,walletLogLevel?):Promise<MidnightWallet>
Builds a wallet from a seed and attempts to restore its state from a saved file if available.
Parametersβ
envβ
Configuration containing indexer, node, and proof server details
seedβ
string
The seed to build the wallet from
directoryPath?β
string = DEFAULT_WALLET_STATE_DIRECTORY
Directory path for wallet state file
filename?β
string = ...
Filename for wallet state file
walletLogLevel?β
LogLevel = DEFAULT_WALLET_LOG_LEVEL
Log level for wallet operations
Returnsβ
Promise<MidnightWallet>
The built and initialized wallet
restore()β
staticrestore(env,serialized,seed,trimTxHistory?,walletLogLevel?):Promise<MidnightWallet>
Restores a wallet instance from a serialized state based on the provided environment configuration.
Parametersβ
envβ
Configuration for the wallet environment
serializedβ
string
Serialized wallet state
seedβ
string
trimTxHistory?β
boolean = true
Optional flag to trim the transaction history during restoration
walletLogLevel?β
LogLevel = DEFAULT_WALLET_LOG_LEVEL
Optional log level for wallet operations
Returnsβ
Promise<MidnightWallet>
A promise that resolves to the restored wallet instance