processors

package
v0.0.0-...-bd7c1ad Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: Apache-2.0, Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EffectTypeNames = map[EffectType]string{
	EffectAccountCreated:                     "account_created",
	EffectAccountRemoved:                     "account_removed",
	EffectAccountCredited:                    "account_credited",
	EffectAccountDebited:                     "account_debited",
	EffectAccountThresholdsUpdated:           "account_thresholds_updated",
	EffectAccountHomeDomainUpdated:           "account_home_domain_updated",
	EffectAccountFlagsUpdated:                "account_flags_updated",
	EffectAccountInflationDestinationUpdated: "account_inflation_destination_updated",
	EffectSignerCreated:                      "signer_created",
	EffectSignerRemoved:                      "signer_removed",
	EffectSignerUpdated:                      "signer_updated",
	EffectTrustlineCreated:                   "trustline_created",
	EffectTrustlineRemoved:                   "trustline_removed",
	EffectTrustlineUpdated:                   "trustline_updated",
	EffectTrustlineFlagsUpdated:              "trustline_flags_updated",
	EffectOfferCreated:                       "offer_created",
	EffectOfferRemoved:                       "offer_removed",
	EffectOfferUpdated:                       "offer_updated",
	EffectTrade:                              "trade",
	EffectDataCreated:                        "data_created",
	EffectDataRemoved:                        "data_removed",
	EffectDataUpdated:                        "data_updated",
	EffectSequenceBumped:                     "sequence_bumped",
	EffectClaimableBalanceCreated:            "claimable_balance_created",
	EffectClaimableBalanceClaimed:            "claimable_balance_claimed",
	EffectClaimableBalanceClaimantCreated:    "claimable_balance_claimant_created",
	EffectAccountSponsorshipCreated:          "account_sponsorship_created",
	EffectAccountSponsorshipUpdated:          "account_sponsorship_updated",
	EffectAccountSponsorshipRemoved:          "account_sponsorship_removed",
	EffectTrustlineSponsorshipCreated:        "trustline_sponsorship_created",
	EffectTrustlineSponsorshipUpdated:        "trustline_sponsorship_updated",
	EffectTrustlineSponsorshipRemoved:        "trustline_sponsorship_removed",
	EffectDataSponsorshipCreated:             "data_sponsorship_created",
	EffectDataSponsorshipUpdated:             "data_sponsorship_updated",
	EffectDataSponsorshipRemoved:             "data_sponsorship_removed",
	EffectClaimableBalanceSponsorshipCreated: "claimable_balance_sponsorship_created",
	EffectClaimableBalanceSponsorshipUpdated: "claimable_balance_sponsorship_updated",
	EffectClaimableBalanceSponsorshipRemoved: "claimable_balance_sponsorship_removed",
	EffectSignerSponsorshipCreated:           "signer_sponsorship_created",
	EffectSignerSponsorshipUpdated:           "signer_sponsorship_updated",
	EffectSignerSponsorshipRemoved:           "signer_sponsorship_removed",
	EffectClaimableBalanceClawedBack:         "claimable_balance_clawed_back",
	EffectLiquidityPoolDeposited:             "liquidity_pool_deposited",
	EffectLiquidityPoolWithdrew:              "liquidity_pool_withdrew",
	EffectLiquidityPoolTrade:                 "liquidity_pool_trade",
	EffectLiquidityPoolCreated:               "liquidity_pool_created",
	EffectLiquidityPoolRemoved:               "liquidity_pool_removed",
	EffectLiquidityPoolRevoked:               "liquidity_pool_revoked",
	EffectContractCredited:                   "contract_credited",
	EffectContractDebited:                    "contract_debited",
	EffectExtendFootprintTtl:                 "extend_footprint_ttl",
	EffectRestoreFootprint:                   "restore_footprint",
}

EffectTypeNames stores a map of effect type ID and names

Functions

func AddLPOperations

func AddLPOperations(txMeta []xdr.OperationMeta, AssetA, AssetB xdr.Asset) []xdr.OperationMeta

func AssetFromContractData

func AssetFromContractData(ledgerEntry xdr.LedgerEntry, passphrase string) *xdr.Asset

AssetFromContractData takes a ledger entry and verifies if the ledger entry corresponds to the asset info entry written to contract storage by the Stellar Asset Contract upon initialization.

Note that AssetFromContractData will ignore forged asset info entries by deriving the Stellar Asset Contract ID from the asset info entry and comparing it to the contract ID found in the ledger entry.

If the given ledger entry is a verified asset info entry, AssetFromContractData will return the corresponding Stellar asset. Otherwise, it returns nil.

References: https://github.com/stellar/rs-soroban-env/blob/v0.0.16/soroban-env-host/src/native_contract/token/public_types.rs#L21 https://github.com/stellar/rs-soroban-env/blob/v0.0.16/soroban-env-host/src/native_contract/token/asset_info.rs#L6 https://github.com/stellar/rs-soroban-env/blob/v0.0.16/soroban-env-host/src/native_contract/token/contract.rs#L115

The asset info in `ContractData` entry takes the following form:

  • Instance storage - it's part of contract instance data storage

  • Key: a vector with one element, which is the symbol "AssetInfo"

    ScVal{ Vec: ScVec({ ScVal{ Sym: ScSymbol("AssetInfo") }})}

  • Value: a map with two key-value pairs: code and issuer

    ScVal{ Map: ScMap( { ScVal{ Sym: ScSymbol("asset_code") } -> ScVal{ Str: ScString(...) } }, { ScVal{ Sym: ScSymbol("issuer") } -> ScVal{ Bytes: ScBytes(...) } } )}

func ContractBalanceFromContractData

func ContractBalanceFromContractData(ledgerEntry xdr.LedgerEntry, passphrase string) ([32]byte, *big.Int, bool)

ContractBalanceFromContractData takes a ledger entry and verifies that the ledger entry corresponds to the balance entry written to contract storage by the Stellar Asset Contract.

Reference:

https://github.com/stellar/rs-soroban-env/blob/da325551829d31dcbfa71427d51c18e71a121c5f/soroban-env-host/src/native_contract/token/storage_types.rs#L11-L24

func ConvertStroopValueToReal

func ConvertStroopValueToReal(input xdr.Int64) float64

ConvertStroopValueToReal converts a value in stroops, the smallest amount unit, into real units

func CreateSampleResultMeta

func CreateSampleResultMeta(successful bool, subOperationCount int) xdr.TransactionResultMeta

CreateSampleResultMeta creates Transaction results with the desired success flag and number of sub operation results

func CreateSampleTx

func CreateSampleTx(sequence int64, operationCount int) xdr.TransactionEnvelope

func CreateSampleTxMeta

func CreateSampleTxMeta(subOperationCount int, AssetA, AssetB xdr.Asset) *xdr.TransactionMetaV1

func ExtractEntryFromChange

func ExtractEntryFromChange(change ingest.Change) (xdr.LedgerEntry, xdr.LedgerEntryChangeType, bool, error)

ExtractEntryFromChange gets the most recent state of an entry from an ingestion change, as well as if the entry was deleted

func ExtractLedgerCloseTime

func ExtractLedgerCloseTime(ledger xdr.LedgerHeaderHistoryEntry) (time.Time, error)

ExtractLedgerCloseTime gets the close time of the provided ledger

func FarmHashAsset

func FarmHashAsset(assetCode, assetIssuer, assetType string) int64

func GetAccountAddressFromMuxedAccount

func GetAccountAddressFromMuxedAccount(account xdr.MuxedAccount) (string, error)

GetAccountAddressFromMuxedAccount takes in a muxed account and returns the address of the account

func GetCloseTime

func GetCloseTime(lcm xdr.LedgerCloseMeta) (time.Time, error)

func GetLedgerSequence

func GetLedgerSequence(lcm xdr.LedgerCloseMeta) uint32

func GetTransactionSet

func GetTransactionSet(transactionEntry historyarchive.Ledger) (transactionProcessing []xdr.TransactionEnvelope)

func HashToHexString

func HashToHexString(inputHash xdr.Hash) string

HashToHexString is utility function that converts and xdr.Hash type to a hex string

func LedgerEntryToLedgerKeyHash

func LedgerEntryToLedgerKeyHash(ledgerEntry xdr.LedgerEntry) string

func LedgerKeyToLedgerKeyHash

func LedgerKeyToLedgerKeyHash(ledgerKey xdr.LedgerKey) string

func PanicOnError

func PanicOnError(err error)

PanicOnError is a function that panics if the provided error is not nil

func PoolIDToString

func PoolIDToString(id xdr.PoolId) string

func TimePointToUTCTimeStamp

func TimePointToUTCTimeStamp(providedTime xdr.TimePoint) (time.Time, error)

TimePointToUTCTimeStamp takes in an xdr TimePoint and converts it to a time.Time struct in UTC. It returns an error for negative timepoints

func TransactionProcessing

func TransactionProcessing(l xdr.LedgerCloseMeta) []xdr.TransactionResultMeta

Types

type AccountOutput

type AccountOutput struct {
	AccountID            string      `json:"account_id"` // account address
	Balance              float64     `json:"balance"`
	BuyingLiabilities    float64     `json:"buying_liabilities"`
	SellingLiabilities   float64     `json:"selling_liabilities"`
	SequenceNumber       int64       `json:"sequence_number"`
	SequenceLedger       zero.Int    `json:"sequence_ledger"`
	SequenceTime         zero.Int    `json:"sequence_time"`
	NumSubentries        uint32      `json:"num_subentries"`
	InflationDestination string      `json:"inflation_destination"`
	Flags                uint32      `json:"flags"`
	HomeDomain           string      `json:"home_domain"`
	MasterWeight         int32       `json:"master_weight"`
	ThresholdLow         int32       `json:"threshold_low"`
	ThresholdMedium      int32       `json:"threshold_medium"`
	ThresholdHigh        int32       `json:"threshold_high"`
	Sponsor              null.String `json:"sponsor"`
	NumSponsored         uint32      `json:"num_sponsored"`
	NumSponsoring        uint32      `json:"num_sponsoring"`
	LastModifiedLedger   uint32      `json:"last_modified_ledger"`
	LedgerEntryChange    uint32      `json:"ledger_entry_change"`
	Deleted              bool        `json:"deleted"`
	ClosedAt             time.Time   `json:"closed_at"`
	LedgerSequence       uint32      `json:"ledger_sequence"`
}

AccountOutput is a representation of an account that aligns with the BigQuery table accounts

func TransformAccount

func TransformAccount(ledgerChange ingest.Change, header xdr.LedgerHeaderHistoryEntry) (AccountOutput, error)

TransformAccount converts an account from the history archive ingestion system into a form suitable for BigQuery

type AccountSignerOutput

type AccountSignerOutput struct {
	AccountID          string      `json:"account_id"`
	Signer             string      `json:"signer"`
	Weight             int32       `json:"weight"`
	Sponsor            null.String `json:"sponsor"`
	LastModifiedLedger uint32      `json:"last_modified_ledger"`
	LedgerEntryChange  uint32      `json:"ledger_entry_change"`
	Deleted            bool        `json:"deleted"`
	ClosedAt           time.Time   `json:"closed_at"`
	LedgerSequence     uint32      `json:"ledger_sequence"`
}

AccountSignerOutput is a representation of an account signer that aligns with the BigQuery table account_signers

func TransformAccountSigners

func TransformAccountSigners(ledgerChange ingest.Change, header xdr.LedgerHeaderHistoryEntry) ([]AccountSignerOutput, error)

TransformAccountSigners converts account signers from the history archive ingestion system into a form suitable for BigQuery

type AssetFromContractDataFunc

type AssetFromContractDataFunc func(ledgerEntry xdr.LedgerEntry, passphrase string) *xdr.Asset

type AssetOutput

type AssetOutput struct {
	AssetCode      string    `json:"asset_code"`
	AssetIssuer    string    `json:"asset_issuer"`
	AssetType      string    `json:"asset_type"`
	AssetID        int64     `json:"asset_id"`
	ClosedAt       time.Time `json:"closed_at"`
	LedgerSequence uint32    `json:"ledger_sequence"`
}

AssetOutput is a representation of an asset that aligns with the BigQuery table history_assets

func TransformAsset

func TransformAsset(operation xdr.Operation, operationIndex int32, transactionIndex int32, ledgerSeq int32, lcm xdr.LedgerCloseMeta) (AssetOutput, error)

TransformAsset converts an asset from a payment operation into a form suitable for BigQuery

type ClaimableBalanceOutput

type ClaimableBalanceOutput struct {
	BalanceID          string      `json:"balance_id"`
	Claimants          []Claimant  `json:"claimants"`
	AssetCode          string      `json:"asset_code"`
	AssetIssuer        string      `json:"asset_issuer"`
	AssetType          string      `json:"asset_type"`
	AssetID            int64       `json:"asset_id"`
	AssetAmount        float64     `json:"asset_amount"`
	Sponsor            null.String `json:"sponsor"`
	Flags              uint32      `json:"flags"`
	LastModifiedLedger uint32      `json:"last_modified_ledger"`
	LedgerEntryChange  uint32      `json:"ledger_entry_change"`
	Deleted            bool        `json:"deleted"`
	ClosedAt           time.Time   `json:"closed_at"`
	LedgerSequence     uint32      `json:"ledger_sequence"`
}

ClaimableBalanceOutput is a representation of a claimable balances that aligns with the BigQuery table claimable_balances

func TransformClaimableBalance

func TransformClaimableBalance(ledgerChange ingest.Change, header xdr.LedgerHeaderHistoryEntry) (ClaimableBalanceOutput, error)

TransformClaimableBalance converts a claimable balance from the history archive ingestion system into a form suitable for BigQuery

type Claimant

type Claimant struct {
	Destination string             `json:"destination"`
	Predicate   xdr.ClaimPredicate `json:"predicate"`
}

Claimants

type ConfigSettingOutput

type ConfigSettingOutput struct {
	ConfigSettingId                 int32               `json:"config_setting_id"`
	ContractMaxSizeBytes            uint32              `json:"contract_max_size_bytes"`
	LedgerMaxInstructions           int64               `json:"ledger_max_instructions"`
	TxMaxInstructions               int64               `json:"tx_max_instructions"`
	FeeRatePerInstructionsIncrement int64               `json:"fee_rate_per_instructions_increment"`
	TxMemoryLimit                   uint32              `json:"tx_memory_limit"`
	LedgerMaxReadLedgerEntries      uint32              `json:"ledger_max_read_ledger_entries"`
	LedgerMaxReadBytes              uint32              `json:"ledger_max_read_bytes"`
	LedgerMaxWriteLedgerEntries     uint32              `json:"ledger_max_write_ledger_entries"`
	LedgerMaxWriteBytes             uint32              `json:"ledger_max_write_bytes"`
	TxMaxReadLedgerEntries          uint32              `json:"tx_max_read_ledger_entries"`
	TxMaxReadBytes                  uint32              `json:"tx_max_read_bytes"`
	TxMaxWriteLedgerEntries         uint32              `json:"tx_max_write_ledger_entries"`
	TxMaxWriteBytes                 uint32              `json:"tx_max_write_bytes"`
	FeeReadLedgerEntry              int64               `json:"fee_read_ledger_entry"`
	FeeWriteLedgerEntry             int64               `json:"fee_write_ledger_entry"`
	FeeRead1Kb                      int64               `json:"fee_read_1kb"`
	BucketListTargetSizeBytes       int64               `json:"bucket_list_target_size_bytes"`
	WriteFee1KbBucketListLow        int64               `json:"write_fee_1kb_bucket_list_low"`
	WriteFee1KbBucketListHigh       int64               `json:"write_fee_1kb_bucket_list_high"`
	BucketListWriteFeeGrowthFactor  uint32              `json:"bucket_list_write_fee_growth_factor"`
	FeeHistorical1Kb                int64               `json:"fee_historical_1kb"`
	TxMaxContractEventsSizeBytes    uint32              `json:"tx_max_contract_events_size_bytes"`
	FeeContractEvents1Kb            int64               `json:"fee_contract_events_1kb"`
	LedgerMaxTxsSizeBytes           uint32              `json:"ledger_max_txs_size_bytes"`
	TxMaxSizeBytes                  uint32              `json:"tx_max_size_bytes"`
	FeeTxSize1Kb                    int64               `json:"fee_tx_size_1kb"`
	ContractCostParamsCpuInsns      []map[string]string `json:"contract_cost_params_cpu_insns"`
	ContractCostParamsMemBytes      []map[string]string `json:"contract_cost_params_mem_bytes"`
	ContractDataKeySizeBytes        uint32              `json:"contract_data_key_size_bytes"`
	ContractDataEntrySizeBytes      uint32              `json:"contract_data_entry_size_bytes"`
	MaxEntryTtl                     uint32              `json:"max_entry_ttl"`
	MinTemporaryTtl                 uint32              `json:"min_temporary_ttl"`
	MinPersistentTtl                uint32              `json:"min_persistent_ttl"`
	AutoBumpLedgers                 uint32              `json:"auto_bump_ledgers"`
	PersistentRentRateDenominator   int64               `json:"persistent_rent_rate_denominator"`
	TempRentRateDenominator         int64               `json:"temp_rent_rate_denominator"`
	MaxEntriesToArchive             uint32              `json:"max_entries_to_archive"`
	BucketListSizeWindowSampleSize  uint32              `json:"bucket_list_size_window_sample_size"`
	EvictionScanSize                uint64              `json:"eviction_scan_size"`
	StartingEvictionScanLevel       uint32              `json:"starting_eviction_scan_level"`
	LedgerMaxTxCount                uint32              `json:"ledger_max_tx_count"`
	BucketListSizeWindow            []uint64            `json:"bucket_list_size_window"`
	LastModifiedLedger              uint32              `json:"last_modified_ledger"`
	LedgerEntryChange               uint32              `json:"ledger_entry_change"`
	Deleted                         bool                `json:"deleted"`
	ClosedAt                        time.Time           `json:"closed_at"`
	LedgerSequence                  uint32              `json:"ledger_sequence"`
}

ConfigSettingOutput is a representation of soroban config settings that aligns with the Bigquery table config_settings

func TransformConfigSetting

func TransformConfigSetting(ledgerChange ingest.Change, header xdr.LedgerHeaderHistoryEntry) (ConfigSettingOutput, error)

TransformConfigSetting converts an config setting ledger change entry into a form suitable for BigQuery

type ContractBalanceFromContractDataFunc

type ContractBalanceFromContractDataFunc func(ledgerEntry xdr.LedgerEntry, passphrase string) ([32]byte, *big.Int, bool)

type ContractCodeOutput

type ContractCodeOutput struct {
	ContractCodeHash   string    `json:"contract_code_hash"`
	ContractCodeExtV   int32     `json:"contract_code_ext_v"`
	LastModifiedLedger uint32    `json:"last_modified_ledger"`
	LedgerEntryChange  uint32    `json:"ledger_entry_change"`
	Deleted            bool      `json:"deleted"`
	ClosedAt           time.Time `json:"closed_at"`
	LedgerSequence     uint32    `json:"ledger_sequence"`
	LedgerKeyHash      string    `json:"ledger_key_hash"`
	//ContractCodeCode                string `json:"contract_code"`
	NInstructions     uint32 `json:"n_instructions"`
	NFunctions        uint32 `json:"n_functions"`
	NGlobals          uint32 `json:"n_globals"`
	NTableEntries     uint32 `json:"n_table_entries"`
	NTypes            uint32 `json:"n_types"`
	NDataSegments     uint32 `json:"n_data_segments"`
	NElemSegments     uint32 `json:"n_elem_segments"`
	NImports          uint32 `json:"n_imports"`
	NExports          uint32 `json:"n_exports"`
	NDataSegmentBytes uint32 `json:"n_data_segment_bytes"`
}

ContractCodeOutput is a representation of contract code that aligns with the Bigquery table soroban_contract_code

func TransformContractCode

func TransformContractCode(ledgerChange ingest.Change, header xdr.LedgerHeaderHistoryEntry) (ContractCodeOutput, error)

TransformContractCode converts a contract code ledger change entry into a form suitable for BigQuery

type ContractDataOutput

type ContractDataOutput struct {
	ContractId                string            `json:"contract_id"`
	ContractKeyType           string            `json:"contract_key_type"`
	ContractDurability        string            `json:"contract_durability"`
	ContractDataAssetCode     string            `json:"asset_code"`
	ContractDataAssetIssuer   string            `json:"asset_issuer"`
	ContractDataAssetType     string            `json:"asset_type"`
	ContractDataBalanceHolder string            `json:"balance_holder"`
	ContractDataBalance       string            `json:"balance"` // balance is a string because it is go type big.Int
	LastModifiedLedger        uint32            `json:"last_modified_ledger"`
	LedgerEntryChange         uint32            `json:"ledger_entry_change"`
	Deleted                   bool              `json:"deleted"`
	ClosedAt                  time.Time         `json:"closed_at"`
	LedgerSequence            uint32            `json:"ledger_sequence"`
	LedgerKeyHash             string            `json:"ledger_key_hash"`
	Key                       map[string]string `json:"key"`
	KeyDecoded                map[string]string `json:"key_decoded"`
	Val                       map[string]string `json:"val"`
	ValDecoded                map[string]string `json:"val_decoded"`
	ContractDataXDR           string            `json:"contract_data_xdr"`
}

ContractDataOutput is a representation of contract data that aligns with the Bigquery table soroban_contract_data

type ContractEventOutput

type ContractEventOutput struct {
	TransactionHash          string                         `json:"transaction_hash"`
	TransactionID            int64                          `json:"transaction_id"`
	Successful               bool                           `json:"successful"`
	LedgerSequence           uint32                         `json:"ledger_sequence"`
	ClosedAt                 time.Time                      `json:"closed_at"`
	InSuccessfulContractCall bool                           `json:"in_successful_contract_call"`
	ContractId               string                         `json:"contract_id"`
	Type                     int32                          `json:"type"`
	TypeString               string                         `json:"type_string"`
	Topics                   map[string][]map[string]string `json:"topics"`
	TopicsDecoded            map[string][]map[string]string `json:"topics_decoded"`
	Data                     map[string]string              `json:"data"`
	DataDecoded              map[string]string              `json:"data_decoded"`
	ContractEventXDR         string                         `json:"contract_event_xdr"`
}

ContractEventOutput is a representation of soroban contract events and diagnostic events

func TransformContractEvent

func TransformContractEvent(transaction ingest.LedgerTransaction, lhe xdr.LedgerHeaderHistoryEntry) ([]ContractEventOutput, error)

TransformContractEvent converts a transaction's contract events and diagnostic events into a form suitable for BigQuery. It is known that contract events are a subset of the diagnostic events XDR definition. We are opting to call all of these events contract events for better clarity to data analytics users.

type DimAccount

type DimAccount struct {
	ID      uint64 `json:"account_id"`
	Address string `json:"address"`
}

DimAccount is a representation of an account that aligns with the BigQuery table dim_accounts

type DimMarket

type DimMarket struct {
	ID            uint64 `json:"market_id"`
	BaseCode      string `json:"base_code"`
	BaseIssuer    string `json:"base_issuer"`
	CounterCode   string `json:"counter_code"`
	CounterIssuer string `json:"counter_issuer"`
}

DimMarket is a representation of an account that aligns with the BigQuery table dim_markets

type DimOffer

type DimOffer struct {
	HorizonID     int64   `json:"horizon_offer_id"`
	DimOfferID    uint64  `json:"dim_offer_id"`
	MarketID      uint64  `json:"market_id"`
	MakerID       uint64  `json:"maker_id"`
	Action        string  `json:"action"`
	BaseAmount    float64 `json:"base_amount"`
	CounterAmount float64 `json:"counter_amount"`
	Price         float64 `json:"price"`
}

DimOffer is a representation of an account that aligns with the BigQuery table dim_offers

type EffectOutput

type EffectOutput struct {
	Address        string                 `json:"address"`
	AddressMuxed   null.String            `json:"address_muxed,omitempty"`
	OperationID    int64                  `json:"operation_id"`
	Details        map[string]interface{} `json:"details"`
	Type           int32                  `json:"type"`
	TypeString     string                 `json:"type_string"`
	LedgerClosed   time.Time              `json:"closed_at"`
	LedgerSequence uint32                 `json:"ledger_sequence"`
	EffectIndex    uint32                 `json:"index"`
	EffectId       string                 `json:"id"`
}

EffectOutput is a representation of an operation that aligns with the BigQuery table history_effects

func TransformEffect

func TransformEffect(transaction ingest.LedgerTransaction, ledgerSeq uint32, ledgerCloseMeta xdr.LedgerCloseMeta, networkPassphrase string) ([]EffectOutput, error)

type EffectType

type EffectType int

EffectType is the numeric type for an effect

const (
	EffectAccountCreated                     EffectType = 0
	EffectAccountRemoved                     EffectType = 1
	EffectAccountCredited                    EffectType = 2
	EffectAccountDebited                     EffectType = 3
	EffectAccountThresholdsUpdated           EffectType = 4
	EffectAccountHomeDomainUpdated           EffectType = 5
	EffectAccountFlagsUpdated                EffectType = 6
	EffectAccountInflationDestinationUpdated EffectType = 7
	EffectSignerCreated                      EffectType = 10
	EffectSignerRemoved                      EffectType = 11
	EffectSignerUpdated                      EffectType = 12
	EffectTrustlineCreated                   EffectType = 20
	EffectTrustlineRemoved                   EffectType = 21
	EffectTrustlineUpdated                   EffectType = 22
	EffectTrustlineFlagsUpdated              EffectType = 26
	EffectOfferCreated                       EffectType = 30
	EffectOfferRemoved                       EffectType = 31
	EffectOfferUpdated                       EffectType = 32
	EffectTrade                              EffectType = 33
	EffectDataCreated                        EffectType = 40
	EffectDataRemoved                        EffectType = 41
	EffectDataUpdated                        EffectType = 42
	EffectSequenceBumped                     EffectType = 43
	EffectClaimableBalanceCreated            EffectType = 50
	EffectClaimableBalanceClaimantCreated    EffectType = 51
	EffectClaimableBalanceClaimed            EffectType = 52
	EffectAccountSponsorshipCreated          EffectType = 60
	EffectAccountSponsorshipUpdated          EffectType = 61
	EffectAccountSponsorshipRemoved          EffectType = 62
	EffectTrustlineSponsorshipCreated        EffectType = 63
	EffectTrustlineSponsorshipUpdated        EffectType = 64
	EffectTrustlineSponsorshipRemoved        EffectType = 65
	EffectDataSponsorshipCreated             EffectType = 66
	EffectDataSponsorshipUpdated             EffectType = 67
	EffectDataSponsorshipRemoved             EffectType = 68
	EffectClaimableBalanceSponsorshipCreated EffectType = 69
	EffectClaimableBalanceSponsorshipUpdated EffectType = 70
	EffectClaimableBalanceSponsorshipRemoved EffectType = 71
	EffectSignerSponsorshipCreated           EffectType = 72
	EffectSignerSponsorshipUpdated           EffectType = 73
	EffectSignerSponsorshipRemoved           EffectType = 74
	EffectClaimableBalanceClawedBack         EffectType = 80
	EffectLiquidityPoolDeposited             EffectType = 90
	EffectLiquidityPoolWithdrew              EffectType = 91
	EffectLiquidityPoolTrade                 EffectType = 92
	EffectLiquidityPoolCreated               EffectType = 93
	EffectLiquidityPoolRemoved               EffectType = 94
	EffectLiquidityPoolRevoked               EffectType = 95
	EffectContractCredited                   EffectType = 96
	EffectContractDebited                    EffectType = 97
	EffectExtendFootprintTtl                 EffectType = 98
	EffectRestoreFootprint                   EffectType = 99
)

type FactOfferEvent

type FactOfferEvent struct {
	LedgerSeq       uint32 `json:"ledger_id"`
	OfferInstanceID uint64 `json:"offer_instance_id"`
}

FactOfferEvent is a representation of an offer event that aligns with the BigQuery table fact_offer_events

type HistoryArchiveLedgerAndLCM

type HistoryArchiveLedgerAndLCM struct {
	Ledger historyarchive.Ledger
	LCM    xdr.LedgerCloseMeta
}

type LedgerOutput

type LedgerOutput struct {
	Sequence                   uint32    `json:"sequence"` // sequence number of the ledger
	LedgerHash                 string    `json:"ledger_hash"`
	PreviousLedgerHash         string    `json:"previous_ledger_hash"`
	LedgerHeader               string    `json:"ledger_header"` // base 64 encoding of the ledger header
	TransactionCount           int32     `json:"transaction_count"`
	OperationCount             int32     `json:"operation_count"` // counts only operations that were a part of successful transactions
	SuccessfulTransactionCount int32     `json:"successful_transaction_count"`
	FailedTransactionCount     int32     `json:"failed_transaction_count"`
	TxSetOperationCount        string    `json:"tx_set_operation_count"` // counts all operations, even those that are part of failed transactions
	ClosedAt                   time.Time `json:"closed_at"`              // UTC timestamp
	TotalCoins                 int64     `json:"total_coins"`
	FeePool                    int64     `json:"fee_pool"`
	BaseFee                    uint32    `json:"base_fee"`
	BaseReserve                uint32    `json:"base_reserve"`
	MaxTxSetSize               uint32    `json:"max_tx_set_size"`
	ProtocolVersion            uint32    `json:"protocol_version"`
	LedgerID                   int64     `json:"id"`
	SorobanFeeWrite1Kb         int64     `json:"soroban_fee_write_1kb"`
	NodeID                     string    `json:"node_id"`
	Signature                  string    `json:"signature"`
	TotalByteSizeOfBucketList  uint64    `json:"total_byte_size_of_bucket_list"`
}

LedgerOutput is a representation of a ledger that aligns with the BigQuery table history_ledgers

func TransformLedger

func TransformLedger(inputLedger historyarchive.Ledger, lcm xdr.LedgerCloseMeta) (LedgerOutput, error)

TransformLedger converts a ledger from the history archive ingestion system into a form suitable for BigQuery

type LedgerTransactionOutput

type LedgerTransactionOutput struct {
	LedgerSequence  uint32    `json:"ledger_sequence"`
	TxEnvelope      string    `json:"tx_envelope"`
	TxResult        string    `json:"tx_result"`
	TxMeta          string    `json:"tx_meta"`
	TxFeeMeta       string    `json:"tx_fee_meta"`
	TxLedgerHistory string    `json:"tx_ledger_history"`
	ClosedAt        time.Time `json:"closed_at"`
}

type LiquidityPoolAsset

type LiquidityPoolAsset struct {
	AssetAType   string
	AssetACode   string
	AssetAIssuer string
	AssetAAmount float64
	AssetBType   string
	AssetBCode   string
	AssetBIssuer string
	AssetBAmount float64
}

LiquidityPoolAsset represents the asset pairs in a liquidity pool

type NormalizedOfferOutput

type NormalizedOfferOutput struct {
	Market  DimMarket
	Offer   DimOffer
	Account DimAccount
	Event   FactOfferEvent
}

NormalizedOfferOutput ties together the information for dim_markets, dim_offers, dim_accounts, and fact_offer-events

func TransformOfferNormalized

func TransformOfferNormalized(ledgerChange ingest.Change, ledgerSeq uint32) (NormalizedOfferOutput, error)

TransformOfferNormalized converts an offer into a normalized form, allowing it to be stored as part of the historical orderbook dataset

type OfferOutput

type OfferOutput struct {
	SellerID           string      `json:"seller_id"` // Account address of the seller
	OfferID            int64       `json:"offer_id"`
	SellingAssetType   string      `json:"selling_asset_type"`
	SellingAssetCode   string      `json:"selling_asset_code"`
	SellingAssetIssuer string      `json:"selling_asset_issuer"`
	SellingAssetID     int64       `json:"selling_asset_id"`
	BuyingAssetType    string      `json:"buying_asset_type"`
	BuyingAssetCode    string      `json:"buying_asset_code"`
	BuyingAssetIssuer  string      `json:"buying_asset_issuer"`
	BuyingAssetID      int64       `json:"buying_asset_id"`
	Amount             float64     `json:"amount"`
	PriceN             int32       `json:"pricen"`
	PriceD             int32       `json:"priced"`
	Price              float64     `json:"price"`
	Flags              uint32      `json:"flags"`
	LastModifiedLedger uint32      `json:"last_modified_ledger"`
	LedgerEntryChange  uint32      `json:"ledger_entry_change"`
	Deleted            bool        `json:"deleted"`
	Sponsor            null.String `json:"sponsor"`
	ClosedAt           time.Time   `json:"closed_at"`
	LedgerSequence     uint32      `json:"ledger_sequence"`
}

OfferOutput is a representation of an offer that aligns with the BigQuery table offers

func TransformOffer

func TransformOffer(ledgerChange ingest.Change, header xdr.LedgerHeaderHistoryEntry) (OfferOutput, error)

TransformOffer converts an account from the history archive ingestion system into a form suitable for BigQuery

type OperationOutput

type OperationOutput struct {
	SourceAccount        string                 `json:"source_account"`
	SourceAccountMuxed   string                 `json:"source_account_muxed,omitempty"`
	Type                 int32                  `json:"type"`
	TypeString           string                 `json:"type_string"`
	OperationDetails     map[string]interface{} `json:"details"` //Details is a JSON object that varies based on operation type
	TransactionID        int64                  `json:"transaction_id"`
	OperationID          int64                  `json:"id"`
	ClosedAt             time.Time              `json:"closed_at"`
	OperationResultCode  string                 `json:"operation_result_code"`
	OperationTraceCode   string                 `json:"operation_trace_code"`
	LedgerSequence       uint32                 `json:"ledger_sequence"`
	OperationDetailsJSON map[string]interface{} `json:"details_json"`
}

OperationOutput is a representation of an operation that aligns with the BigQuery table history_operations

func TransformOperation

func TransformOperation(operation xdr.Operation, operationIndex int32, transaction ingest.LedgerTransaction, ledgerSeq int32, ledgerCloseMeta xdr.LedgerCloseMeta, network string) (OperationOutput, error)

TransformOperation converts an operation from the history archive ingestion system into a form suitable for BigQuery

type Path

type Path struct {
	AssetCode   string `json:"asset_code"`
	AssetIssuer string `json:"asset_issuer"`
	AssetType   string `json:"asset_type"`
}

Path is a representation of an asset without an ID that forms part of a path in a path payment

type PoolOutput

type PoolOutput struct {
	PoolID             string    `json:"liquidity_pool_id"`
	PoolType           string    `json:"type"`
	PoolFee            uint32    `json:"fee"`
	TrustlineCount     uint64    `json:"trustline_count"`
	PoolShareCount     float64   `json:"pool_share_count"`
	AssetAType         string    `json:"asset_a_type"`
	AssetACode         string    `json:"asset_a_code"`
	AssetAIssuer       string    `json:"asset_a_issuer"`
	AssetAReserve      float64   `json:"asset_a_amount"`
	AssetAID           int64     `json:"asset_a_id"`
	AssetBType         string    `json:"asset_b_type"`
	AssetBCode         string    `json:"asset_b_code"`
	AssetBIssuer       string    `json:"asset_b_issuer"`
	AssetBReserve      float64   `json:"asset_b_amount"`
	AssetBID           int64     `json:"asset_b_id"`
	LastModifiedLedger uint32    `json:"last_modified_ledger"`
	LedgerEntryChange  uint32    `json:"ledger_entry_change"`
	Deleted            bool      `json:"deleted"`
	ClosedAt           time.Time `json:"closed_at"`
	LedgerSequence     uint32    `json:"ledger_sequence"`
}

PoolOutput is a representation of a liquidity pool that aligns with the Bigquery table liquidity_pools

func TransformPool

func TransformPool(ledgerChange ingest.Change, header xdr.LedgerHeaderHistoryEntry) (PoolOutput, error)

TransformPool converts an liquidity pool ledger change entry into a form suitable for BigQuery

type Price

type Price struct {
	Numerator   int32 `json:"n"`
	Denominator int32 `json:"d"`
}

Price represents the price of an asset as a fraction

type SponsorshipOutput

type SponsorshipOutput struct {
	Operation      xdr.Operation
	OperationIndex uint32
}

type TestTransaction

type TestTransaction struct {
	Index         uint32
	EnvelopeXDR   string
	ResultXDR     string
	FeeChangesXDR string
	MetaXDR       string
	Hash          string
}

TestTransaction transaction meta

type TradeEffectDetails

type TradeEffectDetails struct {
	Seller            string `json:"seller"`
	SellerMuxed       string `json:"seller_muxed,omitempty"`
	SellerMuxedID     uint64 `json:"seller_muxed_id,omitempty"`
	OfferID           int64  `json:"offer_id"`
	SoldAmount        string `json:"sold_amount"`
	SoldAssetType     string `json:"sold_asset_type"`
	SoldAssetCode     string `json:"sold_asset_code,omitempty"`
	SoldAssetIssuer   string `json:"sold_asset_issuer,omitempty"`
	BoughtAmount      string `json:"bought_amount"`
	BoughtAssetType   string `json:"bought_asset_type"`
	BoughtAssetCode   string `json:"bought_asset_code,omitempty"`
	BoughtAssetIssuer string `json:"bought_asset_issuer,omitempty"`
}

TradeEffectDetails is a struct of data from `effects.DetailsString` when the effect type is trade

type TradeOutput

type TradeOutput struct {
	Order                  int32       `json:"order"`
	LedgerClosedAt         time.Time   `json:"ledger_closed_at"`
	SellingAccountAddress  string      `json:"selling_account_address"`
	SellingAssetCode       string      `json:"selling_asset_code"`
	SellingAssetIssuer     string      `json:"selling_asset_issuer"`
	SellingAssetType       string      `json:"selling_asset_type"`
	SellingAssetID         int64       `json:"selling_asset_id"`
	SellingAmount          float64     `json:"selling_amount"`
	BuyingAccountAddress   string      `json:"buying_account_address"`
	BuyingAssetCode        string      `json:"buying_asset_code"`
	BuyingAssetIssuer      string      `json:"buying_asset_issuer"`
	BuyingAssetType        string      `json:"buying_asset_type"`
	BuyingAssetID          int64       `json:"buying_asset_id"`
	BuyingAmount           float64     `json:"buying_amount"`
	PriceN                 int64       `json:"price_n"`
	PriceD                 int64       `json:"price_d"`
	SellingOfferID         null.Int    `json:"selling_offer_id"`
	BuyingOfferID          null.Int    `json:"buying_offer_id"`
	SellingLiquidityPoolID null.String `json:"selling_liquidity_pool_id"`
	LiquidityPoolFee       null.Int    `json:"liquidity_pool_fee"`
	HistoryOperationID     int64       `json:"history_operation_id"`
	TradeType              int32       `json:"trade_type"`
	RoundingSlippage       null.Int    `json:"rounding_slippage"`
	SellerIsExact          null.Bool   `json:"seller_is_exact"`
}

TradeOutput is a representation of a trade that aligns with the BigQuery table history_trades

func TransformTrade

func TransformTrade(operationIndex int32, operationID int64, transaction ingest.LedgerTransaction, ledgerCloseTime time.Time) ([]TradeOutput, error)

TransformTrade converts a relevant operation from the history archive ingestion system into a form suitable for BigQuery

type TransactionOutput

type TransactionOutput struct {
	TransactionHash                      string         `json:"transaction_hash"`
	LedgerSequence                       uint32         `json:"ledger_sequence"`
	Account                              string         `json:"account"`
	AccountMuxed                         string         `json:"account_muxed,omitempty"`
	AccountSequence                      int64          `json:"account_sequence"`
	MaxFee                               uint32         `json:"max_fee"`
	FeeCharged                           int64          `json:"fee_charged"`
	OperationCount                       int32          `json:"operation_count"`
	TxEnvelope                           string         `json:"tx_envelope"`
	TxResult                             string         `json:"tx_result"`
	TxMeta                               string         `json:"tx_meta"`
	TxFeeMeta                            string         `json:"tx_fee_meta"`
	CreatedAt                            time.Time      `json:"created_at"`
	MemoType                             string         `json:"memo_type"`
	Memo                                 string         `json:"memo"`
	TimeBounds                           string         `json:"time_bounds"`
	Successful                           bool           `json:"successful"`
	TransactionID                        int64          `json:"id"`
	FeeAccount                           string         `json:"fee_account,omitempty"`
	FeeAccountMuxed                      string         `json:"fee_account_muxed,omitempty"`
	InnerTransactionHash                 string         `json:"inner_transaction_hash,omitempty"`
	NewMaxFee                            uint32         `json:"new_max_fee,omitempty"`
	LedgerBounds                         string         `json:"ledger_bounds"`
	MinAccountSequence                   null.Int       `json:"min_account_sequence"`
	MinAccountSequenceAge                null.Int       `json:"min_account_sequence_age"`
	MinAccountSequenceLedgerGap          null.Int       `json:"min_account_sequence_ledger_gap"`
	ExtraSigners                         pq.StringArray `json:"extra_signers"`
	ClosedAt                             time.Time      `json:"closed_at"`
	ResourceFee                          int64          `json:"resource_fee"`
	SorobanResourcesInstructions         uint32         `json:"soroban_resources_instructions"`
	SorobanResourcesReadBytes            uint32         `json:"soroban_resources_read_bytes"`
	SorobanResourcesWriteBytes           uint32         `json:"soroban_resources_write_bytes"`
	TransactionResultCode                string         `json:"transaction_result_code"`
	InclusionFeeBid                      int64          `json:"inclusion_fee_bid"`
	InclusionFeeCharged                  int64          `json:"inclusion_fee_charged"`
	ResourceFeeRefund                    int64          `json:"resource_fee_refund"`
	TotalNonRefundableResourceFeeCharged int64          `json:"non_refundable_resource_fee_charged"`
	TotalRefundableResourceFeeCharged    int64          `json:"refundable_resource_fee_charged"`
	RentFeeCharged                       int64          `json:"rent_fee_charged"`
	TxSigners                            []string       `json:"tx_signers"`
}

TransactionOutput is a representation of a transaction that aligns with the BigQuery table history_transactions

func TransformTransaction

func TransformTransaction(transaction ingest.LedgerTransaction, lhe xdr.LedgerHeaderHistoryEntry) (TransactionOutput, error)

TransformTransaction converts a transaction from the history archive ingestion system into a form suitable for BigQuery

type TransformContractDataStruct

type TransformContractDataStruct struct {
	AssetFromContractData           AssetFromContractDataFunc
	ContractBalanceFromContractData ContractBalanceFromContractDataFunc
}

func (*TransformContractDataStruct) TransformContractData

func (t *TransformContractDataStruct) TransformContractData(ledgerChange ingest.Change, passphrase string, header xdr.LedgerHeaderHistoryEntry) (ContractDataOutput, error, bool)

TransformContractData converts a contract data ledger change entry into a form suitable for BigQuery

type TrustlineOutput

type TrustlineOutput struct {
	LedgerKey          string      `json:"ledger_key"`
	AccountID          string      `json:"account_id"`
	AssetCode          string      `json:"asset_code"`
	AssetIssuer        string      `json:"asset_issuer"`
	AssetType          string      `json:"asset_type"`
	AssetID            int64       `json:"asset_id"`
	Balance            float64     `json:"balance"`
	TrustlineLimit     int64       `json:"trust_line_limit"`
	LiquidityPoolID    string      `json:"liquidity_pool_id"`
	BuyingLiabilities  float64     `json:"buying_liabilities"`
	SellingLiabilities float64     `json:"selling_liabilities"`
	Flags              uint32      `json:"flags"`
	LastModifiedLedger uint32      `json:"last_modified_ledger"`
	LedgerEntryChange  uint32      `json:"ledger_entry_change"`
	Sponsor            null.String `json:"sponsor"`
	Deleted            bool        `json:"deleted"`
	ClosedAt           time.Time   `json:"closed_at"`
	LedgerSequence     uint32      `json:"ledger_sequence"`
}

TrustlineOutput is a representation of a trustline that aligns with the BigQuery table trust_lines

func TransformTrustline

func TransformTrustline(ledgerChange ingest.Change, header xdr.LedgerHeaderHistoryEntry) (TrustlineOutput, error)

TransformTrustline converts a trustline from the history archive ingestion system into a form suitable for BigQuery

type TtlOutput

type TtlOutput struct {
	KeyHash            string    `json:"key_hash"` // key_hash is contract_code_hash or contract_id
	LiveUntilLedgerSeq uint32    `json:"live_until_ledger_seq"`
	LastModifiedLedger uint32    `json:"last_modified_ledger"`
	LedgerEntryChange  uint32    `json:"ledger_entry_change"`
	Deleted            bool      `json:"deleted"`
	ClosedAt           time.Time `json:"closed_at"`
	LedgerSequence     uint32    `json:"ledger_sequence"`
}

TtlOutput is a representation of soroban ttl that aligns with the Bigquery table ttls

func TransformTtl

func TransformTtl(ledgerChange ingest.Change, header xdr.LedgerHeaderHistoryEntry) (TtlOutput, error)

TransformTtl converts an ttl ledger change entry into a form suitable for BigQuery

Jump to

Keyboard shortcuts

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