access

package
v0.48.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: AGPL-3.0 Imports: 8 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// MinContractIDLength is the minimum length of a valid contract ID.
	// The format is "A.{address_hex}.{name}".
	MinContractIDLength = 4 + 2*flow.AddressLength
)

Variables

View Source
var LatestBoundary = map[uint64]Version{0: VersionLatest}

Functions

func CadenceCodeHash added in v0.48.0

func CadenceCodeHash(code []byte) []byte

CadenceCodeHash calculates the SHA3-256 hash of the provided code using the same algorithm as Cadence.

func ContractID added in v0.48.0

func ContractID(address flow.Address, name string) string

ContractID constructs the canonical contract ID string from an address and contract name. Format: "A.{address_hex}.{name}"

func ParseContractID added in v0.48.0

func ParseContractID(id string) (flow.Address, string, error)

ParseContractID extracts the address and contract name from a contract identifier of the form "A.{address_hex}.{name}".

Any error indicates the contractID is not in the expected format.

Types

type AccountTransaction added in v0.47.0

type AccountTransaction struct {
	Address          flow.Address      // Account address
	BlockHeight      uint64            // Block height where transaction was included
	BlockTimestamp   uint64            // Block timestamp where transaction was included, in Unix milliseconds
	TransactionID    flow.Identifier   // Transaction identifier
	TransactionIndex uint32            // Index of transaction within the block
	Roles            []TransactionRole // Roles of the account in the transaction

	// Expansion fields populated when expandResults is true.
	Transaction *flow.TransactionBody `msgpack:"-"` // Transaction body (nil unless expanded)
	Result      *TransactionResult    `msgpack:"-"` // Transaction result (nil unless expanded)
}

AccountTransaction represents a transaction entry from the account transaction index. It contains the essential fields needed to identify and locate a transaction, plus metadata about the account's participation.

type AccountTransactionCursor added in v0.48.0

type AccountTransactionCursor struct {
	Address          flow.Address // Account address
	BlockHeight      uint64       // Block height of the last returned entry
	TransactionIndex uint32       // Transaction index within the block of the last returned entry
}

AccountTransactionCursor identifies a position in the account transaction index for cursor-based pagination. It corresponds to the last entry returned in a previous page.

type AccountTransactionsPage added in v0.48.0

type AccountTransactionsPage struct {
	Transactions []AccountTransaction      // Transactions in this page (descending order by height)
	NextCursor   *AccountTransactionCursor // Cursor to fetch the next page, nil when no more results
}

AccountTransactionsPage represents a single page of account transaction results.

type CompatibleRange

type CompatibleRange struct {
	// StartHeight is the first block that the version supports.
	StartHeight uint64

	// EndHeight is the last block that the version supports.
	EndHeight uint64
}

CompatibleRange contains the first and the last height that the node's version supports.

type ContractDeployment added in v0.48.0

type ContractDeployment struct {
	// Address is the account that owns the contract.
	Address flow.Address
	// ContractName is the unqualified contract name, derived from ContractID.
	ContractName string
	// BlockHeight is the block height at which this deployment was applied.
	BlockHeight uint64
	// TransactionID is the ID of the transaction that applied this deployment.
	TransactionID flow.Identifier
	// TransactionIndex is the position of the deploying transaction within its block.
	TransactionIndex uint32
	// EventIndex is the position of the contract event within its transaction.
	// Needed to uniquely identify a deployment when a single transaction deploys multiple contracts.
	EventIndex uint32
	// Code is the Cadence source code of the contract at the time of deployment.
	// May be nil if code could not be extracted from the transaction body.
	Code []byte
	// CodeHash is the SHA3-256 hash of the contract code, as reported in the protocol event.
	CodeHash []byte

	// IsDeleted is true if the contract was deleted.
	// Deleting contracts is not currently supported by the protocol, however there are contracts on
	// mainnet that are deleted.
	IsDeleted bool

	// IsPlaceholder is true if the deployment was created during bootstrapping based on the current
	// chain state, and not based on a protocol event.
	// When true, the BlockHeight, TransactionID, TxIndex, and EventIndex fields are undefined.
	IsPlaceholder bool

	// Expansion fields populated when expandResults is true. Never persisted.
	Transaction *flow.TransactionBody `msgpack:"-"` // Transaction body (nil unless expanded)
	Result      *TransactionResult    `msgpack:"-"` // Transaction result (nil unless expanded)
}

ContractDeployment is a point-in-time snapshot of a contract on-chain. Each deployment (add or update) produces a distinct ContractDeployment record.

type ContractDeploymentPage added in v0.48.0

type ContractDeploymentPage struct {
	// Deployments is the ordered list of deployments for this page.
	Deployments []ContractDeployment
	// NextCursor is nil when no more results exist.
	NextCursor *ContractDeploymentsCursor
}

ContractDeploymentPage is a page of deployment history for a single contract. Returned by GetContractDeployments.

type ContractDeploymentsCursor added in v0.48.0

type ContractDeploymentsCursor struct {
	// Address is the account that owns the contract.
	Address flow.Address
	// ContractName is the unqualified contract name.
	ContractName string
	// BlockHeight is the block height of the last returned deployment.
	BlockHeight uint64
	// TransactionIndex is the position of the deploying transaction within its block.
	TransactionIndex uint32
	// EventIndex is the position of the contract event within its transaction.
	EventIndex uint32
}

ContractDeploymentsCursor is the single pagination cursor type for all contract index iterators.

type EventProvider added in v0.44.0

type EventProvider func() (flow.EventsList, error)

EventProvider is a callback function that returns a list of events required to construct the system collection.

func StaticEventProvider added in v0.44.0

func StaticEventProvider(events flow.EventsList) EventProvider

StaticEventProvider returns an event provider that returns the given events.

type FungibleTokenTransfer added in v0.48.0

type FungibleTokenTransfer struct {
	TransactionID    flow.Identifier // Transaction that produced the transfer event
	BlockHeight      uint64          // Block height where the transaction was included
	BlockTimestamp   uint64          // Block timestamp where the transaction was included
	TransactionIndex uint32          // Index of the transaction within the block
	EventIndices     []uint32        // Index of the event within the transaction
	TokenType        string          // Fully qualified token type identifier (e.g., "A.0x1654653399040a61.FlowToken")
	Amount           *big.Int        // Amount of tokens transferred
	SourceAddress    flow.Address    // Account that sent the tokens
	RecipientAddress flow.Address    // Account that received the tokens

	// Expansion fields populated when expandResults is true.
	Transaction *flow.TransactionBody `msgpack:"-"` // Transaction body (nil unless expanded)
	Result      *TransactionResult    `msgpack:"-"` // Transaction result (nil unless expanded)
}

FungibleTokenTransfer represents a fungible token transfer event extracted from block execution data. Each transfer is identified by its position within the block (TransactionIndex, EventIndex).

type FungibleTokenTransfersPage added in v0.48.0

type FungibleTokenTransfersPage struct {
	Transfers  []FungibleTokenTransfer // Transfers in this page (descending order by height)
	NextCursor *TransferCursor         // Cursor to fetch the next page, nil when no more results
}

FungibleTokenTransfersPage represents a single page of fungible token transfer results.

type HeightVersionMapper added in v0.44.0

type HeightVersionMapper interface {
	// GetVersion returns the version corresponding to the given height.
	GetVersion(height uint64) Version

	// All versions defined in the mapper.
	AllVersions() []Version
}

HeightVersionMapper defines the interface for mapping heights to protocol versions.

type NetworkParameters

type NetworkParameters struct {
	ChainID flow.ChainID
}

NetworkParameters contains the network-wide parameters for the Flow blockchain.

type NodeVersionInfo

type NodeVersionInfo struct {
	Semver  string
	Commit  string
	SporkId flow.Identifier
	// ProtocolVersion is the deprecated protocol version number.
	// Deprecated: Previously this referred to the major software version as of the most recent spork.
	// Replaced by protocol_state_version.
	ProtocolVersion uint64
	// ProtocolStateVersion is the Protocol State version as of the latest finalized block.
	// This tracks the schema version of the Protocol State and is used to coordinate breaking changes in the Protocol.
	// Version numbers are monotonically increasing.
	ProtocolStateVersion uint64
	SporkRootBlockHeight uint64
	NodeRootBlockHeight  uint64
	CompatibleRange      *CompatibleRange
}

NodeVersionInfo contains information about node, such as semver, commit, sporkID, protocolVersion, etc

type NonFungibleTokenTransfer added in v0.48.0

type NonFungibleTokenTransfer struct {
	TransactionID    flow.Identifier // Transaction that produced the transfer event
	BlockHeight      uint64          // Block height where the transaction was included
	BlockTimestamp   uint64          // Block timestamp where the transaction was included
	TransactionIndex uint32          // Index of the transaction within the block
	EventIndices     []uint32        // Index of the event within the transaction
	TokenType        string          // Fully qualified type of NFT collection (e.g., "A.0x1654653399040a61.MyNFT")
	ID               uint64          // Unique identifier of the NFT within its collection
	SourceAddress    flow.Address    // Account that sent the token
	RecipientAddress flow.Address    // Account that received the token

	// Expansion fields populated when expandResults is true.
	Transaction *flow.TransactionBody `msgpack:"-"` // Transaction body (nil unless expanded)
	Result      *TransactionResult    `msgpack:"-"` // Transaction result (nil unless expanded)
}

NonFungibleTokenTransfer represents a non-fungible token transfer event extracted from block execution data. Each transfer is identified by its position within the block (TransactionIndex, EventIndex).

type NonFungibleTokenTransfersPage added in v0.48.0

type NonFungibleTokenTransfersPage struct {
	Transfers  []NonFungibleTokenTransfer // Transfers in this page (descending order by height)
	NextCursor *TransferCursor            // Cursor to fetch the next page, nil when no more results
}

NonFungibleTokenTransfersPage represents a single page of non-fungible token transfer results.

type ScheduledTransaction added in v0.48.0

type ScheduledTransaction struct {
	ID              uint64
	Priority        ScheduledTransactionPriority
	Timestamp       uint64 // stored by the contract as a UFix64 with the fractional zeroed out
	ExecutionEffort uint64
	Fees            uint64

	TransactionHandlerOwner          flow.Address
	TransactionHandlerTypeIdentifier string
	TransactionHandlerUUID           uint64
	TransactionHandlerPublicPath     string

	Status ScheduledTransactionStatus

	// CreatedTransactionID is the transaction ID of the transaction in which the scheduled transaction was created
	// It is always set unless the scheduled transaction is a placeholder, in which case IsPlaceholder is true.
	CreatedTransactionID flow.Identifier

	// ExecutedTransactionID is the transaction ID of the transaction in which the scheduled transaction was executed
	// If set, status is set to [ScheduledTxStatusExecuted].
	ExecutedTransactionID flow.Identifier

	// CancelledTransactionID is the transaction ID of the transaction in which the scheduled transaction was cancelled
	// If set, status is set to [ScheduledTxStatusCancelled].
	CancelledTransactionID flow.Identifier

	// FeesReturned is the amount of fees returned to the scheduled transaction's owner when the scheduled transaction was cancelled
	FeesReturned uint64

	// FeesDeducted is the amount of fees deducted from the scheduled transaction's owner when the scheduled transaction was cancelled
	FeesDeducted uint64

	// IsPlaceholder is true if the scheduled transaction was created based on the current chain state,
	// and not based on a protocol event. This happens when the index is bootstrapped after the original
	// transaction where the scheduled transaction was first created.
	// When true, the `CreatedTransactionID`, `TransactionHandlerUUID`, and `TransactionHandlerPublicPath`
	// fields are undefined.
	IsPlaceholder bool

	// Expansion fields populated when expandResults is true. Never persisted.
	Transaction     *flow.TransactionBody `msgpack:"-"` // Transaction body (nil unless expanded)
	Result          *TransactionResult    `msgpack:"-"` // Transaction result (nil unless expanded)
	HandlerContract *ContractDeployment   `msgpack:"-"` // Handler contract (nil unless expanded)

	// Timestamp fields are populated by the backend. Never persisted. Zero when not applicable.
	CreatedAt   uint64 `msgpack:"-"` // Unix ms timestamp of block in which the scheduled transaction was created
	CompletedAt uint64 `msgpack:"-"` // Unix ms timestamp of block in which the scheduled transaction was executed or cancelled
}

ScheduledTransaction represents a scheduled transaction as indexed by the access node.

func (*ScheduledTransaction) HandlerContractID added in v0.48.0

func (tx *ScheduledTransaction) HandlerContractID() (string, error)

type ScheduledTransactionCursor added in v0.48.0

type ScheduledTransactionCursor struct {
	ID uint64 // Scheduled transaction ID of the last returned entry
}

ScheduledTransactionCursor identifies a position in the scheduled transaction index for cursor-based pagination. It corresponds to the last entry returned in a previous page.

type ScheduledTransactionPriority added in v0.48.0

type ScheduledTransactionPriority uint8

ScheduledTransactionPriority represents the execution priority of a scheduled transaction.

const (
	ScheduledTxPriorityHigh   ScheduledTransactionPriority = 0
	ScheduledTxPriorityMedium ScheduledTransactionPriority = 1
	ScheduledTxPriorityLow    ScheduledTransactionPriority = 2
)

func ParseScheduledTransactionPriority added in v0.48.0

func ParseScheduledTransactionPriority(s string) (ScheduledTransactionPriority, error)

ParseScheduledTransactionPriority parses a string into a ScheduledTransactionPriority.

Any error indicates the string is not a valid priority.

func (ScheduledTransactionPriority) String added in v0.48.0

String returns the string representation of the priority.

type ScheduledTransactionStatus added in v0.48.0

type ScheduledTransactionStatus int8

ScheduledTransactionStatus represents the lifecycle state of a scheduled transaction.

const (
	ScheduledTxStatusScheduled ScheduledTransactionStatus = iota
	ScheduledTxStatusExecuted
	ScheduledTxStatusCancelled
	ScheduledTxStatusFailed
)

func ParseScheduledTransactionStatus added in v0.48.0

func ParseScheduledTransactionStatus(s string) (ScheduledTransactionStatus, error)

ParseScheduledTransactionStatus parses a string into a ScheduledTransactionStatus.

Any error indicates the string is not a valid status.

func (ScheduledTransactionStatus) String added in v0.48.0

String returns the string representation of the status.

type ScheduledTransactionsPage added in v0.48.0

type ScheduledTransactionsPage struct {
	Transactions []ScheduledTransaction      // Results in this page (descending order by ID)
	NextCursor   *ScheduledTransactionCursor // Cursor to fetch the next page, nil when no more results
}

ScheduledTransactionsPage represents a single page of scheduled transaction results.

type StaticHeightVersionMapper added in v0.44.0

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

StaticHeightVersionMapper is an implementation that allows hardcoding the height boundaries for each protocol version.

func NewStaticHeightVersionMapper added in v0.44.0

func NewStaticHeightVersionMapper(heightVersionBoundaries map[uint64]Version) *StaticHeightVersionMapper

func (*StaticHeightVersionMapper) AllVersions added in v0.44.0

func (s *StaticHeightVersionMapper) AllVersions() []Version

func (*StaticHeightVersionMapper) GetVersion added in v0.44.0

func (s *StaticHeightVersionMapper) GetVersion(height uint64) Version

type SystemCollectionBuilder added in v0.44.0

type SystemCollectionBuilder interface {
	// ProcessCallbacksTransaction constructs a transaction for processing callbacks, for the given callback.
	//
	// No error returns are expected during normal operation.
	ProcessCallbacksTransaction(chain flow.Chain) (*flow.TransactionBody, error)

	// ExecuteCallbacksTransactions constructs a list of transaction to execute callbacks, for the given chain.
	//
	// No error returns are expected during normal operation.
	ExecuteCallbacksTransactions(chain flow.Chain, processEvents flow.EventsList) ([]*flow.TransactionBody, error)

	// ExecuteCallbacksTransaction constructs a transaction to execute a callback, for the given chain.
	//
	// No error returns are expected during normal operation.
	ExecuteCallbacksTransaction(chain flow.Chain, id uint64, effort uint64) (*flow.TransactionBody, error)

	// SystemChunkTransaction creates and returns the transaction corresponding to the
	// system chunk for the given chain.
	//
	// No error returns are expected during normal operation.
	SystemChunkTransaction(chain flow.Chain) (*flow.TransactionBody, error)

	// SystemCollection constructs a system collection for the given chain.
	// Uses the provided event provider to get events required to construct the system collection.
	// A nil event provider behaves the same as an event provider that returns an empty EventsList.
	//
	// No error returns are expected during normal operation.
	SystemCollection(chain flow.Chain, providerFn EventProvider) (*flow.Collection, error)
}

SystemCollectionBuilder defines the builders for the system collections and their transactions.

type TransactionResult

type TransactionResult struct {
	Status          flow.TransactionStatus
	StatusCode      uint
	Events          []flow.Event
	ErrorMessage    string
	BlockID         flow.Identifier
	TransactionID   flow.Identifier
	CollectionID    flow.Identifier
	BlockHeight     uint64
	ComputationUsed uint64
}

TransactionResult represents a flow.TransactionResult with additional fields required for the Access API

func (*TransactionResult) IsExecuted

func (r *TransactionResult) IsExecuted() bool

func (*TransactionResult) IsFinal

func (r *TransactionResult) IsFinal() bool

type TransactionRole added in v0.47.0

type TransactionRole int
const (
	// CAUTION: these values are stored in the database. Do not change the values.
	TransactionRoleAuthorizer TransactionRole = 0 // Account is an authorizer for the transaction
	TransactionRolePayer      TransactionRole = 1 // Account is the payer for the transaction
	TransactionRoleProposer   TransactionRole = 2 // Account is the proposer for the transaction
	TransactionRoleInteracted TransactionRole = 3 // Account is referenced by an event in the transaction
)

func ParseTransactionRole added in v0.48.0

func ParseTransactionRole(s string) (TransactionRole, error)

ParseTransactionRole parses a string into a TransactionRole. Accepted values match the OpenAPI spec enum: "authorizer", "payer", "proposer", "interacted".

Returns an error when the input string does not match any known role name.

func (TransactionRole) String added in v0.48.0

func (r TransactionRole) String() string

String returns the string representation of a TransactionRole matching the OpenAPI spec enum values: "authorizer", "payer", "proposer", "interacted".

Panics on unknown values since roles are stored in the database and unknown values indicate data corruption.

type TransferCursor added in v0.48.0

type TransferCursor struct {
	Address          flow.Address // Account address
	BlockHeight      uint64       // Block height of the last returned entry
	TransactionIndex uint32       // Transaction index within the block of the last returned entry
	EventIndex       uint32       // Event index within the transaction of the last returned entry
}

TransferCursor identifies a position in the token transfer index for cursor-based pagination. It corresponds to the last entry returned in a previous page.

type Version added in v0.44.0

type Version uint8
var (
	VersionLatest Version = math.MaxInt8
)

type Versioned added in v0.44.0

type Versioned[T any] struct {
	// contains filtered or unexported fields
}

Versioned is a generic container that associates different versions of type T with their corresponding protocol versions, as determined by the HeightVersionMapper. This allows retaining and retrieving historical implementations of a type, ensuring correct behavior when the protocol evolves and previous versions must remain accessible for older data.

func NewVersioned added in v0.44.0

func NewVersioned[T any](versionedTypes map[Version]T, versionMapper HeightVersionMapper) *Versioned[T]

func (*Versioned[T]) All added in v0.44.0

func (v *Versioned[T]) All() []T

AllVersions returns All versions defined in the mapper. Note: the values are stored within a map, so the order of the returned slice is not deterministic.

func (*Versioned[T]) ByHeight added in v0.44.0

func (v *Versioned[T]) ByHeight(height uint64) T

ByHeight version of the type at the provided height.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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