bus

package
v0.0.0-...-e8a7bc5 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BusHardTimeout = 120 * time.Second
View Source
var BusTimeout = 60 * time.Second
View Source
var ErrInvalidMessageData = errors.New("invalid message data")

Functions

func GetTimeLeft

func GetTimeLeft(id int) time.Duration

func Init

func Init()

func ProcessMessages

func ProcessMessages()

func ProcessTimers

func ProcessTimers()

func Subscribe

func Subscribe(topic ...string) chan *Message

func TimerLoop

func TimerLoop(seconds int, every int, cancel_timer int, f func() (any, error, bool)) (any, error)

func Unsubscribe

func Unsubscribe(ch chan *Message)

Types

type B_EthBlockNumber

type B_EthBlockNumber struct {
	Blockchain string
}

type B_EthCall

type B_EthCall struct {
	ChainId int
	From    common.Address
	To      common.Address
	Amount  *big.Int
	Data    []byte
}

type B_EthEstimateGas

type B_EthEstimateGas struct {
	Blockchain string
	From       common.Address
	To         common.Address
	Amount     *big.Int
	Data       []byte
}

type B_EthMultiCall

type B_EthMultiCall struct {
	ChainId int
	From    common.Address
	Amount  *big.Int
	Calls   []B_EthMultiCall_Call
}

type B_EthMultiCall_Call

type B_EthMultiCall_Call struct {
	To   common.Address
	Data []byte
}

type B_EthSend

type B_EthSend struct {
	ChainId int
	Token   string
	From    common.Address
	To      common.Address
	Amount  *big.Int
}

---------- eth ----------

type B_EthSendTx

type B_EthSendTx struct {
	ChainId int
	From    common.Address
	To      common.Address
	Amount  *big.Int
	Data    []byte
}

type B_EthSign

type B_EthSign struct {
	Blockchain string
	Address    common.Address
	Data       []byte
}

type B_EthSignTypedData_v4

type B_EthSignTypedData_v4 struct {
	Blockchain string
	Address    common.Address
	TypedData  apitypes.TypedData
}

type B_EthTxByHash

type B_EthTxByHash struct {
	Blockchain string
	Hash       common.Hash
}

type B_EthTxByHash_Response

type B_EthTxByHash_Response struct {
	BlockHash        string `json:"blockHash"`
	BlockNumber      string `json:"blockNumber"`
	ChainID          int    `json:"chainId"`
	From             string `json:"from"`
	Gas              string `json:"gas"`
	GasPrice         string `json:"gasPrice"`
	Hash             string `json:"hash"`
	Input            string `json:"input"`
	Nonce            string `json:"nonce"`
	To               string `json:"to"`
	TransactionIndex string `json:"transactionIndex"`
	Value            string `json:"value"`
	V                string `json:"v"`
	R                string `json:"r"`
	S                string `json:"s"`
}

type B_ExplorerDownloadContract

type B_ExplorerDownloadContract struct {
	Blockchain string
	Address    common.Address
}

---------- explorer ----------

type B_Hail

type B_Hail struct {
	Priorized      bool
	Title          string
	Template       string
	OnOpen         func(*Message, *gocui.Gui, *gocui.View)
	OnClose        func(*Message)
	OnCancel       func(*Message)
	OnOk           func(*Message, *gocui.View) bool // return true to close hail
	OnSuspend      func(*Message)
	OnResume       func(*Message)
	OnTick         func(*Message, int)
	OnClickHotspot func(*Message, *gocui.View, *gocui.Hotspot)
	OnOverHotspot  func(*Message, *gocui.View, *gocui.Hotspot)
	Suspended      bool
}

type B_LP_V3_Discover

type B_LP_V3_Discover struct {
	ChainId int
	Name    string
}

---------- lp_v3 ----------

type B_LP_V3_GetFactory

type B_LP_V3_GetFactory struct {
	ChainId  int
	Provider common.Address
}

type B_LP_V3_GetFeeGrowth

type B_LP_V3_GetFeeGrowth struct {
	ChainId int
	Pool    common.Address
}

type B_LP_V3_GetFeeGrowth_Response

type B_LP_V3_GetFeeGrowth_Response struct {
	FeeGrowthGlobal0X128, FeeGrowthGlobal1X128 *big.Int
}

type B_LP_V3_GetNftPosition

type B_LP_V3_GetNftPosition struct {
	ChainId   int
	Provider  common.Address
	From      common.Address
	NFT_Token *big.Int
}

type B_LP_V3_GetNftPosition_Response

type B_LP_V3_GetNftPosition_Response struct {
	Nonce                                              *big.Int
	Operator                                           common.Address
	Token0                                             common.Address
	Token1                                             common.Address
	Fee                                                *big.Int
	TickLower, TickUpper                               int64
	Liquidity                                          *big.Int
	FeeGrowthInside0LastX128, FeeGrowthInside1LastX128 *big.Int
	TokensOwed0, TokensOwed1                           *big.Int
}

type B_LP_V3_GetPool

type B_LP_V3_GetPool struct {
	ChainId  int
	Provider common.Address
	Factory  common.Address
	Token0   common.Address
	Token1   common.Address
	Fee      *big.Int
}

type B_LP_V3_GetPoolPosition

type B_LP_V3_GetPoolPosition struct {
	ChainId              int
	Provider             common.Address
	Pool                 common.Address
	TickLower, TickUpper int64
}

type B_LP_V3_GetPoolPosition_Response

type B_LP_V3_GetPoolPosition_Response struct {
	Liquidity                                          *big.Int
	FeeGrowthInside0LastX128, FeeGrowthInside1LastX128 *big.Int
	TokensOwed0, TokensOwed1                           *big.Int
}

type B_LP_V3_GetPositionStatus

type B_LP_V3_GetPositionStatus struct {
	ChainId   int
	Provider  common.Address
	NFT_Token *big.Int
}

type B_LP_V3_GetPositionStatus_Response

type B_LP_V3_GetPositionStatus_Response struct {
	Owner             common.Address
	ChainId           int
	Token0            common.Address
	Token1            common.Address
	Provider          common.Address
	On                bool
	Liquidity0        *big.Int
	Liquidity1        *big.Int
	Liquidity0Dollars float64
	Liquidity1Dollars float64
	Gain0             *big.Int
	Gain1             *big.Int
	Gain0Dollars      float64
	Gain1Dollars      float64
	ProviderName      string
	FeeProtocol0      float32 // percentage
	FeeProtocol1      float32 // percentage
}

type B_LP_V3_GetSlot0

type B_LP_V3_GetSlot0 struct {
	ChainId int
	Pool    common.Address
}

type B_LP_V3_GetSlot0_Response

type B_LP_V3_GetSlot0_Response struct {
	SqrtPriceX96 *big.Int
	Tick         int64
	FeeProtocol0 float32 // percentage
	FeeProtocol1 float32 // percentage
	Unlocked     bool
}

type B_LP_V3_GetTick

type B_LP_V3_GetTick struct {
	ChainId int
	Pool    common.Address
	Tick    int64
}

type B_LP_V3_GetTick_Response

type B_LP_V3_GetTick_Response struct {
	LiquidityGross, LiquidityNet                 *big.Int
	FeeGrowthOutside0X128, FeeGrowthOutside1X128 *big.Int
	TickCumulativeOutside                        *big.Int
	SecondsPerLiquidityOutsideX128               *big.Int
	SecondsOutside                               uint32
	Initialized                                  bool
}

type B_SignerConnected

type B_SignerConnected struct {
	Type string
	Name string
}

type B_SignerGetAddresses

type B_SignerGetAddresses struct {
	Type      string
	Name      string
	MasterKey string
	Path      string
	StartFrom int
	Count     int
}

---------- signer ----------

type B_SignerGetAddresses_Response

type B_SignerGetAddresses_Response struct {
	Addresses []common.Address
	Paths     []string
}

type B_SignerIsConnected

type B_SignerIsConnected struct {
	Type string
	Name string
}

type B_SignerIsConnected_Response

type B_SignerIsConnected_Response struct {
	Connected bool
}

type B_SignerList

type B_SignerList struct {
	Type string
}

type B_SignerList_Response

type B_SignerList_Response struct {
	Names []string
}

type B_SignerSign

type B_SignerSign struct {
	Type      string
	Name      string
	MasterKey string
	Address   common.Address
	Path      string
	Data      []byte
}

type B_SignerSignTx

type B_SignerSignTx struct {
	Type      string
	Name      string
	MasterKey string
	Chain     string
	Tx        *types.Transaction
	From      common.Address
	Path      string
}

type B_SignerSignTypedData_v4

type B_SignerSignTypedData_v4 struct {
	Type      string
	Name      string
	MasterKey string
	Address   common.Address
	Path      string
	TypedData apitypes.TypedData
}

type B_TimerInit

type B_TimerInit struct {
	Limit     time.Duration
	HardLimit time.Duration
	Start     bool
}

---------- timer ----------

type B_TimerInitHard

type B_TimerInitHard struct {
	TimerId   int
	Limit     time.Duration
	HardLimit time.Duration
	Start     bool
}

type B_TimerTick

type B_TimerTick struct {
	Tick int
	Left map[int]time.Duration // id -> seconds left
}

type B_UsbConnected

type B_UsbConnected struct {
	USB_ID  string
	Vendor  string
	Product string
}

type B_UsbDisconnected

type B_UsbDisconnected struct {
	USB_ID string
}

type B_UsbIsConnected

type B_UsbIsConnected struct {
	USB_ID string
}

type B_UsbIsConnected_Response

type B_UsbIsConnected_Response struct {
	Connected bool
}

type B_UsbList_Device

type B_UsbList_Device struct {
	USB_ID    string
	Path      string
	Vendor    string
	VendorID  uint16
	Product   string
	ProductID uint16
	Connected bool
}

---------- usb ----------

type B_UsbList_Response

type B_UsbList_Response []B_UsbList_Device

type B_UsbRead

type B_UsbRead struct {
	USB_ID string
}

type B_UsbRead_Response

type B_UsbRead_Response struct {
	Data []byte
}

type B_UsbWrite

type B_UsbWrite struct {
	USB_ID string
	Data   []byte
}

type B_WsList_Conn

type B_WsList_Conn struct {
	Agent string
}

---------- ws ----------

type B_WsList_Response

type B_WsList_Response []B_WsList_Conn

type Bus

type Bus struct {
	Subscribers map[string][]chan *Message //topic -> subscribers
	M           sync.Mutex
	In          chan *Message
	NextID      int
}

type BusTimer

type BusTimer struct {
	Limit     time.Duration
	HardLimit time.Duration
	// contains filtered or unexported fields
}

type Message

type Message struct {
	ID    int
	Topic string
	Type  string
	Data  interface{}

	TimerID   int
	Error     error
	RespondTo int

	OnCancel func(m *Message)
}

func Fetch

func Fetch(topic, t string, data interface{}) *Message

func FetchEx

func FetchEx(topic, t string, data interface{}, timer_id int, limit time.Duration, hardlimit time.Duration) *Message

func Send

func Send(topic, t string, data interface{}) *Message

func SendEx

func SendEx(topic, t string, data interface{}, timer_id int, respond_to int, err error) *Message

func (*Message) Cancel

func (m *Message) Cancel()

func (*Message) Fetch

func (m *Message) Fetch(topic, t string, data interface{}) *Message

Chain fetch (on the same timer)

func (*Message) Respond

func (m *Message) Respond(data interface{}, err error) *Message

type Subscriber

type Subscriber interface {
	Notify(msg Message)
}

Jump to

Keyboard shortcuts

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