Documentation
¶
Index ¶
- Constants
- Variables
- func CreateEventMapper(eventFactory EventFactory, abi *abi.ABI) func(log types.Log) (interface{}, error)
- func GetOngoingDeliveryRange(firstDeliveryDate time.Time, deliveryInterval time.Duration, now time.Time) (start time.Time, end time.Time)
- func UnpackLog(out interface{}, event string, log types.Log, ab *abi.ABI) error
- type CloseDeliveryReq
- type CloseListererFunc
- type CloseReason
- type CloseoutType
- type ContractSpecs
- type DataAccess
- type EthereumClient
- type EventFactory
- type EventMapper
- type FuturesContract
- type FuturesEthereum
- func (g *FuturesEthereum) BatchCloseDelivery(ctx context.Context, reqs []CloseDeliveryReq, privKey string) error
- func (g *FuturesEthereum) ClaimReward(ctx context.Context, deliveryDate time.Time, privKey string) error
- func (g *FuturesEthereum) CloseDelivery(ctx context.Context, positionID common.Hash, blameSeller bool, privKey string) error
- func (g *FuturesEthereum) CreateFuturesSubscription(ctx context.Context, futuresAddr common.Address) (*lib.Subscription, error)
- func (g *FuturesEthereum) GetContractSpecs(ctx context.Context) (*ContractSpecs, error)
- func (g *FuturesEthereum) GetMatchedContracts(ctx context.Context, userAddress common.Address, deliveryDate time.Time) ([]FuturesContract, error)
- func (g *FuturesEthereum) GetOngoingDeliveryRange(ctx context.Context) (start time.Time, end time.Time, duration time.Duration, err error)
- func (g *FuturesEthereum) GetPosition(ctx context.Context, positionID common.Hash) (*FuturesContract, error)
- func (g *FuturesEthereum) GetToken(ctx context.Context) (common.Address, error)
- func (g *FuturesEthereum) SetLegacyTx(legacyTx bool)
- type HashrateEthereum
- func (g *HashrateEthereum) ClaimValidatorReward(ctx context.Context, contractID string, privKey string) error
- func (s *HashrateEthereum) CreateCloneFactorySubscription(ctx context.Context, clonefactoryAddr common.Address) (*lib.Subscription, error)
- func (s *HashrateEthereum) CreateImplementationSubscription(ctx context.Context, contractAddr common.Address) (*lib.Subscription, error)
- func (g *HashrateEthereum) EarlyClose(ctx context.Context, contractID string, reason CloseReason, privKey string) error
- func (g *HashrateEthereum) GetContract(ctx context.Context, contractID string) (*hashrate.EncryptedTerms, error)
- func (g *HashrateEthereum) GetContractsIDs(ctx context.Context) ([]string, error)
- func (g *HashrateEthereum) GetFeeToken(ctx context.Context) (common.Address, error)
- func (g *HashrateEthereum) GetPaymentToken(ctx context.Context) (common.Address, error)
- func (g *HashrateEthereum) SetLegacyTx(legacyTx bool)
- type LogWatcher
- type LogWatcherPolling
- type LogWatcherSubscription
Constants ¶
View Source
const RECONNECT_TIMEOUT = 2 * time.Second
Variables ¶
View Source
var ( ErrNoEventSignature = errors.New("no event signature") ErrEventSignatureMismatch = errors.New("event signature mismatch") )
View Source
var AllContractsMeta = []lib.Meta{ futures.FuturesMetaData, multicall3.Multicall3MetaData, hashrateoracle.HashrateoracleMetaData, ierc20.Ierc20MetaData, aggregatorv3interface.Aggregatorv3interfaceMetaData, }
AllContractsMeta is an array of all contracts metadata to be used for decoding errors
View Source
var (
ErrNotRunning = fmt.Errorf("the contract is not in the running state")
)
View Source
var (
ErrUnknownEvent = errors.New("unknown event")
)
View Source
var (
SubClosedError = errors.New("subscription closed")
)
Functions ¶
func CreateEventMapper ¶
func GetOngoingDeliveryRange ¶ added in v1.9.0
Types ¶
type CloseDeliveryReq ¶ added in v1.9.0
type CloseListererFunc ¶
type CloseListererFunc = func()
type CloseReason ¶
type CloseReason uint8
const ( CloseReasonUnspecified CloseReason = 0 CloseReasonUnderdelivery CloseReason = 1 )
type CloseoutType ¶
type CloseoutType uint8
const ( CloseoutTypeCancel CloseoutType = 0 // to be triggered by the buyer or validator if a contract needs to be canceled early for any reason CloseoutTypeOnlyWithdraw CloseoutType = 1 // to be triggered by the seller to withdraw funds at any time during the smart contracts lifecycle (contract is not closing) CloseoutTypeWithoutClaim CloseoutType = 2 // closeout without claiming funds CloseoutTypeWithClaim CloseoutType = 3 // closeout with claiming funds )
type ContractSpecs ¶ added in v1.9.0
type DataAccess ¶
type DataAccess interface {
// string used as address cause different blockchains may return different type of addresses
GetContractsIDs() ([]string, error)
GetContract(contractID string) (interface{}, error)
CloseContract(contractID string, meta interface{}) error
OnNewContract(func(contractID string)) CloseListererFunc
OnContractUpdated(contractID string, cb func()) CloseListererFunc
OnContractClosed(contractID string, cb func()) CloseListererFunc
}
type EthereumClient ¶
type EthereumClient interface {
bind.ContractBackend
bind.DeployBackend
ChainID(ctx context.Context) (*big.Int, error)
BalanceAt(ctx context.Context, addr common.Address, blockNumber *big.Int) (*big.Int, error)
StorageAt(ctx context.Context, account common.Address, key common.Hash, blockNumber *big.Int) ([]byte, error)
}
type EventFactory ¶
type EventFactory func(name string) interface{}
type EventMapper ¶
type FuturesContract ¶ added in v1.9.0
type FuturesContract struct {
ContractID common.Hash
Seller common.Address
Buyer common.Address
DestURL string
DeliveryAt time.Time
Paid bool
}
func (*FuturesContract) ID ¶ added in v1.9.0
func (fc *FuturesContract) ID() string
type FuturesEthereum ¶ added in v1.9.0
type FuturesEthereum struct {
// contains filtered or unexported fields
}
func NewFuturesEthereum ¶ added in v1.9.0
func NewFuturesEthereum(futuresAddr common.Address, multicalladdr common.Address, client EthereumClient, logWatcher LogWatcher, log interfaces.ILogger) *FuturesEthereum
func (*FuturesEthereum) BatchCloseDelivery ¶ added in v1.9.0
func (g *FuturesEthereum) BatchCloseDelivery(ctx context.Context, reqs []CloseDeliveryReq, privKey string) error
func (*FuturesEthereum) ClaimReward ¶ added in v1.9.0
func (*FuturesEthereum) CloseDelivery ¶ added in v1.9.0
func (*FuturesEthereum) CreateFuturesSubscription ¶ added in v1.9.0
func (g *FuturesEthereum) CreateFuturesSubscription(ctx context.Context, futuresAddr common.Address) (*lib.Subscription, error)
func (*FuturesEthereum) GetContractSpecs ¶ added in v1.9.0
func (g *FuturesEthereum) GetContractSpecs(ctx context.Context) (*ContractSpecs, error)
func (*FuturesEthereum) GetMatchedContracts ¶ added in v1.9.0
func (g *FuturesEthereum) GetMatchedContracts(ctx context.Context, userAddress common.Address, deliveryDate time.Time) ([]FuturesContract, error)
func (*FuturesEthereum) GetOngoingDeliveryRange ¶ added in v1.9.0
func (g *FuturesEthereum) GetOngoingDeliveryRange(ctx context.Context) (start time.Time, end time.Time, duration time.Duration, err error)
GetOngoingDeliveryRange returns the start and end of the ongoing delivery range
func (*FuturesEthereum) GetPosition ¶ added in v1.9.0
func (g *FuturesEthereum) GetPosition(ctx context.Context, positionID common.Hash) (*FuturesContract, error)
func (*FuturesEthereum) SetLegacyTx ¶ added in v1.9.0
func (g *FuturesEthereum) SetLegacyTx(legacyTx bool)
type HashrateEthereum ¶
type HashrateEthereum struct {
// contains filtered or unexported fields
}
func NewHashrateEthereum ¶
func NewHashrateEthereum(clonefactoryAddr common.Address, client EthereumClient, logWatcher LogWatcher, log interfaces.ILogger) *HashrateEthereum
func (*HashrateEthereum) ClaimValidatorReward ¶
func (*HashrateEthereum) CreateCloneFactorySubscription ¶
func (s *HashrateEthereum) CreateCloneFactorySubscription(ctx context.Context, clonefactoryAddr common.Address) (*lib.Subscription, error)
func (*HashrateEthereum) CreateImplementationSubscription ¶
func (s *HashrateEthereum) CreateImplementationSubscription(ctx context.Context, contractAddr common.Address) (*lib.Subscription, error)
func (*HashrateEthereum) EarlyClose ¶
func (g *HashrateEthereum) EarlyClose(ctx context.Context, contractID string, reason CloseReason, privKey string) error
func (*HashrateEthereum) GetContract ¶
func (g *HashrateEthereum) GetContract(ctx context.Context, contractID string) (*hashrate.EncryptedTerms, error)
func (*HashrateEthereum) GetContractsIDs ¶
func (g *HashrateEthereum) GetContractsIDs(ctx context.Context) ([]string, error)
func (*HashrateEthereum) GetFeeToken ¶ added in v1.8.0
func (*HashrateEthereum) GetPaymentToken ¶ added in v1.8.0
func (*HashrateEthereum) SetLegacyTx ¶
func (g *HashrateEthereum) SetLegacyTx(legacyTx bool)
type LogWatcher ¶ added in v1.9.0
type LogWatcher interface {
Watch(ctx context.Context, contractAddr common.Address, mapper EventMapper, fromBlock *big.Int) (*lib.Subscription, error)
}
type LogWatcherPolling ¶ added in v1.9.0
type LogWatcherPolling struct {
// contains filtered or unexported fields
}
func NewLogWatcherPolling ¶ added in v1.9.0
func (*LogWatcherPolling) Watch ¶ added in v1.9.0
func (w *LogWatcherPolling) Watch(ctx context.Context, contractAddr common.Address, mapper EventMapper, fromBlock *big.Int) (*lib.Subscription, error)
type LogWatcherSubscription ¶ added in v1.9.0
type LogWatcherSubscription struct {
// contains filtered or unexported fields
}
func NewLogWatcherSubscription ¶ added in v1.9.0
func NewLogWatcherSubscription(client i.EthClient, maxReconnects int, log i.ILogger) *LogWatcherSubscription
NewLogWatcherSubscription creates a new log subscription using websocket TODO: if it is going to be primary implementation we should rewrite it so it doesn't skip events in case of temporary downtime
func (*LogWatcherSubscription) Watch ¶ added in v1.9.0
func (w *LogWatcherSubscription) Watch(ctx context.Context, contractAddr common.Address, mapper EventMapper, fromBlock *big.Int) (*lib.Subscription, error)
Click to show internal directories.
Click to hide internal directories.