Options
All
  • Public
  • Public/Protected
  • All
Menu

Class UserProfile

All calls must go though the UserProfile. A newly created UserProfile is unlocked until lock() is called, which removes access to private key material. Once locked, a UserProfile cannot be unlocked anymore since the corresponding storage is not available anymore. Instead, re-create the UserProfile via the UserProfileController to get an unlocked UserProfile.

Hierarchy

  • UserProfile

Index

Constructors

constructor

Properties

createdAt

createdAt: ReadonlyDate

locked

locked: ValueAndUpdates<boolean>

wallets

wallets: ValueAndUpdates<keyof WalletInfo[]>

Methods

addWallet

appendSignature

  • appendSignature(identity: Identity, originalTransaction: SignedTransaction, codec: TxCodec, nonce: Nonce): Promise<SignedTransaction>
  • Parameters

    • identity: Identity
    • originalTransaction: SignedTransaction
    • codec: TxCodec
    • nonce: Nonce

    Returns Promise<SignedTransaction>

createIdentity

  • createIdentity(walletId: WalletId, chainId: ChainId, options: Ed25519Keypair | keyof Slip10RawIndex[] | number): Promise<Identity>
  • Creates an identity in the wallet with the given ID in the primary keyring

    The identity is bound to one chain ID to encourage using different keypairs on different chains.

    Parameters

    • walletId: WalletId
    • chainId: ChainId
    • options: Ed25519Keypair | keyof Slip10RawIndex[] | number

    Returns Promise<Identity>

getAllIdentities

  • getAllIdentities(): keyof Identity[]
  • All identities of the primary keyring

    Returns keyof Identity[]

getIdentities

  • getIdentities(id: WalletId): keyof Identity[]
  • Get identities of the wallet with the given ID in the primary keyring

    Parameters

    Returns keyof Identity[]

getIdentityLabel

  • getIdentityLabel(identity: Identity): string | undefined
  • Gets the local label of one of the identities in the wallet with the given ID in the primary keyring

    Parameters

    • identity: Identity

    Returns string | undefined

identityExists

  • identityExists(walletId: WalletId, chainId: ChainId, options: Ed25519Keypair | keyof Slip10RawIndex[] | number): Promise<boolean>
  • Checks if an identity exists in the wallet with the given ID in the primary keyring

    Example usage

    This allows you to detect which accounts of an HD wallet have been created. Pseudocode

    identityExists("m/44'/234'/0'") == true
    identityExists("m/44'/234'/1'") == true
    identityExists("m/44'/234'/2'") == true
    identityExists("m/44'/234'/3'") == false
    // Shows that identities with account indices 0–2 have been created.

    Parameters

    • walletId: WalletId
    • chainId: ChainId
    • options: Ed25519Keypair | keyof Slip10RawIndex[] | number

    Returns Promise<boolean>

lock

  • lock(): void

printableSecret

  • Exposes the secret data of a wallet in a printable format for backup purposes.

    The format depends on the implementation and may change over time, so do not try to parse the result or make any kind of assumtions on how the result looks like.

    Parameters

    Returns string

setIdentityLabel

  • setIdentityLabel(identity: Identity, label: string | undefined): void
  • Assigns a label to one of the identities in the wallet with the given ID in the primary keyring

    Parameters

    • identity: Identity
    • label: string | undefined

    Returns void

setWalletLabel

  • setWalletLabel(walletId: WalletId, label: string | undefined): void
  • Sets the label of the wallet with the given ID in the primary keyring

    Parameters

    • walletId: WalletId
    • label: string | undefined

    Returns void

signTransaction

  • signTransaction(transaction: UnsignedTransaction, codec: TxCodec, nonce: Nonce): Promise<SignedTransaction>
  • Signs a transaction using the profile's primary keyring. The transaction's creator field specifies the keypair to be used for signing.

    Parameters

    • transaction: UnsignedTransaction
    • codec: TxCodec
    • nonce: Nonce

    Returns Promise<SignedTransaction>

storeIn

  • storeIn(db: LevelUp<AbstractLevelDOWN<string, string>>, encryptionSecret: string | UserProfileEncryptionKey): Promise<void>
  • Stores this profile in an open database. This will erase all other data in that database.

    Parameters

    • db: LevelUp<AbstractLevelDOWN<string, string>>

      the target database

    • encryptionSecret: string | UserProfileEncryptionKey

      a password or derivation key used for encryption

    Returns Promise<void>

Static deriveEncryptionKey

  • Derives an encryption key from the password. This is a computationally intense task that can take many seconds.

    Use this function to cache the encryption key in memory.

    Parameters

    • password: string
    • Default value formatVersion: number = storageFormatVersion

      Set this if you got a UnexpectedFormatVersionError. This error usually means a profile was encrypted with an older format version.

    Returns Promise<UserProfileEncryptionKey>

Static loadFrom

Generated using TypeDoc