Class IWorldExtensions
Inheritance
Namespace: Libplanet.Action.State
Assembly: Libplanet.Action.dll
Syntax
public static class IWorldExtensions : object
Methods
| Improve this Doc View SourceBurnAsset(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 |
Returns
Type | Description |
---|---|
IWorld | A new IWorld instance that the given |
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 |
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 |
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 |
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. |
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 |
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
|
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
|
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 |
Address | recipient | The address who receives the fungible asset from
the |
FungibleAssetValue | value | The asset value to transfer. |
Returns
Type | Description |
---|---|
IWorld | A new IWorld instance that the given |
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 |