Skip to content

AddressLists represent a list of addresses, identified by a unique ID.

Defined in: packages/bitbadgesjs-sdk/src/core/addressLists.ts:20

AddressLists represent a list of addresses, identified by a unique ID.

Some list IDs are reserved and auto generated by the blockchain. Otherwise, the list can be created on-chain via MsgCreateAddressLists.

For the BitBadges indexer / API, we also allow users to create off-chain lists hosted in a centralized manner.

On-chain lists are stored on the blockchain, are permanent, non editable, non deletable, and can be used for defining permissions and approvals. Off-chain lists are stored off-chain, are mutable, and can be edited / deleted at any time by the creator.

Extends

Extended by

Implements

Constructors

Constructor

new AddressList(addressList): AddressList

Defined in: packages/bitbadgesjs-sdk/src/core/addressLists.ts:28

Parameters

addressList

iAddressList

Returns

AddressList

Overrides

CustomTypeClass.constructor

Properties

addresses

addresses: string[]

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

The addresses of the address list. If this is a tracker list, the addresses are the tracker IDs.

Implementation of

iAddressList.addresses


createdBy?

optional createdBy?: string

Defined in: packages/bitbadgesjs-sdk/src/core/addressLists.ts:26

The address that created the address list. Handled internally.

Implementation of

iAddressList.createdBy


customData

customData: string

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

Arbitrary custom data that can be stored. Leave blank for no custom data.

Implementation of

iAddressList.customData


listId

listId: string

Defined in: packages/bitbadgesjs-sdk/src/core/addressLists.ts:21

The ID of the address list.

Implementation of

iAddressList.listId


uri

uri: string

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

The URI where to fetch the address list metadata from.

Implementation of

iAddressList.uri


whitelist

whitelist: boolean

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

Whether or not to include ONLY the addresses or include all EXCEPT the addresses.

Implementation of

iAddressList.whitelist

Methods

checkAddress()

checkAddress(address): boolean

Defined in: packages/bitbadgesjs-sdk/src/core/addressLists.ts:44

Checks if a specific account is in the given address list. This means added to a whitelist or NOT included in a blacklist.

Parameters

address

string

Returns

boolean

Remarks

The double negative may get confusing.


clone()

clone(): AddressList

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

Deep copies the object and returns a new instance.

Returns

AddressList

Inherited from

CustomTypeClass.clone


convert()

convert<U>(_convertFunction?, options?): CustomType<any>

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

Type Parameters

U

U extends NumberType

Parameters

_convertFunction?

(val) => U

options?

ConvertOptions

Returns

CustomType<any>

Deprecated

This function is unnecessary as this field has no numeric types. Please use the .clone() method instead.

Inherited from

CustomTypeClass.convert


equals()

equals<U>(other, normalizeNumberTypes?): boolean

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

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

CustomTypeClass.equals


getNumberFieldNames()

getNumberFieldNames(): string[]

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

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

Returns

string[]

Inherited from

CustomTypeClass.getNumberFieldNames


getOverlapDetails()

getOverlapDetails(addressList): [AddressList, AddressList, AddressList]

Defined in: packages/bitbadgesjs-sdk/src/core/addressLists.ts:187

Gets the overlap details for two address lists. Returns [inFirstListButNotSecond, inBothLists, inSecondListButNotFirst].

Parameters

addressList

iAddressList

Returns

[AddressList, AddressList, AddressList]


getOverlaps()

getOverlaps(addressList): AddressList

Defined in: packages/bitbadgesjs-sdk/src/core/addressLists.ts:179

Gets the addresses that are in both lists.

Note the returned value can be a whitelist or a blacklist, depending on the input lists. For example, all addresses except Bob (blacklist) overlap or just Bob (whitelist) overlap.

Parameters

addressList

iAddressList

Returns

AddressList


hasNumberFields()

hasNumberFields(): boolean

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

Checks if the object has number fields.

Returns

boolean

Inherited from

CustomTypeClass.hasNumberFields


invert()

invert(): this

Defined in: packages/bitbadgesjs-sdk/src/core/addressLists.ts:61

Inverts the list in-place. Simply done by invert the whitelist property.

Returns

this


isEmpty()

isEmpty(): boolean

Defined in: packages/bitbadgesjs-sdk/src/core/addressLists.ts:54

Returns

boolean


remove()

remove(addresses): this

Defined in: packages/bitbadgesjs-sdk/src/core/addressLists.ts:80

Removes addresses from the list in-place.

If this is a whitelist, the address will be removed (if it is currently added). If this is a blacklist, the address will be added (if it is not currently added). Otherwise, it is a no-op since it is already removed.

Parameters

addresses

string | iAddressList

Returns

this


toInverted()

toInverted(): AddressList

Defined in: packages/bitbadgesjs-sdk/src/core/addressLists.ts:69

Returns a new list with the addresses inverted.

Returns

AddressList


toJson()

toJson(): JsonObject

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

Converts the object to a JSON object with all primitive types.

Returns

JsonObject

Inherited from

CustomTypeClass.toJson


toJsonString()

toJsonString(): string

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

Converts the object to a JSON string.

Returns

string

Inherited from

CustomTypeClass.toJsonString


toProto()

toProto(): AddressList

Defined in: packages/bitbadgesjs-sdk/src/core/addressLists.ts:429

Returns

AddressList


toRemoved()

toRemoved(addresses): AddressList

Defined in: packages/bitbadgesjs-sdk/src/core/addressLists.ts:103

Wrapper for remove that returns a new list instead of modifying the current one.

Parameters

addresses

string | iAddressList

Returns

AddressList


toUnion()

toUnion(other): AddressList

Defined in: packages/bitbadgesjs-sdk/src/core/addressLists.ts:127

Wrapper for union that returns a new list instead of modifying the current one.

Parameters

other

iAddressList

Returns

AddressList


union()

union(other): this

Defined in: packages/bitbadgesjs-sdk/src/core/addressLists.ts:117

Computes the union of two address lists in-place. The result contains all addresses that are in either list.

Cases:

  • Whitelist ∪ Whitelist = Whitelist with combined addresses
  • Whitelist ∪ Blacklist = Blacklist with addresses in blacklist that are NOT in whitelist
  • Blacklist ∪ Whitelist = Blacklist with addresses in blacklist that are NOT in whitelist
  • Blacklist ∪ Blacklist = Blacklist with intersection of excluded addresses

Parameters

other

iAddressList

Returns

this


AllAddresses()

static AllAddresses(): AddressList

Defined in: packages/bitbadgesjs-sdk/src/core/addressLists.ts:196

Returns the reserved 'All' address list.

Returns

AddressList


computeUnion()

static computeUnion(first, second): AddressList

Defined in: packages/bitbadgesjs-sdk/src/core/addressLists.ts:135

Computes the union of two address lists. The result contains all addresses that are in either list.

Parameters

first

iAddressList

second

iAddressList

Returns

AddressList


fromJson()

static fromJson(jsonValue, options?): AddressList

Defined in: packages/bitbadgesjs-sdk/src/core/addressLists.ts:433

Parameters

jsonValue

JsonValue

options?

Partial<JsonReadOptions>

Returns

AddressList


fromJsonString()

static fromJsonString(jsonString, options?): AddressList

Defined in: packages/bitbadgesjs-sdk/src/core/addressLists.ts:437

Parameters

jsonString

string

options?

Partial<JsonReadOptions>

Returns

AddressList


fromProto()

static fromProto(item): AddressList

Defined in: packages/bitbadgesjs-sdk/src/core/addressLists.ts:441

Parameters

item

AddressList

Returns

AddressList


generateReservedListId()

static generateReservedListId(addressList): string

Defined in: packages/bitbadgesjs-sdk/src/core/addressLists.ts:406

Generates a list ID for a given address list.

Parameters

addressList

iAddressList

The address list to generate the ID for

Returns

string


getOverlapDetails()

static getOverlapDetails(firstList, secondList): [AddressList, AddressList, AddressList]

Defined in: packages/bitbadgesjs-sdk/src/core/addressLists.ts:286

Gets the overlap details between two address lists. Returns [inFirstButNotSecond, overlaps, inSecondButNotFirst].

Parameters

firstList

iAddressList

secondList

iAddressList

Returns

[AddressList, AddressList, AddressList]


getReservedAddressList()

static getReservedAddressList(addressListId): AddressList

Defined in: packages/bitbadgesjs-sdk/src/core/addressLists.ts:303

Returns the address list for a list ID, if it is a reserved ID (i.e. Mint, Manager, All, None, validly formatted address, ...)

Parameters

addressListId

string

Returns

AddressList


getReservedTrackerList()

static getReservedTrackerList(trackerListId): AddressList

Defined in: packages/bitbadgesjs-sdk/src/core/addressLists.ts:296

Returns the tracker list for a tracker ID list. Little different logic because tracker ID lists can only be reserved IDs (no storage) and can be nonvalid addresses

Parameters

trackerListId

string

Returns

AddressList


Reserved()

static Reserved(addressListId): AddressList

Defined in: packages/bitbadgesjs-sdk/src/core/addressLists.ts:203

Returns a reserved address list by ID.

Parameters

addressListId

string

Returns

AddressList

Edit this page on GitHub