Options
All
  • Public
  • Public/Protected
  • All
Menu

This class manages ai configurations for AINFT object,
manages the credits needed for their uses, and checks if tokens are available for creation.
Do not create it directly; Get it from AinftJs instance.

Hierarchy

Index

Constructors

  • new Ai(baseUrl: string, route: null | string, ain: default, ainize?: default): Ai

Properties

ain: default

The Ain object for sign and send transaction to AIN blockchain.

ainize?: default

The Ainize object for send request to AIN blockchain.

baseUrl: string = ''

The base url of api server of AINFT Factory.

route: string

The subpath of api server request url.

Methods

  • buildTxBodyForConfigureAi(objectId: string, serviceName: string, address: string): TransactionInput
  • Parameters

    • objectId: string
    • serviceName: string
    • address: string

    Returns TransactionInput

  • Sets up ai configuration for an AINFT object.

    Parameters

    • objectId: string

      The ID of the AINFT object.

    • serviceName: string

      The name of Ainize service.

    Returns Promise<AiConfigurationTransactionResult>

    A promise that resolves with both the transaction result and the configuration info.

  • getCredit(serviceName: string): Promise<number>
  • Retrieves the credit balance for a service.

    Parameters

    • serviceName: string

      The name of Ainize service.

    Returns Promise<number>

    A promise that resolves with the credit balance.

  • getUserTokensByStatus(objectId: string, address: string, status?: null | string, __namedParameters?: QueryParamsWithoutSort): Promise<{ items: NftToken[]; total: number }>
  • todo

    Enable deposit function once withdrawal is fully implemented and tested. Deposits a credits for a service.

    Parameters

    Returns Promise<{ items: NftToken[]; total: number }>

    A promise that resolves with the deposit transaction info.

  • sendFormRequest(method: POST | PUT, trailingUrl: string, stringFields: {}, fileFields: {}): Promise<any>
  • Sends request that include form to api server of AINFT Factory. Used to upload asset data.

    Parameters

    • method: POST | PUT

      The method of Http request.

    • trailingUrl: string

      The suffix of request url.

    • stringFields: {}

      The string fields of form.

      • [key: string]: string
    • fileFields: {}

      The file fields of form.

      • [key: string]: { buffer: Buffer; filename: string }
        • buffer: Buffer
        • filename: string

    Returns Promise<any>

    Returns response of api request.

  • sendRequest(method: HttpMethod, trailingUrl: string, data?: Record<string, any>): Promise<any>
  • Sends request to api server of AINFT Factory. Authenticate by signing data.

    Parameters

    • method: HttpMethod

      The method of Http request.

    • trailingUrl: string

      The suffix of request url.

    • Optional data: Record<string, any>

      The data to be included in the api request.

    Returns Promise<any>

    Returns response of api request.

  • sendRequestWithoutSign(method: HttpMethod, trailingUrl: string, data?: Record<string, any>, headers?: AxiosRequestHeaders): Promise<any>
  • Sends request to api server of AINFT Factory. Used when authentication is not required.

    Parameters

    • method: HttpMethod

      The method of Http request.

    • trailingUrl: string

      The suffix of request url.

    • Optional data: Record<string, any>

      The data to be included in the api request.

    • Optional headers: AxiosRequestHeaders

      The headers of Http api request.

    Returns Promise<any>

    Returns response of api request.

  • setBaseUrl(baseUrl: string): void
  • signData(data: any): string | Promise<string>
  • Sign the data with the private key that the user has registered.

    Parameters

    • data: any

      The data to sign.

    Returns string | Promise<string>

    Returns signature string.

  • waitForUpdate(service: default, expected: number, timeout: number, txHash: string): Promise<number>
  • Parameters

    • service: default
    • expected: number
    • timeout: number
    • txHash: string

    Returns Promise<number>

Generated using TypeDoc