Class WalletClient

A client class for interacting with wallets, which can seamlessly work with WebExtensions.

Remarks

The WalletClient manages multiple accounts and handles operations such as transaction signing, fetching account information, and interacting with the blockchain. It extends the BaseClient class and implements the IWalletClient interface.

Hierarchy

  • BaseClient
    • WalletClient

Implements

Constructors

Properties

baseAccount?: IBaseAccount
clientConfig: IClientConfig
publicApiClient: PublicApiClient

A PublicApiClient instance used for making API calls.

wallet: IAccount[] = []

Methods

  • Adds a set of accounts to the wallet.

    Throws

    • If the number of accounts exceeds the MAX_WALLET_ACCOUNTS limit
    • If an account is missing a private key
    • If a submitted public key doesn't correspond to the associated private key
    • If an account address doesn't correspond to the private key-derived address

    Returns

    A Promise that resolves to an array of IAccount objects.

    Parameters

    • accounts: IAccount[]

      An array of accounts (IAccount objects) to be added to the wallet.

    Returns Promise<IAccount[]>

  • Adds a set of private keys to the wallet.

    Throws

    if the number of private keys exceeds the maximum limit.

    Returns

    A Promise that resolves to an array of IAccount objects.

    Parameters

    • secretKeys: string[]

      An array of base58 encoded private keys to be added to the wallet.

    Returns Promise<IAccount[]>

  • Buy rolls with wallet address.

    Throws

    if no sender account is available for the transaction.

    Returns

    a promise that resolves to an array of operations ids.

    Parameters

    • txData: IRollsData

      The transaction data

    • Optional executor: IBaseAccount

      (Optional) The account that will execute the transaction. If not specified, the base account is used by default.

    Returns Promise<string[]>

  • Compacts bytes payload per operation.

    Returns

    The compacted bytes payload.

    Parameters

    • data: DataType

      The operation data.

    • opTypeId: OperationTypeId

      The operation type id.

    • expirePeriod: number

      The expire period.

    Returns Buffer

  • Retrieves information about specified wallet addresses.

    Returns

    A Promise that resolves to an array of IAddressInfo objects, each containing information about a corresponding wallet address.

    Parameters

    • addresses: string[]

      An array of wallet addresses for which information is to be retrieved.

    Returns Promise<IAddressInfo[]>

  • Sell rolls with wallet address.

    Throws

    if no sender account is available for the transaction.

    Returns

    a promise that resolves to an array of operations ids.

    Parameters

    • txData: IRollsData

      The transaction data.

    • Optional executor: IBaseAccount

      (Optional) The account that will execute the transaction. If not specified, the base account is used by default.

    Returns Promise<string[]>

  • Sends a post JSON rpc request to the node.

    Throws

    An error if the rpc method returns an error.

    Returns

    A promise that resolves as the result of the rpc method.

    Type Parameters

    • T

    Parameters

    • resource: JSON_RPC_REQUEST_METHOD

      The rpc method to call.

    • params: object

      The parameters to pass to the rpc method.

    Returns Promise<T>

  • Sends native MAS from a wallet address to another.

    Throws

    if no sender account is available for the transaction.

    Returns

    a promise that resolves to an array of operations ids.

    Parameters

    • txData: ITransactionData

      The transaction data.

    • Optional executor: IBaseAccount

      (Optional) The account that will execute the transaction. If not provided, the base account is used.

    Returns Promise<string[]>

  • Set new providers as IProvider.

    Throws

    Will throw an error if no public providers are included in the given array of providers.

    Throws

    Will throw an error if no private providers are included in the given array of providers.

    Parameters

    • providers: IProvider[]

      The new providers to set as an array of IProvider.

    Returns void

  • Signs a random message data using a wallet account that has already been added.

    Throws

    Will throw an error if the account associated with the provided address is not found in the wallet.

    Returns

    A Promise that resolves to an ISignature object representing the signature.

    Parameters

    • data: string | Buffer

      The data to be signed.

    • accountSignerAddress: string

      The address of the wallet account that will sign the data.

    Returns Promise<ISignature>

  • Verify a signature.

    Returns

    A Promise that resolves to true if the signature is valid, false otherwise.

    Parameters

    • data: string | Buffer

      The signed data to verify.

    • signature: ISignature

      The signature to verify.

    Returns Promise<boolean>

  • Generates an account from a given private key.

    Returns

    A Promise that resolves to an IAccount object.

    Parameters

    • secretKeyBase58: string

      A base58 encoded private key from which the account will be generated.

    Returns Promise<IAccount>

  • Signs the provided data with the given address.

    Remarks

    The address must be present in the wallet.

    Throws

    • if no private key is available for signing the message.
    • if no public key is available for verifying the signed message.
    • if the length of the generated signature is not valid.
    • if the signature could not be verified with the public key.

    Returns

    A Promise that resolves to an ISignature object representing the signature.

    Parameters

    • data: string | Buffer

      The data to be signed.

    • signer: IBaseAccount

      The account that will be used to sign the data.

    Returns Promise<ISignature>

Generated using TypeDoc