Table of Contents

Class CollectionModule

Namespace
Nekoyume.Module
Assembly
Lib9c.dll

Provides utility methods for working with collection states in the world state.

public static class CollectionModule
Inheritance
CollectionModule
Inherited Members

Methods

GetCollectionState(IWorldState, Address)

Get the CollectionState for a given address from the world state.

public static CollectionState GetCollectionState(this IWorldState worldState, Address address)

Parameters

worldState IWorldState

The world state object.

address Address

The address to retrieve the CollectionState.

Returns

CollectionState

The CollectionState corresponding to the address.

Exceptions

FailedLoadStateException

Thrown when the Collection state for the given address is not found in the world state.

InvalidCastException

Thrown when the serialized Collection state is not in the correct format.

GetCollectionStates(IWorldState, IReadOnlyList<Address>)

Retrieves the collection states for the given addresses from the world state.

public static Dictionary<Address, CollectionState> GetCollectionStates(this IWorldState worldState, IReadOnlyList<Address> addresses)

Parameters

worldState IWorldState

The world state used to retrieve the collection states.

addresses IReadOnlyList<Address>

The list of addresses to retrieve the collection states for.

Returns

Dictionary<Address, CollectionState>

A dictionary of Address and CollectionState pairs representing the collection states for the given addresses, or an empty dictionary for addresses that do not have a collection state.

SetCollectionState(IWorld, Address, CollectionState)

Sets the state of a collection in the world.

public static IWorld SetCollectionState(this IWorld world, Address collection, CollectionState state)

Parameters

world IWorld
collection Address

The address of the collection.

state CollectionState

The state of the collection.

Returns

IWorld

The updated world with the updated collection state.

TryGetCollectionState(IWorldState, Address, out CollectionState)

Tries to get the collection state for a specific address from the given world state.

public static bool TryGetCollectionState(this IWorldState worldState, Address address, out CollectionState collectionState)

Parameters

worldState IWorldState

The world state from which to get the collection state.

address Address

The address for which to retrieve the collection state.

collectionState CollectionState

The resulting collection state, if found.

Returns

bool

True if the collection state is found, otherwise false.