Show / Hide Table of Contents

Class IWorldExtensions

Inheritance
System.Object
IWorldExtensions
Namespace: Libplanet.Action.State
Assembly: Libplanet.Action.dll
Syntax
public static class IWorldExtensions : object

Methods

| Improve this Doc View Source

BurnAsset(IWorld, IActionContext, Address, FungibleAssetValue)

Burns the fungible asset value (i.e., in-game monetary) from owner's balance.

Declaration
public static IWorld BurnAsset(this IWorld world, IActionContext context, Address owner, FungibleAssetValue value)
Parameters
Type Name Description
IWorld world

The IWorld to manipulate.

IActionContext context

The IActionContext of the IAction executing this method.

Address owner

The address who owns the fungible asset to burn.

FungibleAssetValue value

The fungible asset value to burn.

Returns
Type Description
IWorld

A new IWorld instance that the given value is subtracted from owner's balance.

Exceptions
Type Condition
CurrencyPermissionException

Thrown when a transaction signer (or a miner in case of block actions) is not a member of the Currency's Minters.

InsufficientBalanceException

Thrown when the owner has insufficient balance than value to burn.

| Improve this Doc View Source

GetBalance(IWorldState, Address, Currency)

Queries address's balance of the currency.

Declaration
public static FungibleAssetValue GetBalance(this IWorldState worldState, Address address, Currency currency)
Parameters
Type Name Description
IWorldState worldState

The IWorldState to read from.

Address address

The owner address to query.

Currency currency

The currency type to query.

Returns
Type Description
FungibleAssetValue

The address's balance of the currency.

| Improve this Doc View Source

GetTotalSupply(IWorldState, Currency)

Returns the total supply of currency.

The total supply of a given Currency is determined by the following:

  • If Version is less than CurrencyAccountProtocolVersion, it is the amount of total supply for the Currency in question if the value of TotalSupplyTrackable is true, and zero otherwise. That is, an untracked Currency's total supply is always considered zero.
  • If Version is greater than or equal to CurrencyAccountProtocolVersion, it is the amount of total supply for the Currency in question regardless of the value of TotalSupplyTrackable.
Declaration
public static FungibleAssetValue GetTotalSupply(this IWorldState worldState, Currency currency)
Parameters
Type Name Description
IWorldState worldState

The IWorldState to read from.

Currency currency

The currency type to query.

Returns
Type Description
FungibleAssetValue

The total supply of the currency.

| Improve this Doc View Source

GetValidatorSet(IWorldState)

Returns the validator set.

Declaration
public static ValidatorSet GetValidatorSet(this IWorldState worldState)
Parameters
Type Name Description
IWorldState worldState

The IWorldState to read from.

Returns
Type Description
ValidatorSet

The validator set of type ValidatorSet.

| Improve this Doc View Source

MintAsset(IWorld, IActionContext, Address, FungibleAssetValue)

Mints the fungible asset value (i.e., in-game monetary), and give it to the recipient.

Declaration
public static IWorld MintAsset(this IWorld world, IActionContext context, Address recipient, FungibleAssetValue value)
Parameters
Type Name Description
IWorld world

The IWorld to manipulate.

IActionContext context

The IActionContext of the IAction executing this method.

Address recipient

The address who receives the minted asset.

FungibleAssetValue value

The asset value to mint.

Returns
Type Description
IWorld

A new IWorld instance that the given value is added to recipient's balance.

Exceptions
Type Condition
CurrencyPermissionException

Thrown when a transaction signer (or a miner in case of block actions) is not a member of the Currency's Minters.

SupplyOverflowException

Thrown when the sum of the value to be minted and the current total supply amount of the Currency exceeds the MaximumSupply.

| Improve this Doc View Source

SetValidatorSet(IWorld, ValidatorSet)

Sets validatorSet to the stored ValidatorSet.

Declaration
public static IWorld SetValidatorSet(this IWorld world, ValidatorSet validatorSet)
Parameters
Type Name Description
IWorld world

The IWorld to manipulate.

ValidatorSet validatorSet

The ValidatorSet instance to write.

Returns
Type Description
IWorld

A new IWorld instance with validator set.

| Improve this Doc View Source

TransferAsset(IWorld, IActionContext, Address, Address, FungibleAssetValue)

Transfers the fungible asset value (i.e., in-game monetary) from the sender to the recipient.

Declaration
public static IWorld TransferAsset(this IWorld world, IActionContext context, Address sender, Address recipient, FungibleAssetValue value)
Parameters
Type Name Description
IWorld world

The IWorld to manipulate.

IActionContext context

The IActionContext of the IAction executing this method.

Address sender

The address who sends the fungible asset to the recipient.

Address recipient

The address who receives the fungible asset from the sender.

FungibleAssetValue value

The asset value to transfer.

Returns
Type Description
IWorld

A new IWorld instance that the given value is subtracted from sender's balance and added to recipient's balance.

Remarks

The behavior is different depending on context's BlockProtocolVersion. There is a bug for version 0 where this may not act as intended. Such behavior is left intact for backward compatibility.

Exceptions
Type Condition
InsufficientBalanceException

Thrown when the sender has insufficient balance than value to transfer.

  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2023 Planetarium