Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Store

This class supports managing items, store and user items.
Do not create it directly; Get it from AinftJs instance.

Hierarchy

Index

Constructors

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

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

  • Creates a new item.

    Parameters

    Returns Promise<Item>

    Returns created item information.

  • deregisterItem(appId: string, storeId: string, itemName: string): Promise<any>
  • Deregisters an item from the store.

    Parameters

    • appId: string

      The ID of the app.

    • storeId: string

      The ID of the store.

    • itemName: string

      The name of the item.

    Returns Promise<any>

  • deregisterItemFromAllStore(appId: string, type: string, subtype: string, value: string): Promise<void>
  • Deregisters an item from all stores.

    Parameters

    • appId: string

      The ID of the app.

    • type: string

      The type of the item.

    • subtype: string

      The subtype of the item.

    • value: string

      The value of the item.

    Returns Promise<void>

  • getAllItems(appId: string, type?: string, subtype?: string): Promise<Item[]>
  • Returns a list of all items created in the app. If type/subtype is given, returns only items of the given type/subtype.

    Parameters

    • appId: string

      The ID of the app.

    • Optional type: string

      The type of the items to fetch.

    • Optional subtype: string

      The subtype of the items to fetch.

    Returns Promise<Item[]>

    List of items.

  • Retrieves the usage history of all items of an app.

    Parameters

    Returns Promise<History<ItemHistory>>

    • A Promise that resolves to an object containing the usage history.
  • Retrieves the usage history of a specific item of an app.

    Parameters

    Returns Promise<History<ItemHistory>>

    • A Promise that resolves to an object containing the usage history of the item.
  • getStoreItemInfo(appId: string, storeId: string, itemName: string): Promise<StoreItem>
  • Returns information about a specific store item for a given app and store.

    Parameters

    • appId: string

      The ID of the app.

    • storeId: string

      The ID of the store.

    • itemName: string

      The name of the item to fetch.

    Returns Promise<StoreItem>

    Information about the store item.

  • getStoreItemList(appId: string, storeId: string): Promise<StoreItem[]>
  • Returns a list of store items for a given app and store.

    Parameters

    • appId: string

      The ID of the app.

    • storeId: string

      The ID of the store.

    Returns Promise<StoreItem[]>

    List of store items.

  • getUserInventory(appId: string, userId: string): Promise<UserItem[]>
  • Returns a list of user items for a given app and user.

    Parameters

    • appId: string

      The ID of the app.

    • userId: string

      The ID of the user.

    Returns Promise<UserItem[]>

    List of user items.

  • Retrieves the usage history of a specific user of an app.

    Parameters

    Returns Promise<History<ItemHistory>>

    • A Promise that resolves to an object containing the item usage history of the user.
  • getUserItemInfo(appId: string, userId: string, itemName: string): Promise<UserItem>
  • Returns information about a specific user item for a given app and user.

    Parameters

    • appId: string

      The ID of the app.

    • userId: string

      The ID of the user.

    • itemName: string

      The name of the item to fetch.

    Returns Promise<UserItem>

    Information about the user item.

  • giveItemToUser(appId: string, userId: string, itemName: string, quantity: number, reason?: string): Promise<ItemGiveHistory>
  • Gives item to user.

    Parameters

    • appId: string

      The ID of app.

    • userId: string

      The ID of user who will receive the item.

    • itemName: string

      The name of the item to give.

    • quantity: number

      The quantity of the item to give.

    • Optional reason: string

      The reason for giving an item. ex) Event for NFT holder

    Returns Promise<ItemGiveHistory>

    Returns information of item give history.

  • Registers an item in the store for selling.

    Parameters

    Returns Promise<StoreItem>

    Returns item information registered in the store.

  • resetNftTraitItem(appId: string, userId: string, chain: string, network: string, contractAddress: string, tokenId: string): Promise<NftMetadata>
  • Unequips all NFT traits currently worn on the NFT.

    Parameters

    • appId: string

      The ID of the app.

    • userId: string

      The ID of the user.

    • chain: string

      The symbol of chain with the NFT to unequip item.

    • network: string

      The name of network with the NFT to unequip item.

    • contractAddress: string

      The contract address of NFT to unequip item.

    • tokenId: string

      The ID of NFT to unequip item.

    Returns Promise<NftMetadata>

    • A promise that returns the metadata of the NFT after unequip nft trait item.
  • 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.

  • tryOnItem(ItemTryOnParams: ItemTryOnParams): Promise<{ image: string; isOccupied: boolean }>
  • Tries on store item to own NFT

    Parameters

    Returns Promise<{ image: string; isOccupied: boolean }>

    } - A promise that returns an object containing the image and whether the item is occupied or not.

  • unequipNftTraitItem(appId: string, userId: string, itemName: string, chain: string, network: string, contractAddress: string, tokenId: string): Promise<NftMetadata>
  • Unequips an NFT trait item that is being worn on the NFT. When unworn, it will be restored to its original NFT attribute.

    Parameters

    • appId: string

      The ID of the app.

    • userId: string

      The ID of the user.

    • itemName: string

      The name of the item to unequip.

    • chain: string

      The symbol of chain with the NFT to unequip item.

    • network: string

      The name of network with the NFT to unequip item.

    • contractAddress: string

      The contract address of NFT to unequip item.

    • tokenId: string

      The ID of NFT to unequip item.

    Returns Promise<NftMetadata>

    • A promise that returns the metadata of the NFT after unequip nft trait item.
  • Uses an item

    Type parameters

    Parameters

    Returns UseItemReturnType[T]

    • A Promise representing the retrieved item. The return type is determined based on the itemType.

Generated using TypeDoc