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
mnsResolver: MnsResolver
publicApiClient: PublicApiClient

A PublicApiClient instance used for making API calls.

wallet: IAccount[] = []

Methods

  • Adds a set of accounts to the wallet.

    Parameters

    • accounts: IAccount[]

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

    Returns Promise<IAccount[]>

    A Promise that resolves to an array of IAccount objects.

    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
  • Buy rolls with wallet address.

    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[]>

    a promise that resolves to an array of operations ids.

    Throws

    if no sender account is available for the transaction.

  • Retrieves information about specified wallet addresses.

    Parameters

    • addresses: string[]

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

    Returns Promise<IAddressInfo[]>

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

  • Sell rolls with wallet address.

    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[]>

    a promise that resolves to an array of operations ids.

    Throws

    if no sender account is available for the transaction.

  • Sends a post JSON rpc request to the node.

    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>

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

    Throws

    An error if the rpc method returns an error.

  • Sends native MAS from a wallet address to another.

    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[]>

    a promise that resolves to an array of operations ids.

    Throws

    if no sender account is available for the transaction.

  • Set new providers as IProvider.

    Parameters

    • providers: IProvider[]

      The new providers to set as an array of IProvider.

    Returns void

    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.

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

    Parameters

    • data: string | Buffer

      The data to be signed.

    • chainId: bigint
    • accountSignerAddress: string

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

    Returns Promise<ISignature>

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

    Throws

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

  • Signs the provided data with the given address.

    Parameters

    • data: string | Buffer

      The data to be signed.

    • signer: IBaseAccount

      The account that will be used to sign the data.

    Returns Promise<ISignature>

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

    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.

Generated using TypeDoc