github.com/stellar/stellar-etl@v1.0.1-0.20240312145900-4874b6bf2b89/internal/transform/schema.go (about)

     1  package transform
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/guregu/null"
     7  	"github.com/guregu/null/zero"
     8  	"github.com/lib/pq"
     9  	"github.com/stellar/go/xdr"
    10  )
    11  
    12  // LedgerOutput is a representation of a ledger that aligns with the BigQuery table history_ledgers
    13  type LedgerOutput struct {
    14  	Sequence                   uint32    `json:"sequence"` // sequence number of the ledger
    15  	LedgerHash                 string    `json:"ledger_hash"`
    16  	PreviousLedgerHash         string    `json:"previous_ledger_hash"`
    17  	LedgerHeader               string    `json:"ledger_header"` // base 64 encoding of the ledger header
    18  	TransactionCount           int32     `json:"transaction_count"`
    19  	OperationCount             int32     `json:"operation_count"` // counts only operations that were a part of successful transactions
    20  	SuccessfulTransactionCount int32     `json:"successful_transaction_count"`
    21  	FailedTransactionCount     int32     `json:"failed_transaction_count"`
    22  	TxSetOperationCount        string    `json:"tx_set_operation_count"` // counts all operations, even those that are part of failed transactions
    23  	ClosedAt                   time.Time `json:"closed_at"`              // UTC timestamp
    24  	TotalCoins                 int64     `json:"total_coins"`
    25  	FeePool                    int64     `json:"fee_pool"`
    26  	BaseFee                    uint32    `json:"base_fee"`
    27  	BaseReserve                uint32    `json:"base_reserve"`
    28  	MaxTxSetSize               uint32    `json:"max_tx_set_size"`
    29  	ProtocolVersion            uint32    `json:"protocol_version"`
    30  	LedgerID                   int64     `json:"id"`
    31  }
    32  
    33  // TransactionOutput is a representation of a transaction that aligns with the BigQuery table history_transactions
    34  type TransactionOutput struct {
    35  	TransactionHash              string         `json:"transaction_hash"`
    36  	LedgerSequence               uint32         `json:"ledger_sequence"`
    37  	Account                      string         `json:"account"`
    38  	AccountMuxed                 string         `json:"account_muxed,omitempty"`
    39  	AccountSequence              int64          `json:"account_sequence"`
    40  	MaxFee                       uint32         `json:"max_fee"`
    41  	FeeCharged                   int64          `json:"fee_charged"`
    42  	OperationCount               int32          `json:"operation_count"`
    43  	TxEnvelope                   string         `json:"tx_envelope"`
    44  	TxResult                     string         `json:"tx_result"`
    45  	TxMeta                       string         `json:"tx_meta"`
    46  	TxFeeMeta                    string         `json:"tx_fee_meta"`
    47  	CreatedAt                    time.Time      `json:"created_at"`
    48  	MemoType                     string         `json:"memo_type"`
    49  	Memo                         string         `json:"memo"`
    50  	TimeBounds                   string         `json:"time_bounds"`
    51  	Successful                   bool           `json:"successful"`
    52  	TransactionID                int64          `json:"id"`
    53  	FeeAccount                   string         `json:"fee_account,omitempty"`
    54  	FeeAccountMuxed              string         `json:"fee_account_muxed,omitempty"`
    55  	InnerTransactionHash         string         `json:"inner_transaction_hash,omitempty"`
    56  	NewMaxFee                    uint32         `json:"new_max_fee,omitempty"`
    57  	LedgerBounds                 string         `json:"ledger_bounds"`
    58  	MinAccountSequence           null.Int       `json:"min_account_sequence"`
    59  	MinAccountSequenceAge        null.Int       `json:"min_account_sequence_age"`
    60  	MinAccountSequenceLedgerGap  null.Int       `json:"min_account_sequence_ledger_gap"`
    61  	ExtraSigners                 pq.StringArray `json:"extra_signers"`
    62  	ClosedAt                     time.Time      `json:"closed_at"`
    63  	ResourceFee                  int64          `json:"resource_fee"`
    64  	SorobanResourcesInstructions uint32         `json:"soroban_resources_instructions"`
    65  	SorobanResourcesReadBytes    uint32         `json:"soroban_resources_read_bytes"`
    66  	SorobanResourcesWriteBytes   uint32         `json:"soroban_resources_write_bytes"`
    67  	TransactionResultCode        string         `json:"transaction_result_code"`
    68  	InclusionFeeBid              int64          `json:"inclusion_fee_bid"`
    69  	InclusionFeeCharged          int64          `json:"inclusion_fee_charged"`
    70  	ResourceFeeRefund            int64          `json:"resource_fee_refund"`
    71  }
    72  
    73  type LedgerTransactionOutput struct {
    74  	LedgerSequence  uint32    `json:"ledger_sequence"`
    75  	TxEnvelope      string    `json:"tx_envelope"`
    76  	TxResult        string    `json:"tx_result"`
    77  	TxMeta          string    `json:"tx_meta"`
    78  	TxFeeMeta       string    `json:"tx_fee_meta"`
    79  	TxLedgerHistory string    `json:"tx_ledger_history"`
    80  	ClosedAt        time.Time `json:"closed_at"`
    81  }
    82  
    83  // AccountOutput is a representation of an account that aligns with the BigQuery table accounts
    84  type AccountOutput struct {
    85  	AccountID            string      `json:"account_id"` // account address
    86  	Balance              float64     `json:"balance"`
    87  	BuyingLiabilities    float64     `json:"buying_liabilities"`
    88  	SellingLiabilities   float64     `json:"selling_liabilities"`
    89  	SequenceNumber       int64       `json:"sequence_number"`
    90  	SequenceLedger       zero.Int    `json:"sequence_ledger"`
    91  	SequenceTime         zero.Int    `json:"sequence_time"`
    92  	NumSubentries        uint32      `json:"num_subentries"`
    93  	InflationDestination string      `json:"inflation_destination"`
    94  	Flags                uint32      `json:"flags"`
    95  	HomeDomain           string      `json:"home_domain"`
    96  	MasterWeight         int32       `json:"master_weight"`
    97  	ThresholdLow         int32       `json:"threshold_low"`
    98  	ThresholdMedium      int32       `json:"threshold_medium"`
    99  	ThresholdHigh        int32       `json:"threshold_high"`
   100  	Sponsor              null.String `json:"sponsor"`
   101  	NumSponsored         uint32      `json:"num_sponsored"`
   102  	NumSponsoring        uint32      `json:"num_sponsoring"`
   103  	LastModifiedLedger   uint32      `json:"last_modified_ledger"`
   104  	LedgerEntryChange    uint32      `json:"ledger_entry_change"`
   105  	Deleted              bool        `json:"deleted"`
   106  	ClosedAt             time.Time   `json:"closed_at"`
   107  	LedgerSequence       uint32      `json:"ledger_sequence"`
   108  }
   109  
   110  // AccountSignerOutput is a representation of an account signer that aligns with the BigQuery table account_signers
   111  type AccountSignerOutput struct {
   112  	AccountID          string      `json:"account_id"`
   113  	Signer             string      `json:"signer"`
   114  	Weight             int32       `json:"weight"`
   115  	Sponsor            null.String `json:"sponsor"`
   116  	LastModifiedLedger uint32      `json:"last_modified_ledger"`
   117  	LedgerEntryChange  uint32      `json:"ledger_entry_change"`
   118  	Deleted            bool        `json:"deleted"`
   119  	ClosedAt           time.Time   `json:"closed_at"`
   120  	LedgerSequence     uint32      `json:"ledger_sequence"`
   121  }
   122  
   123  // OperationOutput is a representation of an operation that aligns with the BigQuery table history_operations
   124  type OperationOutput struct {
   125  	SourceAccount       string                 `json:"source_account"`
   126  	SourceAccountMuxed  string                 `json:"source_account_muxed,omitempty"`
   127  	Type                int32                  `json:"type"`
   128  	TypeString          string                 `json:"type_string"`
   129  	OperationDetails    map[string]interface{} `json:"details"` //Details is a JSON object that varies based on operation type
   130  	TransactionID       int64                  `json:"transaction_id"`
   131  	OperationID         int64                  `json:"id"`
   132  	ClosedAt            time.Time              `json:"closed_at"`
   133  	OperationResultCode string                 `json:"operation_result_code"`
   134  	OperationTraceCode  string                 `json:"operation_trace_code"`
   135  }
   136  
   137  // ClaimableBalanceOutput is a representation of a claimable balances that aligns with the BigQuery table claimable_balances
   138  type ClaimableBalanceOutput struct {
   139  	BalanceID          string      `json:"balance_id"`
   140  	Claimants          []Claimant  `json:"claimants"`
   141  	AssetCode          string      `json:"asset_code"`
   142  	AssetIssuer        string      `json:"asset_issuer"`
   143  	AssetType          string      `json:"asset_type"`
   144  	AssetID            int64       `json:"asset_id"`
   145  	AssetAmount        float64     `json:"asset_amount"`
   146  	Sponsor            null.String `json:"sponsor"`
   147  	Flags              uint32      `json:"flags"`
   148  	LastModifiedLedger uint32      `json:"last_modified_ledger"`
   149  	LedgerEntryChange  uint32      `json:"ledger_entry_change"`
   150  	Deleted            bool        `json:"deleted"`
   151  	ClosedAt           time.Time   `json:"closed_at"`
   152  	LedgerSequence     uint32      `json:"ledger_sequence"`
   153  }
   154  
   155  // Claimants
   156  type Claimant struct {
   157  	Destination string             `json:"destination"`
   158  	Predicate   xdr.ClaimPredicate `json:"predicate"`
   159  }
   160  
   161  // Price represents the price of an asset as a fraction
   162  type Price struct {
   163  	Numerator   int32 `json:"n"`
   164  	Denominator int32 `json:"d"`
   165  }
   166  
   167  // Path is a representation of an asset without an ID that forms part of a path in a path payment
   168  type Path struct {
   169  	AssetCode   string `json:"asset_code"`
   170  	AssetIssuer string `json:"asset_issuer"`
   171  	AssetType   string `json:"asset_type"`
   172  }
   173  
   174  // LiquidityPoolAsset represents the asset pairs in a liquidity pool
   175  type LiquidityPoolAsset struct {
   176  	AssetAType   string
   177  	AssetACode   string
   178  	AssetAIssuer string
   179  	AssetAAmount float64
   180  	AssetBType   string
   181  	AssetBCode   string
   182  	AssetBIssuer string
   183  	AssetBAmount float64
   184  }
   185  
   186  // PoolOutput is a representation of a liquidity pool that aligns with the Bigquery table liquidity_pools
   187  type PoolOutput struct {
   188  	PoolID             string    `json:"liquidity_pool_id"`
   189  	PoolType           string    `json:"type"`
   190  	PoolFee            uint32    `json:"fee"`
   191  	TrustlineCount     uint64    `json:"trustline_count"`
   192  	PoolShareCount     float64   `json:"pool_share_count"`
   193  	AssetAType         string    `json:"asset_a_type"`
   194  	AssetACode         string    `json:"asset_a_code"`
   195  	AssetAIssuer       string    `json:"asset_a_issuer"`
   196  	AssetAReserve      float64   `json:"asset_a_amount"`
   197  	AssetAID           int64     `json:"asset_a_id"`
   198  	AssetBType         string    `json:"asset_b_type"`
   199  	AssetBCode         string    `json:"asset_b_code"`
   200  	AssetBIssuer       string    `json:"asset_b_issuer"`
   201  	AssetBReserve      float64   `json:"asset_b_amount"`
   202  	AssetBID           int64     `json:"asset_b_id"`
   203  	LastModifiedLedger uint32    `json:"last_modified_ledger"`
   204  	LedgerEntryChange  uint32    `json:"ledger_entry_change"`
   205  	Deleted            bool      `json:"deleted"`
   206  	ClosedAt           time.Time `json:"closed_at"`
   207  	LedgerSequence     uint32    `json:"ledger_sequence"`
   208  }
   209  
   210  // AssetOutput is a representation of an asset that aligns with the BigQuery table history_assets
   211  type AssetOutput struct {
   212  	AssetCode   string `json:"asset_code"`
   213  	AssetIssuer string `json:"asset_issuer"`
   214  	AssetType   string `json:"asset_type"`
   215  	AssetID     uint64 `json:"id"`
   216  	ID          int64  `json:"asset_id"`
   217  }
   218  
   219  // TrustlineOutput is a representation of a trustline that aligns with the BigQuery table trust_lines
   220  type TrustlineOutput struct {
   221  	LedgerKey          string      `json:"ledger_key"`
   222  	AccountID          string      `json:"account_id"`
   223  	AssetCode          string      `json:"asset_code"`
   224  	AssetIssuer        string      `json:"asset_issuer"`
   225  	AssetType          int32       `json:"asset_type"`
   226  	AssetID            int64       `json:"asset_id"`
   227  	Balance            float64     `json:"balance"`
   228  	TrustlineLimit     int64       `json:"trust_line_limit"`
   229  	LiquidityPoolID    string      `json:"liquidity_pool_id"`
   230  	BuyingLiabilities  float64     `json:"buying_liabilities"`
   231  	SellingLiabilities float64     `json:"selling_liabilities"`
   232  	Flags              uint32      `json:"flags"`
   233  	LastModifiedLedger uint32      `json:"last_modified_ledger"`
   234  	LedgerEntryChange  uint32      `json:"ledger_entry_change"`
   235  	Sponsor            null.String `json:"sponsor"`
   236  	Deleted            bool        `json:"deleted"`
   237  	ClosedAt           time.Time   `json:"closed_at"`
   238  	LedgerSequence     uint32      `json:"ledger_sequence"`
   239  }
   240  
   241  // OfferOutput is a representation of an offer that aligns with the BigQuery table offers
   242  type OfferOutput struct {
   243  	SellerID           string      `json:"seller_id"` // Account address of the seller
   244  	OfferID            int64       `json:"offer_id"`
   245  	SellingAssetType   string      `json:"selling_asset_type"`
   246  	SellingAssetCode   string      `json:"selling_asset_code"`
   247  	SellingAssetIssuer string      `json:"selling_asset_issuer"`
   248  	SellingAssetID     int64       `json:"selling_asset_id"`
   249  	BuyingAssetType    string      `json:"buying_asset_type"`
   250  	BuyingAssetCode    string      `json:"buying_asset_code"`
   251  	BuyingAssetIssuer  string      `json:"buying_asset_issuer"`
   252  	BuyingAssetID      int64       `json:"buying_asset_id"`
   253  	Amount             float64     `json:"amount"`
   254  	PriceN             int32       `json:"pricen"`
   255  	PriceD             int32       `json:"priced"`
   256  	Price              float64     `json:"price"`
   257  	Flags              uint32      `json:"flags"`
   258  	LastModifiedLedger uint32      `json:"last_modified_ledger"`
   259  	LedgerEntryChange  uint32      `json:"ledger_entry_change"`
   260  	Deleted            bool        `json:"deleted"`
   261  	Sponsor            null.String `json:"sponsor"`
   262  	ClosedAt           time.Time   `json:"closed_at"`
   263  	LedgerSequence     uint32      `json:"ledger_sequence"`
   264  }
   265  
   266  // TradeOutput is a representation of a trade that aligns with the BigQuery table history_trades
   267  type TradeOutput struct {
   268  	Order                  int32       `json:"order"`
   269  	LedgerClosedAt         time.Time   `json:"ledger_closed_at"`
   270  	SellingAccountAddress  string      `json:"selling_account_address"`
   271  	SellingAssetCode       string      `json:"selling_asset_code"`
   272  	SellingAssetIssuer     string      `json:"selling_asset_issuer"`
   273  	SellingAssetType       string      `json:"selling_asset_type"`
   274  	SellingAssetID         int64       `json:"selling_asset_id"`
   275  	SellingAmount          float64     `json:"selling_amount"`
   276  	BuyingAccountAddress   string      `json:"buying_account_address"`
   277  	BuyingAssetCode        string      `json:"buying_asset_code"`
   278  	BuyingAssetIssuer      string      `json:"buying_asset_issuer"`
   279  	BuyingAssetType        string      `json:"buying_asset_type"`
   280  	BuyingAssetID          int64       `json:"buying_asset_id"`
   281  	BuyingAmount           float64     `json:"buying_amount"`
   282  	PriceN                 int64       `json:"price_n"`
   283  	PriceD                 int64       `json:"price_d"`
   284  	SellingOfferID         null.Int    `json:"selling_offer_id"`
   285  	BuyingOfferID          null.Int    `json:"buying_offer_id"`
   286  	SellingLiquidityPoolID null.String `json:"selling_liquidity_pool_id"`
   287  	LiquidityPoolFee       null.Int    `json:"liquidity_pool_fee"`
   288  	HistoryOperationID     int64       `json:"history_operation_id"`
   289  	TradeType              int32       `json:"trade_type"`
   290  	RoundingSlippage       null.Int    `json:"rounding_slippage"`
   291  	SellerIsExact          null.Bool   `json:"seller_is_exact"`
   292  }
   293  
   294  // DimAccount is a representation of an account that aligns with the BigQuery table dim_accounts
   295  type DimAccount struct {
   296  	ID      uint64 `json:"account_id"`
   297  	Address string `json:"address"`
   298  }
   299  
   300  // DimOffer is a representation of an account that aligns with the BigQuery table dim_offers
   301  type DimOffer struct {
   302  	HorizonID     int64   `json:"horizon_offer_id"`
   303  	DimOfferID    uint64  `json:"dim_offer_id"`
   304  	MarketID      uint64  `json:"market_id"`
   305  	MakerID       uint64  `json:"maker_id"`
   306  	Action        string  `json:"action"`
   307  	BaseAmount    float64 `json:"base_amount"`
   308  	CounterAmount float64 `json:"counter_amount"`
   309  	Price         float64 `json:"price"`
   310  }
   311  
   312  // FactOfferEvent is a representation of an offer event that aligns with the BigQuery table fact_offer_events
   313  type FactOfferEvent struct {
   314  	LedgerSeq       uint32 `json:"ledger_id"`
   315  	OfferInstanceID uint64 `json:"offer_instance_id"`
   316  }
   317  
   318  // DimMarket is a representation of an account that aligns with the BigQuery table dim_markets
   319  type DimMarket struct {
   320  	ID            uint64 `json:"market_id"`
   321  	BaseCode      string `json:"base_code"`
   322  	BaseIssuer    string `json:"base_issuer"`
   323  	CounterCode   string `json:"counter_code"`
   324  	CounterIssuer string `json:"counter_issuer"`
   325  }
   326  
   327  // NormalizedOfferOutput ties together the information for dim_markets, dim_offers, dim_accounts, and fact_offer-events
   328  type NormalizedOfferOutput struct {
   329  	Market  DimMarket
   330  	Offer   DimOffer
   331  	Account DimAccount
   332  	Event   FactOfferEvent
   333  }
   334  
   335  type SponsorshipOutput struct {
   336  	Operation      xdr.Operation
   337  	OperationIndex uint32
   338  }
   339  
   340  // EffectOutput is a representation of an operation that aligns with the BigQuery table history_effects
   341  type EffectOutput struct {
   342  	Address      string                 `json:"address"`
   343  	AddressMuxed null.String            `json:"address_muxed,omitempty"`
   344  	OperationID  int64                  `json:"operation_id"`
   345  	Details      map[string]interface{} `json:"details"`
   346  	Type         int32                  `json:"type"`
   347  	TypeString   string                 `json:"type_string"`
   348  	LedgerClosed time.Time              `json:"closed_at"`
   349  }
   350  
   351  // EffectType is the numeric type for an effect
   352  type EffectType int
   353  
   354  const (
   355  	EffectAccountCreated                     EffectType = 0
   356  	EffectAccountRemoved                     EffectType = 1
   357  	EffectAccountCredited                    EffectType = 2
   358  	EffectAccountDebited                     EffectType = 3
   359  	EffectAccountThresholdsUpdated           EffectType = 4
   360  	EffectAccountHomeDomainUpdated           EffectType = 5
   361  	EffectAccountFlagsUpdated                EffectType = 6
   362  	EffectAccountInflationDestinationUpdated EffectType = 7
   363  	EffectSignerCreated                      EffectType = 10
   364  	EffectSignerRemoved                      EffectType = 11
   365  	EffectSignerUpdated                      EffectType = 12
   366  	EffectTrustlineCreated                   EffectType = 20
   367  	EffectTrustlineRemoved                   EffectType = 21
   368  	EffectTrustlineUpdated                   EffectType = 22
   369  	EffectTrustlineFlagsUpdated              EffectType = 26
   370  	EffectOfferCreated                       EffectType = 30
   371  	EffectOfferRemoved                       EffectType = 31
   372  	EffectOfferUpdated                       EffectType = 32
   373  	EffectTrade                              EffectType = 33
   374  	EffectDataCreated                        EffectType = 40
   375  	EffectDataRemoved                        EffectType = 41
   376  	EffectDataUpdated                        EffectType = 42
   377  	EffectSequenceBumped                     EffectType = 43
   378  	EffectClaimableBalanceCreated            EffectType = 50
   379  	EffectClaimableBalanceClaimantCreated    EffectType = 51
   380  	EffectClaimableBalanceClaimed            EffectType = 52
   381  	EffectAccountSponsorshipCreated          EffectType = 60
   382  	EffectAccountSponsorshipUpdated          EffectType = 61
   383  	EffectAccountSponsorshipRemoved          EffectType = 62
   384  	EffectTrustlineSponsorshipCreated        EffectType = 63
   385  	EffectTrustlineSponsorshipUpdated        EffectType = 64
   386  	EffectTrustlineSponsorshipRemoved        EffectType = 65
   387  	EffectDataSponsorshipCreated             EffectType = 66
   388  	EffectDataSponsorshipUpdated             EffectType = 67
   389  	EffectDataSponsorshipRemoved             EffectType = 68
   390  	EffectClaimableBalanceSponsorshipCreated EffectType = 69
   391  	EffectClaimableBalanceSponsorshipUpdated EffectType = 70
   392  	EffectClaimableBalanceSponsorshipRemoved EffectType = 71
   393  	EffectSignerSponsorshipCreated           EffectType = 72
   394  	EffectSignerSponsorshipUpdated           EffectType = 73
   395  	EffectSignerSponsorshipRemoved           EffectType = 74
   396  	EffectClaimableBalanceClawedBack         EffectType = 80
   397  	EffectLiquidityPoolDeposited             EffectType = 90
   398  	EffectLiquidityPoolWithdrew              EffectType = 91
   399  	EffectLiquidityPoolTrade                 EffectType = 92
   400  	EffectLiquidityPoolCreated               EffectType = 93
   401  	EffectLiquidityPoolRemoved               EffectType = 94
   402  	EffectLiquidityPoolRevoked               EffectType = 95
   403  	EffectContractCredited                   EffectType = 96
   404  	EffectContractDebited                    EffectType = 97
   405  	EffectExtendFootprintTtl                 EffectType = 98
   406  	EffectRestoreFootprint                   EffectType = 99
   407  )
   408  
   409  // EffectTypeNames stores a map of effect type ID and names
   410  var EffectTypeNames = map[EffectType]string{
   411  	EffectAccountCreated:                     "account_created",
   412  	EffectAccountRemoved:                     "account_removed",
   413  	EffectAccountCredited:                    "account_credited",
   414  	EffectAccountDebited:                     "account_debited",
   415  	EffectAccountThresholdsUpdated:           "account_thresholds_updated",
   416  	EffectAccountHomeDomainUpdated:           "account_home_domain_updated",
   417  	EffectAccountFlagsUpdated:                "account_flags_updated",
   418  	EffectAccountInflationDestinationUpdated: "account_inflation_destination_updated",
   419  	EffectSignerCreated:                      "signer_created",
   420  	EffectSignerRemoved:                      "signer_removed",
   421  	EffectSignerUpdated:                      "signer_updated",
   422  	EffectTrustlineCreated:                   "trustline_created",
   423  	EffectTrustlineRemoved:                   "trustline_removed",
   424  	EffectTrustlineUpdated:                   "trustline_updated",
   425  	EffectTrustlineFlagsUpdated:              "trustline_flags_updated",
   426  	EffectOfferCreated:                       "offer_created",
   427  	EffectOfferRemoved:                       "offer_removed",
   428  	EffectOfferUpdated:                       "offer_updated",
   429  	EffectTrade:                              "trade",
   430  	EffectDataCreated:                        "data_created",
   431  	EffectDataRemoved:                        "data_removed",
   432  	EffectDataUpdated:                        "data_updated",
   433  	EffectSequenceBumped:                     "sequence_bumped",
   434  	EffectClaimableBalanceCreated:            "claimable_balance_created",
   435  	EffectClaimableBalanceClaimed:            "claimable_balance_claimed",
   436  	EffectClaimableBalanceClaimantCreated:    "claimable_balance_claimant_created",
   437  	EffectAccountSponsorshipCreated:          "account_sponsorship_created",
   438  	EffectAccountSponsorshipUpdated:          "account_sponsorship_updated",
   439  	EffectAccountSponsorshipRemoved:          "account_sponsorship_removed",
   440  	EffectTrustlineSponsorshipCreated:        "trustline_sponsorship_created",
   441  	EffectTrustlineSponsorshipUpdated:        "trustline_sponsorship_updated",
   442  	EffectTrustlineSponsorshipRemoved:        "trustline_sponsorship_removed",
   443  	EffectDataSponsorshipCreated:             "data_sponsorship_created",
   444  	EffectDataSponsorshipUpdated:             "data_sponsorship_updated",
   445  	EffectDataSponsorshipRemoved:             "data_sponsorship_removed",
   446  	EffectClaimableBalanceSponsorshipCreated: "claimable_balance_sponsorship_created",
   447  	EffectClaimableBalanceSponsorshipUpdated: "claimable_balance_sponsorship_updated",
   448  	EffectClaimableBalanceSponsorshipRemoved: "claimable_balance_sponsorship_removed",
   449  	EffectSignerSponsorshipCreated:           "signer_sponsorship_created",
   450  	EffectSignerSponsorshipUpdated:           "signer_sponsorship_updated",
   451  	EffectSignerSponsorshipRemoved:           "signer_sponsorship_removed",
   452  	EffectClaimableBalanceClawedBack:         "claimable_balance_clawed_back",
   453  	EffectLiquidityPoolDeposited:             "liquidity_pool_deposited",
   454  	EffectLiquidityPoolWithdrew:              "liquidity_pool_withdrew",
   455  	EffectLiquidityPoolTrade:                 "liquidity_pool_trade",
   456  	EffectLiquidityPoolCreated:               "liquidity_pool_created",
   457  	EffectLiquidityPoolRemoved:               "liquidity_pool_removed",
   458  	EffectLiquidityPoolRevoked:               "liquidity_pool_revoked",
   459  	EffectContractCredited:                   "contract_credited",
   460  	EffectContractDebited:                    "contract_debited",
   461  	EffectExtendFootprintTtl:                 "extend_footprint_ttl",
   462  	EffectRestoreFootprint:                   "restore_footprint",
   463  }
   464  
   465  // TradeEffectDetails is a struct of data from `effects.DetailsString`
   466  // when the effect type is trade
   467  type TradeEffectDetails struct {
   468  	Seller            string `json:"seller"`
   469  	SellerMuxed       string `json:"seller_muxed,omitempty"`
   470  	SellerMuxedID     uint64 `json:"seller_muxed_id,omitempty"`
   471  	OfferID           int64  `json:"offer_id"`
   472  	SoldAmount        string `json:"sold_amount"`
   473  	SoldAssetType     string `json:"sold_asset_type"`
   474  	SoldAssetCode     string `json:"sold_asset_code,omitempty"`
   475  	SoldAssetIssuer   string `json:"sold_asset_issuer,omitempty"`
   476  	BoughtAmount      string `json:"bought_amount"`
   477  	BoughtAssetType   string `json:"bought_asset_type"`
   478  	BoughtAssetCode   string `json:"bought_asset_code,omitempty"`
   479  	BoughtAssetIssuer string `json:"bought_asset_issuer,omitempty"`
   480  }
   481  
   482  // TestTransaction transaction meta
   483  type TestTransaction struct {
   484  	Index         uint32
   485  	EnvelopeXDR   string
   486  	ResultXDR     string
   487  	FeeChangesXDR string
   488  	MetaXDR       string
   489  	Hash          string
   490  }
   491  
   492  // ContractDataOutput is a representation of contract data that aligns with the Bigquery table soroban_contract_data
   493  type ContractDataOutput struct {
   494  	ContractId                string    `json:"contract_id"`
   495  	ContractKeyType           string    `json:"contract_key_type"`
   496  	ContractDurability        string    `json:"contract_durability"`
   497  	ContractDataAssetCode     string    `json:"asset_code"`
   498  	ContractDataAssetIssuer   string    `json:"asset_issuer"`
   499  	ContractDataAssetType     string    `json:"asset_type"`
   500  	ContractDataBalanceHolder string    `json:"balance_holder"`
   501  	ContractDataBalance       string    `json:"balance"` // balance is a string because it is go type big.Int
   502  	LastModifiedLedger        uint32    `json:"last_modified_ledger"`
   503  	LedgerEntryChange         uint32    `json:"ledger_entry_change"`
   504  	Deleted                   bool      `json:"deleted"`
   505  	ClosedAt                  time.Time `json:"closed_at"`
   506  	LedgerSequence            uint32    `json:"ledger_sequence"`
   507  	LedgerKeyHash             string    `json:"ledger_key_hash"`
   508  }
   509  
   510  // ContractCodeOutput is a representation of contract code that aligns with the Bigquery table soroban_contract_code
   511  type ContractCodeOutput struct {
   512  	ContractCodeHash   string    `json:"contract_code_hash"`
   513  	ContractCodeExtV   int32     `json:"contract_code_ext_v"`
   514  	LastModifiedLedger uint32    `json:"last_modified_ledger"`
   515  	LedgerEntryChange  uint32    `json:"ledger_entry_change"`
   516  	Deleted            bool      `json:"deleted"`
   517  	ClosedAt           time.Time `json:"closed_at"`
   518  	LedgerSequence     uint32    `json:"ledger_sequence"`
   519  	LedgerKeyHash      string    `json:"ledger_key_hash"`
   520  	//ContractCodeCode                string `json:"contract_code"`
   521  }
   522  
   523  // ConfigSettingOutput is a representation of soroban config settings that aligns with the Bigquery table config_settings
   524  type ConfigSettingOutput struct {
   525  	ConfigSettingId                 int32               `json:"config_setting_id"`
   526  	ContractMaxSizeBytes            uint32              `json:"contract_max_size_bytes"`
   527  	LedgerMaxInstructions           int64               `json:"ledger_max_instructions"`
   528  	TxMaxInstructions               int64               `json:"tx_max_instructions"`
   529  	FeeRatePerInstructionsIncrement int64               `json:"fee_rate_per_instructions_increment"`
   530  	TxMemoryLimit                   uint32              `json:"tx_memory_limit"`
   531  	LedgerMaxReadLedgerEntries      uint32              `json:"ledger_max_read_ledger_entries"`
   532  	LedgerMaxReadBytes              uint32              `json:"ledger_max_read_bytes"`
   533  	LedgerMaxWriteLedgerEntries     uint32              `json:"ledger_max_write_ledger_entries"`
   534  	LedgerMaxWriteBytes             uint32              `json:"ledger_max_write_bytes"`
   535  	TxMaxReadLedgerEntries          uint32              `json:"tx_max_read_ledger_entries"`
   536  	TxMaxReadBytes                  uint32              `json:"tx_max_read_bytes"`
   537  	TxMaxWriteLedgerEntries         uint32              `json:"tx_max_write_ledger_entries"`
   538  	TxMaxWriteBytes                 uint32              `json:"tx_max_write_bytes"`
   539  	FeeReadLedgerEntry              int64               `json:"fee_read_ledger_entry"`
   540  	FeeWriteLedgerEntry             int64               `json:"fee_write_ledger_entry"`
   541  	FeeRead1Kb                      int64               `json:"fee_read_1kb"`
   542  	BucketListTargetSizeBytes       int64               `json:"bucket_list_target_size_bytes"`
   543  	WriteFee1KbBucketListLow        int64               `json:"write_fee_1kb_bucket_list_low"`
   544  	WriteFee1KbBucketListHigh       int64               `json:"write_fee_1kb_bucket_list_high"`
   545  	BucketListWriteFeeGrowthFactor  uint32              `json:"bucket_list_write_fee_growth_factor"`
   546  	FeeHistorical1Kb                int64               `json:"fee_historical_1kb"`
   547  	TxMaxContractEventsSizeBytes    uint32              `json:"tx_max_contract_events_size_bytes"`
   548  	FeeContractEvents1Kb            int64               `json:"fee_contract_events_1kb"`
   549  	LedgerMaxTxsSizeBytes           uint32              `json:"ledger_max_txs_size_bytes"`
   550  	TxMaxSizeBytes                  uint32              `json:"tx_max_size_bytes"`
   551  	FeeTxSize1Kb                    int64               `json:"fee_tx_size_1kb"`
   552  	ContractCostParamsCpuInsns      []map[string]string `json:"contract_cost_params_cpu_insns"`
   553  	ContractCostParamsMemBytes      []map[string]string `json:"contract_cost_params_mem_bytes"`
   554  	ContractDataKeySizeBytes        uint32              `json:"contract_data_key_size_bytes"`
   555  	ContractDataEntrySizeBytes      uint32              `json:"contract_data_entry_size_bytes"`
   556  	MaxEntryTtl                     uint32              `json:"max_entry_ttl"`
   557  	MinTemporaryTtl                 uint32              `json:"min_temporary_ttl"`
   558  	MinPersistentTtl                uint32              `json:"min_persistent_ttl"`
   559  	AutoBumpLedgers                 uint32              `json:"auto_bump_ledgers"`
   560  	PersistentRentRateDenominator   int64               `json:"persistent_rent_rate_denominator"`
   561  	TempRentRateDenominator         int64               `json:"temp_rent_rate_denominator"`
   562  	MaxEntriesToArchive             uint32              `json:"max_entries_to_archive"`
   563  	BucketListSizeWindowSampleSize  uint32              `json:"bucket_list_size_window_sample_size"`
   564  	EvictionScanSize                uint64              `json:"eviction_scan_size"`
   565  	StartingEvictionScanLevel       uint32              `json:"starting_eviction_scan_level"`
   566  	LedgerMaxTxCount                uint32              `json:"ledger_max_tx_count"`
   567  	BucketListSizeWindow            []uint64            `json:"bucket_list_size_window"`
   568  	LastModifiedLedger              uint32              `json:"last_modified_ledger"`
   569  	LedgerEntryChange               uint32              `json:"ledger_entry_change"`
   570  	Deleted                         bool                `json:"deleted"`
   571  	ClosedAt                        time.Time           `json:"closed_at"`
   572  	LedgerSequence                  uint32              `json:"ledger_sequence"`
   573  }
   574  
   575  // TtlOutput is a representation of soroban ttl that aligns with the Bigquery table ttls
   576  type TtlOutput struct {
   577  	KeyHash            string    `json:"key_hash"` // key_hash is contract_code_hash or contract_id
   578  	LiveUntilLedgerSeq uint32    `json:"live_until_ledger_seq"`
   579  	LastModifiedLedger uint32    `json:"last_modified_ledger"`
   580  	LedgerEntryChange  uint32    `json:"ledger_entry_change"`
   581  	Deleted            bool      `json:"deleted"`
   582  	ClosedAt           time.Time `json:"closed_at"`
   583  	LedgerSequence     uint32    `json:"ledger_sequence"`
   584  }
   585  
   586  // DiagnosticEventOutput is a representation of soroban diagnostic events that currently are not stored in a BQ table
   587  type DiagnosticEventOutput struct {
   588  	TransactionHash          string    `json:"transaction_hash"`
   589  	LedgerSequence           uint32    `json:"ledger_sequence"`
   590  	TransactionID            int64     `json:"transaction_id"`
   591  	ClosedAt                 time.Time `json:"closed_at"`
   592  	InSuccessfulContractCall bool      `json:"in_successful_contract_call"`
   593  	ExtV                     int32     `json:"ext_v"`
   594  	ContractId               string    `json:"contract_id"`
   595  	Type                     string    `json:"type"`
   596  	BodyV                    int32     `json:"body_v"`
   597  	Body                     string    `json:"body"`
   598  }