services

package
v1.2603.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 28 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// Network
	BlockChainName = "Filecoin"

	// Currency
	CurrencySymbol   = "FIL"
	CurrencyDecimals = 18

	// Operation status
	OperationStatusOk     = "Ok"
	OperationStatusFailed = "Fail"

	// Account
	LockedBalanceStr         = "LockedBalance"
	SpendableBalanceStr      = "SpendableBalance"
	VestingScheduleStr       = "VestingSchedule"
	LockedFundsKey           = "LockedFunds"
	VestingStartEpochKey     = "StartEpoch"
	VestingUnlockDurationKey = "UnlockDuration"
	VestingInitialBalanceKey = "InitialBalance"

	// Misc
	ProxyLoggerName = "rosetta-filecoin-proxy"
)
View Source
const BlockCIDsKey = "blockCIDs"

BlockCIDsKey is the name of the key in the Metadata map inside a BlockResponse that specifies blocks' CIDs inside a TipSet.

View Source
const ChainIDKey = "chainID"

ChainIDKey is the name of the key in the Options map inside a ConstructionMetadataRequest that specifies the current chain id

View Source
const DestinationActorIdKey = "destinationActorId"

DestinationActorIdKey is the name of the key in the Metadata map inside a ConstructionMetadataResponse that specifies the receiver's actor id

View Source
const FactorSecondToMillisecond int64 = 1e3
View Source
const GasFeeCapKey = "gasFeeCap"

GasFeeCapKey is the name of the key in the Metadata map inside a ConstructionMetadataResponse that specifies gas fee cap

View Source
const GasLimitKey = "gasLimit"

GasLimitKey is the name of the key in the Metadata map inside a ConstructionMetadataResponse that specifies tx's gas limit

View Source
const GasPremiumKey = "gasPremium"

GasPremiumKey is the name of the key in the Metadata map inside a ConstructionMetadataResponse that specifies tx's gas premium

View Source
const LotusCallTimeOut = 60 * 4 * time.Second

LotusCallTimeOut TimeOut for RPC Lotus calls

View Source
const LotusErrKey = "lotusErr"
View Source
const NonceKey = "nonce"

NonceKey is the name of the key in the Metadata map inside a ConstructionMetadataResponse that specifies the next valid nonce.

View Source
const OptionsBlockInclKey = "blockIncl"

OptionsBlockInclKey is the name of the key in the Metadata map inside a ConstructionMetadataResponse determines on how many epochs message should included being 0 the fastest (and the most gas expensive one)

View Source
const OptionsReceiverIDKey = "idReceiver"

OptionsReceiverIDKey is the name of the key in the Options map inside a ConstructionMetadataRequest that specifies the receiver's account ID

View Source
const OptionsSenderIDKey = "idSender"

OptionsSenderIDKey is the name of the key in the Options map inside a ConstructionMetadataRequest that specifies the sender's account ID

View Source
const OptionsValueKey = "value"

OptionsValueKey is the name of the key in the Options map inside a ConstructionMetadataRequest that specifies the tokens quantity to be sent

Variables

View Source
var (
	// Versions info to be injected on build time
	RosettaSDKVersion = "Unknown"
	LotusVersion      = "Unknown"
	GitRevision       = "Unknown"

	// ServerPort to be injected on build time
	RosettaServerPort = "8080"

	// Other configs
	RetryConnectAttempts = "1000000"

	// Network name (read from api in main)
	NetworkName = ""
)
View Source
var (
	ErrUnableToGetChainID = &types.Error{
		Code:      1,
		Message:   "unable to get chain ID",
		Retriable: true,
	}

	ErrInvalidBlockchain = &types.Error{
		Code:      2,
		Message:   "invalid blockchain specified in network identifier",
		Retriable: false,
	}

	ErrInvalidSubnetwork = &types.Error{
		Code:      3,
		Message:   "invalid sub-network identifier",
		Retriable: false,
	}

	ErrInvalidNetwork = &types.Error{
		Code:      4,
		Message:   "invalid network specified in network identifier",
		Retriable: false,
	}

	ErrMissingNID = &types.Error{
		Code:      5,
		Message:   "network identifier is missing",
		Retriable: false,
	}

	ErrUnableToGetLatestBlk = &types.Error{
		Code:      6,
		Message:   "unable to get latest block",
		Retriable: true,
	}

	ErrUnableToGetGenesisBlk = &types.Error{
		Code:      7,
		Message:   "unable to get genesis block",
		Retriable: true,
	}

	ErrUnableToGetAccount = &types.Error{
		Code:      8,
		Message:   "unable to get account",
		Retriable: true,
	}

	ErrInsufficientQueryInputs = &types.Error{
		Code:      9,
		Message:   "query inputs insufficient",
		Retriable: false,
	}

	ErrInvalidAccountAddress = &types.Error{
		Code:      10,
		Message:   "invalid account address",
		Retriable: false,
	}

	ErrMustSpecifySubAccount = &types.Error{
		Code:      11,
		Message:   "a valid subaccount must be specified ('LockedBalance' or 'VestingSchedule')",
		Retriable: false,
	}

	ErrUnableToGetBlk = &types.Error{
		Code:      12,
		Message:   "unable to get block",
		Retriable: true,
	}

	ErrNotImplemented = &types.Error{
		Code:      13,
		Message:   "operation not implemented",
		Retriable: false,
	}

	ErrUnableToGetTxns = &types.Error{
		Code:      14,
		Message:   "unable to get transactions",
		Retriable: true,
	}

	ErrUnableToSubmitTx = &types.Error{
		Code:      15,
		Message:   "unable to submit transaction",
		Retriable: false,
	}

	ErrUnableToGetNextNonce = &types.Error{
		Code:      16,
		Message:   "unable to get next nonce",
		Retriable: true,
	}

	ErrMalformedValue = &types.Error{
		Code:      17,
		Message:   "malformed value",
		Retriable: false,
	}

	ErrUnableToGetNodeStatus = &types.Error{
		Code:      18,
		Message:   "unable to get node status",
		Retriable: true,
	}

	ErrUnableToGetTipsetCID = &types.Error{
		Code:      19,
		Message:   "unable to get tipset CID",
		Retriable: true,
	}

	ErrUnableToGetPeers = &types.Error{
		Code:      20,
		Message:   "unable to get peer list",
		Retriable: true,
	}

	ErrUnableToGetBalance = &types.Error{
		Code:      21,
		Message:   "unable to get balance for address",
		Retriable: true,
	}

	ErrUnableToGetTipset = &types.Error{
		Code:      22,
		Message:   "unable to get tipset",
		Retriable: true,
	}

	ErrUnableToGetParentBlk = &types.Error{
		Code:      23,
		Message:   "unable to get parent block",
		Retriable: true,
	}

	ErrUnableToGetNodeInfo = &types.Error{
		Code:      24,
		Message:   "unable to get node information",
		Retriable: true,
	}

	ErrUnableToGetSyncStatus = &types.Error{
		Code:      25,
		Message:   "unable to get sync status",
		Retriable: true,
	}

	ErrUnableToGetUnsyncedBlock = &types.Error{
		Code:      26,
		Message:   "requested block not yet synchronized",
		Retriable: true,
	}

	ErrSyncErrored = &types.Error{
		Code:      27,
		Message:   "error on node sync process",
		Retriable: true,
	}

	ErrUnableToBuildTipSetHash = &types.Error{
		Code:      28,
		Message:   "error on creating TipSetKey hash",
		Retriable: true,
	}

	ErrUnableToRetrieveNetworkName = &types.Error{
		Code:      29,
		Message:   "error when querying network name",
		Retriable: true,
	}

	ErrMalformedTx = &types.Error{
		Code:      30,
		Message:   "malformed transaction",
		Retriable: false,
	}

	ErrInvalidHash = &types.Error{
		Code:      31,
		Message:   "hash does not match with provided block index",
		Retriable: false,
	}

	ErrUnableToGetTxnReceipt = &types.Error{
		Code:      32,
		Message:   "unable to get transaction receipt",
		Retriable: true,
	}

	ErrMsgsAndReceiptsCountMismatch = &types.Error{
		Code:      33,
		Message:   "retrieved Messages count don't match with Receipts count",
		Retriable: false,
	}

	ErrUnableToEstimateGasPremium = &types.Error{
		Code:      34,
		Message:   "unable to estimate gas premium",
		Retriable: false,
	}

	ErrInsufficientBalanceForGas = &types.Error{
		Code:      35,
		Message:   "insufficient balance for gas",
		Retriable: false,
	}

	ErrLotusCallTimedOut = &types.Error{
		Code:      36,
		Message:   "Lotus RPC call timed out",
		Retriable: true,
	}

	ErrCouldNotRetrieveMethodName = &types.Error{
		Code:      37,
		Message:   "could not retrieve method name in message",
		Retriable: false,
	}

	ErrUnableToGetActor = &types.Error{
		Code:      38,
		Message:   "could not retrieve actor from address",
		Retriable: false,
	}

	ErrUnableToGetActorState = &types.Error{
		Code:      39,
		Message:   "could not retrieve actor state",
		Retriable: false,
	}

	ErrAddNotMSig = &types.Error{
		Code:      40,
		Message:   "address does not correspond to a multisig account",
		Retriable: false,
	}

	ErrNodeNotSynced = &types.Error{
		Code:      41,
		Message:   "node is not yet fully synced",
		Retriable: true,
	}

	ErrUnableToGetLockedBalance = &types.Error{
		Code:      42,
		Message:   "unable to get locked balance for address",
		Retriable: true,
	}

	ErrUnableToGetVesting = &types.Error{
		Code:      43,
		Message:   "unable to get vesting schedule parameters",
		Retriable: true,
	}

	ErrUnableToEstimateGasLimit = &types.Error{
		Code:      44,
		Message:   "unable to estimate gas limit",
		Retriable: false,
	}

	ErrUnableToEstimateGasFeeCap = &types.Error{
		Code:      45,
		Message:   "unable to estimate gas fee cap",
		Retriable: false,
	}

	ErrOperationNotSupported = &types.Error{
		Code:      46,
		Message:   "operation not supported",
		Retriable: false,
	}

	ErrUnableToGetTrace = &types.Error{
		Code:      47,
		Message:   "unable to get trace for tipSet",
		Retriable: true,
	}

	ErrorList = []*types.Error{
		ErrUnableToGetChainID,
		ErrInvalidBlockchain,
		ErrInvalidSubnetwork,
		ErrInvalidNetwork,
		ErrUnableToRetrieveNetworkName,
		ErrMissingNID,
		ErrUnableToGetLatestBlk,
		ErrUnableToGetGenesisBlk,
		ErrUnableToGetAccount,
		ErrInsufficientQueryInputs,
		ErrInvalidAccountAddress,
		ErrMustSpecifySubAccount,
		ErrUnableToGetBlk,
		ErrNotImplemented,
		ErrUnableToGetTxns,
		ErrUnableToSubmitTx,
		ErrUnableToGetNextNonce,
		ErrMalformedValue,
		ErrUnableToGetNodeStatus,
		ErrUnableToGetTipsetCID,
		ErrUnableToGetPeers,
		ErrUnableToGetBalance,
		ErrUnableToGetTipset,
		ErrUnableToGetParentBlk,
		ErrUnableToGetNodeInfo,
		ErrUnableToGetSyncStatus,
		ErrUnableToGetUnsyncedBlock,
		ErrSyncErrored,
		ErrUnableToBuildTipSetHash,
		ErrMalformedTx,
		ErrInvalidHash,
		ErrUnableToGetTxnReceipt,
		ErrMsgsAndReceiptsCountMismatch,
		ErrUnableToEstimateGasPremium,
		ErrInsufficientBalanceForGas,
		ErrLotusCallTimedOut,
		ErrCouldNotRetrieveMethodName,
		ErrUnableToGetActor,
		ErrAddNotMSig,
		ErrNodeNotSynced,
		ErrUnableToGetActorState,
		ErrUnableToGetLockedBalance,
		ErrUnableToGetVesting,
		ErrUnableToEstimateGasLimit,
		ErrUnableToEstimateGasFeeCap,
		ErrOperationNotSupported,
		ErrUnableToGetTrace,
	}
)
View Source
var SupportedOperations = map[string]bool{
	"Send":                   true,
	"Fee":                    true,
	"Exec":                   true,
	"SwapSigner":             true,
	"Propose":                true,
	"Approve":                true,
	"Cancel":                 true,
	"AwardBlockReward":       true,
	"OnDeferredCronEvent":    true,
	"PreCommitSector":        true,
	"ProveCommitSector":      true,
	"SubmitWindowedPoSt":     true,
	"ApplyRewards":           true,
	"AddBalance":             true,
	"RepayDebt":              true,
	"InvokeContract":         true,
	"InvokeContractDelegate": true,
	"EVM_CALL":               true,
	"unknown":                true,
}

Supported operations

Functions

func BuildError

func BuildError(proxyErr *types.Error, lotusErr error, showDetails bool) *types.Error

func BuildTipSetKeyHash

func BuildTipSetKeyHash(key filTypes.TipSetKey) (*string, error)

func EthereumAddressFromHex added in v1.2000.0

func EthereumAddressFromHex(add string) (ethtypes.EthAddress, error)

func EthereumAddressToFilecoin added in v1.2000.0

func EthereumAddressToFilecoin(add string) (address.Address, error)

func GetActorNameFromAddress added in v1.800.0

func GetActorNameFromAddress(address address.Address, lib *rosettaFilecoinLib.RosettaConstructionFilecoin) string

func GetActorPubKey added in v0.801.2

func GetActorPubKey(add address.Address, lib *rosettaFilecoinLib.RosettaConstructionFilecoin) (string, *types.Error)

func GetCurrencyData

func GetCurrencyData() *types.Currency

func GetSupportedOpList

func GetSupportedOpList() []string

func IsEthereumAddress added in v1.2000.0

func IsEthereumAddress(address string) bool

func IsFilecoinAddress added in v1.2000.0

func IsFilecoinAddress(add string) (bool, address.Address)

func IsOpSupported

func IsOpSupported(op string) bool

func NewAccountAPIService

NewBlockAPIService creates a new instance of a BlockAPIService.

func NewBlockAPIService

NewBlockAPIService creates a new instance of a BlockAPIService.

func NewConstructionAPIService

NewConstructionAPIService creates a new instance of an ConstructionAPIService.

func NewMemPoolAPIService

NewBlockAPIService creates a new instance of a BlockAPIService.

func NewNetworkAPIService

func NewNetworkAPIService(network *types.NetworkIdentifier, node *api.FullNode, supportedOps []string) server.NetworkAPIServicer

NewNetworkAPIService creates a new instance of a NetworkAPIService.

func TimeTrack added in v0.801.2

func TimeTrack(start time.Time, name string)

func ValidateNetworkId

func ValidateNetworkId(ctx context.Context, node *api.FullNode, networkId *types.NetworkIdentifier) *types.Error

Types

type AccountAPIService

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

AccountAPIService implements the server.BlockAPIServicer interface.

func (AccountAPIService) AccountBalance

AccountBalance implements the /account/balance endpoint.

func (AccountAPIService) AccountCoins added in v1.800.0

type BlockAPIService

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

BlockAPIService implements the server.BlockAPIServicer interface.

func (*BlockAPIService) Block

Block implements the /block endpoint.

func (*BlockAPIService) BlockTransaction

BlockTransaction implements the /block/transaction endpoint.

type ConstructionAPIService

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

ConstructionAPIService implements the server.ConstructionAPIServicer interface.

func (*ConstructionAPIService) ConstructionCombine

func (*ConstructionAPIService) ConstructionDerive

func (*ConstructionAPIService) ConstructionHash

func (*ConstructionAPIService) ConstructionMetadata

ConstructionMetadata implements the /construction/metadata endpoint.

func (*ConstructionAPIService) ConstructionParse

func (*ConstructionAPIService) ConstructionPayloads

func (*ConstructionAPIService) ConstructionPreprocess

func (*ConstructionAPIService) ConstructionSubmit

ConstructionSubmit implements the /construction/submit endpoint.

type MemPoolAPIService

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

BlockAPIService implements the server.BlockAPIServicer interface.

func (*MemPoolAPIService) Mempool

Mempool implements the /mempool endpoint.

func (MemPoolAPIService) MempoolTransaction

MempoolTransaction implements the /mempool/transaction endpoint.

type NetworkAPIService

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

NetworkAPIService implements the server.NetworkAPIServicer interface.

func (*NetworkAPIService) NetworkList

NetworkList implements the /network/list endpoint

func (*NetworkAPIService) NetworkOptions

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

NetworkOptions implements the /network/options endpoint.

func (*NetworkAPIService) NetworkStatus

NetworkStatus implements the /network/status endpoint.

type SyncStatus

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

func CheckSyncStatus

func CheckSyncStatus(ctx context.Context, node *api.FullNode) (*SyncStatus, *types.Error)

func (SyncStatus) GetMaxHeight

func (status SyncStatus) GetMaxHeight() int64

func (SyncStatus) GetMinHeight

func (status SyncStatus) GetMinHeight() int64

func (SyncStatus) GetTargetIndex

func (status SyncStatus) GetTargetIndex() *int64

func (SyncStatus) IsSynced

func (status SyncStatus) IsSynced() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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