common

package
v1.10.2 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RosettaVersion tied back to the version of the rosetta go-sdk
	RosettaVersion = "1.4.6" // TODO (dm): set variable via build flags

	// Blockchain ..
	Blockchain = "Harmony"

	// NativeSymbol ..
	NativeSymbol = "ONE"

	// NativePrecision in the number of decimal places
	NativePrecision = 18

	// CurveType ..
	CurveType = types.Secp256k1

	// SignatureType ..
	SignatureType = types.EcdsaRecovery
)
View Source
const (
	// ExpendGasOperation is an operation that only affects the native currency.
	ExpendGasOperation = "Gas"

	// ContractCreationOperation is an operation that only affects the native currency.
	ContractCreationOperation = "ContractCreation"

	// NativeTransferOperation is an operation that only affects the native currency.
	NativeTransferOperation = "NativeTransfer"

	// NativeCrossShardTransferOperation is an operation that only affects the native currency.
	NativeCrossShardTransferOperation = "NativeCrossShardTransfer"

	// GenesisFundsOperation is a side effect operation for genesis block only.
	// Note that no transaction can be constructed with this operation.
	GenesisFundsOperation = "Genesis"

	// PreStakingBlockRewardOperation is a side effect operation for pre-staking era only.
	// Note that no transaction can be constructed with this operation.
	PreStakingBlockRewardOperation = "PreStakingBlockReward"

	// UndelegationPayoutOperation is a side effect operation for committee election block only.
	// Note that no transaction can be constructed with this operation.
	UndelegationPayoutOperation = "UndelegationPayout"
)

Variables

View Source
var (
	// ReadTimeout ..
	ReadTimeout = 30 * time.Second

	// WriteTimeout ..
	WriteTimeout = 30 * time.Second

	// IdleTimeout ..
	IdleTimeout = 120 * time.Second

	// NativeCurrency ..
	NativeCurrency = types.Currency{
		Symbol:   NativeSymbol,
		Decimals: NativePrecision,
	}

	// NativeCurrencyHash for quick equivalent checks
	NativeCurrencyHash = types.Hash(NativeCurrency)
)
View Source
var (
	// CatchAllError ..
	CatchAllError = types.Error{
		Code:      0,
		Message:   "catch all error",
		Retriable: false,
	}

	// SanityCheckError ..
	SanityCheckError = types.Error{
		Code:      1,
		Message:   "sanity check error",
		Retriable: false,
	}

	// InvalidNetworkError ..
	InvalidNetworkError = types.Error{
		Code:      2,
		Message:   "invalid network error",
		Retriable: false,
	}

	// TransactionSubmissionError ..
	TransactionSubmissionError = types.Error{
		Code:      3,
		Message:   "transaction submission error",
		Retriable: true,
	}

	// StakingTransactionSubmissionError ..
	StakingTransactionSubmissionError = types.Error{
		Code:      4,
		Message:   "staking transaction submission error",
		Retriable: true,
	}

	// BlockNotFoundError ..
	BlockNotFoundError = types.Error{
		Code:      5,
		Message:   "block not found error",
		Retriable: false,
	}

	// TransactionNotFoundError ..
	TransactionNotFoundError = types.Error{
		Code:      6,
		Message:   "transaction or staking transaction not found",
		Retriable: false,
	}

	// ReceiptNotFoundError ..
	ReceiptNotFoundError = types.Error{
		Code:      7,
		Message:   "receipt not found",
		Retriable: false,
	}

	// UnsupportedCurveTypeError ..
	UnsupportedCurveTypeError = types.Error{
		Code:      8,
		Message:   "unsupported curve type",
		Retriable: false,
	}

	// InvalidTransactionConstructionError ..
	InvalidTransactionConstructionError = types.Error{
		Code:      9,
		Message:   "invalid transaction construction",
		Retriable: false,
	}
)
View Source
var (
	// PlainOperationTypes ..
	PlainOperationTypes = []string{
		ExpendGasOperation,
		NativeTransferOperation,
		NativeCrossShardTransferOperation,
		ContractCreationOperation,
		GenesisFundsOperation,
		PreStakingBlockRewardOperation,
		UndelegationPayoutOperation,
	}

	// StakingOperationTypes ..
	StakingOperationTypes = []string{
		staking.DirectiveCreateValidator.String(),
		staking.DirectiveEditValidator.String(),
		staking.DirectiveDelegate.String(),
		staking.DirectiveUndelegate.String(),
		staking.DirectiveCollectRewards.String(),
	}

	// MutuallyExclusiveOperations for invariant: A transaction can only contain 1 type of 'native' operation.
	MutuallyExclusiveOperations = map[string]interface{}{
		NativeTransferOperation:           struct{}{},
		NativeCrossShardTransferOperation: struct{}{},
	}
)
View Source
var (
	// SuccessOperationStatus for tx operations who's amount affects the account
	SuccessOperationStatus = &types.OperationStatus{
		Status:     "success",
		Successful: true,
	}

	// ContractFailureOperationStatus for tx operations who's amount does not affect the account
	// due to a contract call failure (but still incurs gas).
	ContractFailureOperationStatus = &types.OperationStatus{
		Status:     "contract_failure",
		Successful: false,
	}

	// FailureOperationStatus ..
	FailureOperationStatus = &types.OperationStatus{
		Status:     "failure",
		Successful: false,
	}
)

Functions

func GetNetwork

func GetNetwork(shardID uint32) (*types.NetworkIdentifier, error)

GetNetwork fetches the networking identifier for the given shard

func NewError

func NewError(rosettaError types.Error, detailStructure interface{}) *types.Error

NewError create a new error with a given detail structure

Types

type CollectRewardsMetadata

type CollectRewardsMetadata rpcV2.CollectRewardsMsg

CollectRewardsMetadata ..

type CreateValidatorOperationMetadata

type CreateValidatorOperationMetadata rpcV2.CreateValidatorMsg

CreateValidatorOperationMetadata ..

type CrossShardTransactionOperationMetadata

type CrossShardTransactionOperationMetadata struct {
	From *types.AccountIdentifier `json:"from"`
	To   *types.AccountIdentifier `json:"to"`
}

CrossShardTransactionOperationMetadata ..

func (*CrossShardTransactionOperationMetadata) UnmarshalFromInterface

func (s *CrossShardTransactionOperationMetadata) UnmarshalFromInterface(data interface{}) error

UnmarshalFromInterface ..

type DelegateOperationMetadata

type DelegateOperationMetadata rpcV2.DelegateMsg

DelegateOperationMetadata ..

type EditValidatorOperationMetadata

type EditValidatorOperationMetadata rpcV2.EditValidatorMsg

EditValidatorOperationMetadata ..

type SubNetworkMetadata

type SubNetworkMetadata struct {
	IsBeacon bool `json:"is_beacon"`
}

SubNetworkMetadata for the sub network identifier of a shard

func (*SubNetworkMetadata) UnmarshalFromInterface

func (s *SubNetworkMetadata) UnmarshalFromInterface(metadata interface{}) error

UnmarshalFromInterface ..

type SyncStatus

type SyncStatus int

SyncStatus ..

const (
	SyncingUnknown SyncStatus = iota
	SyncingNewBlock
	SyncingFinish
)

Sync status enum

func (SyncStatus) String

func (s SyncStatus) String() string

String ..

type UndelegateOperationMetadata

type UndelegateOperationMetadata rpcV2.UndelegateMsg

UndelegateOperationMetadata ..

Jump to

Keyboard shortcuts

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