Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Auth

This class supports creating AINFT factory app and users.
Do not create it directly; Get it from AinftJs instance.

Hierarchy

Index

Constructors

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

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

  • addManagedContract(appId: string, chain: string, network: string, contractAddress: string): Promise<void>
  • Registers contract to managed contract. By registering as a managed contract, metadata can be managed in AINFT Factory.

    Parameters

    • appId: string

      The ID of app.

    • chain: string

      The symbol of chain with a contract.

    • network: string

      The name of network.

    • contractAddress: string

      The address of contract.

    Returns Promise<void>

  • addOwners(appId: string, owners: string[]): Promise<string>
  • You can add blockchain app owners.

    Parameters

    • appId: string

      The ID of app.

    • owners: string[]

      The list of addresses to be owner.

    Returns Promise<string>

    transaction hash

  • addUserEthAddress(appId: string, userId: string, ethAddress: string): Promise<User>
  • Adds ETH address info to AINFT factory user.

    Parameters

    • appId: string

      The ID of app.

    • userId: string

      The ID of user.

    • ethAddress: string

      The ethereum address to add.

    Returns Promise<User>

  • createAdmin(appId: string, userId: string): Promise<User>
  • Create AINFT factory admin user in app.

    Parameters

    • appId: string

      The ID of app.

    • userId: string

      The ID of user to be admin.

    Returns Promise<User>

  • createApp(appname: string): Promise<any>
  • Creates AIN Blockchain app using private key.

    Parameters

    • appname: string

      The name of app.

    Returns Promise<any>

    Returns transaction result.

  • createUser(appId: string, userId: string): Promise<User>
  • Creates AINFT factory user in app.

    Parameters

    • appId: string

      The ID of app.

    • userId: string

      The ID of user to create.

    Returns Promise<User>

  • delegateApp(appId: string): Promise<any>
  • Sends transaction to delegate app using private key. App permission is obtained from ainft factory, and trigger function for ainft is registered.

    Parameters

    • appId: string

      The ID of app.

    Returns Promise<any>

  • getTxBodyForDelegateApp(appId: string): Promise<any>
  • Gets transaction body to delegate app. App permission is obtained from AINFT factory, and trigger function for ainft is registered.

    Parameters

    • appId: string

      The ID of app.

    Returns Promise<any>

  • getUser(appId: string, userId: string): Promise<User>
  • Gets AINFT factory user in app.

    Parameters

    • appId: string

      The ID of app.

    • userId: string

      The ID of user to get.

    Returns Promise<User>

    Return user information.

  • getUserDepositAddress(appId: string, userId: string, chain: string): Promise<string>
  • You can get user deposit crypto address. If user doesn't have address, create new deposit account.

    Parameters

    • appId: string

      The ID of app.

    • userId: string

      The ID of user.

    • chain: string

      The symbol of chain.

    Returns Promise<string>

  • registerBlockchainApp(appId: string, accessAinAddress?: string): Promise<any>
  • Registers exsiting AIN blockchain app to AINFT Factory.

    Parameters

    • appId: string

      The ID of app.

    • Optional accessAinAddress: string

      This is the address of the account that will be accessible to the AINFT Factory app. If not set, it is set to the address of the account set as the privateKey.

    Returns Promise<any>

  • removeManagedContract(appId: string, chain: string, network: string, contractAddress: string): Promise<void>
  • Removes managed contract.

    Parameters

    • appId: string

      The ID of app.

    • chain: string

      The symbol of chain with a contract.

    • network: string

      The name of network.

    • contractAddress: string

      The address of contract.

    Returns Promise<void>

  • removeUserEthAddress(appId: string, userId: string, ethAddress: string): Promise<User>
  • Removes ETH address info from user.

    Parameters

    • appId: string

      The ID of app.

    • userId: string

      The ID of user.

    • ethAddress: string

      The ethereum address to delete.

    Returns Promise<User>

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

Generated using TypeDoc