Skip to content

Balance is used to represent a balance of a token. A user owns x(amount) of the token IDs (tokenIds) from a specific collection (collectionId) for a range of…

Defined in: packages/bitbadgesjs-sdk/src/core/balances.ts:22

Balance is used to represent a balance of a token. A user owns x(amount) of the token IDs (tokenIds) from a specific collection (collectionId) for a range of times (ownershipTimes).

See

BitBadges Documentation - Balances

Extends

Type Parameters

T

T extends NumberType

Implements

Constructors

Constructor

new Balance<T>(balance): Balance<T>

Defined in: packages/bitbadgesjs-sdk/src/core/balances.ts:27

Parameters

balance

iBalance<T>

Returns

Balance<T>

Overrides

BaseNumberTypeClass.constructor

Properties

amount

amount: T

Defined in: packages/bitbadgesjs-sdk/src/core/balances.ts:23

The amount or balance of the owned token.

Implementation of

iBalance.amount


ownershipTimes

ownershipTimes: UintRangeArray<T>

Defined in: packages/bitbadgesjs-sdk/src/core/balances.ts:25

The times that the token is owned from.

Implementation of

iBalance.ownershipTimes


tokenIds

tokenIds: UintRangeArray<T>

Defined in: packages/bitbadgesjs-sdk/src/core/balances.ts:24

The token IDs corresponding to the balance.

Implementation of

iBalance.tokenIds

Methods

clone()

clone(): Balance

Defined in: packages/bitbadgesjs-sdk/src/common/base.ts:151

Deep copies the object and returns a new instance.

Returns

Balance

Inherited from

BaseNumberTypeClass.clone


convert()

convert<U>(convertFunction, options?): Balance<U>

Defined in: packages/bitbadgesjs-sdk/src/core/balances.ts:38

Converts the object to a different NumberType equivalent.

Type Parameters

U

U extends NumberType

Parameters

convertFunction

(item) => U

options?

ConvertOptions

Returns

Balance<U>

Overrides

BaseNumberTypeClass.convert


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

Inherited from

BaseNumberTypeClass.equals


getNumberFieldNames()

getNumberFieldNames(): string[]

Defined in: packages/bitbadgesjs-sdk/src/core/balances.ts:34

Internal helper method to convert the number fields of the object to a different NumberType equivalent.

Returns

string[]

Overrides

BaseNumberTypeClass.getNumberFieldNames


hasNumberFields()

hasNumberFields(): boolean

Defined in: packages/bitbadgesjs-sdk/src/common/base.ts:161

Checks if the object has number fields.

Returns

boolean

Inherited from

BaseNumberTypeClass.hasNumberFields


toArray()

toArray(): BalanceArray<T>

Defined in: packages/bitbadgesjs-sdk/src/core/balances.ts:76

Returns

BalanceArray<T>


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

Inherited from

BaseNumberTypeClass.toJson


toJsonString()

toJsonString(): string

Defined in: packages/bitbadgesjs-sdk/src/common/base.ts:143

Converts the object to a JSON string.

Returns

string

Inherited from

BaseNumberTypeClass.toJsonString


toProto()

toProto(): Balance

Defined in: packages/bitbadgesjs-sdk/src/core/balances.ts:48

Returns

Balance


fromJson()

static fromJson<U>(jsonValue, convertFunction, options?): Balance<U>

Defined in: packages/bitbadgesjs-sdk/src/core/balances.ts:52

Type Parameters

U

U extends NumberType

Parameters

jsonValue

JsonValue

convertFunction

(item) => U

options?

Partial<JsonReadOptions>

Returns

Balance<U>


fromJsonString()

static fromJsonString<U>(jsonString, convertFunction, options?): Balance<U>

Defined in: packages/bitbadgesjs-sdk/src/core/balances.ts:60

Type Parameters

U

U extends NumberType

Parameters

jsonString

string

convertFunction

(item) => U

options?

Partial<JsonReadOptions>

Returns

Balance<U>


fromProto()

static fromProto<U>(item, convertFunction): Balance<U>

Defined in: packages/bitbadgesjs-sdk/src/core/balances.ts:68

Type Parameters

U

U extends NumberType

Parameters

item

Balance

convertFunction

(item) => U

Returns

Balance<U>

Edit this page on GitHub