Class: BitBadgesCollection<T>
BitBadgesCollection is the type for collections returned by the BitBadges API. It extends the base CollectionDoc type and adds additional accompanying…
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:204
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.
Extends
Type Parameters
T
T extends NumberType
Implements
iBitBadgesCollection<T>CustomType<BitBadgesCollection<T>>
Constructors
Constructor
new BitBadgesCollection<
T>(data):BitBadgesCollection<T>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:256
Parameters
data
Returns
BitBadgesCollection<T>
Overrides
Properties
_docId
_docId:
string
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/docs-types/docs.ts:353
A unique stringified document ID
Implementation of
Inherited from
_id?
optional_id?:string
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/docs-types/docs.ts:354
A unique document ID (Mongo DB ObjectID)
Implementation of
Inherited from
activity
activity:
TransferActivityDoc<T>[]
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:214
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.
Implementation of
aliasPaths
aliasPaths:
AliasPathWithDetails<T>[]
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:242
The alias (non-wrapping) paths for the collection, with off-chain metadata populated.
Implementation of
iBitBadgesCollection.aliasPaths
Overrides
approvalTrackers
approvalTrackers:
ApprovalTrackerDoc<T>[]
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:217
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.
Implementation of
iBitBadgesCollection.approvalTrackers
challengeTrackers
challengeTrackers:
MerkleChallengeTrackerDoc<T>[]
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:216
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.
Implementation of
iBitBadgesCollection.challengeTrackers
claims
claims:
ClaimDetails<T>[]
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:221
Details about any off-chain claims for this collection. Only applicable when outsourced to BitBadges.
Implementation of
collectionApprovals
collectionApprovals:
CollectionApprovalWithDetails<T>[]
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:208
The collection approvals for this collection, with off-chain metadata populated.
Implementation of
iBitBadgesCollection.collectionApprovals
Overrides
CollectionDoc.collectionApprovals
collectionId
collectionId:
string
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/docs-types/docs.ts:355
The collection ID
Implementation of
iBitBadgesCollection.collectionId
Inherited from
collectionMetadata
collectionMetadata:
CollectionMetadataDetails<T>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:212
The collection metadata for this collection, with off-chain metadata populated.
Implementation of
iBitBadgesCollection.collectionMetadata
Overrides
CollectionDoc.collectionMetadata
collectionPermissions
collectionPermissions:
CollectionPermissionsWithDetails<T>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:209
The collection permissions for this collection, with off-chain metadata populated.
Implementation of
iBitBadgesCollection.collectionPermissions
Overrides
CollectionDoc.collectionPermissions
cosmosCoinWrapperPaths
cosmosCoinWrapperPaths:
CosmosCoinWrapperPathWithDetails<T>[]
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:240
The IBC wrapper paths for the collection, with off-chain metadata populated.
Implementation of
iBitBadgesCollection.cosmosCoinWrapperPaths
Overrides
CollectionDoc.cosmosCoinWrapperPaths
createdBlock
createdBlock:
T
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/docs-types/docs.ts:366
The block number when this collection was created
Implementation of
iBitBadgesCollection.createdBlock
Inherited from
createdBy
createdBy:
string
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/docs-types/docs.ts:365
The BitBadges address of the user who created this collection
Implementation of
iBitBadgesCollection.createdBy
Inherited from
createdTimestamp
createdTimestamp:
T
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/docs-types/docs.ts:367
The timestamp when this collection was created (milliseconds since epoch)
Implementation of
iBitBadgesCollection.createdTimestamp
Inherited from
CollectionDoc.createdTimestamp
customData
customData:
string
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/docs-types/docs.ts:358
The custom data
Implementation of
iBitBadgesCollection.customData
Inherited from
defaultBalances
defaultBalances:
UserBalanceStoreWithDetails<T>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:210
The default balances for users upon genesis, with off-chain metadata populated.
Implementation of
iBitBadgesCollection.defaultBalances
Overrides
invariants
invariants:
CollectionInvariantsWithDetails<T>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:244
Collection-level invariants with EVM query challenge metadata populated (WithDetails).
Implementation of
iBitBadgesCollection.invariants
Overrides
isArchived
isArchived:
boolean
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/docs-types/docs.ts:363
The is archived flag
Implementation of
iBitBadgesCollection.isArchived
Inherited from
listings
listings:
UtilityPageDoc<T>[]
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:219
The listings for this collection.
Implementation of
manager
manager:
string
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/docs-types/docs.ts:359
The manager
Implementation of
Inherited from
mintEscrowAddress
mintEscrowAddress:
string
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/docs-types/docs.ts:370
Mint escrow address
Implementation of
iBitBadgesCollection.mintEscrowAddress
Inherited from
CollectionDoc.mintEscrowAddress
nsfw?
optionalnsfw?:object
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:223
The token IDs in this collection that are marked as NSFW.
reason
reason:
string
tokenIds
tokenIds:
UintRangeArray<T>
Implementation of
owners
owners:
BalanceDocWithDetails<T>[]
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:215
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.
Implementation of
reported?
optionalreported?:object
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:224
The token IDs in this collection that have been reported.
reason
reason:
string
tokenIds
tokenIds:
UintRangeArray<T>
Implementation of
standards
standards:
string[]
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/docs-types/docs.ts:362
The standards
Implementation of
iBitBadgesCollection.standards
Inherited from
standardsConformance?
optionalstandardsConformance?:object
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:246
Standards conformance results for this collection. Populated by the indexer after evaluating each declared standard (e.g. NFTMarketplace, NFTPricingDenom) against the on-chain collection state. Conformance is deterministic, so the indexer recomputes on each fetch rather than caching.
The key is the standard name (e.g. "NFTMarketplace"); the value is a
{ conforms, errors?, warnings? } object where errors lists rule
violations that cause conforms to be false, and warnings lists soft
advisories that do not affect conformance.
Index Signature
[standardName: string]: object
Implementation of
iBitBadgesCollection.standardsConformance
standardsInfo?
optionalstandardsInfo?:iStandardsInfo
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:254
Per-standard core-details object attached by the indexer. Companion to
standardsConformance. Only contains data that requires an extra fetch
(e.g. an escrow balance) or is a derived status enum — does NOT duplicate
data already on the collection doc (approvals, metadata, amounts), which
is derivable client-side.
Implementation of
iBitBadgesCollection.standardsInfo
stats?
optionalstats?:CollectionStatsDoc<T>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:236
The stats for this collection.
Implementation of
tokenFloorPrices?
optionaltokenFloorPrices?:iTokenFloorPriceDoc<T>[]
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:238
The floor prices for this collection.
Implementation of
iBitBadgesCollection.tokenFloorPrices
tokenMetadata
tokenMetadata:
TokenMetadataDetails<T>[]
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:213
The token metadata for this collection, with off-chain metadata populated.
Implementation of
iBitBadgesCollection.tokenMetadata
Overrides
updateHistory
updateHistory:
UpdateHistory<T>[]
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/docs-types/docs.ts:368
The update history of this collection
Implementation of
iBitBadgesCollection.updateHistory
Inherited from
validTokenIds
validTokenIds:
UintRangeArray<T>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/docs-types/docs.ts:369
Valid token IDs for the collection
Implementation of
iBitBadgesCollection.validTokenIds
Inherited from
views
views:
object
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:226
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.
Index Signature
[viewId: string]: { ids: string[]; pagination: PaginationInfo; type: string; } | undefined
Implementation of
Methods
checkCanAddMoreAliasPaths()
checkCanAddMoreAliasPaths(
time?):Error|null
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:714
Checks if this permission is executable at a specific time (Date.now() by default).
Wrapper for ActionPermission.check.
Parameters
time?
Returns
Error | null
checkCanAddMoreCosmosCoinWrapperPaths()
checkCanAddMoreCosmosCoinWrapperPaths(
time?):Error|null
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:723
Checks if this permission is executable at a specific time (Date.now() by default).
Wrapper for ActionPermission.check.
Parameters
time?
Returns
Error | null
checkCanArchiveCollection()
checkCanArchiveCollection(
time?):Error|null
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:601
Checks if this permission is executable for the provided values at a specific time (Date.now() by default).
Wrapper for ActionPermission.check.
Parameters
time?
Returns
Error | null
checkCanDeleteCollection()
checkCanDeleteCollection(
time?):Error|null
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:592
Checks if this permission is executable at a specific time (Date.now() by default).
Wrapper for ActionPermission.check.
Parameters
time?
Returns
Error | null
checkCanUpdateCollectionApprovals()
checkCanUpdateCollectionApprovals(
details,time?):Error|null
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:673
Checks if this permission is executable for the provided values at a specific time (Date.now() by default).
Wrapper for CollectionApprovalPermission.check.
Parameters
details
object[]
time?
Returns
Error | null
checkCanUpdateCollectionMetadata()
checkCanUpdateCollectionMetadata(
time?):Error|null
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:635
Checks if this permission is executable for the provided values at a specific time (Date.now() by default).
Wrapper for ActionPermission.check.
Parameters
time?
Returns
Error | null
checkCanUpdateCustomData()
checkCanUpdateCustomData(
time?):Error|null
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:627
Checks if this permission is executable for the provided values at a specific time (Date.now() by default).
Wrapper for ActionPermission.check.
Parameters
time?
Returns
Error | null
checkCanUpdateManager()
checkCanUpdateManager(
time?):Error|null
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:610
Checks if this permission is executable for the provided values at a specific time (Date.now() by default).
Wrapper for ActionPermission.check.
Parameters
time?
Returns
Error | null
checkCanUpdateStandards()
checkCanUpdateStandards(
time?):Error|null
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:619
Checks if this permission is executable for the provided values at a specific time (Date.now() by default).
Wrapper for ActionPermission.check.
Parameters
time?
Returns
Error | null
checkCanUpdateTokenMetadata()
checkCanUpdateTokenMetadata(
tokenIds,time?):Error|null
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:658
Checks if this permission is executable for the provided values at a specific time (Date.now() by default).
Parameters
tokenIds
iUintRange<T>[]
time?
Returns
Error | null
checkCanUpdateValidTokenIds()
checkCanUpdateValidTokenIds(
tokenIds,time?):Error|null
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:646
Checks if this permission is executable for the provided values at a specific time (Date.now() by default).
Wrapper for TimedUpdatePermission.check.
Parameters
tokenIds
iUintRange<T>[]
time?
Returns
Error | null
clone()
clone():
BitBadgesCollection<T>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:289
Deep copies the object and returns a new instance.
Returns
BitBadgesCollection<T>
Implementation of
Overrides
convert()
convert<
U>(convertFunction,options?):BitBadgesCollection<U>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:285
Converts the object to a different NumberType equivalent.
Type Parameters
U
U extends NumberType
Parameters
convertFunction
(item) => U
options?
Returns
BitBadgesCollection<U>
Implementation of
Overrides
equals()
equals<
U>(other,normalizeNumberTypes?):boolean
Defined in: packages/bitbadgesjs-sdk/src/common/base.ts:147
Compares this object's fields to another object's fields for equality. Equality is determined by comparing the JSON representations of the objects.
If normalizeNumberTypes is true, then all number types will be compared as strings (i.e. "1n" === "1" === 1). Else, they will be compared as their native types (i.e. 1n !== 1 !== "1").
Type Parameters
U
U extends CustomType<U>
Parameters
other
CustomType<U> | null | undefined
normalizeNumberTypes?
boolean
Returns
boolean
Implementation of
Inherited from
fetchAllForView()
fetchAllForView(
api,viewType,viewId,oldestFirst?,address?):Promise<void>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:1001
Fetches the entire view (all pages) for a specific view. This will update the current collection with the new response information.
There is a 1 second delay between each page fetch to prevent rate limiting.
Parameters
api
viewType
viewId
string
oldestFirst?
boolean
address?
string
Returns
Promise<void>
fetchAndUpdate()
fetchAndUpdate(
api,options,forceful?):Promise<void>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:909
Specify a new fetch request for the current collection. This will update the current collection with the new response information. For example, paginations, metadata, views, etc. will all be handled automatically.
Parameters
api
options
GetMetadataForCollectionPayload & GetAdditionalCollectionDetailsPayload
forceful?
boolean
Returns
Promise<void>
fetchBalances()
fetchBalances(
api,address,forceful?):Promise<BalanceDocWithDetails<T>>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:808
Fetches the owner information (balances) for a specific address for the current collection. This will update the current collection with the new response information.
Parameters
api
address
string
forceful?
boolean
Returns
Promise<BalanceDocWithDetails<T>>
Remarks
Returns the cached value if already fetched. Use forceful to force a new fetch.
fetchMetadata()
fetchMetadata(
api,options,forceful?):Promise<void>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:946
Wrapper for fetchAndUpdate that fetches collection metadata.
Parameters
api
options
GetMetadataForCollectionPayload
forceful?
boolean
Returns
Promise<void>
fetchNextForView()
fetchNextForView(
api,viewType,viewId,oldestFirst?,address?):Promise<void>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:980
Fetches the next page for a specific view. This will update the current collection with the new response information (handling paginations).
If the view has no more pages, this will do nothing.
Parameters
api
viewType
viewId
string
oldestFirst?
boolean
address?
string
Returns
Promise<void>
FilterTokensInCollection()
FilterTokensInCollection(
api,bodyOptions):Promise<FilterTokensInCollectionSuccessResponse<T>>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:1275
Execute a filter query for the collection. You have to handle the pagination yourself.
Parameters
api
bodyOptions
Omit<iFilterTokensInCollectionPayload, "collectionId">
Returns
Promise<FilterTokensInCollectionSuccessResponse<T>>
generateAliasForTokenId()
generateAliasForTokenId(
tokenId):string
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:1088
Generates the alias for a specific token ID. Collection alias is stored in the root of the collection.
Wrapper for generateAlias.
Parameters
tokenId
T
Returns
string
getActivityView()
getActivityView(
viewId):TransferActivityDoc<T>[]
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:1033
Gets the documents for a specific view.
Parameters
viewId
string
Returns
TransferActivityDoc<T>[]
getApprovalTrackersView()
getApprovalTrackersView(
viewId):ApprovalTrackerDoc<T>[]
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:1068
Gets the documents for a specific view.
Parameters
viewId
string
Returns
ApprovalTrackerDoc<T>[]
getBalanceAmountForToken()
getBalanceAmountForToken(
address,tokenId):T
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:448
Returns the balance amount for a specific token ID at the current time for a given address. Uses the cached balance data. Returns 0 if no balance info is found.
Parameters
address
string
The address to look up.
tokenId
T
The token ID to look up.
Returns
T
getBalanceInfo()
getBalanceInfo(
address):BalanceDocWithDetails<T> |undefined
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:401
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
BalanceDocWithDetails<T> | undefined
Remarks
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.
Example
const collection: BitBadgesCollection<bigint> = { ... }
const address = 'bb1...'
const balance = collection.getBalance(address)
console.log(balance?.balances)
console.log(balance?.outgoingApprovals)getBalances()
getBalances(
address):BalanceArray<T> |undefined
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:430
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
BalanceArray<T> | undefined
Remarks
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.
Example
const collection: BitBadgesCollection<bigint> = { ... }
const address = 'bb1...'
const balances = collection.getBalances(address)
console.log(balances)getChallengeTrackersView()
getChallengeTrackersView(
viewId):MerkleChallengeTrackerDoc<T>[]
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:1051
Gets the documents for a specific view.
Parameters
viewId
string
Returns
MerkleChallengeTrackerDoc<T>[]
getCollectionMetadata()
getCollectionMetadata():
Metadata<T> |undefined
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:303
Get the cached collection metadata. This is the fetched metadata, not the timeline values.
Returns
Metadata<T> | undefined
Example
const collection: BitBadgesCollection<bigint> = { ... }
const metadata = collection.getCollectionMetadata()
const metadataImage = metadata.imagegetCollectionMetadataDetails()
getCollectionMetadataDetails():
CollectionMetadataDetails<T>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:307
Returns
getDefaultDisplayCurrency()
getDefaultDisplayCurrency():
string
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:357
Gets default display currency, if set. Defaults to ubadge.
Returns
string
getDefaultUserBalance()
getDefaultUserBalance():
UserBalanceStore<T>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/docs-types/docs.ts:404
Creates a blank balance object with the genesis default approvals and balances.
Returns
Inherited from
CollectionDoc.getDefaultUserBalance
getListingsView()
getListingsView(
viewId):UtilityPageDoc<T>[]
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:1060
Gets the documents for a specific view.
Parameters
viewId
string
Returns
UtilityPageDoc<T>[]
getMaxTokenId()
getMaxTokenId():
bigint
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:459
Gets the maximum token ID for the collection. Checks both the circulating supplys + genesis default balances.
Precondition: The Total balance must be fetched.
Returns
bigint
getMintCollectionApprovals()
getMintCollectionApprovals():
CollectionApprovalWithDetails<bigint>[]
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:1117
Returns all the mint collection approvals.
Wrapper for getMintApprovals.
Returns
CollectionApprovalWithDetails<bigint>[]
getNonMintCollectionApprovals()
getNonMintCollectionApprovals():
CollectionApprovalWithDetails<bigint>[]
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:1108
Returns all the non-mint collection approvals.
Wrapper for getNonMintApprovals.
Returns
CollectionApprovalWithDetails<bigint>[]
getNumberFieldNames()
getNumberFieldNames():
string[]
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:281
Internal helper method to convert the number fields of the object to a different NumberType equivalent.
Returns
string[]
Implementation of
CustomType.getNumberFieldNames
Overrides
CollectionDoc.getNumberFieldNames
getOwners()
getOwners(
api,tokenId,body):Promise<GetOwnersSuccessResponse<T>>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:1243
Gets the owners for a specific token. You have to handle the pagination yourself.
Parameters
api
tokenId
T
body
Returns
Promise<GetOwnersSuccessResponse<T>>
getOwnersView()
getOwnersView(
viewId):BalanceDocWithDetails<T>[]
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:1042
Gets the documents for a specific view.
Parameters
viewId
string
Returns
getRefreshStatus()
getRefreshStatus(
api):Promise<RefreshStatusSuccessResponse<T>>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:1141
Check the refresh queue status for the collection via the API.
Parameters
api
Returns
Promise<RefreshStatusSuccessResponse<T>>
getTokenActivity()
getTokenActivity(
api,tokenId,body):Promise<GetTokenActivitySuccessResponse<T>>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:1207
Get the token activity for a specific token ID. You have to handle the pagination yourself.
Parameters
api
tokenId
T
body
Returns
Promise<GetTokenActivitySuccessResponse<T>>
getTokenFloorPricesView()
getTokenFloorPricesView(
viewId):TokenFloorPriceDoc<T>[]
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:1077
Gets the documents for a specific view.
Parameters
viewId
string
Returns
TokenFloorPriceDoc<T>[]
getTokenIdRange()
getTokenIdRange():
UintRangeArray<bigint>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:350
Gets a UintRangeArray of 1 - Max Token ID for the collection (i.e. [{ start: 1n, end: maxTokenId }]).
Returns
UintRangeArray<bigint>
getTokenMetadata()
getTokenMetadata():
TokenMetadataDetails<T>[]
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:316
Gets the token metadata at a specific time (Date.now() by default).
This gets the timeline value. For the actual fetched value, use getTokenMetadataForTokenId() instead.
Returns
TokenMetadataDetails<T>[]
getTokenMetadataDetails()
getTokenMetadataDetails(
tokenId):TokenMetadataDetails<T> |undefined
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:343
Gets the details for a specific token ID. This includes the metadata, URI, and custom data.
If you only want the metadata, use getTokenMetadata, or you can access it via result.metadata.
Parameters
tokenId
T
Returns
TokenMetadataDetails<T> | undefined
getTokenMetadataForTokenId()
getTokenMetadataForTokenId(
tokenId):Metadata<T> |undefined
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:334
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
Metadata<T> | undefined
Example
const collection: BitBadgesCollection<bigint> = { ... }
const tokenId = 123n
const metadata = collection.getTokenMetadataForTokenId(tokenId)
const metadataImage = metadata.imagegetUnhandledCollectionApprovals()
getUnhandledCollectionApprovals():
CollectionApprovalWithDetails<bigint>[]
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:1099
Returns all the unhandled collection approvals. Unhandled means disapproved.
Wrapper for getUnhandledCollectionApprovals.
Returns
CollectionApprovalWithDetails<bigint>[]
getView()
getView<
KeyType>(viewType,viewId):CollectionViewData<T>[KeyType]
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:1011
Type agnostic get view function. Uses the viewType to determine the type of view to fetch.
Type Parameters
KeyType
KeyType extends CollectionViewKey
Parameters
viewType
KeyType
viewId
string
Returns
CollectionViewData<T>[KeyType]
getViewBookmark()
getViewBookmark(
viewId):string|undefined
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:971
Returns the bookmark for a specific view. This is used to fetch the next page.
Parameters
viewId
string
Returns
string | undefined
getViewPagination()
getViewPagination(
viewId):PaginationInfo|undefined
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:964
Returns the pagination information for a specific view ({ hasMore, bookmark }).
Parameters
viewId
string
Returns
PaginationInfo | undefined
hasNFTMarketplaceStandard()
hasNFTMarketplaceStandard():
boolean
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:370
Checks if collection has the NFT marketplace standard (accepts both new 'NFTMarketplace' and legacy 'Tradable' names).
Returns
boolean
hasNumberFields()
hasNumberFields():
boolean
Defined in: packages/bitbadgesjs-sdk/src/common/base.ts:161
Checks if the object has number fields.
Returns
boolean
Implementation of
Inherited from
isRedundantRequest()
isRedundantRequest(
options):boolean
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:821
Returns if a new collection API request body is redundant (meaning we already have the data cached).
Parameters
options
GetMetadataForCollectionPayload & GetAdditionalCollectionDetailsPayload
Returns
boolean
mustGetBalanceInfo()
mustGetBalanceInfo(
address):BalanceDocWithDetails<T>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:408
Wrapper for getBalanceInfo that throws an error if the balance is not found in the document.
Parameters
address
string
Returns
mustGetBalances()
mustGetBalances(
address):BalanceArray<T>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:437
Wrapper for getBalances that throws an error if the balance is not found in the document.
Parameters
address
string
Returns
BalanceArray<T>
pruneMetadataToFetch()
pruneMetadataToFetch(
metadataToFetch):object
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:480
For a metadata fetch request, prune the request to only request the metadata that is not already fetched.
Parameters
metadataToFetch
Returns
object
doNotFetchCollectionMetadata
doNotFetchCollectionMetadata:
boolean
uris
uris:
string[]
Example
const collection: BitBadgesCollection<bigint> = { ... }
const metadataToFetch = collection.pruneMetadataToFetch({ tokenIds: [1n, 2n, 3n], uris: ['ipfs://...'] })
console.log(metadataToFetch)prunePayload()
prunePayload(
options):GetMetadataForCollectionPayload&GetAdditionalCollectionDetailsPayload&object
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:870
Prunes a new collection API request body to only request the data that is not already fetched.
Parameters
options
GetMetadataForCollectionPayload & GetAdditionalCollectionDetailsPayload
Returns
GetMetadataForCollectionPayload & GetAdditionalCollectionDetailsPayload & object
refresh()
refresh(
api):Promise<RefreshMetadataSuccessResponse>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:1171
Trigger a refresh for the collection via the API. Note there is a cooldown period for refreshing.
Parameters
api
Returns
Promise<RefreshMetadataSuccessResponse>
toJson()
toJson():
JsonObject
Defined in: packages/bitbadgesjs-sdk/src/common/base.ts:139
Converts the object to a JSON object with all primitive types.
Returns
JsonObject
Implementation of
Inherited from
toJsonString()
toJsonString():
string
Defined in: packages/bitbadgesjs-sdk/src/common/base.ts:143
Converts the object to a JSON string.
Returns
string
Implementation of
Inherited from
updateWithNewResponse()
updateWithNewResponse(
newResponse,forceful?):void
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:931
Updates the current collection with a new response from the API. If forceful is true, we fully overwrite the current collection with the new response. Else, we will append the new response to the current collection while handling duplicates, paginations, etc.
Parameters
newResponse
BitBadgesCollection<T>
forceful?
boolean
Returns
void
validateCollectionApprovalsUpdate()
validateCollectionApprovalsUpdate(
newApprovals):Error|null
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:521
Validates if a state transition (old approvals -> new approvals) is valid, given the current state of the collection and its permissions.
Wrapper for CollectionApprovalWithDetails.validateUpdate.
Parameters
newApprovals
CollectionApprovalWithDetails<T>[]
Returns
Error | null
validateCollectionMetadataUpdate()
validateCollectionMetadataUpdate(
newCollectionMetadata):Error|null
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:582
Validates if a state transition (old collection metadata -> new collection metadata) is valid, given the current state of the collection and its permissions.
Wrapper for validateCollectionMetadataUpdate.
Parameters
newCollectionMetadata
Returns
Error | null
validateCustomDataUpdate()
validateCustomDataUpdate(
newCustomData):Error|null
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:546
Validates if a state transition (old custom data -> new custom data) is valid, given the current state of the collection and its permissions.
Wrapper for validateCustomDataUpdate.
Parameters
newCustomData
string
Returns
Error | null
validateIsArchivedUpdate()
validateIsArchivedUpdate(
newIsArchived):Error|null
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:564
Validates if a state transition (old isArchived -> new isArchived) is valid, given the current state of the collection and its permissions.
Wrapper for validateIsArchivedUpdate.
Parameters
newIsArchived
boolean
Returns
Error | null
validateManagerUpdate()
validateManagerUpdate(
newManager):Error|null
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:573
Validates if a state transition (old manager -> new manager) is valid, given the current state of the collection and its permissions.
Wrapper for validateManagerUpdate.
Parameters
newManager
string
Returns
Error | null
validatePermissionsUpdate()
validatePermissionsUpdate(
newPermissions):Error|null
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:496
Validates if a state transition (old permissions -> new permissions) is valid. Must not update any permanently frozen permissions.
Wrapper for CollectionPermissionsWithDetails.validateUpdate.
Parameters
newPermissions
CollectionPermissionsWithDetails<T>
Returns
Error | null
See
Remarks
This is validating the updatability of the permissions. To validate whether a permission is executable, use the checkCan* functions.
validatePermissionUpdate()
validatePermissionUpdate(
permissionName,newPermissions):Error|null
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:509
Validates if a single permission type is updated correctly. Cannot edit anything permanently frozen.
This is validating the updatability of the permissions. To validate whether a permission is executable, use the checkCan* functions.
Parameters
permissionName
newPermissions
any[]
Returns
Error | null
See
validateStandardsUpdate()
validateStandardsUpdate(
newStandards):Error|null
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:555
Validates if a state transition (old standards -> new standards) is valid, given the current state of the collection and its permissions.
Wrapper for validateStandardsUpdate.
Parameters
newStandards
string[]
Returns
Error | null
validateTokenMetadataUpdate()
validateTokenMetadataUpdate(
newTokenMetadata):Error|null
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:535
Validates if a state transition (old token metadata -> new token metadata) is valid, given the current state of the collection and its permissions.
Wrapper for validateTokenMetadataUpdate.
Parameters
newTokenMetadata
iTokenMetadata<T>[]
Returns
Error | null
viewHasMore()
viewHasMore(
viewId):boolean
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:957
Returns if the view has more pages to fetch.
Parameters
viewId
string
Returns
boolean
FetchAndInitialize()
staticFetchAndInitialize<T>(api,options):Promise<BitBadgesCollection<T>>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:733
Fetches and initializes a new BitBadgesCollection object from an API request. Must pass in a valid API instance.
Type Parameters
T
T extends NumberType
Parameters
api
options
object & GetMetadataForCollectionPayload & GetAdditionalCollectionDetailsPayload
Returns
Promise<BitBadgesCollection<T>>
FetchAndInitializeBatch()
staticFetchAndInitializeBatch<T>(api,collectionsToFetch):Promise<(BitBadgesCollection<T> |undefined)[]>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:794
Fetches and initializes a batch of new BitBadgesCollection objects from an API request. Must pass in a valid API instance.
Type Parameters
T
T extends NumberType
Parameters
api
collectionsToFetch
object & GetMetadataForCollectionPayload & GetAdditionalCollectionDetailsPayload[]
Returns
Promise<(BitBadgesCollection<T> | undefined)[]>
FilterTokensInCollection()
staticFilterTokensInCollection<T>(api,collectionId,body):Promise<FilterTokensInCollectionSuccessResponse<T>>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:1250
Execute a filter query for the collection. You have to handle the pagination yourself.
Type Parameters
T
T extends NumberType
Parameters
api
collectionId
string
body
iFilterTokensInCollectionPayload
Returns
Promise<FilterTokensInCollectionSuccessResponse<T>>
GetBalanceByAddress()
staticGetBalanceByAddress<T>(api,collectionId,address,payload?):Promise<GetBalanceByAddressSuccessResponse<T>>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:766
Gets the balance for a specific address for a specific collection. Must pass in a valid API instance.
Type Parameters
T
T extends NumberType
Parameters
api
collectionId
string
address
string
payload?
Returns
Promise<GetBalanceByAddressSuccessResponse<T>>
GetCollections()
staticGetCollections<T>(api,body):Promise<GetCollectionsSuccessResponse<T>>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:745
Gets collections from the API. Must pass in a valid API instance.
Type Parameters
T
T extends NumberType
Parameters
api
body
Returns
Promise<GetCollectionsSuccessResponse<T>>
GetOwners()
staticGetOwners<T>(api,collectionId,tokenId,payload?):Promise<GetOwnersSuccessResponse<T>>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:1214
Gets owners for a specific token ID. You have to handle the pagination yourself.
Type Parameters
T
T extends NumberType
Parameters
api
collectionId
string
tokenId
payload?
Returns
Promise<GetOwnersSuccessResponse<T>>
GetRefreshStatus()
staticGetRefreshStatus<T>(api,collectionId):Promise<RefreshStatusSuccessResponse<T>>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:1124
Returns the status of this collection in the refresh queue.
Type Parameters
T
T extends NumberType
Parameters
api
collectionId
string
Returns
Promise<RefreshStatusSuccessResponse<T>>
GetTokenActivity()
staticGetTokenActivity<T>(api,collectionId,tokenId,payload?):Promise<GetTokenActivitySuccessResponse<T>>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:1178
Gets activity for a specific token ID. You have to handle the pagination yourself.
Type Parameters
T
T extends NumberType
Parameters
api
collectionId
string
tokenId
payload?
Returns
Promise<GetTokenActivitySuccessResponse<T>>
RefreshMetadata()
staticRefreshMetadata<T>(api,collectionId,body?):Promise<RefreshMetadataSuccessResponse>
Defined in: packages/bitbadgesjs-sdk/src/api-indexer/BitBadgesCollection.ts:1148
Trigger a refresh for the collection via the API. Note there is a cooldown period for refreshing.
Type Parameters
T
T extends NumberType
Parameters
api
collectionId
string
body?
Returns
Promise<RefreshMetadataSuccessResponse>