Back to godoc.org
github.com/iotexproject/iotex-core/action

package action

v1.0.0
Latest Go to latest
Published: May 14, 2020 | License: Apache-2.0 | Module: github.com/iotexproject/iotex-core

Index

Constants

const (
	// CandidateRegisterPayloadGas represents the CandidateRegister payload gas per uint
	CandidateRegisterPayloadGas = uint64(100)
	// CandidateRegisterBaseIntrinsicGas represents the base intrinsic gas for CandidateRegister
	CandidateRegisterBaseIntrinsicGas = uint64(10000)
)
const (
	// EmptyAddress is the empty string
	EmptyAddress = ""
	// ExecutionDataGas represents the execution data gas per uint
	ExecutionDataGas = uint64(100)
	// ExecutionBaseIntrinsicGas represents the base intrinsic gas for execution
	ExecutionBaseIntrinsicGas = uint64(10000)
)
const (
	// BlockReward indicates that the action is to grant block reward
	BlockReward = iota
	// EpochReward indicates that the action is to grant epoch reward
	EpochReward
)
const (
	// DepositToStakePayloadGas represents the DepositToStake payload gas per uint
	DepositToStakePayloadGas = uint64(100)
	// DepositToStakeBaseIntrinsicGas represents the base intrinsic gas for DepositToStake
	DepositToStakeBaseIntrinsicGas = uint64(10000)
)
const (
	// MoveStakePayloadGas represents the stake move payload gas per uint
	MoveStakePayloadGas = uint64(100)
	// MoveStakeBaseIntrinsicGas represents the base intrinsic gas for stake move
	MoveStakeBaseIntrinsicGas = uint64(10000)
)
const (
	// CreateStakePayloadGas represents the CreateStake payload gas per uint
	CreateStakePayloadGas = uint64(100)
	// CreateStakeBaseIntrinsicGas represents the base intrinsic gas for CreateStake
	CreateStakeBaseIntrinsicGas = uint64(10000)
)
const (
	// ReclaimStakePayloadGas represents the stake reclaim payload gas per uint
	ReclaimStakePayloadGas = uint64(100)
	// ReclaimStakeBaseIntrinsicGas represents the base intrinsic gas for stake reclaim
	ReclaimStakeBaseIntrinsicGas = uint64(10000)
)
const (
	// RestakePayloadGas represents the Restake payload gas per uint
	RestakePayloadGas = uint64(100)
	// RestakeBaseIntrinsicGas represents the base intrinsic gas for stake again
	RestakeBaseIntrinsicGas = uint64(10000)
)
const (
	// TransferPayloadGas represents the transfer payload gas per uint
	TransferPayloadGas = uint64(100)
	// TransferBaseIntrinsicGas represents the base intrinsic gas for transfer
	TransferBaseIntrinsicGas = uint64(10000)
)
const CandidateUpdateBaseIntrinsicGas = uint64(10000)

CandidateUpdateBaseIntrinsicGas represents the base intrinsic gas for CandidateUpdate

Variables

var (
	// ErrAction indicates error for an action
	ErrAction = errors.New("action error")
	// ErrAddress indicates error of address
	ErrAddress = errors.New("address error")
)
var (
	// ClaimFromRewardingFundBaseGas represents the base intrinsic gas for claimFromRewardingFund
	ClaimFromRewardingFundBaseGas = uint64(10000)
	// ClaimFromRewardingFundGasPerByte represents the claimFromRewardingFund payload gas per uint
	ClaimFromRewardingFundGasPerByte = uint64(100)
)
var (
	// ErrActPool indicates the error of actpool
	ErrActPool = errors.New("invalid actpool")
	// ErrHitGasLimit is the error when hit gas limit
	ErrHitGasLimit = errors.New("Hit gas limit")
	// ErrInsufficientBalanceForGas is the error that the balance in executor account is lower than gas
	ErrInsufficientBalanceForGas = errors.New("Insufficient balance for gas")
	// ErrOutOfGas is the error when running out of gas
	ErrOutOfGas = errors.New("Out of gas")
	// ErrTransfer indicates the error of transfer
	ErrTransfer = errors.New("invalid transfer")
	// ErrNonce indicates the error of nonce
	ErrNonce = errors.New("invalid nonce")
	// ErrBalance indicates the error of balance
	ErrBalance = errors.New("invalid balance")
	// ErrGasPrice indicates the error of gas price
	ErrGasPrice = errors.New("invalid gas price")
	// ErrVotee indicates the error of votee
	ErrVotee = errors.New("votee is not a candidate")
	// ErrNotFound indicates the nonexistence of action
	ErrNotFound = errors.New("action not found")
)
var (
	// DepositToRewardingFundBaseGas represents the base intrinsic gas for depositToRewardingFund
	DepositToRewardingFundBaseGas = uint64(10000)
	// DepositToRewardingFundGasPerByte represents the depositToRewardingFund payload gas per uint
	DepositToRewardingFundGasPerByte = uint64(100)
)
var (
	// ErrInvalidAmount represents that amount is 0 or negative
	ErrInvalidAmount = errors.New("invalid amount")
)
var InContractTransfer = common.Hash{} // 32 bytes with all zeros

InContractTransfer is topic for system log of evm transfer

func ClassifyActions

func ClassifyActions(actions []SealedEnvelope) ([]*Transfer, []*Execution)

ClassifyActions classfies actions

func IsSystemLog

func IsSystemLog(l *Log) bool

IsSystemLog checks whether a log is system log lowerBound chooses the largest system log topic, which is InContractTransfer currently

func Verify

func Verify(sealed SealedEnvelope) error

Verify verifies the action using sender's public key

type AbstractAction

type AbstractAction struct {
	// contains filtered or unexported fields
}

AbstractAction is an abstract implementation of Action interface

func (*AbstractAction) BasicActionSize

func (act *AbstractAction) BasicActionSize() uint32

BasicActionSize returns the basic size of action

func (*AbstractAction) GasLimit

func (act *AbstractAction) GasLimit() uint64

GasLimit returns the gas limit

func (*AbstractAction) GasPrice

func (act *AbstractAction) GasPrice() *big.Int

GasPrice returns the gas price

func (*AbstractAction) Hash

func (act *AbstractAction) Hash() hash.Hash256

Hash returns the hash value of referred SealedActionEnvelope hash.

func (*AbstractAction) Nonce

func (act *AbstractAction) Nonce() uint64

Nonce returns the nonce

func (*AbstractAction) SanityCheck

func (act *AbstractAction) SanityCheck() error

SanityCheck validates the variables in the action

func (*AbstractAction) SetEnvelopeContext

func (act *AbstractAction) SetEnvelopeContext(selp SealedEnvelope)

SetEnvelopeContext sets the SealedEnvelope context to action context.

func (*AbstractAction) SrcPubkey

func (act *AbstractAction) SrcPubkey() crypto.PublicKey

SrcPubkey returns the source public key

func (*AbstractAction) Version

func (act *AbstractAction) Version() uint32

Version returns the version

type Action

type Action interface {
	SetEnvelopeContext(SealedEnvelope)
	SanityCheck() error
}

Action is the action can be Executed in protocols. The method is added to avoid mistakenly used empty interface as action.

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder is used to build an action.

func (*Builder) Build

func (b *Builder) Build() AbstractAction

Build builds a new action.

func (*Builder) SetGasLimit

func (b *Builder) SetGasLimit(l uint64) *Builder

SetGasLimit sets action's gas limit.

func (*Builder) SetGasPrice

func (b *Builder) SetGasPrice(p *big.Int) *Builder

SetGasPrice sets action's gas price.

func (*Builder) SetGasPriceByBytes

func (b *Builder) SetGasPriceByBytes(buf []byte) *Builder

SetGasPriceByBytes sets action's gas price from a byte slice source.

func (*Builder) SetNonce

func (b *Builder) SetNonce(n uint64) *Builder

SetNonce sets action's nonce.

func (*Builder) SetSourcePublicKey

func (b *Builder) SetSourcePublicKey(key crypto.PublicKey) *Builder

SetSourcePublicKey sets action's source's public key.

func (*Builder) SetVersion

func (b *Builder) SetVersion(v uint32) *Builder

SetVersion sets action's version.

type CandidateRegister

type CandidateRegister struct {
	AbstractAction
	// contains filtered or unexported fields
}

CandidateRegister is the action to register a candidate

func NewCandidateRegister

func NewCandidateRegister(
	nonce uint64,
	name, operatorAddrStr, rewardAddrStr, ownerAddrStr, amountStr string,
	duration uint32,
	autoStake bool,
	payload []byte,
	gasLimit uint64,
	gasPrice *big.Int,
) (*CandidateRegister, error)

NewCandidateRegister creates a CandidateRegister instance

func (*CandidateRegister) Amount

func (cr *CandidateRegister) Amount() *big.Int

Amount returns the amount

func (*CandidateRegister) AutoStake

func (cr *CandidateRegister) AutoStake() bool

AutoStake returns the if staking is auth stake

func (*CandidateRegister) Cost

func (cr *CandidateRegister) Cost() (*big.Int, error)

Cost returns the total cost of a CandidateRegister

func (*CandidateRegister) Duration

func (cr *CandidateRegister) Duration() uint32

Duration returns the self-stake duration

func (*CandidateRegister) IntrinsicGas

func (cr *CandidateRegister) IntrinsicGas() (uint64, error)

IntrinsicGas returns the intrinsic gas of a CandidateRegister

func (*CandidateRegister) LoadProto

func (cr *CandidateRegister) LoadProto(pbAct *iotextypes.CandidateRegister) error

LoadProto converts a protobuf's Action to CandidateRegister

func (*CandidateRegister) Name

func (cr *CandidateRegister) Name() string

Name returns candidate name to register

func (*CandidateRegister) OperatorAddress

func (cr *CandidateRegister) OperatorAddress() address.Address

OperatorAddress returns candidate operatorAddress to register

func (*CandidateRegister) OwnerAddress

func (cr *CandidateRegister) OwnerAddress() address.Address

OwnerAddress returns candidate ownerAddress to register

func (*CandidateRegister) Payload

func (cr *CandidateRegister) Payload() []byte

Payload returns the payload bytes

func (*CandidateRegister) Proto

func (cr *CandidateRegister) Proto() *iotextypes.CandidateRegister

Proto converts to protobuf CandidateRegister Action

func (*CandidateRegister) RewardAddress

func (cr *CandidateRegister) RewardAddress() address.Address

RewardAddress returns candidate rewardAddress to register

func (*CandidateRegister) SanityCheck

func (cr *CandidateRegister) SanityCheck() error

SanityCheck validates the variables in the action

func (*CandidateRegister) Serialize

func (cr *CandidateRegister) Serialize() []byte

Serialize returns a raw byte stream of the CandidateRegister struct

type CandidateUpdate

type CandidateUpdate struct {
	AbstractAction
	// contains filtered or unexported fields
}

CandidateUpdate is the action to register a candidate

func NewCandidateUpdate

func NewCandidateUpdate(
	nonce uint64,
	name, operatorAddrStr, rewardAddrStr string,
	gasLimit uint64,
	gasPrice *big.Int,
) (*CandidateUpdate, error)

NewCandidateUpdate creates a CandidateUpdate instance

func (*CandidateUpdate) Cost

func (cu *CandidateUpdate) Cost() (*big.Int, error)

Cost returns the total cost of a CandidateUpdate

func (*CandidateUpdate) IntrinsicGas

func (cu *CandidateUpdate) IntrinsicGas() (uint64, error)

IntrinsicGas returns the intrinsic gas of a CandidateUpdate

func (*CandidateUpdate) LoadProto

func (cu *CandidateUpdate) LoadProto(pbAct *iotextypes.CandidateBasicInfo) error

LoadProto converts a protobuf's Action to CandidateUpdate

func (*CandidateUpdate) Name

func (cu *CandidateUpdate) Name() string

Name returns candidate name to update

func (*CandidateUpdate) OperatorAddress

func (cu *CandidateUpdate) OperatorAddress() address.Address

OperatorAddress returns candidate operatorAddress to update

func (*CandidateUpdate) Proto

func (cu *CandidateUpdate) Proto() *iotextypes.CandidateBasicInfo

Proto converts to protobuf CandidateUpdate Action

func (*CandidateUpdate) RewardAddress

func (cu *CandidateUpdate) RewardAddress() address.Address

RewardAddress returns candidate rewardAddress to update

func (*CandidateUpdate) Serialize

func (cu *CandidateUpdate) Serialize() []byte

Serialize returns a raw byte stream of the CandidateUpdate struct

type ChangeCandidate

type ChangeCandidate struct {
	AbstractAction
	// contains filtered or unexported fields
}

ChangeCandidate defines the action of changing stake candidate ts the other

func NewChangeCandidate

func NewChangeCandidate(
	nonce uint64,
	candName string,
	bucketIndex uint64,
	payload []byte,
	gasLimit uint64,
	gasPrice *big.Int,
) (*ChangeCandidate, error)

NewChangeCandidate returns a ChangeCandidate instance

func (*ChangeCandidate) BucketIndex

func (cc *ChangeCandidate) BucketIndex() uint64

BucketIndex returns bucket index

func (*ChangeCandidate) Candidate

func (cc *ChangeCandidate) Candidate() string

Candidate returns the address of recipient

func (*ChangeCandidate) Cost

func (cc *ChangeCandidate) Cost() (*big.Int, error)

Cost returns the tstal cost of a ChangeCandidate

func (*ChangeCandidate) IntrinsicGas

func (cc *ChangeCandidate) IntrinsicGas() (uint64, error)

IntrinsicGas returns the intrinsic gas of a ChangeCandidate

func (*ChangeCandidate) LoadProto

func (cc *ChangeCandidate) LoadProto(pbAct *iotextypes.StakeChangeCandidate) error

LoadProto loads change candidate from protobuf

func (*ChangeCandidate) Payload

func (cc *ChangeCandidate) Payload() []byte

Payload returns the payload bytes

func (*ChangeCandidate) Proto

func (cc *ChangeCandidate) Proto() *iotextypes.StakeChangeCandidate

Proto converts change candidate to protobuf

func (*ChangeCandidate) Serialize

func (cc *ChangeCandidate) Serialize() []byte

Serialize returns a raw byte stream of the stake move action struct

type ClaimFromRewardingFund

type ClaimFromRewardingFund struct {
	AbstractAction
	// contains filtered or unexported fields
}

ClaimFromRewardingFund is the action to claim reward from the rewarding fund

func (*ClaimFromRewardingFund) Amount

func (c *ClaimFromRewardingFund) Amount() *big.Int

Amount returns the amount to claim

func (*ClaimFromRewardingFund) Cost

func (c *ClaimFromRewardingFund) Cost() (*big.Int, error)

Cost returns the total cost of a claim action

func (*ClaimFromRewardingFund) Data

func (c *ClaimFromRewardingFund) Data() []byte

Data returns the additional data

func (*ClaimFromRewardingFund) IntrinsicGas

func (c *ClaimFromRewardingFund) IntrinsicGas() (uint64, error)

IntrinsicGas returns the intrinsic gas of a claim action

func (*ClaimFromRewardingFund) LoadProto

func (c *ClaimFromRewardingFund) LoadProto(claim *iotextypes.ClaimFromRewardingFund) error

LoadProto converts a claim action protobuf to a claim action struct

func (*ClaimFromRewardingFund) Proto

func (c *ClaimFromRewardingFund) Proto() *iotextypes.ClaimFromRewardingFund

Proto converts a claim action struct to a claim action protobuf

func (*ClaimFromRewardingFund) SanityCheck

func (c *ClaimFromRewardingFund) SanityCheck() error

SanityCheck validates the variables in the action

func (*ClaimFromRewardingFund) Serialize

func (c *ClaimFromRewardingFund) Serialize() []byte

Serialize returns a raw byte stream of a claim action

type ClaimFromRewardingFundBuilder

type ClaimFromRewardingFundBuilder struct {
	Builder
	// contains filtered or unexported fields
}

ClaimFromRewardingFundBuilder is the struct to build ClaimFromRewardingFund

func (*ClaimFromRewardingFundBuilder) Build

func (b *ClaimFromRewardingFundBuilder) Build() ClaimFromRewardingFund

Build builds a new claim from rewarding fund action

func (*ClaimFromRewardingFundBuilder) SetAmount

func (b *ClaimFromRewardingFundBuilder) SetAmount(amount *big.Int) *ClaimFromRewardingFundBuilder

SetAmount sets the amount to claim

func (*ClaimFromRewardingFundBuilder) SetData

func (b *ClaimFromRewardingFundBuilder) SetData(data []byte) *ClaimFromRewardingFundBuilder

SetData sets the additional data

type CreateStake

type CreateStake struct {
	AbstractAction
	// contains filtered or unexported fields
}

CreateStake defines the action of CreateStake creation

func NewCreateStake

func NewCreateStake(
	nonce uint64,
	candidateName, amount string,
	duration uint32,
	autoStake bool,
	payload []byte,
	gasLimit uint64,
	gasPrice *big.Int,
) (*CreateStake, error)

NewCreateStake returns a CreateStake instance

func (*CreateStake) Amount

func (cs *CreateStake) Amount() *big.Int

Amount returns the amount

func (*CreateStake) AutoStake

func (cs *CreateStake) AutoStake() bool

AutoStake returns the flag of AutoStake s

func (*CreateStake) Candidate

func (cs *CreateStake) Candidate() string

Candidate returns the candidate name

func (*CreateStake) Cost

func (cs *CreateStake) Cost() (*big.Int, error)

Cost returns the total cost of a CreateStake

func (*CreateStake) Duration

func (cs *CreateStake) Duration() uint32

Duration returns the CreateStaked duration

func (*CreateStake) IntrinsicGas

func (cs *CreateStake) IntrinsicGas() (uint64, error)

IntrinsicGas returns the intrinsic gas of a CreateStake

func (*CreateStake) LoadProto

func (cs *CreateStake) LoadProto(pbAct *iotextypes.StakeCreate) error

LoadProto converts a protobuf's Action to CreateStake

func (*CreateStake) Payload

func (cs *CreateStake) Payload() []byte

Payload returns the payload bytes

func (*CreateStake) Proto

func (cs *CreateStake) Proto() *iotextypes.StakeCreate

Proto converts to protobuf CreateStake Action

func (*CreateStake) SanityCheck

func (cs *CreateStake) SanityCheck() error

SanityCheck validates the variables in the action

func (*CreateStake) Serialize

func (cs *CreateStake) Serialize() []byte

Serialize returns a raw byte stream of the CreateStake struct

type DepositToRewardingFund

type DepositToRewardingFund struct {
	AbstractAction
	// contains filtered or unexported fields
}

DepositToRewardingFund is the action to deposit to the rewarding fund

func (*DepositToRewardingFund) Amount

func (d *DepositToRewardingFund) Amount() *big.Int

Amount returns the amount to deposit

func (*DepositToRewardingFund) Cost

func (d *DepositToRewardingFund) Cost() (*big.Int, error)

Cost returns the total cost of a deposit action

func (*DepositToRewardingFund) Data

func (d *DepositToRewardingFund) Data() []byte

Data returns the additional data

func (*DepositToRewardingFund) IntrinsicGas

func (d *DepositToRewardingFund) IntrinsicGas() (uint64, error)

IntrinsicGas returns the intrinsic gas of a deposit action

func (*DepositToRewardingFund) LoadProto

func (d *DepositToRewardingFund) LoadProto(deposit *iotextypes.DepositToRewardingFund) error

LoadProto converts a deposit action protobuf to a deposit action struct

func (*DepositToRewardingFund) Proto

func (d *DepositToRewardingFund) Proto() *iotextypes.DepositToRewardingFund

Proto converts a deposit action struct to a deposit action protobuf

func (*DepositToRewardingFund) SanityCheck

func (d *DepositToRewardingFund) SanityCheck() error

SanityCheck validates the variables in the action

func (*DepositToRewardingFund) Serialize

func (d *DepositToRewardingFund) Serialize() []byte

Serialize returns a raw byte stream of a deposit action

type DepositToRewardingFundBuilder

type DepositToRewardingFundBuilder struct {
	Builder
	// contains filtered or unexported fields
}

DepositToRewardingFundBuilder is the struct to build DepositToRewardingFund

func (*DepositToRewardingFundBuilder) Build

func (b *DepositToRewardingFundBuilder) Build() DepositToRewardingFund

Build builds a new deposit to rewarding fund action

func (*DepositToRewardingFundBuilder) SetAmount

func (b *DepositToRewardingFundBuilder) SetAmount(amount *big.Int) *DepositToRewardingFundBuilder

SetAmount sets the amount to deposit

func (*DepositToRewardingFundBuilder) SetData

func (b *DepositToRewardingFundBuilder) SetData(data []byte) *DepositToRewardingFundBuilder

SetData sets the additional data

type DepositToStake

type DepositToStake struct {
	AbstractAction
	// contains filtered or unexported fields
}

DepositToStake defines the action of stake add deposit

func NewDepositToStake

func NewDepositToStake(
	nonce uint64,
	index uint64,
	amount string,
	payload []byte,
	gasLimit uint64,
	gasPrice *big.Int,
) (*DepositToStake, error)

NewDepositToStake returns a DepositToStake instance

func (*DepositToStake) Amount

func (ds *DepositToStake) Amount() *big.Int

Amount returns the amount

func (*DepositToStake) BucketIndex

func (ds *DepositToStake) BucketIndex() uint64

BucketIndex returns bucket indexs

func (*DepositToStake) Cost

func (ds *DepositToStake) Cost() (*big.Int, error)

Cost returns the total cost of a DepositToStake

func (*DepositToStake) IntrinsicGas

func (ds *DepositToStake) IntrinsicGas() (uint64, error)

IntrinsicGas returns the intrinsic gas of a DepositToStake

func (*DepositToStake) LoadProto

func (ds *DepositToStake) LoadProto(pbAct *iotextypes.StakeAddDeposit) error

LoadProto converts a protobuf's Action to DepositToStake

func (*DepositToStake) Payload

func (ds *DepositToStake) Payload() []byte

Payload returns the payload bytes

func (*DepositToStake) Proto

func (ds *DepositToStake) Proto() *iotextypes.StakeAddDeposit

Proto converts to protobuf DepositToStake Action

func (*DepositToStake) SanityCheck

func (ds *DepositToStake) SanityCheck() error

SanityCheck validates the variables in the action

func (*DepositToStake) Serialize

func (ds *DepositToStake) Serialize() []byte

Serialize returns a raw byte stream of the Stake Create struct

type Envelope

type Envelope struct {
	// contains filtered or unexported fields
}

Envelope defines an envelope wrapped on action with some envelope metadata.

func (*Envelope) Action

func (elp *Envelope) Action() Action

Action returns the action payload.

func (*Envelope) Cost

func (elp *Envelope) Cost() (*big.Int, error)

Cost returns cost of actions

func (*Envelope) Destination

func (elp *Envelope) Destination() (string, bool)

Destination returns the destination address

func (*Envelope) GasLimit

func (elp *Envelope) GasLimit() uint64

GasLimit returns the gas limit

func (*Envelope) GasPrice

func (elp *Envelope) GasPrice() *big.Int

GasPrice returns the gas price

func (*Envelope) Hash

func (elp *Envelope) Hash() hash.Hash256

Hash returns the hash value of SealedEnvelope.

func (*Envelope) IntrinsicGas

func (elp *Envelope) IntrinsicGas() (uint64, error)

IntrinsicGas returns intrinsic gas of action.

func (*Envelope) LoadProto

func (elp *Envelope) LoadProto(pbAct *iotextypes.ActionCore) error

LoadProto loads fields from protobuf format.

func (*Envelope) Nonce

func (elp *Envelope) Nonce() uint64

Nonce returns the nonce

func (*Envelope) Proto

func (elp *Envelope) Proto() *iotextypes.ActionCore

Proto convert Envelope to protobuf format.

func (*Envelope) Serialize

func (elp *Envelope) Serialize() []byte

Serialize returns encoded binary.

func (*Envelope) Version

func (elp *Envelope) Version() uint32

Version returns the version

type EnvelopeBuilder

type EnvelopeBuilder struct {
	// contains filtered or unexported fields
}

EnvelopeBuilder is the builder to build Envelope.

func (*EnvelopeBuilder) Build

func (b *EnvelopeBuilder) Build() Envelope

Build builds a new action.

func (*EnvelopeBuilder) SetAction

func (b *EnvelopeBuilder) SetAction(action actionPayload) *EnvelopeBuilder

SetAction sets the action payload for the Envelope Builder is building.

func (*EnvelopeBuilder) SetGasLimit

func (b *EnvelopeBuilder) SetGasLimit(l uint64) *EnvelopeBuilder

SetGasLimit sets action's gas limit.

func (*EnvelopeBuilder) SetGasPrice

func (b *EnvelopeBuilder) SetGasPrice(p *big.Int) *EnvelopeBuilder

SetGasPrice sets action's gas price.

func (*EnvelopeBuilder) SetGasPriceByBytes

func (b *EnvelopeBuilder) SetGasPriceByBytes(buf []byte) *EnvelopeBuilder

SetGasPriceByBytes sets action's gas price from a byte slice source.

func (*EnvelopeBuilder) SetNonce

func (b *EnvelopeBuilder) SetNonce(n uint64) *EnvelopeBuilder

SetNonce sets action's nonce.

func (*EnvelopeBuilder) SetVersion

func (b *EnvelopeBuilder) SetVersion(v uint32) *EnvelopeBuilder

SetVersion sets action's version.

type Execution

type Execution struct {
	AbstractAction
	// contains filtered or unexported fields
}

Execution defines the struct of account-based contract execution

func NewExecution

func NewExecution(
	contractAddress string,
	nonce uint64,
	amount *big.Int,
	gasLimit uint64,
	gasPrice *big.Int,
	data []byte,
) (*Execution, error)

NewExecution returns a Execution instance

func (*Execution) Amount

func (ex *Execution) Amount() *big.Int

Amount returns the amount

func (*Execution) Contract

func (ex *Execution) Contract() string

Contract returns a contract address

func (*Execution) Cost

func (ex *Execution) Cost() (*big.Int, error)

Cost returns the cost of an execution

func (*Execution) Data

func (ex *Execution) Data() []byte

Data returns the data bytes

func (*Execution) Destination

func (ex *Execution) Destination() string

Destination returns a contract address

func (*Execution) ExecutorPublicKey

func (ex *Execution) ExecutorPublicKey() crypto.PublicKey

ExecutorPublicKey returns the executor's public key

func (*Execution) IntrinsicGas

func (ex *Execution) IntrinsicGas() (uint64, error)

IntrinsicGas returns the intrinsic gas of an execution

func (*Execution) LoadProto

func (ex *Execution) LoadProto(pbAct *iotextypes.Execution) error

LoadProto converts a protobuf's Execution to Execution

func (*Execution) Proto

func (ex *Execution) Proto() *iotextypes.Execution

Proto converts Execution to protobuf's Execution

func (*Execution) SanityCheck

func (ex *Execution) SanityCheck() error

SanityCheck validates the variables in the action

func (*Execution) Serialize

func (ex *Execution) Serialize() []byte

Serialize returns a raw byte stream of this Transfer

func (*Execution) TotalSize

func (ex *Execution) TotalSize() uint32

TotalSize returns the total size of this Execution

type GrantReward

type GrantReward struct {
	AbstractAction
	// contains filtered or unexported fields
}

GrantReward is the action to grant either block or epoch reward

func (*GrantReward) Cost

func (*GrantReward) Cost() (*big.Int, error)

Cost returns the total cost of a grant reward action

func (*GrantReward) Height

func (g *GrantReward) Height() uint64

Height returns the block height to grant reward

func (*GrantReward) IntrinsicGas

func (*GrantReward) IntrinsicGas() (uint64, error)

IntrinsicGas returns the intrinsic gas of a grant reward action, which is 0

func (*GrantReward) LoadProto

func (g *GrantReward) LoadProto(gProto *iotextypes.GrantReward) error

LoadProto converts a grant reward action protobuf to a grant reward action struct

func (*GrantReward) Proto

func (g *GrantReward) Proto() *iotextypes.GrantReward

Proto converts a grant reward action struct to a grant reward action protobuf

func (*GrantReward) RewardType

func (g *GrantReward) RewardType() int

RewardType returns the grant reward type

func (*GrantReward) Serialize

func (g *GrantReward) Serialize() []byte

Serialize returns a raw byte stream of a grant reward action

type GrantRewardBuilder

type GrantRewardBuilder struct {
	Builder
	// contains filtered or unexported fields
}

GrantRewardBuilder is the struct to build GrantReward

func (*GrantRewardBuilder) Build

func (b *GrantRewardBuilder) Build() GrantReward

Build builds a new grant reward action

func (*GrantRewardBuilder) SetHeight

func (b *GrantRewardBuilder) SetHeight(height uint64) *GrantRewardBuilder

SetHeight sets the grant reward block height

func (*GrantRewardBuilder) SetRewardType

func (b *GrantRewardBuilder) SetRewardType(t int) *GrantRewardBuilder

SetRewardType sets the grant reward type

type Log

type Log struct {
	Address            string
	Topics             Topics
	Data               []byte
	BlockHeight        uint64
	ActionHash         hash.Hash256
	Index              uint
	NotFixTopicCopyBug bool
}

Log stores an evm contract event

func (*Log) ConvertFromLogPb

func (log *Log) ConvertFromLogPb(pbLog *iotextypes.Log)

ConvertFromLogPb converts a protobuf's LogPb to Log

func (*Log) ConvertToLogPb

func (log *Log) ConvertToLogPb() *iotextypes.Log

ConvertToLogPb converts a Log to protobuf's Log

func (*Log) Deserialize

func (log *Log) Deserialize(buf []byte) error

Deserialize parse the byte stream into Log

func (*Log) Serialize

func (log *Log) Serialize() ([]byte, error)

Serialize returns a serialized byte stream for the Log

type PutPollResult

type PutPollResult struct {
	AbstractAction
	// contains filtered or unexported fields
}

PutPollResult represents put the poll result from gravity chain.

func NewPutPollResult

func NewPutPollResult(
	nonce uint64,
	height uint64,
	candidates state.CandidateList,
) *PutPollResult

NewPutPollResult instantiates a putting poll result action struct.

func (*PutPollResult) Candidates

func (r *PutPollResult) Candidates() state.CandidateList

Candidates returns the list of candidates.

func (*PutPollResult) Cost

func (r *PutPollResult) Cost() (*big.Int, error)

Cost returns the total cost of a put poll result action

func (*PutPollResult) Height

func (r *PutPollResult) Height() uint64

Height returns put poll result height.

func (*PutPollResult) IntrinsicGas

func (r *PutPollResult) IntrinsicGas() (uint64, error)

IntrinsicGas returns the intrinsic gas of a put poll result action

func (*PutPollResult) LoadProto

func (r *PutPollResult) LoadProto(putPollResultPb *iotextypes.PutPollResult) error

LoadProto converts a proto message into put block action.

func (*PutPollResult) ProducerPublicKey

func (r *PutPollResult) ProducerPublicKey() crypto.PublicKey

ProducerPublicKey return producer public key.

func (*PutPollResult) Proto

func (r *PutPollResult) Proto() *iotextypes.PutPollResult

Proto converts put poll result action into a proto message.

func (*PutPollResult) Serialize

func (r *PutPollResult) Serialize() []byte

Serialize returns the byte representation of put poll result action.

type Receipt

type Receipt struct {
	Status          uint64
	BlockHeight     uint64
	ActionHash      hash.Hash256
	GasConsumed     uint64
	ContractAddress string
	Logs            []*Log
}

Receipt represents the result of a contract

func (*Receipt) ConvertFromReceiptPb

func (receipt *Receipt) ConvertFromReceiptPb(pbReceipt *iotextypes.Receipt)

ConvertFromReceiptPb converts a protobuf's Receipt to Receipt

func (*Receipt) ConvertToReceiptPb

func (receipt *Receipt) ConvertToReceiptPb() *iotextypes.Receipt

ConvertToReceiptPb converts a Receipt to protobuf's Receipt

func (*Receipt) Deserialize

func (receipt *Receipt) Deserialize(buf []byte) error

Deserialize parse the byte stream into Receipt

func (*Receipt) Hash

func (receipt *Receipt) Hash() hash.Hash256

Hash returns the hash of receipt

func (*Receipt) Serialize

func (receipt *Receipt) Serialize() ([]byte, error)

Serialize returns a serialized byte stream for the Receipt

type Restake

type Restake struct {
	AbstractAction
	// contains filtered or unexported fields
}

Restake defines the action of stake again

func NewRestake

func NewRestake(
	nonce uint64,
	index uint64,
	duration uint32,
	autoStake bool,
	payload []byte,
	gasLimit uint64,
	gasPrice *big.Int,
) (*Restake, error)

NewRestake returns a Restake instance

func (*Restake) AutoStake

func (rs *Restake) AutoStake() bool

AutoStake returns the autoStake boolean

func (*Restake) BucketIndex

func (rs *Restake) BucketIndex() uint64

BucketIndex returns bucket index

func (*Restake) Cost

func (rs *Restake) Cost() (*big.Int, error)

Cost returns the total cost of a Restake

func (*Restake) Duration

func (rs *Restake) Duration() uint32

Duration returns the updated duration

func (*Restake) IntrinsicGas

func (rs *Restake) IntrinsicGas() (uint64, error)

IntrinsicGas returns the intrinsic gas of a Restake

func (*Restake) LoadProto

func (rs *Restake) LoadProto(pbAct *iotextypes.StakeRestake) error

LoadProto converts a protobuf's Action to Restake

func (*Restake) Payload

func (rs *Restake) Payload() []byte

Payload returns the payload bytes

func (*Restake) Proto

func (rs *Restake) Proto() *iotextypes.StakeRestake

Proto converts to protobuf Restake Action

func (*Restake) Serialize

func (rs *Restake) Serialize() []byte

Serialize returns a raw byte stream of the Stake again struct

type SealedEnvelope

type SealedEnvelope struct {
	Envelope
	// contains filtered or unexported fields
}

SealedEnvelope is a signed action envelope.

func AssembleSealedEnvelope

func AssembleSealedEnvelope(act Envelope, pk crypto.PublicKey, sig []byte) SealedEnvelope

AssembleSealedEnvelope assembles a SealedEnvelope use Envelope, Sender Address and Signature. This method should be only used in tests.

func FakeSeal

func FakeSeal(act Envelope, pubk crypto.PublicKey) SealedEnvelope

FakeSeal creates a SealedActionEnvelope without signature. This method should be only used in tests.

func Sign

func Sign(act Envelope, sk crypto.PrivateKey) (SealedEnvelope, error)

Sign signs the action using sender's private key

func (*SealedEnvelope) Hash

func (sealed *SealedEnvelope) Hash() hash.Hash256

Hash returns the hash value of SealedEnvelope.

func (*SealedEnvelope) LoadProto

func (sealed *SealedEnvelope) LoadProto(pbAct *iotextypes.Action) error

LoadProto loads from proto scheme.

func (*SealedEnvelope) Proto

func (sealed *SealedEnvelope) Proto() *iotextypes.Action

Proto converts it to it's proto scheme.

func (*SealedEnvelope) Signature

func (sealed *SealedEnvelope) Signature() []byte

Signature returns signature bytes

func (*SealedEnvelope) SrcPubkey

func (sealed *SealedEnvelope) SrcPubkey() crypto.PublicKey

SrcPubkey returns the source public key

type SealedEnvelopeValidator

type SealedEnvelopeValidator interface {
	// Validate returns an error if any validation failed
	Validate(context.Context, SealedEnvelope) error
}

SealedEnvelopeValidator is the interface of validating an SealedEnvelope action

type Topics

type Topics []hash.Hash256

Topics are data items of a transaction, such as send/recipient address

type Transfer

type Transfer struct {
	AbstractAction
	// contains filtered or unexported fields
}

Transfer defines the struct of account-based transfer

func NewTransfer

func NewTransfer(
	nonce uint64,
	amount *big.Int,
	recipient string,
	payload []byte,
	gasLimit uint64,
	gasPrice *big.Int,
) (*Transfer, error)

NewTransfer returns a Transfer instance

func (*Transfer) Amount

func (tsf *Transfer) Amount() *big.Int

Amount returns the amount

func (*Transfer) Cost

func (tsf *Transfer) Cost() (*big.Int, error)

Cost returns the total cost of a transfer

func (*Transfer) Destination

func (tsf *Transfer) Destination() string

Destination returns the recipient address as destination.

func (*Transfer) IntrinsicGas

func (tsf *Transfer) IntrinsicGas() (uint64, error)

IntrinsicGas returns the intrinsic gas of a transfer

func (*Transfer) LoadProto

func (tsf *Transfer) LoadProto(pbAct *iotextypes.Transfer) error

LoadProto converts a protobuf's Action to Transfer

func (*Transfer) Payload

func (tsf *Transfer) Payload() []byte

Payload returns the payload bytes

func (*Transfer) Proto

func (tsf *Transfer) Proto() *iotextypes.Transfer

Proto converts Transfer to protobuf's Action

func (*Transfer) Recipient

func (tsf *Transfer) Recipient() string

Recipient returns the recipient address. It's the wrapper of Action.DstAddr

func (*Transfer) SanityCheck

func (tsf *Transfer) SanityCheck() error

SanityCheck validates the variables in the action

func (*Transfer) SenderPublicKey

func (tsf *Transfer) SenderPublicKey() crypto.PublicKey

SenderPublicKey returns the sender public key. It's the wrapper of Action.SrcPubkey

func (*Transfer) Serialize

func (tsf *Transfer) Serialize() []byte

Serialize returns a raw byte stream of this Transfer

func (*Transfer) TotalSize

func (tsf *Transfer) TotalSize() uint32

TotalSize returns the total size of this Transfer

type TransferStake

type TransferStake struct {
	AbstractAction
	// contains filtered or unexported fields
}

TransferStake defines the action of transfering stake ownership ts the other

func NewTransferStake

func NewTransferStake(
	nonce uint64,
	voterAddress string,
	bucketIndex uint64,
	payload []byte,
	gasLimit uint64,
	gasPrice *big.Int,
) (*TransferStake, error)

NewTransferStake returns a TransferStake instance

func (*TransferStake) BucketIndex

func (ts *TransferStake) BucketIndex() uint64

BucketIndex returns bucket index

func (*TransferStake) Cost

func (ts *TransferStake) Cost() (*big.Int, error)

Cost returns the tstal cost of a TransferStake

func (*TransferStake) IntrinsicGas

func (ts *TransferStake) IntrinsicGas() (uint64, error)

IntrinsicGas returns the intrinsic gas of a TransferStake

func (*TransferStake) LoadProto

func (ts *TransferStake) LoadProto(pbAct *iotextypes.StakeTransferOwnership) error

LoadProto loads transfer stake protobuf

func (*TransferStake) Payload

func (ts *TransferStake) Payload() []byte

Payload returns the payload bytes

func (*TransferStake) Proto

func (ts *TransferStake) Proto() *iotextypes.StakeTransferOwnership

Proto converts transfer stake to protobuf

func (*TransferStake) Serialize

func (ts *TransferStake) Serialize() []byte

Serialize returns a raw byte stream of the transfer stake action struct

func (*TransferStake) VoterAddress

func (ts *TransferStake) VoterAddress() address.Address

VoterAddress returns the address of recipient

type Unstake

type Unstake struct {
	// contains filtered or unexported fields
}

Unstake defines the action of unstake

func NewUnstake

func NewUnstake(
	nonce uint64,
	bucketIndex uint64,
	payload []byte,
	gasLimit uint64,
	gasPrice *big.Int,
) (*Unstake, error)

NewUnstake returns a Unstake instance

func (*Unstake) BucketIndex

func (sr *Unstake) BucketIndex() uint64

BucketIndex returns bucket index

func (*Unstake) Cost

func (su *Unstake) Cost() (*big.Int, error)

Cost returns the total cost of a Unstake

func (*Unstake) IntrinsicGas

func (su *Unstake) IntrinsicGas() (uint64, error)

IntrinsicGas returns the intrinsic gas of a Unstake

func (*Unstake) LoadProto

func (sr *Unstake) LoadProto(pbAct *iotextypes.StakeReclaim) error

LoadProto converts a protobuf's Action to reclaimStake

func (*Unstake) Payload

func (sr *Unstake) Payload() []byte

Payload returns the payload bytes

func (*Unstake) Proto

func (sr *Unstake) Proto() *iotextypes.StakeReclaim

Proto converts to protobuf stake reclaim action struct

func (*Unstake) Serialize

func (sr *Unstake) Serialize() []byte

Serialize returns a raw byte stream of the stake reclaim action struct

type WithdrawStake

type WithdrawStake struct {
	// contains filtered or unexported fields
}

WithdrawStake defines the action of stake withdraw

func NewWithdrawStake

func NewWithdrawStake(
	nonce uint64,
	bucketIndex uint64,
	payload []byte,
	gasLimit uint64,
	gasPrice *big.Int,
) (*WithdrawStake, error)

NewWithdrawStake returns a WithdrawStake instance

func (*WithdrawStake) BucketIndex

func (sr *WithdrawStake) BucketIndex() uint64

BucketIndex returns bucket index

func (*WithdrawStake) Cost

func (sw *WithdrawStake) Cost() (*big.Int, error)

Cost returns the total cost of a WithdrawStake

func (*WithdrawStake) IntrinsicGas

func (sw *WithdrawStake) IntrinsicGas() (uint64, error)

IntrinsicGas returns the intrinsic gas of a WithdrawStake

func (*WithdrawStake) LoadProto

func (sr *WithdrawStake) LoadProto(pbAct *iotextypes.StakeReclaim) error

LoadProto converts a protobuf's Action to reclaimStake

func (*WithdrawStake) Payload

func (sr *WithdrawStake) Payload() []byte

Payload returns the payload bytes

func (*WithdrawStake) Proto

func (sr *WithdrawStake) Proto() *iotextypes.StakeReclaim

Proto converts to protobuf stake reclaim action struct

func (*WithdrawStake) Serialize

func (sr *WithdrawStake) Serialize() []byte

Serialize returns a raw byte stream of the stake reclaim action struct

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
f or F : Jump to identifier