Documentation ¶
Index ¶
- Constants
- Variables
- func ConstructTransaction(components *OperationComponents, metadata *ConstructMetadata, ...) (response hmyTypes.PoolTransaction, rosettaError *types.Error)
- func FormatCrossShardReceiverTransaction(cxReceipt *hmytypes.CXReceipt) (txs *types.Transaction, rosettaError *types.Error)
- func FormatTransaction(tx hmytypes.PoolTransaction, receipt *hmytypes.Receipt, ...) (fmtTx *types.Transaction, rosettaError *types.Error)
- func GetNativeOperationsFromStakingTransaction(tx *stakingTypes.StakingTransaction, receipt *hmytypes.Receipt) ([]*types.Operation, *types.Error)
- func GetNativeOperationsFromTransaction(tx *hmytypes.Transaction, receipt *hmytypes.Receipt, ...) ([]*types.Operation, *types.Error)
- func GetSideEffectOperationsFromGenesisSpec(spec *core.Genesis, startingOperationIndex *int64) ([]*types.Operation, *types.Error)
- func GetSideEffectOperationsFromPreStakingRewards(rewards hmy.PreStakingBlockRewards, startingOperationIndex *int64) ([]*types.Operation, *types.Error)
- func GetSideEffectOperationsFromUndelegationPayouts(payouts hmy.UndelegationPayouts, startingOperationIndex *int64) ([]*types.Operation, *types.Error)
- func GetTransactionStatus(tx hmytypes.PoolTransaction, receipt *hmytypes.Receipt) string
- func NewAccountAPI(hmy *hmy.Harmony) server.AccountAPIServicer
- func NewBlockAPI(hmy *hmy.Harmony) server.BlockAPIServicer
- func NewConstructionAPI(hmy *hmy.Harmony) server.ConstructionAPIServicer
- func NewMempoolAPI(hmy *hmy.Harmony) server.MempoolAPIServicer
- func NewNetworkAPI(hmy *hmy.Harmony) server.NetworkAPIServicer
- type AccountAPI
- type AccountMetadata
- type BlockAPI
- type BlockMetadata
- type ConstructAPI
- func (s *ConstructAPI) ConstructionCombine(ctx context.Context, request *types.ConstructionCombineRequest) (*types.ConstructionCombineResponse, *types.Error)
- func (s *ConstructAPI) ConstructionDerive(ctx context.Context, request *types.ConstructionDeriveRequest) (*types.ConstructionDeriveResponse, *types.Error)
- func (s *ConstructAPI) ConstructionHash(ctx context.Context, request *types.ConstructionHashRequest) (*types.TransactionIdentifierResponse, *types.Error)
- func (s *ConstructAPI) ConstructionMetadata(ctx context.Context, request *types.ConstructionMetadataRequest) (*types.ConstructionMetadataResponse, *types.Error)
- func (s *ConstructAPI) ConstructionParse(ctx context.Context, request *types.ConstructionParseRequest) (*types.ConstructionParseResponse, *types.Error)
- func (s *ConstructAPI) ConstructionPayloads(ctx context.Context, request *types.ConstructionPayloadsRequest) (*types.ConstructionPayloadsResponse, *types.Error)
- func (s *ConstructAPI) ConstructionPreprocess(ctx context.Context, request *types.ConstructionPreprocessRequest) (*types.ConstructionPreprocessResponse, *types.Error)
- func (s *ConstructAPI) ConstructionSubmit(ctx context.Context, request *types.ConstructionSubmitRequest) (*types.TransactionIdentifierResponse, *types.Error)
- type ConstructMetadata
- type ConstructMetadataOptions
- type ContractInfo
- type MempoolAPI
- type NetworkAPI
- func (s *NetworkAPI) NetworkList(ctx context.Context, request *types.MetadataRequest) (*types.NetworkListResponse, *types.Error)
- func (s *NetworkAPI) NetworkOptions(ctx context.Context, request *types.NetworkRequest) (*types.NetworkOptionsResponse, *types.Error)
- func (s *NetworkAPI) NetworkStatus(ctx context.Context, request *types.NetworkRequest) (*types.NetworkStatusResponse, *types.Error)
- type OperationComponents
- type TransactionMetadata
- type WrappedTransaction
Constants ¶
const ( // DefaultGasPrice .. DefaultGasPrice = denominations.Nano )
const ( // SideEffectTransactionSuffix is use in the transaction identifier for each block that contains // side-effect operations. SideEffectTransactionSuffix = "side_effect" )
const (
// SignedPayloadLength is the required length of the ECDSA payload
SignedPayloadLength = 65
)
Variables ¶
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 ConstructAPI ¶
type ConstructAPI struct {
// contains filtered or unexported fields
}
ConstructAPI implements the server.ConstructAPIServicer interface.
func (*ConstructAPI) ConstructionCombine ¶
func (s *ConstructAPI) ConstructionCombine( ctx context.Context, request *types.ConstructionCombineRequest, ) (*types.ConstructionCombineResponse, *types.Error)
ConstructionCombine implements the /construction/combine endpoint.
func (*ConstructAPI) ConstructionDerive ¶
func (s *ConstructAPI) ConstructionDerive( ctx context.Context, request *types.ConstructionDeriveRequest, ) (*types.ConstructionDeriveResponse, *types.Error)
ConstructionDerive implements the /construction/derive endpoint.
func (*ConstructAPI) ConstructionHash ¶
func (s *ConstructAPI) ConstructionHash( ctx context.Context, request *types.ConstructionHashRequest, ) (*types.TransactionIdentifierResponse, *types.Error)
ConstructionHash implements the /construction/hash endpoint.
func (*ConstructAPI) ConstructionMetadata ¶
func (s *ConstructAPI) ConstructionMetadata( ctx context.Context, request *types.ConstructionMetadataRequest, ) (*types.ConstructionMetadataResponse, *types.Error)
ConstructionMetadata implements the /construction/metadata endpoint.
func (*ConstructAPI) ConstructionParse ¶
func (s *ConstructAPI) ConstructionParse( ctx context.Context, request *types.ConstructionParseRequest, ) (*types.ConstructionParseResponse, *types.Error)
ConstructionParse implements the /construction/parse endpoint.
func (*ConstructAPI) ConstructionPayloads ¶
func (s *ConstructAPI) ConstructionPayloads( ctx context.Context, request *types.ConstructionPayloadsRequest, ) (*types.ConstructionPayloadsResponse, *types.Error)
ConstructionPayloads implements the /construction/payloads endpoint.
func (*ConstructAPI) ConstructionPreprocess ¶
func (s *ConstructAPI) ConstructionPreprocess( ctx context.Context, request *types.ConstructionPreprocessRequest, ) (*types.ConstructionPreprocessResponse, *types.Error)
ConstructionPreprocess implements the /construction/preprocess endpoint. Note that `request.MaxFee` is never considered for this construction implementation.
func (*ConstructAPI) ConstructionSubmit ¶
func (s *ConstructAPI) ConstructionSubmit( ctx context.Context, request *types.ConstructionSubmitRequest, ) (*types.TransactionIdentifierResponse, *types.Error)
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 ¶
func (s *MempoolAPI) Mempool( ctx context.Context, req *types.NetworkRequest, ) (*types.MempoolResponse, *types.Error)
Mempool implements the /mempool endpoint.
func (*MempoolAPI) MempoolTransaction ¶
func (s *MempoolAPI) MempoolTransaction( ctx context.Context, req *types.MempoolTransactionRequest, ) (*types.MempoolTransactionResponse, *types.Error)
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
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.