bitbadgesjs-sdk - v0.27.2
    Preparing search index...

    Class BitBadgesCollection<T>

    BitBadgesCollection is the type for collections returned by the BitBadges API. It extends the base CollectionDoc type and adds additional accompanying Docrmation such as metadata, activity, balances, preferred chain, etc.

    Type Parameters

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    Methods

    checkCanAddMoreAliasPaths checkCanAddMoreCosmosCoinWrapperPaths checkCanArchiveCollection checkCanDeleteCollection checkCanUpdateCollectionApprovals checkCanUpdateCollectionMetadata checkCanUpdateCustomData checkCanUpdateManager checkCanUpdateStandards checkCanUpdateTokenMetadata checkCanUpdateValidTokenIds clone convert equals fetchAllForView fetchAndUpdate fetchBalances fetchMetadata fetchNextForView FilterTokensInCollection generateAliasForTokenId getActivityView getApprovalTrackersView getBalanceInfo getBalances getChallengeTrackersView getCollectionMetadata getCollectionMetadataDetails getDefaultDisplayCurrency getDefaultUserBalance getListingsView getMaxTokenId getMintCollectionApprovals getNonMintCollectionApprovals getNumberFieldNames getOwners getOwnersView getRefreshStatus getTokenActivity getTokenFloorPricesView getTokenIdRange getTokenMetadata getTokenMetadataDetails getTokenMetadataForTokenId getUnhandledCollectionApprovals getView getViewBookmark getViewPagination hasNumberFields isRedundantRequest mustGetBalanceInfo mustGetBalances pruneMetadataToFetch prunePayload refresh toJson toJsonString updateWithNewResponse validateCollectionApprovalsUpdate validateCollectionMetadataUpdate validateCustomDataUpdate validateIsArchivedUpdate validateManagerUpdate validatePermissionsUpdate validatePermissionUpdate validateStandardsUpdate validateTokenMetadataUpdate viewHasMore FetchAndInitialize FetchAndInitializeBatch FilterTokensInCollection GetBalanceByAddress GetCollections GetOwners GetRefreshStatus GetTokenActivity RefreshMetadata

    Constructors

    Properties

    _docId: string

    A unique stringified document ID

    _id?: string

    A unique document ID (Mongo DB ObjectID)

    activity: TransferActivityDoc<T>[]

    The fetched activity for this collection. Returned collections will only fetch the current page. Use the pagination to fetch more. To be used in conjunction with views.

    aliasPaths: AliasPathWithDetails<T>[]

    The alias (non-wrapping) paths for the collection, with off-chain metadata populated.

    approvalTrackers: ApprovalTrackerDoc<T>[]

    The fetched approval trackers for this collection. Returned collections will only fetch the current page. Use the pagination to fetch more. To be used in conjunction with views.

    challengeTrackers: MerkleChallengeTrackerDoc<T>[]

    The fetched merkle challenge trackers for this collection. Returned collections will only fetch the current page. Use the pagination to fetch more. To be used in conjunction with views.

    claims: ClaimDetails<T>[]

    Details about any off-chain claims for this collection. Only applicable when outsourced to BitBadges.

    collectionApprovals: CollectionApprovalWithDetails<T>[]

    The collection approvals for this collection, with off-chain metadata populated.

    collectionId: string

    The collection ID

    collectionMetadata: CollectionMetadataDetails<T>

    The collection metadata for this collection, with off-chain metadata populated.

    collectionPermissions: CollectionPermissionsWithDetails<T>

    The collection permissions for this collection, with off-chain metadata populated.

    cosmosCoinWrapperPaths: CosmosCoinWrapperPathWithDetails<T>[]

    The IBC wrapper paths for the collection, with off-chain metadata populated.

    createdBlock: T

    The block number when this collection was created

    createdBy: string

    The BitBadges address of the user who created this collection

    createdTimestamp: T

    The timestamp when this collection was created (milliseconds since epoch)

    customData: string

    The custom data

    defaultBalances: UserBalanceStoreWithDetails<T>

    The default balances for users upon genesis, with off-chain metadata populated.

    invariants: CollectionInvariants<T>

    Collection-level invariants that cannot be broken. These are set upon genesis and cannot be modified.

    isArchived: boolean

    The is archived flag

    listings: UtilityPageDoc<T>[]

    The listings for this collection.

    manager: string

    The manager

    mintEscrowAddress: string

    Mint escrow address

    nsfw?: { reason: string; tokenIds: UintRangeArray<T> }

    The token IDs in this collection that are marked as NSFW.

    The fetched owners of this collection. Returned collections will only fetch the current page. Use the pagination to fetch more. To be used in conjunction with views.

    reported?: { reason: string; tokenIds: UintRangeArray<T> }

    The token IDs in this collection that have been reported.

    standards: string[]

    The standards

    The stats for this collection.

    tokenFloorPrices?: iTokenFloorPriceDoc<T>[]

    The floor prices for this collection.

    tokenMetadata: TokenMetadataDetails<T>[]

    The token metadata for this collection, with off-chain metadata populated.

    updateHistory: UpdateHistory<T>[]

    The update history of this collection

    validTokenIds: UintRangeArray<T>

    Valid token IDs for the collection

    views: {
        [viewId: string]:
            | undefined
            | { ids: string[]; pagination: PaginationInfo; type: string };
    }

    The views for this collection and their pagination Doc. Views will only include the doc _ids. Use the pagination to fetch more. For example, if you want to fetch the activity for a view, you would use the view's pagination to fetch the doc _ids, then use the corresponding activity array to find the matching docs.

    Methods

    • Gets the balance document for a specific address from the cached owners array. Returns undefined if not fetched yet. The balance document includes the balances, outgoing approvals, and other details. Use getBalances to only get the balances.

      Parameters

      • address: string

      Returns undefined | BalanceDocWithDetails<T>

      This does not fetch the balance from the API. It only returns the cached balance. To fetch the balance, this can either be done directly, or if the collection balances are indexable then the balances can also be fetched via the views and / or the other fetch methods.

      const collection: BitBadgesCollection<bigint> = { ... }
      const address = 'bb1...'
      const balance = collection.getBalance(address)
      console.log(balance?.balances)
      console.log(balance?.outgoingApprovals)
    • Gets the balances for a specific address from the cached owners array. Returns undefined if not fetched yet. This returns the balances only, not the other details. Use getBalanceInfo to get the other details for a user balance store (approvals, etc.).

      Parameters

      • address: string

      Returns undefined | BalanceArray<T>

      This does not fetch the balance from the API. It only returns the cached balance. To fetch the balance, this can either be done directly, or if the collection balances are indexable (i.e. balances type is anything but Off-Chain - Non-Indexed), then the balances can also be fetched via the views and / or the other fetch methods.

      const collection: BitBadgesCollection<bigint> = { ... }
      const address = 'bb1...'
      const balances = collection.getBalances(address)
      console.log(balances)
    • Get the metadata for a specific token ID. This is the fetched metadata, not the timeline values.

      This only returns the metadata object (name, image, etc.) and not the URI or other accompanying details. For those, use getTokenMetadataDetails.

      Parameters

      • tokenId: T

      Returns undefined | Metadata<T>

      const collection: BitBadgesCollection<bigint> = { ... }
      const tokenId = 123n
      const metadata = collection.getTokenMetadataForTokenId(tokenId)
      const metadataImage = metadata.image