Documentation ¶
Index ¶
- func NetName(id int64) (string, error)
- func ParseGas(msg *EthTxPayload) (gasBaseFeeGwei, gasTipGwei float64, err error)
- type Account
- type AddressSubscribe
- type BaseMessage
- type Blockchain
- type Client
- type Config
- type Configuration
- type ConnectResponse
- type EthTxPayload
- type MsgHistory
- type Opts
- type Transaction
- type TxSubscribe
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseGas ¶
func ParseGas(msg *EthTxPayload) (gasBaseFeeGwei, gasTipGwei float64, err error)
Types ¶
type Account ¶
type Account struct {
Address string `json:"address"`
}
Account bundles a single account address
type AddressSubscribe ¶
type AddressSubscribe struct { BaseMessage Account `json:"account"` }
AddressSubscribe is used to subscribe/unsubscribe to address events
func NewAddressSubscribe ¶
func NewAddressSubscribe(msg BaseMessage, address string) AddressSubscribe
NewAddressSubscribe constructs a address subscription message
func NewAddressUnsubscribe ¶
func NewAddressUnsubscribe(msg BaseMessage, address string) AddressSubscribe
NewAddressUnsubscribe constructs a address unsubscribe message
type BaseMessage ¶
type BaseMessage struct { CategoryCode string `json:"categoryCode"` EventCode string `json:"eventCode"` Timestamp time.Time `json:"timeStamp"` DappID string `json:"dappId"` // api key Version string `json:"version"` Blockchain `json:"blockchain"` }
BaseMessage is the base message required for all interactions with the websockets api
func NewBaseMessageMainnet ¶
func NewBaseMessageMainnet(apiKey string) BaseMessage
NewBaseMessageMainnet returns a base message suitable for mainnet usage
type Blockchain ¶
Blockchain is a type fulfilling the blockchain params
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps gorilla websocket connections
func (*Client) EventSub ¶
func (c *Client) EventSub(msg Configuration) error
EventSub creates an event subscription.
func (*Client) Initialize ¶
func (c *Client) Initialize(msg BaseMessage) error
Initialize is used to handle blocknative websockets api initialization note we set CategoryCode and EventCode ourselves.
type Config ¶
type Config struct { // valid Ethereum address or 'global' Scope string `json:"scope"` // A slice of valid filters (jsql: https://github.com/deitch/searchjs) Filters []map[string]string `json:"filters,omitempty"` // JSON abis ABI interface{} `json:"abi,omitempty"` // defines whether the service should automatically watch the address as defined in WatchAddress bool `json:"watchAddress,omitempty"` }
Config provides a specific config instance
type Configuration ¶
type Configuration struct { BaseMessage Config `json:"config"` }
Configuration enables configuration of the blocknative websockets api and wraps the Config type
func NewConfiguration ¶
func NewConfiguration(msg BaseMessage, config Config) Configuration
NewConfiguration constructs a new configuration message
type ConnectResponse ¶
type ConnectResponse struct { ConnectionID string `json:"connectionId"` ServerVersion string `json:"serverVersion"` ShowUX bool `json:"showUX"` Status string `json:"status"` Reason string `json:"reason"` Version int `json:"version"` }
ConnectResponse is the message we receive when opening a connection to the API
type EthTxPayload ¶
type EthTxPayload struct { Version int `json:"version"` ServerVersion string `json:"serverVersion"` TimeStamp time.Time `json:"timeStamp"` ConnectionID string `json:"connectionId"` Status string `json:"status"` Event struct { BaseMessage Transaction struct { Type int `json:"type"` MaxFeePerGas string `json:"maxFeePerGas"` MaxPriorityFeePerGas string `json:"maxPriorityFeePerGas"` BaseFeePerGas string `json:"baseFeePerGas"` TimeStamp time.Time `json:"timeStamp"` Status string `json:"status"` MonitorID string `json:"monitorId"` MonitorVersion string `json:"monitorVersion"` TimePending string `json:"timePending"` PendingTimeStamp time.Time `json:"pendingTimeStamp"` BlocksPending int `json:"blocksPending"` Hash string `json:"hash"` From string `json:"from"` To string `json:"to"` Value string `json:"value"` Gas int `json:"gas"` GasPrice string `json:"gasPrice"` GasPriceGwei int `json:"gasPriceGwei"` Nonce int `json:"nonce"` BlockHash string `json:"blockHash"` BlockNumber int `json:"blockNumber"` TransactionIndex int `json:"transactionIndex"` Input string `json:"input"` GasUsed string `json:"gasUsed"` Asset string `json:"asset"` WatchedAddress string `json:"watchedAddress"` Direction string `json:"direction"` Counterparty string `json:"counterparty"` } `json:"transaction"` } `json:"event"` }
EthTxPayload is payload returned from a subscription to blocknative api
type MsgHistory ¶
type MsgHistory struct {
// contains filtered or unexported fields
}
MsgHistory is used to store a copy of all messages we send such that in the event of connection drops we can re-establish our state
func (*MsgHistory) Len ¶
func (mg *MsgHistory) Len() int
Len returns the length of the msg history buffewr
func (*MsgHistory) Pop ¶
func (mg *MsgHistory) Pop() interface{}
Pop is used to pop a message out of the buffer
func (*MsgHistory) PopAll ¶
func (mg *MsgHistory) PopAll() []interface{}
PopAll returns all elements from the buffer, resetting the buffer
func (*MsgHistory) Push ¶
func (mg *MsgHistory) Push(msg interface{})
Push is used to push a message onto our buffer
type Transaction ¶
type Transaction struct {
Hash string `json:"hash"`
}
Transaction bundles a single tx
type TxSubscribe ¶
type TxSubscribe struct { BaseMessage Transaction `json:"transaction"` }
TxSubscribe is used to subscribe/unsubscribe to transaction id events
func NewTxSubscribe ¶
func NewTxSubscribe(msg BaseMessage, txHash string) TxSubscribe
NewTxSubscribe constructs a Transaction subscription message
func NewTxUnsubscribe ¶
func NewTxUnsubscribe(msg BaseMessage, txHash string) TxSubscribe
NewTxUnsubscribe constructs a Transaciton unsubscribe message