Documentation ¶
Index ¶
- func NetName(id int64) (string, error)
- func NewSubscription(key string) *subscription
- func ParseGas(msg *EthTxPayload) (gasBaseFeeGwei, gasTipGwei float64, err error)
- type Account
- type AddressSubscribe
- type BaseMessage
- type Blockchain
- type Client
- func (c *Client) APIKey() string
- func (c *Client) Close() error
- func (c *Client) Initialize(msg BaseMessage) error
- func (c *Client) KillSubscription(key string)
- func (c *Client) NewAddressSubscription(address string) error
- func (c *Client) NewEventSubscription(msg Configuration) error
- func (c *Client) NewTransactionSubscription(txHash string) error
- func (c *Client) ReadJSON(out interface{}) error
- func (c *Client) SubscriptionRegistry() map[string]Subscription
- func (c *Client) WriteJSON(out interface{}) error
- type Config
- type Configuration
- type ConnectResponse
- type EthTxPayload
- type MsgHistory
- type Opts
- type Subscription
- type Transaction
- type TxSubscribe
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSubscription ¶
func NewSubscription(key string) *subscription
NewSubscription creates a carrier for tracking events
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 NewBaseMessage ¶
func NewBaseMessage(apiKey string, netID int64) (BaseMessage, error)
NewBaseMessage returns a base message for the supplied network ID
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) Initialize ¶
func (c *Client) Initialize(msg BaseMessage) error
Initialize is used to handle blocknative websockets api initialization note we set CategoryCode and EventCode ourselves.
func (*Client) KillSubscription ¶
KillSubscription unsubscribes from the subscription in the registry at the index supplied. Killing the subscription releases the resource for the Client as well notifying block native servers to not monitor for events tracked by the subscription
func (*Client) NewAddressSubscription ¶
NewAddressSubscription creates a new subscription to blocknative for monitoring address activity. the subscription is added to the client's subscription registry which contains an event channel for watched events provided by blocknative servers
func (*Client) NewEventSubscription ¶
func (c *Client) NewEventSubscription(msg Configuration) error
NewEventSubscription creates an event subscription.
func (*Client) NewTransactionSubscription ¶
NewTransactionSubscription creates a new subscription for monitoring a transaction by supplied transaction ID
func (*Client) SubscriptionRegistry ¶
func (c *Client) SubscriptionRegistry() map[string]Subscription
SubscriptionRegistry returns the chached subscription map
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
func NewEventUnsubscribe ¶
func NewEventUnsubscribe(msg BaseMessage, config Config) Configuration
NewEventUnsubscribe constructs an Event unsubscribe 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 Subscription ¶
type Subscription interface { Events() chan interface{} Unsubscribe() Err() chan error }
Subscription represents a stream of events. Implementations carry a channel with which to store events returned by the subscription backend
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