Show / Hide Table of Contents

Interface IAccountStateDelta

An interface to manipulate account states with maintaining the set of UpdatedAddresses.

It is like a map which is virtually initialized such that every possible Address exists and is mapped to null. That means that:

  • it does not have length,
  • its index getter never throws , but returns null instead, and
  • filling an Address with null state cannot be distinguished from the Address having never been set to any state.
Namespace: Libplanet.Action
Assembly: Libplanet.dll
Syntax
public interface IAccountStateDelta
Remarks

This interface is immutable. SetState(Address, IValue) method does not manipulate the instance, but returns a new IAccountStateDelta instance with updated states.

Properties

| Improve this Doc View Source

StateUpdatedAddresses

Addresses of the accounts whose states have been updated since then.

Declaration
IImmutableSet<Address> StateUpdatedAddresses { get; }
Property Value
Type Description
IImmutableSet<Address>
| Improve this Doc View Source

UpdatedAddresses

Addresses of the accounts that have been updated since then.

Declaration
IImmutableSet<Address> UpdatedAddresses { get; }
Property Value
Type Description
IImmutableSet<Address>
| Improve this Doc View Source

UpdatedFungibleAssets

Addresses and sets of Currency whose fungible assets have been updated since then.

For example, if A transfers 10 FOO to B and B transfers 20 BAR to C, UpdatedFungibleAssets become likes { [A] = { FOO }, [B] = { FOO, BAR }, [C] = { BAR } }.

Declaration
IImmutableDictionary<Address, IImmutableSet<Currency>> UpdatedFungibleAssets { get; }
Property Value
Type Description
IImmutableDictionary<Address, IImmutableSet<Currency>>

Methods

| Improve this Doc View Source

BurnAsset(Address, FungibleAssetValue)

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

Declaration
IAccountStateDelta BurnAsset(Address owner, FungibleAssetValue value)
Parameters
Type Name Description
Address owner

The address who owns the fungible asset to burn.

FungibleAssetValue value

The fungible asset value to burn.

Returns
Type Description
IAccountStateDelta

A new IAccountStateDelta 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(Address, Currency)

Queries address's balance of the currency.

Declaration
FungibleAssetValue GetBalance(Address address, Currency currency)
Parameters
Type Name Description
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

GetState(Address)

Gets the account state of the given address.

Declaration
IValue? GetState(Address address)
Parameters
Type Name Description
Address address

The Address referring the account to get its state.

Returns
Type Description
Nullable<IValue>

The account state of the given address. If it has never been set to any state it returns null instead.

| Improve this Doc View Source

MintAsset(Address, FungibleAssetValue)

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

Declaration
IAccountStateDelta MintAsset(Address recipient, FungibleAssetValue value)
Parameters
Type Name Description
Address recipient

The address who receives the minted asset.

FungibleAssetValue value

The asset value to mint.

Returns
Type Description
IAccountStateDelta

A new IAccountStateDelta 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.

| Improve this Doc View Source

SetState(Address, IValue)

Gets a new instance that the account state of the given address is set to the given state.

Declaration
IAccountStateDelta SetState(Address address, IValue state)
Parameters
Type Name Description
Address address

The Address referring the account to set its state.

IValue state

The new state to fill the account with.

Returns
Type Description
IAccountStateDelta

A new IAccountStateDelta instance that the account state of the given address is set to the given state.

Remarks

This method method does not manipulate the instance, but returns a new IAccountStateDelta instance with updated states instead.

| Improve this Doc View Source

TransferAsset(Address, Address, FungibleAssetValue, Boolean)

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

Declaration
IAccountStateDelta TransferAsset(Address sender, Address recipient, FungibleAssetValue value, bool allowNegativeBalance = false)
Parameters
Type Name Description
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.

Boolean allowNegativeBalance

Turn on to allow sender's balance less than zero. Turned off by default.

Returns
Type Description
IAccountStateDelta

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

Exceptions
Type Condition
InsufficientBalanceException

Thrown when the sender has insufficient balance than value to transfer and the allowNegativeBalance option is turned off.

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