Wallet

class Wallet(config)

exported from wallet

Extends:
  • middleware.MiddlewareConsumer()

Wallet is the central object that keeps configuration and references to the different managers.

Arguments:
  • config (Partial<wallet.WalletConfig>) –
Wallet.accountManager

type: managers/account-manager.AccountManager

Used to access account manager instance

Wallet.datastore

type: storages/storage.Storage

Wallet.defaultChainId

type: string

Wallet.defaultLimit

type: undefined|number

Wallet.keyManager

type: managers/key-manager.KeyManager

Used to access key manager instance

Wallet.keystore

type: storages/storage.Storage

Wallet.transactionManager

type: managers/transaction-manager.TransactionManager

Used to access transaction manager instance

Wallet.unlocked

type: boolean

Wallet.close()

Closes storages.

Returns:Promise<void>
Wallet.deleteAllData()

Clears all storages

Returns:Promise<void>
Wallet.getClient(chainId)

Get AergoClient for chainId. If called the first time, create AergoClient instance.

Arguments:
  • chainId (undefined|string) – optional, uses default chainId when undefined
Returns:

AergoClient

Wallet.isSetup()

Shortcut for keyManager.isSetup()

Returns:Promise<boolean>
Wallet.lock()

Shortcut for keyManager.lock()

Wallet.prepareTransaction(account, transaction)

Prepare a transaction from given account specified by simple TxBody. Completes missing information (chainIdHash, nonce) and signs tx using key of account.

Arguments:
  • account (models/account.Account|models/account.AccountSpec) – account object or specification
  • transaction (Partial<models/transaction.TxBody>) –
Returns:

Promise<models/transaction.SignedTransaction> – prepared and signed transaction

Wallet.sendTransaction(account, transaction)

Send a transaction to the network using the specified account. Calls prepareTransaction() if not already prepared.

Arguments:
  • account (models/account.Account|models/account.AccountSpec) –
  • transaction (Partial<models/transaction.TxBody>|models/transaction.SignedTransaction) –
Returns:

Promise<managers/transaction-manager.TransactionTracker>

Wallet.set(configKey, value)

Sets a configuration value

Arguments:
  • configKey (keyof:wallet.WalletConfig) –
  • value
Wallet.setDefaultChain(chainId)

Set the default chain for subsequent actions.

Arguments:
  • chainId (string) –
Wallet.setDefaultLimit(limit)

Set the default gas limit for subsequent transactions.

Arguments:
  • limit (number) –
Wallet.setupAndUnlock(passphrase)

Shortcut for keyManager.setupAndUnlock()

Arguments:
  • passphrase (string) –
Returns:

Promise<void>

Wallet.unlock(passphrase)

Shortcut for keyManager.unlock()

Arguments:
  • passphrase (string) –
Returns:

Promise<void>

Wallet.useChain(chainConfig)

Add a chain configuration. Sets new chain as default if first to be added and default chain was unchanged.

Arguments:
  • chainConfig (wallet.ChainConfig) –
Wallet.useDataStorage(classOrInstance)

Sets storage to use for datastore

Arguments:
  • classOrInstance (T|utils.Constructor<T|extends|storages/storage.Storage>) –
Returns:

Promise<storages/storage.Storage>

Wallet.useKeyStorage(classOrInstance)

Sets storage to use for keystore

Arguments:
  • classOrInstance (T|utils.Constructor<T|extends|storages/storage.Storage>) –
Returns:

Promise<storages/storage.Storage>

Wallet.useStorage(classOrInstance)

Sets storage to use for both keystore and datastore

Arguments:
  • classOrInstance (T|utils.Constructor<T|extends|storages/storage.Storage>) –
Returns:

Promise<[storages/storage.Storage,storages/storage.Storage]>