accounts

package
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2021 License: Apache-2.0, BSD-2-Clause Imports: 13 Imported by: 4

Documentation

Index

Constants

View Source
const (
	ParamAgentID        = "a"
	ParamWithdrawColor  = "c"
	ParamWithdrawAmount = "m"
	ParamAccountNonce   = "n"
)

Variables

View Source
var (
	FuncViewBalance     = coreutil.ViewFunc("balance")
	FuncViewTotalAssets = coreutil.ViewFunc("totalAssets")
	FuncViewAccounts    = coreutil.ViewFunc("accounts")
	FuncDeposit         = coreutil.Func("deposit")
	FuncWithdraw        = coreutil.Func("withdraw")
	FuncHarvest         = coreutil.Func("harvest")
	FuncGetAccountNonce = coreutil.ViewFunc("getAccountNonce")
)
View Source
var Contract = coreutil.NewContract(coreutil.CoreContractAccounts, "Chain account ledger contract")
View Source
var Processor = Contract.Processor(initialize,
	FuncViewBalance.WithHandler(viewBalance),
	FuncViewTotalAssets.WithHandler(viewTotalAssets),
	FuncViewAccounts.WithHandler(viewAccounts),
	FuncDeposit.WithHandler(deposit),
	FuncWithdraw.WithHandler(withdraw),
	FuncHarvest.WithHandler(harvest),
	FuncGetAccountNonce.WithHandler(getAccountNonce),
)

Functions

func CreditToAccount

func CreditToAccount(state kv.KVStore, agentID *iscp.AgentID, transfer colored.Balances)

CreditToAccount brings new funds to the on chain ledger.

func DebitFromAccount

func DebitFromAccount(state kv.KVStore, agentID *iscp.AgentID, transfer colored.Balances) bool

DebitFromAccount removes funds from the chain ledger.

func DecodeBalances

func DecodeBalances(balances dict.Dict) (colored.Balances, error)

func EncodeBalances

func EncodeBalances(balances colored.Balances) dict.Dict

func GetAccountBalances

func GetAccountBalances(state kv.KVStoreReader, agentID *iscp.AgentID) (colored.Balances, bool)

GetAccountBalances returns all colored balances belonging to the agentID on the state. Normally, the state is the partition of the 'accountsc'

func GetBalance

func GetBalance(state kv.KVStoreReader, agentID *iscp.AgentID, col colored.Color) uint64

func GetMaxAssumedNonce added in v0.2.0

func GetMaxAssumedNonce(state kv.KVStoreReader, address ledgerstate.Address) uint64

func GetTotalAssets added in v0.2.0

func GetTotalAssets(state kv.KVStoreReader) colored.Balances

func MoveBetweenAccounts

func MoveBetweenAccounts(state kv.KVStore, fromAgentID, toAgentID *iscp.AgentID, transfer colored.Balances) bool

func RecordMaxAssumedNonce added in v0.2.0

func RecordMaxAssumedNonce(state kv.KVStore, address ledgerstate.Address, nonce uint64)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL