action

package
v0.18.15 Latest Latest
Warning

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

Go to latest
Published: May 17, 2022 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SkipFee  = -1
	WrongFee = 0
)
View Source
const DEFAULT_CURRENCY = "OLT"

Variables

View Source
var (
	ErrMissingData        = codes.ProtocolError{codes.TxErrMissingData, "missing data in transaction"}
	ErrUnserializable     = codes.ProtocolError{codes.TxErrUnserializable, "unserializable tx"}
	ErrWrongTxType        = codes.ProtocolError{codes.TxErrWrongTxType, "wrong tx type"}
	ErrInvalidAmount      = codes.ProtocolError{codes.TxErrInvalidAmount, "invalid amount"}
	ErrInvalidPubkey      = codes.ProtocolError{codes.TxErrInvalidPubKey, "invalid pubkey"}
	ErrUnmatchSigner      = codes.ProtocolError{codes.TxErrUnmatchedSigner, "unmatch signers"}
	ErrInvalidSignature   = codes.ProtocolError{codes.TxErrInvalidSignature, "invalid signatures"}
	ErrInvalidFeeCurrency = codes.ProtocolError{codes.TxErrInvalidFeeCurrency, "invalid fees currency"}
	ErrInvalidFeePrice    = codes.ProtocolError{codes.TxErrInvalidFeePrice, "fee price is smaller than minimal fee"}
	ErrPoolDoesNotExist   = codes.ProtocolError{codes.TxErrPoolDoesNotExist, "Pool does not exist"}
	ErrNotEnoughFund      = codes.ProtocolError{codes.TxErrInsufficientFunds, "not enough fund"}
	ErrGasOverflow        = codes.ProtocolError{codes.TxErrGasOverflow, "gas used exceed limit"}
	ErrInvalidExtTx       = codes.ProtocolError{codes.TxErrInvalidExtTx, "invalid external tx"}
	ErrInvalidVmExecution = codes.ProtocolError{codes.TxErrVMExecution, "vm execution error"}

	ErrInvalidAddress          = codes.ErrBadAddress
	ErrInvalidCurrency         = codes.ProtocolError{codes.TxErrInvalidFeeCurrency, "invalid fee currency"}
	ErrTokenNotSupported       = codes.ProtocolError{codes.ExternalErrTokenNotSuported, "Token not supported"}
	ErrTransactionNotSupported = codes.ProtocolError{codes.ExternalTransactionNotSupported, "TX not supported"}

	ErrGettingValidatorList = codes.ProtocolError{codes.GovErrGettingValidatorList, "fund proposal failed in getting validator list"}
	ErrGettingWitnessList   = codes.ProtocolError{codes.GovErrGettingWitnessList, "failed in getting witness list"}

	ErrInvalidValidatorAddr = codes.ProtocolError{codes.GovErrInvalidValidatorAddr, "invalid validator address"}
	ErrStakeAddressInUse    = codes.ProtocolError{codes.DelgErrStakeAddressInUse, "current stake address is in use"}
	ErrStakeAddressMismatch = codes.ProtocolError{codes.DelgErrStakeAddressMismatch, "stake address does not match"}
)

Functions

func BoolTag added in v0.18.15

func BoolTag(key string, value bool) kv.Pair

func GetEvent added in v0.14.0

func GetEvent(pairs kv.Pairs, eventType string) []types.Event

func RegisterTxType added in v0.16.1

func RegisterTxType(value Type, name string)

func UintTag added in v0.17.0

func UintTag(key string, value uint64) kv.Pair

func ValidateBasic added in v0.10.8

func ValidateBasic(data []byte, signerAddr []Address, signatures []Signature) error

func ValidateFee added in v0.12.0

func ValidateFee(feeOpt *fees.FeeOption, fee Fee) error

Types

type Address

type Address = keys.Address

Address an action package over Address in data/keys package

type Amount

type Amount struct {
	Currency string         `json:"currency"`
	Value    balance.Amount `json:"value"`
}

Amount is an easily serializable representation of coin. Nodes can create coin from the Amount object received over the network

func NewAmount added in v0.10.4

func NewAmount(currency string, amount balance.Amount) *Amount

New Amount creates a new amount account object

func (Amount) IsValid

func (a Amount) IsValid(list *balance.CurrencySet) bool

IsValid checks the validity of the currency and the amount string in the account object, which may be received over a network.

func (Amount) String

func (a Amount) String() string

String returns a string representation of the Amount object.

func (Amount) ToCoin

func (a Amount) ToCoin(list *balance.CurrencySet) balance.Coin

ToCoin converts an easier to transport Amount object to a Coin object in Oneledger protocol. It takes the action context to determine the currency from which to create the coin.

func (Amount) ToCoinWithBase added in v0.14.3

func (a Amount) ToCoinWithBase(list *balance.CurrencySet) balance.Coin

type Balance

type Balance = balance.Balance

Balance an action package over Balance in data/balance

type Context

type Context struct {
	Router              Router
	State               *storage.State
	Header              *abci.Header
	Accounts            accounts.Wallet
	Balances            *balance.Store
	Domains             *ons.DomainStore
	Delegators          *delegation.DelegationStore
	NetwkDelegators     *netwkDeleg.MasterStore
	EvidenceStore       *evidence.EvidenceStore
	FeePool             *fees.Store
	Currencies          *balance.CurrencySet
	FeeOpt              *fees.FeeOption
	Validators          *identity.ValidatorStore
	Witnesses           *identity.WitnessStore
	BTCTrackers         *bitcoin.TrackerStore
	ETHTrackers         *ethereum.TrackerStore
	Logger              *log.Logger
	JobStore            *jobs.JobStore
	LockScriptStore     *bitcoin.LockScriptStore
	ProposalMasterStore *governance.ProposalMasterStore
	RewardMasterStore   *rewards.RewardMasterStore
	GovernanceStore     *governance.Store
	ExtStores           data.Router
	GovUpdate           *GovernaceUpdateAndValidate

	// evm
	StateDB *vm.CommitStateDB
}

func NewContext

func NewContext(r Router, header *abci.Header, state *storage.State,
	wallet accounts.Wallet, balances *balance.Store,
	currencies *balance.CurrencySet, feePool *fees.Store,
	validators *identity.ValidatorStore, witnesses *identity.WitnessStore,
	domains *ons.DomainStore, delegators *delegation.DelegationStore, netwkDelegators *netwkDeleg.MasterStore, evidenceStore *evidence.EvidenceStore,
	btcTrackers *bitcoin.TrackerStore, ethTrackers *ethereum.TrackerStore, jobStore *jobs.JobStore,
	lockScriptStore *bitcoin.LockScriptStore, logger *log.Logger, proposalmaster *governance.ProposalMasterStore,
	rewardmaster *rewards.RewardMasterStore, govern *governance.Store, extStores data.Router, govUpdate *GovernaceUpdateAndValidate,
	stateDB *vm.CommitStateDB,
) *Context

type Fee

type Fee struct {
	Price Amount `json:"price"`
	Gas   int64  `json:"gas"`
}

type FunctionBehaviour added in v0.15.1

type FunctionBehaviour int
const (
	ValidateOnly      FunctionBehaviour = 0
	ValidateAndUpdate FunctionBehaviour = 1
)

type Gas added in v0.12.0

type Gas = storage.Gas

Gas an action package over Gas in storage

type GovernaceUpdateAndValidate added in v0.15.1

type GovernaceUpdateAndValidate struct {
	GovernanceUpdateFunction map[string]func(interface{}, *Context, FunctionBehaviour) (bool, error)
}

func NewGovUpdate added in v0.15.1

func NewGovUpdate() *GovernaceUpdateAndValidate

type Msg

type Msg interface {
	// return the necessary signers for the message, should have consistent order across the network
	Signers() []Address

	Type() Type

	Tags() kv.Pairs

	Marshal() ([]byte, error)

	Unmarshal([]byte) error
}

type MsgData added in v0.10.8

type MsgData []byte

type RawTx added in v0.10.8

type RawTx struct {
	Type Type    `json:"type"`
	Data MsgData `json:"data"`
	Fee  Fee     `json:"fee"`
	Memo string  `json:"memo"`
}

func (*RawTx) RawBytes added in v0.10.8

func (t *RawTx) RawBytes() []byte

type Response

type Response struct {
	Data      []byte
	Events    []types.Event
	Log       string
	Info      string
	GasWanted int64
	GasUsed   int64
}

func BasicFeeHandling added in v0.12.0

func BasicFeeHandling(ctx *Context, signedTx SignedTx, start Gas, size Gas, signatureCnt Gas) (bool, Response)

func ContractFeeHandling added in v0.17.0

func ContractFeeHandling(ctx *Context, signedTx SignedTx, gasUsed Gas, start Gas) (bool, Response)

func StakingPayerFeeHandling added in v0.16.1

func StakingPayerFeeHandling(ctx *Context, feePayer keys.Address, signedTx SignedTx, start Gas, size Gas, signatureCnt Gas) (bool, Response)

type Router

type Router interface {
	AddHandler(Type, Tx) error
	Handler(Type) Tx
}

Router interface supplies functionality to add a handler function and Handle a request.

func NewRouter

func NewRouter(name string) Router

NewRouter creates a new router object with given name.

type Signature

type Signature struct {
	Signer keys.PublicKey
	Signed []byte
}

func (Signature) Verify

func (s Signature) Verify(msg []byte) bool

type SignedTx added in v0.10.8

type SignedTx struct {
	RawTx
	Signatures []Signature `json:"signatures"`
}

func (*SignedTx) SignedBytes added in v0.10.8

func (t *SignedTx) SignedBytes() []byte

type Tx

type Tx interface {
	//it should be able to validate a tx by itself, non-valid tx will be reject by the node directly
	//without going to node process
	Validate(ctx *Context, signedTx SignedTx) (bool, error)

	//check tx on the first node who receives it, if process check failed, the tx will not be broadcast
	//could store a version of checked value in storage, but not implemented now
	ProcessCheck(ctx *Context, tx RawTx) (bool, Response)

	//deliver tx on the chain by changing the storage values, which should only be committed at Application
	//commit stage
	ProcessDeliver(ctx *Context, tx RawTx) (bool, Response)

	//process the charge of fees
	ProcessFee(ctx *Context, signedTx SignedTx, start Gas, size Gas, gasUsed Gas) (bool, Response)
}

type TxTypeDescribe added in v0.14.0

type TxTypeDescribe struct {
	TxTypeNum    Type
	TxTypeString string
}

type TxTypeMap added in v0.16.1

type TxTypeMap map[Type]string

type Type

type Type int
const (
	SEND     Type = 0x01
	SENDPOOL Type = 0x02

	//staking related transaction
	STAKE    Type = 0x11
	UNSTAKE  Type = 0x12
	WITHDRAW Type = 0x13

	//network network_delegation
	ADD_NETWORK_DELEGATE              Type = 0x51
	NETWORK_UNDELEGATE                Type = 0x52
	REWARDS_WITHDRAW_NETWORK_DELEGATE Type = 0x53
	REWARDS_REINVEST_NETWORK_DELEGATE Type = 0x54

	//Evidence
	ALLEGATION      Type = 0x61
	ALLEGATION_VOTE Type = 0x62
	RELEASE         Type = 0x63

	//ons related transaction
	DOMAIN_CREATE     Type = 0x21
	DOMAIN_UPDATE     Type = 0x22
	DOMAIN_SELL       Type = 0x23
	DOMAIN_PURCHASE   Type = 0x24
	DOMAIN_SEND       Type = 0x25
	DOMAIN_DELETE_SUB Type = 0x26
	DOMAIN_RENEW      Type = 0x27

	BTC_LOCK                   Type = 0x81
	BTC_ADD_SIGNATURE          Type = 0x82
	BTC_BROADCAST_SUCCESS      Type = 0x83
	BTC_REPORT_FINALITY_MINT   Type = 0x84
	BTC_EXT_MINT               Type = 0x85
	BTC_REDEEM                 Type = 0x86
	BTC_FAILED_BROADCAST_RESET Type = 0x87

	//Ethereum Actions
	ETH_LOCK                 Type = 0x91
	ETH_REPORT_FINALITY_MINT Type = 0x92
	ETH_REDEEM               Type = 0x93
	ERC20_LOCK               Type = 0x94
	ERC20_REDEEM             Type = 0x95

	//Governance Action
	PROPOSAL_CREATE         Type = 0x30
	PROPOSAL_CANCEL         Type = 0x31
	PROPOSAL_FUND           Type = 0x32
	PROPOSAL_VOTE           Type = 0x33
	PROPOSAL_FINALIZE       Type = 0x34
	EXPIRE_VOTES            Type = 0x35
	PROPOSAL_WITHDRAW_FUNDS Type = 0x36

	//Rewards
	WITHDRAW_REWARD Type = 0x41

	// OLVM transactions (new sends + evm)
	OLVM Type = 0x101

	//EOF here Only used as a marker to mark the end of Type list
	//So that the query for Types can return all Types dynamically
	//, when there is a change made in Type list
	//This value should be manually set as the largest among the list
	EOF Type = 0xFF
)

func (Type) String

func (t Type) String() string

Directories

Path Synopsis
Package for transactions related to Etheruem Package for transactions related to Etheruem Package for transactions related to Etheruem Package for transactions related to Etheruem Package for transactions related to Etheruem Package for transactions related to Etheruem
Package for transactions related to Etheruem Package for transactions related to Etheruem Package for transactions related to Etheruem Package for transactions related to Etheruem Package for transactions related to Etheruem Package for transactions related to Etheruem

Jump to

Keyboard shortcuts

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