Documentation ¶
Overview ¶
Package sql contains the sql store.
Index ¶
- Variables
- type BridgeEvent
- type HybridBridgeEvent
- type LastBlock
- type MessageBusEvent
- type Store
- func (s *Store) GetAddressRanking(ctx context.Context, query string) ([]*model.AddressRanking, error)
- func (s *Store) GetAllBridgeEvents(ctx context.Context, query string) ([]HybridBridgeEvent, error)
- func (s *Store) GetBridgeEvent(ctx context.Context, query string) (*BridgeEvent, error)
- func (s *Store) GetBridgeEvents(ctx context.Context, query string) ([]BridgeEvent, error)
- func (s *Store) GetDateResults(ctx context.Context, query string) ([]*model.DateResult, error)
- func (s *Store) GetFloat64(ctx context.Context, query string) (float64, error)
- func (s *Store) GetStringArray(ctx context.Context, query string) ([]string, error)
- func (s *Store) GetTokenCounts(ctx context.Context, query string) ([]*model.TokenCountResult, error)
- func (s *Store) GetTxCounts(ctx context.Context, query string) ([]*model.TransactionCountResult, error)
- func (s *Store) GetUint64(ctx context.Context, query string) (uint64, error)
- func (s *Store) PartialInfosFromIdentifiers(ctx context.Context, query string) ([]*model.PartialInfo, error)
- func (s *Store) PartialInfosFromIdentifiersByChain(ctx context.Context, query string) (map[int]*model.PartialInfo, error)
- func (s *Store) StoreEvent(ctx context.Context, event interface{}) error
- func (s *Store) StoreEvents(ctx context.Context, events []interface{}) error
- func (s *Store) StoreLastBlock(ctx context.Context, chainID uint32, blockNumber uint64, ...) error
- func (s *Store) StoreTokenIndex(ctx context.Context, chainID uint32, tokenIndex uint8, tokenAddress string, ...) error
- func (s *Store) UNSAFE_DB() *gorm.DB
- type SwapEvent
- type TokenIndex
Constants ¶
This section is empty.
Variables ¶
var ( // TxHashFieldName is the field name of the tx hash. TxHashFieldName string // ChainIDFieldName gets the chain id field name. ChainIDFieldName string // BlockNumberFieldName is the name of the block number field. BlockNumberFieldName string // ContractAddressFieldName is the address of the contract. ContractAddressFieldName string // InsertTimeFieldName is the insert time field name. InsertTimeFieldName string // EventTypeFieldName is the event type field name. EventTypeFieldName string // AmountFieldName is the amount field name. AmountFieldName string // EventIndexFieldName is the event index field name. EventIndexFieldName string // DestinationChainIDFieldName is the destination chain id field name. DestinationChainIDFieldName string // TokenFieldName is the token field name. TokenFieldName string // RecipientFieldName is the recipient field name. RecipientFieldName string // KappaFieldName is the kappa field name. KappaFieldName string // DestinationKappaFieldName is the destination kappa field name. DestinationKappaFieldName string // SenderFieldName is the sender field name. SenderFieldName string // TimeStampFieldName is the timestamp field name. TimeStampFieldName string // AmountUSDFieldName is the amount in USD field name. AmountUSDFieldName string // TokenDecimalFieldName is the token decimal field name. TokenDecimalFieldName string )
var PageSize = 100
PageSize is the amount of entries per page of events.
Functions ¶
This section is empty.
Types ¶
type BridgeEvent ¶
type BridgeEvent struct { // InsertTime is the time the event was inserted into the database. InsertTime uint64 `gorm:"column:insert_time"` // ContractAddress is the address of the contract that generated the event. ContractAddress string `gorm:"column:contract_address"` // ChainID is the chain id of the contract that generated the event. ChainID uint32 `gorm:"column:chain_id"` // EventType is the type of the event. EventType uint8 `gorm:"column:event_type"` // BlockNumber is the block number of the event. BlockNumber uint64 `gorm:"column:block_number"` // TxHash is the transaction hash of the event. TxHash string `gorm:"column:tx_hash"` // Token is the address of the token. Token string `gorm:"column:token"` // Amount is the amount of tokens. Amount *big.Int `gorm:"column:amount;type:UInt256"` // EventIndex is the index of the log. EventIndex uint64 `gorm:"column:event_index"` // DestinationKappa is the destination kappa. DestinationKappa string `gorm:"column:destination_kappa"` // Sender is the address of the sender. Sender string `gorm:"column:sender"` // Recipient is the address to send the tokens to. Recipient sql.NullString `gorm:"column:recipient"` // RecipientBytes is the recipient address in bytes. RecipientBytes sql.NullString `gorm:"column:recipient_bytes"` // DestinationChainID is the chain id of the chain to send the tokens to. DestinationChainID *big.Int `gorm:"column:destination_chain_id;type:UInt256"` // Fee is the fee. Fee *big.Int `gorm:"column:fee;type:UInt256"` // Kappa is theFee keccak256 hash of the transaction. Kappa sql.NullString `gorm:"column:kappa"` // TokenIndexFrom is the index of the from token in the pool. TokenIndexFrom *big.Int `gorm:"column:token_index_from;type:UInt256"` // TokenIndexTo is the index of the to token in the pool. TokenIndexTo *big.Int `gorm:"column:token_index_to;type:UInt256"` // MinDy is the minimum amount of tokens to receive. MinDy *big.Int `gorm:"column:min_dy;type:UInt256"` // Deadline is the deadline of the transaction. Deadline *big.Int `gorm:"column:deadline;type:UInt256"` // SwapSuccess is whether the swap was successful. SwapSuccess *big.Int `gorm:"column:swap_success;type:UInt256"` // SwapTokenIndex is the index of the token in the pool. SwapTokenIndex *big.Int `gorm:"column:swap_token_index;type:UInt256"` // SwapMinAmount is the minimum amount of tokens to receive. SwapMinAmount *big.Int `gorm:"column:swap_min_amount;type:UInt256"` // SwapDeadline is the deadline of the swap transaction. SwapDeadline *big.Int `gorm:"column:swap_deadline;type:UInt256"` // TokenID is the token's ID. TokenID sql.NullString `gorm:"column:token_id"` // AmountUSD is the amount in USD. AmountUSD *float64 `gorm:"column:amount_usd;type:Float64"` // FeeAmountUSD is the fee amount in USD. FeeAmountUSD *float64 `gorm:"column:fee_amount_usd;type:Float64"` // TokenDecimal is the token's decimal. TokenDecimal *uint8 `gorm:"column:token_decimal"` // TokenSymbol is the token's symbol from coin gecko. TokenSymbol sql.NullString `gorm:"column:token_symbol"` // TimeStamp is the timestamp of the block in which the event occurred. TimeStamp *uint64 `gorm:"column:timestamp"` }
BridgeEvent stores data for emitted events from the Bridge contract.
type HybridBridgeEvent ¶ added in v0.0.43
type HybridBridgeEvent struct { // FInsertTime is the time the event was inserted into the database. FInsertTime uint64 `gorm:"column:finsert_time"` // FContractAddress is the address of the contract that generated the event. FContractAddress string `gorm:"column:fcontract_address"` // FChainID is the chain id of the contract that generated the event. FChainID uint32 `gorm:"column:fchain_id"` // FEventType is the type of the event. FEventType uint8 `gorm:"column:fevent_type"` // FBlockNumber is the block number of the event. FBlockNumber uint64 `gorm:"column:fblock_number"` // FTxHash is the transaction hash of the event. FTxHash string `gorm:"column:ftx_hash"` // FToken is the address of the token. FToken string `gorm:"column:ftoken"` // FAmount is the amount of tokens. FAmount *big.Int `gorm:"column:famount;type:UInt256"` // FEventIndex is the index of the log. FEventIndex uint64 `gorm:"column:fevent_index"` // FDestinationKappa is the destination kappa. FDestinationKappa string `gorm:"column:fdestination_kappa"` // FSender is the address of the sender. FSender string `gorm:"column:fsender"` // FRecipient is the address to send the tokens to. FRecipient sql.NullString `gorm:"column:frecipient"` // FRecipientBytes is the recipient address in bytes. FRecipientBytes sql.NullString `gorm:"column:frecipient_bytes"` // FDestinationChainID is the chain id of the chain to send the tokens to. FDestinationChainID *big.Int `gorm:"column:fdestination_chain_id;type:UInt256"` // FFee is the fee. FFee *big.Int `gorm:"column:ffee;type:UInt256"` // FKappa is theFee keccak256 hash of the transaction. FKappa sql.NullString `gorm:"column:fkappa"` // FTokenIndexFrom is the index of the from token in the pool. FTokenIndexFrom *big.Int `gorm:"column:ftoken_index_from;type:UInt256"` // FTokenIndexTo is the index of the to token in the pool. FTokenIndexTo *big.Int `gorm:"column:ftoken_index_to;type:UInt256"` // FMinDy is the minimum amount of tokens to receive. FMinDy *big.Int `gorm:"column:fmin_dy;type:UInt256"` // FDeadline is the deadline of the transaction. FDeadline *big.Int `gorm:"column:fdeadline;type:UInt256"` // FSwapSuccess is whether the swap was successful. FSwapSuccess *big.Int `gorm:"column:fswap_success;type:UInt256"` // FSwapTokenIndex is the index of the token in the pool. FSwapTokenIndex *big.Int `gorm:"column:fswap_token_index;type:UInt256"` // FSwapMinAmount is the minimum amount of tokens to receive. FSwapMinAmount *big.Int `gorm:"column:fswap_min_amount;type:UInt256"` // FSwapDeadline is the deadline of the swap transaction. FSwapDeadline *big.Int `gorm:"column:fswap_deadline;type:UInt256"` // FTokenID is the token's ID. FTokenID sql.NullString `gorm:"column:ftoken_id"` // FAmountUSD is the amount in USD. FAmountUSD *float64 `gorm:"column:famount_usd;type:Float64"` // FFeeAmountUSD is the fee amount in USD. FFeeAmountUSD *float64 `gorm:"column:ffee_amount_usd;type:Float64"` // FTokenDecimal is the token's decimal. FTokenDecimal *uint8 `gorm:"column:ftoken_decimal"` // FTokenSymbol is the token's symbol from coin gecko. FTokenSymbol sql.NullString `gorm:"column:ftoken_symbol"` // FTimeStamp is the timestamp of the block in which the event occurred. FTimeStamp *uint64 `gorm:"column:ftimestamp"` // TInsertTime is the time the event was inserted into the database. TInsertTime uint64 `gorm:"column:finsert_time"` // TContractAddress is the address of the contract that generated the event. TContractAddress string `gorm:"column:tcontract_address"` // TChainID is the chain id of the contract that generated the event. TChainID uint32 `gorm:"column:tchain_id"` // TEventType is the type of the event. TEventType uint8 `gorm:"column:tevent_type"` // TBlockNumber is the block number of the event. TBlockNumber uint64 `gorm:"column:tblock_number"` // TTxHash is the transaction hash of the event. TTxHash string `gorm:"column:ttx_hash"` // TToken is the address of the token. TToken string `gorm:"column:ttoken"` // TAmount is the amount of tokens. TAmount *big.Int `gorm:"column:tamount;type:UInt256"` // TEventIndex is the index of the log. TEventIndex uint64 `gorm:"column:tevent_index"` // TDestinationKappa is the destination kappa. TDestinationKappa string `gorm:"column:tdestination_kappa"` // TSender is the address of the sender. TSender string `gorm:"column:tsender"` // TRecipient is the address to send the tokens to. TRecipient sql.NullString `gorm:"column:trecipient"` // TRecipientBytes is the recipient address in bytes. TRecipientBytes sql.NullString `gorm:"column:trecipient_bytes"` // TDestinationChainID is the chain id of the chain to send the tokens to. TDestinationChainID *big.Int `gorm:"column:tdestination_chain_id;type:UInt256"` // TFee is the fee. TFee *big.Int `gorm:"column:tfee;type:UInt256"` // TKappa is theFee keccak256 hash of the transaction. TKappa sql.NullString `gorm:"column:tkappa"` // TTokenIndexFrom is the index of the from token in the pool. TTokenIndexFrom *big.Int `gorm:"column:ttoken_index_from;type:UInt256"` // TTokenIndexTo is the index of the to token in the pool. TTokenIndexTo *big.Int `gorm:"column:ttoken_index_to;type:UInt256"` // TMinDy is the minimum amount of tokens to receive. TMinDy *big.Int `gorm:"column:tmin_dy;type:UInt256"` // TDeadline is the deadline of the transaction. TDeadline *big.Int `gorm:"column:tdeadline;type:UInt256"` // TSwapSuccess is whether the swap was successful. TSwapSuccess *big.Int `gorm:"column:tswap_success;type:UInt256"` // TSwapTokenIndex is the index of the token in the pool. TSwapTokenIndex *big.Int `gorm:"column:tswap_token_index;type:UInt256"` // TSwapMinAmount is the minimum amount of tokens to receive. TSwapMinAmount *big.Int `gorm:"column:tswap_min_amount;type:UInt256"` // TSwapDeadline is the deadline of the swap transaction. TSwapDeadline *big.Int `gorm:"column:tswap_deadline;type:UInt256"` // TTokenID is the token's ID. TTokenID sql.NullString `gorm:"column:ttoken_id"` // TAmountUSD is the amount in USD. TAmountUSD *float64 `gorm:"column:tamount_usd;type:Float64"` // TFeeAmountUSD is the fee amount in USD. TFeeAmountUSD *float64 `gorm:"column:tfee_amount_usd;type:Float64"` // TTokenDecimal is the token's decimal. TTokenDecimal *uint8 `gorm:"column:ttoken_decimal"` // TTokenSymbol is the token's symbol from coin gecko. TTokenSymbol sql.NullString `gorm:"column:ttoken_symbol"` // TTimeStamp is the timestamp of the block in which the event occurred. TTimeStamp *uint64 `gorm:"column:ttimestamp"` }
HybridBridgeEvent is the datatype for a returned bridge event.
type LastBlock ¶ added in v0.0.11
type LastBlock struct { // ChainID is the chain id of the chain. ChainID uint32 `gorm:"column:chain_id"` // BlockNumber is the last block number that the explorer has backfilled to. BlockNumber uint64 `gorm:"column:block_number"` // ContractAddress is the address of the contract that generated the event. ContractAddress string `gorm:"column:contract_address"` }
LastBlock stores the last block number that the explorer has backfilled to on each chain.
type MessageBusEvent ¶ added in v0.0.19
type MessageBusEvent struct { // InsertTime is the time the event was inserted into the database InsertTime uint64 `gorm:"column:insert_time"` // ContractAddress is the address of the contract that generated the event ContractAddress string `gorm:"column:contract_address"` // ChainID is the chain id of the contract that generated the event ChainID uint32 `gorm:"column:chain_id"` // BlockNumber is the block number of the event BlockNumber uint64 `gorm:"column:block_number"` // TxHash is the transaction hash of the event TxHash string `gorm:"column:tx_hash"` // EventType is the type of the event EventType uint8 `gorm:"column:event_type"` // EventIndex is the index of the log EventIndex uint64 `gorm:"column:event_index"` // Sender is the address of the sender Sender string `gorm:"column:sender"` // MessageId is the message id of the event. MessageID sql.NullString `gorm:"column:message_id"` // SourceChainID is the chain id of the message's source chain. SourceChainID *big.Int `gorm:"column:source_chain_id;type:UInt256"` // Status is the status of the event. Status sql.NullString `gorm:"column:status"` // SourceAddress is the address that the message will be passed from. SourceAddress sql.NullString `gorm:"column:source_address"` // DestinationAddress is the address that the message will be passed to. DestinationAddress sql.NullString `gorm:"column:destination_address"` // DestinationChainID is the chain id of the message's destination chain. DestinationChainID *big.Int `gorm:"column:destination_chain_id;type:UInt256"` // Nonce is the nonce of the message. It is equivalent to the nonce on the origin chain. Nonce *big.Int `gorm:"column:nonce;type:UInt256"` // Message is the message. Message sql.NullString `gorm:"column:message"` // Receiver is the receiver of the event. Receiver sql.NullString `gorm:"column:receiver"` // Options are the options chosen for the message. Options sql.NullString `gorm:"column:options"` // Fee is the fee of the message. Fee *big.Int `gorm:"column:fee;type:UInt256"` // RevertedReason is the reason a call was reverted. RevertedReason sql.NullString `gorm:"column:reverted_reason"` // TimeStamp is the timestamp in which the record was inserted. TimeStamp *uint64 `gorm:"column:timestamp"` }
MessageBusEvent stores data for emitted events from the message bus contract.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the clickhouse store. It extends the base store for sqlite specific queries.
func OpenGormClickhouse ¶
OpenGormClickhouse opens a gorm connection to clickhouse.
func (*Store) GetAddressRanking ¶ added in v0.0.15
func (s *Store) GetAddressRanking(ctx context.Context, query string) ([]*model.AddressRanking, error)
GetAddressRanking gets AddressRanking for a given query.
func (*Store) GetAllBridgeEvents ¶ added in v0.0.43
GetAllBridgeEvents returns bridge events.
func (*Store) GetBridgeEvent ¶ added in v0.0.15
GetBridgeEvent returns a bridge event.
func (*Store) GetBridgeEvents ¶ added in v0.0.25
GetBridgeEvents returns bridge events.
func (*Store) GetDateResults ¶ added in v0.0.15
GetDateResults returns the dya by day data.
func (*Store) GetFloat64 ¶ added in v0.0.15
GetFloat64 gets a float64 from a given query.
func (*Store) GetStringArray ¶ added in v0.0.15
GetStringArray returns a string array for a given query.
func (*Store) GetTokenCounts ¶ added in v0.0.25
func (s *Store) GetTokenCounts(ctx context.Context, query string) ([]*model.TokenCountResult, error)
GetTokenCounts returns Tx counts.
func (*Store) GetTxCounts ¶ added in v0.0.25
func (s *Store) GetTxCounts(ctx context.Context, query string) ([]*model.TransactionCountResult, error)
GetTxCounts returns Tx counts.
func (*Store) PartialInfosFromIdentifiers ¶ added in v0.0.9
func (s *Store) PartialInfosFromIdentifiers(ctx context.Context, query string) ([]*model.PartialInfo, error)
PartialInfosFromIdentifiers returns events given identifiers. If order is true, the events are ordered by block number.
func (*Store) PartialInfosFromIdentifiersByChain ¶ added in v0.0.25
func (s *Store) PartialInfosFromIdentifiersByChain(ctx context.Context, query string) (map[int]*model.PartialInfo, error)
PartialInfosFromIdentifiersByChain returns events given identifiers. If order is true, the events are ordered by block number.
func (*Store) StoreEvent ¶
StoreEvent stores a generic event that has the proper fields set by `eventToBridgeEvent`.
func (*Store) StoreEvents ¶ added in v0.0.31
StoreEvents stores a list of events in batches.
func (*Store) StoreLastBlock ¶ added in v0.0.11
func (s *Store) StoreLastBlock(ctx context.Context, chainID uint32, blockNumber uint64, contractAddress string) error
StoreLastBlock stores the last block number that has been backfilled for a given chain.
type SwapEvent ¶
type SwapEvent struct { // InsertTime is the time the event was inserted into the database. InsertTime uint64 `gorm:"column:insert_time"` // ContractAddress is the address of the contract that generated the event. ContractAddress string `gorm:"column:contract_address"` // ChainID is the chain id of the contract that generated the event. ChainID uint32 `gorm:"column:chain_id"` // BlockNumber is the block number of the event. BlockNumber uint64 `gorm:"column:block_number"` // TxHash is the transaction hash of the event. TxHash string `gorm:"column:tx_hash"` // EventType is the type of the event. EventType uint8 `gorm:"column:event_type"` // EventIndex is the index of the log. EventIndex uint64 `gorm:"column:event_index"` // Sender is the address of the sender. Sender string `gorm:"column:sender"` // Amount is the amount of tokens. Amount map[uint8]string `gorm:"column:amount;type:Map(UInt8, String)"` // AmountFee is the amount of fees. AmountFee map[uint8]string `gorm:"column:amount_fee;type:Map(UInt8, String)"` // ProtocolFee is the protocol fee. ProtocolFee *big.Int `gorm:"column:protocol_fee;type:UInt256"` // Buyer is the address of the buyer. Buyer sql.NullString `gorm:"column:buyer"` // TokensSold is the amount of tokens sold. TokensSold *big.Int `gorm:"column:tokens_sold;type:UInt256"` // SoldID is the id of the token sold. SoldID *big.Int `gorm:"column:sold_id;type:UInt256"` // TokensBought is the amount of tokens bought. TokensBought *big.Int `gorm:"column:tokens_bought;type:UInt256"` // BoughtID is the id of the token bought. BoughtID *big.Int `gorm:"column:bought_id;type:UInt256"` // Provider is the address of the provider. Provider sql.NullString `gorm:"column:provider"` // Invariant is the invariant of the pool. Invariant *big.Int `gorm:"column:invariant;type:UInt256"` // LPTokenAmount is the amount of LP tokens. LPTokenAmount *big.Int `gorm:"column:lp_token_amount;type:UInt256"` // LPTokenSupply is the supply of the LP token. LPTokenSupply *big.Int `gorm:"column:lp_token_supply;type:UInt256"` // NewAdminFee is the new admin fee. NewAdminFee *big.Int `gorm:"column:new_admin_fee;type:UInt256"` // NewSwapFee is the new swap fee. NewSwapFee *big.Int `gorm:"column:new_swap_fee;type:UInt256"` // OldA is the old A value. OldA *big.Int `gorm:"column:old_a;type:UInt256"` // NewA is the new A value. NewA *big.Int `gorm:"column:new_a;type:UInt256"` // InitialTime is the initial time. InitialTime *big.Int `gorm:"column:initial_time;type:UInt256"` // FutureTime is the future time. FutureTime *big.Int `gorm:"column:future_time;type:UInt256"` // CurrentA is the current A value. CurrentA *big.Int `gorm:"column:current_a;type:UInt256"` // Time is the time. Time *big.Int `gorm:"column:time;type:UInt256"` // Receiver is the address of the receiver. Receiver sql.NullString `gorm:"column:receiver"` // TokenPrices are the prices of each token at the given time. TokenPrices map[uint8]float64 `gorm:"column:amount_usd;type:Map(UInt8, Float64)"` // TokenDecimal is the token's decimal. TokenDecimal map[uint8]uint8 `gorm:"column:token_decimal;type:Map(UInt8, UInt8)"` // TokenSymbol is the token's symbol from coingecko. TokenSymbol map[uint8]string `gorm:"column:token_symbol;type:Map(UInt8, String)"` // TimeStamp is the timestamp of the block in which the event occurred. TimeStamp *uint64 `gorm:"column:timestamp"` }
SwapEvent stores data for emitted events from the Swap contract.
type TokenIndex ¶ added in v0.0.43
type TokenIndex struct { // ChainID is the chain id of the chain. ChainID uint32 `gorm:"column:chain_id"` // TokenIndex is the token index in the pool. TokenIndex uint8 `gorm:"column:token_index"` // TokenAddress is the address of the token. TokenAddress string `gorm:"column:token_address"` // ContractAddress is the address of the contract that generated the event. ContractAddress string `gorm:"column:contract_address"` }
TokenIndex stores the data for each token index on each chain.