Class CollectionModule
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
IWorldStateThe world state object.
address
AddressThe 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
IWorldStateThe 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
IWorldcollection
AddressThe address of the collection.
state
CollectionStateThe 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
IWorldStateThe world state from which to get the collection state.
address
AddressThe address for which to retrieve the collection state.
collectionState
CollectionStateThe resulting collection state, if found.
Returns
- bool
True if the collection state is found, otherwise false.