abel-sdk
    Preparing search index...

    Class AbelSDK

    The AbelSDK class is an SDK for interacting with an asset labeling system, allowing querying, management, and association of labels, assets, and operators within a given application. The class supports read and write operations and relies on Algorand blockchain infrastructure.

    import { AlgorandClient } from "@algorandfoundation/algokit-utils";
    import { AbelSDK } from "abel-sdk";

    const abel = new AbelSDK({
    appId: 2914159523n, // Abel Mainnet PoC App ID
    algorand: AlgorandClient.fromConfig({
    algodConfig: { server: "https://mainnet-api.4160.nodely.dev", port: 443 },
    }),
    });
    Index

    Constructors

    Properties

    Represents an instance of AssetLabelingClient used to read data from the Asset Labeling contract. Provides functionality to manage and retrieve asset labeling data.

    writeAccount?: TransactionSignerAccount

    An optional variable representing an account that can authorize and sign transactions.

    The writeAccount variable is either an instance of TransactionSignerAccount or is undefined. It is used to execute and authenticate transaction operations.

    writeClient: undefined | AssetLabelingClient

    Represents an instance of AssetLabelingClient or undefined.

    The variable is used to write data to the Asset Labeling contract. Ensure to properly check for undefined before attempting to invoke any methods or properties associated with the AssetLabelingClient.

    Accessors

    • get appId(): bigint

      Retrieves the application ID associated with the current client instance.

      Returns bigint

    Methods

    • Adds a label to the specified entity with the given details.

      Parameters

      • labelId: string

        The unique identifier for the label.

      • name: string

        The name of the label.

      • url: string

        The URL associated with the label.

      Returns Promise<ClientResponse>

      Returns a promise that resolves to the result of the operation, potentially wrapped with error handling.

    • Adds a label to a specified asset by associating the label ID with the asset ID.

      Parameters

      • assetId: bigint

        The unique identifier of the asset to which the label will be added.

      • labelId: string

        The unique identifier of the label to be associated with the asset.

      Returns Promise<ClientResponse>

      A promise that resolves to the client response indicating the result of the operation.

    • Adds a specified label to a set of asset IDs.

      This function permits assigning a label to assets in batches to optimize performance. If the list of asset IDs exceeds the maximum limit for a single method invocation, the function segments the asset IDs into chunks and processes them asynchronously with controlled concurrency.

      Parameters

      • assetIds: bigint[]

        An array of asset IDs to be labeled.

      • labelId: string

        The identifier of the label to be added to the assets.

      Returns Promise<ClientResponse | ClientResponse[]>

      A promise that resolves to the response(s) from the operation. If the operation involves chunked requests, the responses are returned as an array.

      Error Throws an error if the write client is not available.

    • Add a label to an operator. This allows the operator address to add/remove operators to the label, as well as label assets with this label.

      Parameters

      • operator: string

        Operator address

      • labelId: string

        Label to add to operator

      Returns Promise<ClientResponse>

    • Updates the label with the specified ID, changing its name and URL.

      Parameters

      • labelId: string

        The unique identifier of the label to be changed.

      • name: string

        The new name to assign to the label.

      • url: string

        The new URL to associate with the label.

      Returns Promise<ClientResponse>

      A promise that resolves with the response from the client after attempting to update the label.

      If the name or url parameters are nullish (undefined or null).

    • Return all asset IDs available on the contract

      Returns Promise<bigint[]>

      Asset IDs

    • Return all label IDs available on the contract

      Returns Promise<string[]>

      Label IDs

    • Return all operator addresses on the contract

      Returns Promise<string[]>

      Operator addresses

    • Fetches the labels associated with a specific asset.

      Parameters

      • assetId: bigint

        The unique identifier of the asset for which labels need to be retrieved.

      Returns Promise<string[]>

      A promise that resolves to an array of asset labels.

    • Retrieves detailed information for a list of asset IDs as a map of asset ID to asset details.

      If the number of asset IDs exceeds the maximum allowed per method call, the request is automatically divided into smaller batches to handle the data in chunks.

      Parameters

      • assetIds: bigint[]

        An array of asset IDs for which the detailed information is requested.

      Returns Promise<Map<bigint, AssetFull>>

      A promise resolving to a map where each key is an asset ID and the value is the corresponding detailed asset information.

      Throws an error if the underlying request fails or an unexpected response format is encountered.

    • Retrieves asset labels for a given list of asset IDs asynchronously.

      This method performs a simulation of fetching labels for the specified assets by calling the logAssetsLabels function through the readClient instance. If the input list of asset IDs exceeds the predefined maximum (METHOD_MAX), it automatically splits the call into batches for processing.

      Parameters

      • assetIds: bigint[]

        An array of asset IDs for which labels are to be fetched.

      Returns Promise<Map<bigint, string[]>>

      A promise that resolves to a map where each asset ID corresponds to its associated array of labels.

      If an error occurs during the simulation or log parsing process.

    • Retrieves a map of asset micro details for the provided asset IDs.

      This function handles querying for the details of multiple assets using their respective IDs. It ensures batched processing if the number of asset IDs exceeds the maximum method capacity.

      Parameters

      • assetIds: bigint[]

        An array of asset IDs for which the micro details are requested.

      Returns Promise<Map<bigint, AssetMicro>>

      A promise that resolves to a map where each key is the asset ID, and the value is the corresponding AssetMicro data.

      Throws an error if the query or data parsing encounters an issue.

    • Fetches the micro labels for a given list of asset IDs.

      This method retrieves metadata for the specified assets by making a request to the underlying data source. It supports batching for optimizing requests, ensuring that if the asset list exceeds a predefined maximum limit (METHOD_MAX), it splits the calls into batches for processing.

      Parameters

      • assetIds: bigint[]

        An array of asset IDs for which micro labels are to be fetched.

      Returns Promise<Map<bigint, AssetMicroLabels>>

      A promise resolving to a Map where each key is an asset ID and the value is its corresponding micro label information.

      Error Throws an error if the underlying client encounters issues processing the request.

    • Retrieves a map of small asset details for the given list of asset IDs.

      If the number of asset IDs exceeds the maximum allowable batch size (METHOD_MAX), the method splits the request into batches by recursively calling itself with the appropriate subdivisions of the assetIds array.

      The method interacts with a read client to simulate a data retrieval process and parses the resulting logs to map each asset ID to its corresponding asset data.

      Parameters

      • assetIds: bigint[]

        An array of asset IDs for which the small asset details should be retrieved.

      Returns Promise<Map<bigint, AssetSmall>>

      A promise resolving to a map where the keys are asset IDs (bigint) and the values are AssetSmall objects containing the corresponding small asset details.

      Error Will propagate any errors encountered during the read client interaction or log parsing.

    • Retrieves asset text details for a given list of asset IDs.

      This function fetches the text descriptors for the specified asset IDs asynchronously. If the number of asset IDs exceeds the defined method limit (METHOD_MAX), the function breaks the request into smaller batches and calls itself recursively.

      Parameters

      • assetIds: bigint[]

        An array of bigint values representing the asset IDs.

      Returns Promise<Map<bigint, AssetText>>

      A promise that resolves to a Map, where each key is an asset ID and the value is an AssetText object containing the text descriptor for the respective asset.

      Error Will throw errors if the internal simulation or parsing of logs fails.

    • Fetches text labels for a given list of asset IDs.

      The function retrieves the text labels associated with the provided asset IDs by calling the backend services and simulating the results. If the number of asset IDs exceeds the maximum allowed limit (METHOD_MAX), the function divides the request into smaller batch calls.

      Parameters

      • assetIds: bigint[]

        An array of asset IDs for which text labels are to be fetched.

      Returns Promise<Map<bigint, AssetTextLabels>>

      A promise that resolves to a map where the keys are the asset IDs and the values are their associated text label objects.

      Error Will throw errors if the simulation or parsing of logs fails during the process.

    • Retrieves a mapping of asset IDs to their corresponding "AssetTiny" details. This asynchronous function fetches details for the provided asset IDs in an optimized manner, using batching if the number of asset IDs exceeds the allowed limit.

      Parameters

      • assetIds: bigint[]

        An array of asset identifiers for which the details are requested.

      Returns Promise<Map<bigint, AssetTiny>>

      A promise that resolves to a Map where each asset ID is mapped to its corresponding "AssetTiny" details.

      Error Will throw an error if there is an issue during the retrieval or processing of the asset details.

    • Fetches tiny label details for the given list of asset IDs.

      This method queries asset data in batches if the number of asset IDs exceeds a pre-defined limit. It uses simulated calls to the read client for retrieving asset label information and parses the logs to extract the results. The returned data is mapped to each asset ID.

      Parameters

      • assetIds: bigint[]

        Array of asset IDs for which tiny labels are to be retrieved.

      Returns Promise<Map<bigint, AssetTinyLabels>>

      A promise that resolves to a map, where each key is an asset ID (bigint) and the value is an object containing the tiny label details for the asset.

      Error Will throw an error if any issue occurs while simulating or parsing logs.

    • Get a label descriptor for a label by its ID.

      Parameters

      • labelId: string

        The label to look up by label ID

      Returns Promise<null | LabelDescriptor>

      A label descriptor

    • Get multiple label descriptors for labels, by their IDs.

      Parameters

      • labelIds: string[]

        The label IDs to look up

      Returns Promise<Map<string, LabelDescriptor>>

      Result wap with label IDs as keys and LabelDescriptors as values.

    • Get all labels for an operator

      Parameters

      • operator: string

        The operator address to query

      Returns Promise<string[]>

      Labels that this account can operate on

    • Return whether an asset has a specific label

      Parameters

      • assetId: bigint

        Asset to look up, by asset ID

      • label: string

        label to query for, by label ID

      Returns Promise<boolean>

      True if an asset exists and has a label

    • Returns whether a specific label ID exists or not

      Parameters

      • labelId: string

        label ID

      Returns Promise<boolean>

      Whether the label exists or not

    • Returns whether or not an operator has access to a label

      Parameters

      • operator: string

        The operator address to query

      • label: string

        The label ID to look up

      Returns Promise<boolean>

    • parse typed arc4 structs from logs

      tupleParser is like generated clients' xyzArcStructFromTuple abiDecodingMethod is a method name that returns the same avi return type as we are logging e.g. if we are parsing log_label_descriptors() logs that logs LabelDescriptor, abiDecodingMethod can be get_label_descriptor that has ABI return LabelDescriptor

      Type Parameters

      Parameters

      • logs: Uint8Array<ArrayBufferLike>[]
      • tupleParser: T
      • abiDecodingMethodName: string

      Returns ReturnType<T>[]

    • Removes a label specified by the labelId.

      Parameters

      • labelId: string

        The unique identifier of the label to be removed.

      Returns Promise<ClientResponse>

      A promise that resolves with the result of the removal operation or rejects with an error if the operation fails.

    • Removes a label from a specified asset.

      Parameters

      • assetId: bigint

        The unique identifier of the asset from which the label should be removed.

      • labelId: string

        The unique identifier of the label to be removed from the asset.

      Returns Promise<ClientResponse>

      A promise that resolves to a ClientResponse indicating the result of the label removal operation.

    • Removes an operator from a specified label.

      Parameters

      • operator: string

        The address of the operator to be removed.

      • labelId: string

        The ID of the label from which the operator is to be removed.

      Returns Promise<ClientResponse>

      A promise that resolves to the client response indicating the result of the operation.