Function getMetadataIdForBadgeId

This function returns the Metadata ID for a specific badge ID. Returns -1 if not found.

The badge metadata array is the timeline values (BadgeMetadataTimeline.badgeMetadata), not the cached fetched values from the API.

import { getMetadataIdForBadgeId } from 'bitbadgesjs-sdk'
const collection: BitBadgesCollection<bigint> = { ... }
const badgeId = 123n
const metadataId = getMetadataIdForBadgeId(badgeId, collection.getBadgeMetadataTimelineValue())

This can also be used with the BitBadges collection interface

import { BitBadgesCollection } from 'bitbadgesjs-sdk'
const collection: BitBadgesCollection<bigint> = { ... }
const badgeId = 123n
const metadataId = collection.getMetadataIdForBadgeId(badgeId)