Options
All
  • Public
  • Public/Protected
  • All
Menu

The class for creating and managing credits to be used in each app.
Do not create it directly; Get it from AinftJs instance.

Hierarchy

Index

Constructors

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

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

  • burnAppCredit(appId: string, symbol: string, from: string, amount: number, payload?: object): Promise<void>
  • Burn credit from user.

    Parameters

    • appId: string

      The ID of app.

    • symbol: string

      The symbol of credit.

    • from: string

      The ID of user the credit will be burned.

    • amount: number

      The amount of credit to burn.

    • Optional payload: object

      The additional data about burning.

    Returns Promise<void>

  • createAppCredit(appId: string, symbol: string, name: string, maxSupply?: number): Promise<AppCreditInfo>
  • Creates credit to use in app.

    Parameters

    • appId: string

      The ID of app.

    • symbol: string

      The symbol of credit.

    • name: string

      The name of credit.

    • Optional maxSupply: number

      Maximum number of credits that can be generated.

    Returns Promise<AppCreditInfo>

  • deleteAppCredit(appId: string, symbol: string): Promise<void>
  • Deletes app credit.

    Parameters

    • appId: string

      The ID of app.

    • symbol: string

      The symbol of credit.

    Returns Promise<void>

  • Deposits user's credits to Crypto tokens.

    Parameters

    • appId: string

      The ID of app.

    • transaction: DepositTransaction

      The transaction information about deposit.

    Returns Promise<void>

  • getAppCredit(appId: string, symbol: string): Promise<AppCreditInfo>
  • Gets app credit info.

    Parameters

    • appId: string

      The ID of app.

    • symbol: string

      The symbol of credit.

    Returns Promise<AppCreditInfo>

    Returns credit information.

  • getCreditBalanceOfUser(appId: string, symbol: string, userId: string): Promise<number>
  • Get the user's credit balance

    Parameters

    • appId: string

      The ID of app.

    • symbol: string

      The symbol of credit.

    • userId: string

      The ID of user.

    Returns Promise<number>

    A Promise that resolves to the credit balance of the user

  • getCreditBalances(appId: string, symbol: string): Promise<{}>
  • Get the credit balance of all users

    Parameters

    • appId: string

      The ID of app.

    • symbol: string

      The symbol of credit.

    Returns Promise<{}>

    } A Promise that resolves to the credit balance of all users.

  • getDepositHistory(appId: string, userId: string, chain?: string): Promise<DepositHistory>
  • Gets user's deposit history.

    Parameters

    • appId: string

      The ID of app.

    • userId: string

      The ID of user.

    • Optional chain: string

      The symbol of chain.

    Returns Promise<DepositHistory>

    Returns depositHistory list of user.

  • getUserLockupList(appId: string, symbol: string, userId: string): Promise<LockupList>
  • Gets a user's lockup list.

    Parameters

    • appId: string

      The ID of app.

    • symbol: string

      The symbol of credit.

    • userId: string

      The ID of user.

    Returns Promise<LockupList>

    Returns lockup list by userId.

  • You can get withdrawal list applied by all users

    Parameters

    • appId: string

      The ID of app.

    • symbol: string

      The symbol of credit.

    Returns Promise<AppWithdrawList>

    Return AppWithdrawList Object

  • getWithdrawListByUserId(appId: string, symbol: string, userId: string): Promise<UserWithdrawList>
  • You can get withdrawal list apllied by one user

    Parameters

    • appId: string

      The ID of app.

    • symbol: string

      The symbol of credit.

    • userId: string

      The ID of user.

    Returns Promise<UserWithdrawList>

    Return UserWithdrawList Object

  • lockupUserBalance(appId: string, symbol: string, userId: string, amount: number, endAt: number, reason?: string): Promise<void>
  • You can restrict the user to leave a certain amount of credit

    Parameters

    • appId: string

      The ID of app.

    • symbol: string

      The symbol of credit.

    • userId: string

      The ID of user.

    • amount: number

      The amount of credit to lock.

    • endAt: number

      The timestamp when the lockup period ends.

    • Optional reason: string

      The reason for the lockup.

    Returns Promise<void>

  • mintAppCredit(appId: string, symbol: string, to: string, amount: number, payload?: object): Promise<void>
  • Mints app credit to user.

    Parameters

    • appId: string

      The ID of app.

    • symbol: string

      The symbol of credit.

    • to: string

      The ID of user the credit will be minted.

    • amount: number

      The amount of credit to mint.

    • Optional payload: object

      The additional data about minting.

    Returns Promise<void>

  • rejectWithdrawal(appId: string, symbol: string, requestMap: WithdrawRequestMap, reason: string): Promise<void>
  • Rejects requested withdrawals.

    Parameters

    • appId: string

      The ID of app.

    • symbol: string

      The symbol of credit.

    • requestMap: WithdrawRequestMap

      A map containing withdrawal request information to reject.

    • reason: string

      The reason for the reject.

    Returns Promise<void>

  • 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.

  • transferAppCredit(appId: string, symbol: string, from: string, to: string, amount: number, payload?: object): Promise<void>
  • Transfer app credit to user.

    Parameters

    • appId: string

      The ID of app.

    • symbol: string

      The symbol of credit.

    • from: string

      The address the credit will send from.

    • to: string

      The address the credit will send to.

    • amount: number

      The amount of credit to transfer.

    • Optional payload: object

      The additional data about transferring.

    Returns Promise<void>

  • withdrawAppCredit(appId: string, symbol: string, userId: string, chain: string, amount: number, userAddress: string): Promise<void>
  • You can request withdraw app credit to crypto wallet.

    Parameters

    • appId: string

      The ID of app.

    • symbol: string

      The symbol of credit.

    • userId: string

      The ID of user who request withdraw.

    • chain: string

      The symbol of chain.

    • amount: number

      The amount of withdraw credit.

    • userAddress: string

      The address where will receive withdraw credit.

    Returns Promise<void>

  • withdrawComplete(appId: string, symbol: string, requestMap: WithdrawRequestMap, txHash: string): Promise<void>
  • Reflects withdraws complete status to server after transfer tokens

    Parameters

    • appId: string

      The ID of app.

    • symbol: string

      The symbol of credit.

    • requestMap: WithdrawRequestMap

      A map containing withdrawal request information for each user.

    • txHash: string

      Hash of transfer transaction.

    Returns Promise<void>

Generated using TypeDoc