services

package
v1.10.3-0...-ec03cfc Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2021 License: LGPL-3.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultGasPrice ..
	DefaultGasPrice = denominations.Nano
)
View Source
const (
	// SideEffectTransactionSuffix is use in the transaction identifier for each block that contains
	// side-effect operations.
	SideEffectTransactionSuffix = "side_effect"
)
View Source
const (
	// SignedPayloadLength is the required length of the ECDSA payload
	SignedPayloadLength = 65
)

Variables

View Source
var (
	// FormatDefaultSenderAddress ..
	FormatDefaultSenderAddress = ethcommon.HexToAddress("0xEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE")
)

Functions

func ConstructTransaction

func ConstructTransaction(
	components *OperationComponents, metadata *ConstructMetadata, sourceShardID uint32,
) (response hmyTypes.PoolTransaction, rosettaError *types.Error)

ConstructTransaction object (unsigned). TODO (dm): implement staking transaction construction

func FormatCrossShardReceiverTransaction

func FormatCrossShardReceiverTransaction(
	cxReceipt *hmytypes.CXReceipt,
) (txs *types.Transaction, rosettaError *types.Error)

FormatCrossShardReceiverTransaction for cross-shard payouts on destination shard

func FormatTransaction

func FormatTransaction(
	tx hmytypes.PoolTransaction, receipt *hmytypes.Receipt, contractInfo *ContractInfo,
) (fmtTx *types.Transaction, rosettaError *types.Error)

FormatTransaction for staking, cross-shard sender, and plain transactions

func GetNativeOperationsFromStakingTransaction

func GetNativeOperationsFromStakingTransaction(
	tx *stakingTypes.StakingTransaction, receipt *hmytypes.Receipt,
) ([]*types.Operation, *types.Error)

GetNativeOperationsFromStakingTransaction for all staking directives Note that only native token operations can come from staking transactions.

func GetNativeOperationsFromTransaction

func GetNativeOperationsFromTransaction(
	tx *hmytypes.Transaction, receipt *hmytypes.Receipt, contractInfo *ContractInfo,
) ([]*types.Operation, *types.Error)

GetNativeOperationsFromTransaction for one of the following transactions: contract creation, cross-shard sender, same-shard transfer with and without code execution. Native operations only include operations that affect the native currency balance of an account.

func GetSideEffectOperationsFromGenesisSpec

func GetSideEffectOperationsFromGenesisSpec(
	spec *core.Genesis, startingOperationIndex *int64,
) ([]*types.Operation, *types.Error)

GetSideEffectOperationsFromGenesisSpec for the given spec. If the startingOperationIndex is provided, all operations will be indexed starting from the given operation index.

func GetSideEffectOperationsFromPreStakingRewards

func GetSideEffectOperationsFromPreStakingRewards(
	rewards hmy.PreStakingBlockRewards, startingOperationIndex *int64,
) ([]*types.Operation, *types.Error)

GetSideEffectOperationsFromPreStakingRewards from the given rewards. If the startingOperationIndex is provided, all operations will be indexed starting from the given operation index.

func GetSideEffectOperationsFromUndelegationPayouts

func GetSideEffectOperationsFromUndelegationPayouts(
	payouts hmy.UndelegationPayouts, startingOperationIndex *int64,
) ([]*types.Operation, *types.Error)

GetSideEffectOperationsFromUndelegationPayouts from the given payouts. If the startingOperationIndex is provided, all operations will be indexed starting from the given operation index.

func GetTransactionStatus

func GetTransactionStatus(tx hmytypes.PoolTransaction, receipt *hmytypes.Receipt) string

GetTransactionStatus for any valid harmony transaction given its receipt.

func NewAccountAPI

func NewAccountAPI(hmy *hmy.Harmony) server.AccountAPIServicer

NewAccountAPI creates a new instance of a BlockAPI.

func NewBlockAPI

func NewBlockAPI(hmy *hmy.Harmony) server.BlockAPIServicer

NewBlockAPI creates a new instance of a BlockAPI.

func NewConstructionAPI

func NewConstructionAPI(hmy *hmy.Harmony) server.ConstructionAPIServicer

NewConstructionAPI creates a new instance of a ConstructAPI.

func NewMempoolAPI

func NewMempoolAPI(hmy *hmy.Harmony) server.MempoolAPIServicer

NewMempoolAPI creates a new instance of MempoolAPI

func NewNetworkAPI

func NewNetworkAPI(hmy *hmy.Harmony) server.NetworkAPIServicer

NewNetworkAPI creates a new instance of a NetworkAPI.

Types

type AccountAPI

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

AccountAPI implements the server.AccountAPIServicer interface.

func (*AccountAPI) AccountBalance

func (s *AccountAPI) AccountBalance(
	ctx context.Context, request *types.AccountBalanceRequest,
) (*types.AccountBalanceResponse, *types.Error)

AccountBalance implements the /account/balance endpoint

type AccountMetadata

type AccountMetadata struct {
	Address string `json:"hex_address"`
}

AccountMetadata used for account identifiers

type BlockAPI

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

BlockAPI implements the server.BlockAPIServicer interface.

func (*BlockAPI) Block

func (s *BlockAPI) Block(
	ctx context.Context, request *types.BlockRequest,
) (response *types.BlockResponse, rosettaError *types.Error)

Block implements the /block endpoint

func (*BlockAPI) BlockTransaction

func (s *BlockAPI) BlockTransaction(
	ctx context.Context, request *types.BlockTransactionRequest,
) (*types.BlockTransactionResponse, *types.Error)

BlockTransaction implements the /block/transaction endpoint

type BlockMetadata

type BlockMetadata struct {
	Epoch *big.Int `json:"epoch"`
}

BlockMetadata ..

type ConstructAPI

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

ConstructAPI implements the server.ConstructAPIServicer interface.

func (*ConstructAPI) ConstructionCombine

ConstructionCombine implements the /construction/combine endpoint.

func (*ConstructAPI) ConstructionDerive

ConstructionDerive implements the /construction/derive endpoint.

func (*ConstructAPI) ConstructionHash

ConstructionHash implements the /construction/hash endpoint.

func (*ConstructAPI) ConstructionMetadata

ConstructionMetadata implements the /construction/metadata endpoint.

func (*ConstructAPI) ConstructionParse

ConstructionParse implements the /construction/parse endpoint.

func (*ConstructAPI) ConstructionPayloads

ConstructionPayloads implements the /construction/payloads endpoint.

func (*ConstructAPI) ConstructionPreprocess

ConstructionPreprocess implements the /construction/preprocess endpoint. Note that `request.MaxFee` is never considered for this construction implementation.

func (*ConstructAPI) ConstructionSubmit

ConstructionSubmit implements the /construction/submit endpoint.

type ConstructMetadata

type ConstructMetadata struct {
	Nonce           uint64               `json:"nonce"`
	GasLimit        uint64               `json:"gas_limit"`
	GasPrice        *big.Int             `json:"gas_price"`
	ContractCode    hexutil.Bytes        `json:"contract_code"`
	EvmReturn       hexutil.Bytes        `json:"evm_return"`
	EvmErrorMessage string               `json:"evm_error_message"`
	Transaction     *TransactionMetadata `json:"transaction_metadata"`
}

ConstructMetadata with a set of operations will construct a valid transaction

func (*ConstructMetadata) UnmarshalFromInterface

func (m *ConstructMetadata) UnmarshalFromInterface(blockArgs interface{}) error

UnmarshalFromInterface ..

type ConstructMetadataOptions

type ConstructMetadataOptions struct {
	TransactionMetadata *TransactionMetadata `json:"transaction_metadata"`
	OperationType       string               `json:"operation_type,omitempty"`
	GasPriceMultiplier  *float64             `json:"gas_price_multiplier,omitempty"`
}

ConstructMetadataOptions is constructed by ConstructionPreprocess for ConstructionMetadata options

func (*ConstructMetadataOptions) UnmarshalFromInterface

func (m *ConstructMetadataOptions) UnmarshalFromInterface(metadata interface{}) error

UnmarshalFromInterface ..

type ContractInfo

type ContractInfo struct {
	// ContractAddress is the address of the primary (or first) contract related to the tx.
	ContractAddress *ethcommon.Address `json:"contract_hex_address"`
	// ContractCode is the code of the primary (or first) contract related to the tx.
	ContractCode    []byte               `json:"contract_code"`
	ExecutionResult *hmy.ExecutionResult `json:"execution_result"`
}

ContractInfo contains all relevant data for formatting/inspecting transactions involving contracts

type MempoolAPI

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

MempoolAPI implements the server.MempoolAPIServicer interface

func (*MempoolAPI) Mempool

Mempool implements the /mempool endpoint.

func (*MempoolAPI) MempoolTransaction

MempoolTransaction implements the /mempool/transaction endpoint.

type NetworkAPI

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

NetworkAPI implements the server.NetworkAPIServicer interface.

func (*NetworkAPI) NetworkList

func (s *NetworkAPI) NetworkList(
	ctx context.Context, request *types.MetadataRequest,
) (*types.NetworkListResponse, *types.Error)

NetworkList implements the /network/list endpoint TODO (dm): Update Node API to support multiple shards...

func (*NetworkAPI) NetworkOptions

func (s *NetworkAPI) NetworkOptions(
	ctx context.Context, request *types.NetworkRequest,
) (*types.NetworkOptionsResponse, *types.Error)

NetworkOptions implements the /network/options endpoint

func (*NetworkAPI) NetworkStatus

func (s *NetworkAPI) NetworkStatus(
	ctx context.Context, request *types.NetworkRequest,
) (*types.NetworkStatusResponse, *types.Error)

NetworkStatus implements the /network/status endpoint

type OperationComponents

type OperationComponents struct {
	Type           string                   `json:"type"`
	From           *types.AccountIdentifier `json:"from"`
	To             *types.AccountIdentifier `json:"to"`
	Amount         *big.Int                 `json:"amount"`
	StakingMessage interface{}              `json:"staking_message,omitempty"`
}

OperationComponents are components from a set of operations to construct a valid transaction

func GetOperationComponents

func GetOperationComponents(
	operations []*types.Operation,
) (*OperationComponents, *types.Error)

GetOperationComponents ensures the provided operations creates a valid transaction and returns the OperationComponents of the resulting transaction.

Providing a gas expenditure operation is INVALID. All staking & cross-shard operations require metadata matching the operation type to be a valid. All other operations do not require metadata. TODO (dm): implement staking transaction construction

func (*OperationComponents) IsStaking

func (s *OperationComponents) IsStaking() bool

IsStaking ..

type TransactionMetadata

type TransactionMetadata struct {
	// CrossShardIdentifier is the transaction identifier on the from/source shard
	CrossShardIdentifier *types.TransactionIdentifier `json:"cross_shard_transaction_identifier,omitempty"`
	ToShardID            *uint32                      `json:"to_shard,omitempty"`
	FromShardID          *uint32                      `json:"from_shard,omitempty"`
	// ContractAccountIdentifier is the 'main' contract account ID associated with a transaction
	ContractAccountIdentifier *types.AccountIdentifier `json:"contract_account_identifier,omitempty"`
	Data                      *string                  `json:"data,omitempty"`
	Logs                      []*hmyTypes.Log          `json:"logs,omitempty"`
}

TransactionMetadata contains all (optional) information for a transaction.

func (*TransactionMetadata) UnmarshalFromInterface

func (t *TransactionMetadata) UnmarshalFromInterface(metaData interface{}) error

UnmarshalFromInterface ..

type WrappedTransaction

type WrappedTransaction struct {
	RLPBytes     []byte                   `json:"rlp_bytes"`
	IsStaking    bool                     `json:"is_staking"`
	ContractCode hexutil.Bytes            `json:"contract_code"`
	From         *types.AccountIdentifier `json:"from"`
}

WrappedTransaction is a wrapper for a transaction that includes all relevant data to parse a transaction.

Jump to

Keyboard shortcuts

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