sctransaction

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: Apache-2.0, BSD-2-Clause Imports: 15 Imported by: 0

Documentation

Overview

implements smart contract transaction. smart contract transaction is value transaction with special payload

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterSemanticAnalyzerConstructor added in v0.1.0

func RegisterSemanticAnalyzerConstructor(constr constructorNew)

Types

type NewStateSectionParams added in v0.1.0

type NewStateSectionParams struct {
	Color      balance.Color
	BlockIndex uint32
	StateHash  hashing.HashValue
	Timestamp  int64
}

type RequestRef

type RequestRef struct {
	Tx    *Transaction
	Index uint16
}

func (*RequestRef) RequestID added in v0.1.0

func (ref *RequestRef) RequestID() *coretypes.RequestID

func (*RequestRef) RequestSection added in v0.1.0

func (ref *RequestRef) RequestSection() *RequestSection

func (*RequestRef) SenderAddress added in v0.1.0

func (ref *RequestRef) SenderAddress() *address.Address

func (*RequestRef) SenderAgentID added in v0.1.0

func (ref *RequestRef) SenderAgentID() coretypes.AgentID

func (*RequestRef) SenderContractHname added in v0.1.0

func (ref *RequestRef) SenderContractHname() coretypes.Hname

func (*RequestRef) SenderContractID added in v0.1.0

func (ref *RequestRef) SenderContractID() (ret coretypes.ContractID, err error)

type RequestSection added in v0.1.0

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

func NewRequestSection added in v0.1.0

func NewRequestSection(senderContractHname coretypes.Hname, targetContract coretypes.ContractID, entryPointCode coretypes.Hname) *RequestSection

RequestSection creates new request block

func NewRequestSectionByWallet added in v0.1.0

func NewRequestSectionByWallet(targetContract coretypes.ContractID, entryPointCode coretypes.Hname) *RequestSection

NewRequestSectionByWallet same as NewRequestSection but assumes senderAddress index is 0

func (*RequestSection) Clone added in v0.1.0

func (req *RequestSection) Clone() *RequestSection

func (*RequestSection) EntryPointCode added in v0.1.0

func (req *RequestSection) EntryPointCode() coretypes.Hname

func (*RequestSection) Read added in v0.1.0

func (req *RequestSection) Read(r io.Reader) error

func (*RequestSection) SenderContractHname added in v0.1.0

func (req *RequestSection) SenderContractHname() coretypes.Hname

func (*RequestSection) SolidArgs added in v0.1.0

func (req *RequestSection) SolidArgs() dict.Dict

SolidArgs returns solid args if decoded already or nil otherwise

func (*RequestSection) SolidifyArgs added in v0.1.0

func (req *RequestSection) SolidifyArgs(reg coretypes.BlobCache) (bool, error)

SolidifyArgs return true if solidified successfully

func (*RequestSection) String added in v0.1.0

func (req *RequestSection) String() string

func (*RequestSection) Target added in v0.1.0

func (req *RequestSection) Target() coretypes.ContractID

func (*RequestSection) Timelock added in v0.1.0

func (req *RequestSection) Timelock() uint32

func (*RequestSection) Transfer added in v0.1.0

func (req *RequestSection) Transfer() coretypes.ColoredBalances

func (*RequestSection) WithArgs added in v0.1.0

WithArgs sets encoded args

func (*RequestSection) WithTimelock added in v0.1.0

func (req *RequestSection) WithTimelock(tl uint32) *RequestSection

func (*RequestSection) WithTimelockUntil added in v0.1.0

func (req *RequestSection) WithTimelockUntil(deadline time.Time) *RequestSection

func (*RequestSection) WithTransfer added in v0.1.0

func (req *RequestSection) WithTransfer(transfer coretypes.ColoredBalances) *RequestSection

func (*RequestSection) Write added in v0.1.0

func (req *RequestSection) Write(w io.Writer) error

type StateSection added in v0.1.0

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

StateSection of the SC transaction. Represents SC state update previous state block can be determined by the chain transfer of the SC token in the UTXO part of the transaction

func NewStateSection added in v0.1.0

func NewStateSection(par NewStateSectionParams) *StateSection

func (*StateSection) BlockIndex added in v0.1.0

func (sb *StateSection) BlockIndex() uint32

func (*StateSection) Clone added in v0.1.0

func (sb *StateSection) Clone() *StateSection

func (*StateSection) Color added in v0.1.0

func (sb *StateSection) Color() balance.Color

func (*StateSection) Read added in v0.1.0

func (sb *StateSection) Read(r io.Reader) error

func (*StateSection) StateHash added in v0.1.0

func (sb *StateSection) StateHash() hashing.HashValue

func (*StateSection) String added in v0.1.0

func (sb *StateSection) String() string

func (*StateSection) Timestamp added in v0.1.0

func (sb *StateSection) Timestamp() int64

func (*StateSection) WithStateParams added in v0.1.0

func (sb *StateSection) WithStateParams(stateIndex uint32, h hashing.HashValue, ts int64) *StateSection

func (*StateSection) Write added in v0.1.0

func (sb *StateSection) Write(w io.Writer) error

type Transaction

type Transaction struct {
	*valuetransaction.Transaction
	// contains filtered or unexported fields
}

Smart contract transaction wraps value transaction the stateSection and requestSection are parsed from the dataPayload of the value transaction

func NewTransaction

func NewTransaction(vtx *valuetransaction.Transaction, stateBlock *StateSection, requestBlocks []*RequestSection) (*Transaction, error)

creates new sc transaction. It is immutable, i.e. tx hash is stable

func ParseValueTransaction

func ParseValueTransaction(vtx *valuetransaction.Transaction) (*Transaction, error)

parses dataPayload. Error is returned only if pre-parsing succeeded and parsing failed usually this can happen only due to targeted attack or

func (*Transaction) MustProperties

func (tx *Transaction) MustProperties() coretypes.SCTransactionProperties

func (*Transaction) MustState

func (tx *Transaction) MustState() *StateSection

func (*Transaction) OutputBalancesByAddress

func (tx *Transaction) OutputBalancesByAddress(addr address.Address) ([]*balance.Balance, bool)

func (*Transaction) Properties

func (tx *Transaction) Properties() (coretypes.SCTransactionProperties, error)

Properties returns valid properties if sc transaction is semantically correct

func (*Transaction) Requests

func (tx *Transaction) Requests() []*RequestSection

func (*Transaction) Sender

func (tx *Transaction) Sender() *address.Address

Sender returns first input address. It is the unique address, because ParseValueTransaction doesn't allow other options

func (*Transaction) State

func (tx *Transaction) State() (*StateSection, bool)

func (*Transaction) String

func (tx *Transaction) String() string

Directories

Path Synopsis
package semantically analyzes parsed smart contract transaction return object with transaction properties or error if semantically incorrect
package semantically analyzes parsed smart contract transaction return object with transaction properties or error if semantically incorrect

Jump to

Keyboard shortcuts

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