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, Currency, BigInteger)

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

Declaration
IAccountStateDelta BurnAsset(Address owner, Currency currency, BigInteger amount)
Parameters
Type Name Description
Address owner

The address who owns the fungible asset to burn.

Currency currency

The currency type to burn.

BigInteger amount

The amount of the currency to burn.

Returns
Type Description
IAccountStateDelta

A new IAccountStateDelta instance that the given amount of the currency 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 currency's Minters.

InsufficientBalanceException

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

| Improve this Doc View Source

GetBalance(Address, Currency)

Queries address's balance of the currency.

Declaration
BigInteger 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
BigInteger

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, Currency, BigInteger)

Mints the amount of a new currency, fungible asset (i.e., in-game monetary), and give it to the recipient.

Declaration
IAccountStateDelta MintAsset(Address recipient, Currency currency, BigInteger amount)
Parameters
Type Name Description
Address recipient

The address who receives the minted asset.

Currency currency

The currency type to mint.

BigInteger amount

The amount of the currency to mint.

Returns
Type Description
IAccountStateDelta

A new IAccountStateDelta instance that the given amount of the currency 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 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, Currency, BigInteger, Boolean)

Transfers the amount of a new currency, fungible asset (i.e., in-game monetary), from the sender to the recipient.

Declaration
IAccountStateDelta TransferAsset(Address sender, Address recipient, Currency currency, BigInteger amount, 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.

Currency currency

The currency type to transfer.

BigInteger amount

The amount of the currency to transfer.

Boolean allowNegativeBalance

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

Returns
Type Description
IAccountStateDelta

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

Exceptions
Type Condition
InsufficientBalanceException

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

  • Improve this Doc
  • View Source
Back to top Copyright © 2019–2020 Planetarium