blockchain

package
v0.4.25 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2019 License: GPL-3.0 Imports: 25 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DealOpenedTopic               = common.HexToHash("0xb9ffc65567b7238dd641372277b8c93ed03df73945932dd84fd3cbb33f3eddbf")
	DealUpdatedTopic              = common.HexToHash("0x0b27183934cfdbeb1fbbe288c2e163ed7aa8f458a954054970f78446bccb36e0")
	OrderPlacedTopic              = common.HexToHash("0xffa896d8919f0556f53ace1395617969a3b53ab5271a085e28ac0c4a3724e63d")
	OrderUpdatedTopic             = common.HexToHash("0xb8b459bc0688c37baf5f735d17f1711684bc14ab7db116f88bc18bf409b9309a")
	DealChangeRequestSentTopic    = common.HexToHash("0x7ff56b2eb3ce318aad93d0ba39a3e4a406992a136f9554f17f6bcc43509275d1")
	DealChangeRequestUpdatedTopic = common.HexToHash("0x4b92d35447745e95b7344414a41ae94984787d0ebcd2c12021169197bb59af39")
	BilledTopic                   = common.HexToHash("0x51f87cd83a2ce6c4ff7957861f7aba400dc3857d2325e0c94cc69f468874515c")
	WorkerAnnouncedTopic          = common.HexToHash("0xe398d33bf7e881cdfc9f34c743822904d4e45a0be0db740dd88cb132e4ce2ed9")
	WorkerConfirmedTopic          = common.HexToHash("0x4940ef08d5aed63b7d3d3db293d69d6ed1d624995b90e9e944839c8ea0ae450d")
	WorkerRemovedTopic            = common.HexToHash("0x7822736ed69a5fe0ad6dc2c6669e8053495d711118e5435b047f9b83deda4c37")
	NumBenchmarksUpdatedTopic     = common.HexToHash("0x1acf16d0a0451282e1d2cac3f5473ca7c931bcda610ff6e061041af50e2abc13")
)

Market topics

View Source
var (
	PayinTopic   = common.HexToHash("0x14312725abbc46ad798bc078b2663e1fcbace97be0247cd177176f3b4df2538e")
	PayoutTopic  = common.HexToHash("0x731af16374848c2c73a6154fd410cb421138e7db45c5a904e5a475c756faa8d9")
	SuicideTopic = common.HexToHash("0xa1ea9b09ea114021983e9ecf71cf2ffddfd80f5cb4f925e5bf24f9bdb5e55fde")
)

Gatekeeper topics

View Source
var (
	AddedToBlacklistTopic     = common.HexToHash("0x708802ac7da0a63d9f6b2df693b53345ad263e42d74c245110e1ec1e03a1567e")
	RemovedFromBlacklistTopic = common.HexToHash("0x576a9aef294e1b4baf3617fde4cbc80ba5344d5eb508222f29e558981704a457")
)

Blacklist topics

View Source
var (
	ValidatorCreatedTopic   = common.HexToHash("0x02db26aafd16e8ecd93c4fa202917d50b1693f30b1594e57f7a432ede944eefc")
	ValidatorDeletedTopic   = common.HexToHash("0xa7a579573d398d7b67cd7450121bb250bbd060b29eabafdebc3ce0918658635c")
	CertificateCreatedTopic = common.HexToHash("0xb9bb1df26fde5c1295a7ccd167330e5d6cb9df14fe4c3884669a64433cc9e760")
	CertificateUpdatedTopic = common.HexToHash("0x9a100d2018161ede6ca34c8007992b09bbffc636a636014a922e4c8750412628")
)

ProfileRegistry topics

View Source
var (
	TransferTopic = common.HexToHash("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef")
	ApprovalTopic = common.HexToHash("0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925")
)

StandardToken topics

View Source
var (
	ConfirmationTopic      = common.HexToHash("0x4a504a94899432a9846e1aa406dceb1bcfd538bb839071d49d1e5e23f5be30ef")
	RevocationTopic        = common.HexToHash("0xf6a317157440607f36269043eb55f1287a5a19ba2216afeab88cd46cbcfb88e9")
	SubmissionTopic        = common.HexToHash("0xc0ba8fe4b176c1714197d43b9cc6bcf797a4a7461c5fe8d0ef6e184ae7601e51")
	ExecutionTopic         = common.HexToHash("0x33e13ecb54c3076d8e8bb8c2881800a4d972b792045ffae98fdf46df365fed75")
	ExecutionFailureTopic  = common.HexToHash("0x526441bb6c1aba3c9a4a6ca1d6545da9c2333c8c48343ef398eb858d72b79236")
	DepositTopic           = common.HexToHash("0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c")
	OwnerAdditionTopic     = common.HexToHash("0xf39e6e1eb0edcf53c221607b54b00cd28f3196fed0a24994dc308b8f611b682d")
	OwnerRemovalTopic      = common.HexToHash("0x8001553a916ef2f495d26a907cc54d96ed840d7bda71e73194bf5a9df7a76b90")
	RequirementChangeTopic = common.HexToHash("0xa3f1ee9126a074d9326c682f561767f710e927faa811f7a99829d49dc421797a")
)

MultiSig topics

View Source
var (
	Wei    = Unit{Int: big.NewInt(1)}
	KWei   = Unit{Int: new(big.Int).Exp(big.NewInt(10), big.NewInt(3), nil)}
	MWei   = Unit{Int: new(big.Int).Exp(big.NewInt(10), big.NewInt(6), nil)}
	GWei   = Unit{Int: new(big.Int).Exp(big.NewInt(10), big.NewInt(9), nil)}
	Szabo  = Unit{Int: new(big.Int).Exp(big.NewInt(10), big.NewInt(12), nil)}
	Finney = Unit{Int: new(big.Int).Exp(big.NewInt(10), big.NewInt(15), nil)}
	Ether  = Unit{Int: new(big.Int).Exp(big.NewInt(10), big.NewInt(18), nil)}
	KEther = Unit{Int: new(big.Int).Exp(big.NewInt(10), big.NewInt(21), nil)}
	MEther = Unit{Int: new(big.Int).Exp(big.NewInt(10), big.NewInt(24), nil)}
	GEther = Unit{Int: new(big.Int).Exp(big.NewInt(10), big.NewInt(27), nil)}
)
View Source
var (
	GiveAwayTopic = common.HexToHash("0xe08e9d066634006283658128ec91f58d444719d7a07d49f72924da4352ff94ad")
)

SNMT topics

View Source
var (
	OwnershipTransferredTopic = common.HexToHash("0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0")
)

Ownable topics

Functions

func FindLogByTopic added in v0.4.1

func FindLogByTopic(txReceipt *Receipt, topic common.Hash) (*types.Log, error)

FindLogByTopic safety search log in transaction receipt return error if transaction failed return error if topic doesn't contain in receipt

func WaitTxAndExtractLog added in v0.4.1

func WaitTxAndExtractLog(ctx context.Context, client CustomEthereumClient, confirmations int64, logParsePeriod time.Duration, tx *types.Transaction, topic common.Hash) (*types.Log, error)

WaitTxAndExtractLog await transaction mining and extract log contains for given topic this func is composition of FindLogByTopic and WaitTransactionReceipt

Types

type API added in v0.4.1

type API interface {
	ProfileRegistry() ProfileRegistryAPI
	Events() EventsAPI
	Market() MarketAPI
	Blacklist() BlacklistAPI
	MasterchainToken() TokenAPI
	SidechainToken() TokenAPI
	OracleUSD() OracleAPI
	MasterchainGate() SimpleGatekeeperAPI
	SidechainGate() SimpleGatekeeperAPI
	OracleMultiSig() MultiSigAPI
	ContractRegistry() ContractRegistry
}

func NewAPI

func NewAPI(ctx context.Context, opts ...Option) (API, error)

type AddedToBlacklistData added in v0.4.1

type AddedToBlacklistData struct {
	AdderID common.Address
	AddeeID common.Address
}

type Balance added in v0.4.5

type Balance struct {
	Eth *big.Int
	SNM *big.Int
}

type BasicAPI added in v0.4.1

type BasicAPI struct {
	// contains filtered or unexported fields
}

func (*BasicAPI) Blacklist added in v0.4.1

func (api *BasicAPI) Blacklist() BlacklistAPI

func (*BasicAPI) ContractRegistry added in v0.4.1

func (api *BasicAPI) ContractRegistry() ContractRegistry

func (*BasicAPI) Events added in v0.4.1

func (api *BasicAPI) Events() EventsAPI

func (*BasicAPI) Market added in v0.4.1

func (api *BasicAPI) Market() MarketAPI

func (*BasicAPI) MasterchainGate added in v0.4.1

func (api *BasicAPI) MasterchainGate() SimpleGatekeeperAPI

func (*BasicAPI) MasterchainToken added in v0.4.1

func (api *BasicAPI) MasterchainToken() TokenAPI

func (*BasicAPI) OracleMultiSig added in v0.4.1

func (api *BasicAPI) OracleMultiSig() MultiSigAPI

func (*BasicAPI) OracleUSD added in v0.4.1

func (api *BasicAPI) OracleUSD() OracleAPI

func (*BasicAPI) ProfileRegistry added in v0.4.1

func (api *BasicAPI) ProfileRegistry() ProfileRegistryAPI

func (*BasicAPI) SidechainGate added in v0.4.1

func (api *BasicAPI) SidechainGate() SimpleGatekeeperAPI

func (*BasicAPI) SidechainToken added in v0.4.1

func (api *BasicAPI) SidechainToken() TokenAPI

type BasicBlacklistAPI added in v0.4.1

type BasicBlacklistAPI struct {
	// contains filtered or unexported fields
}

func (*BasicBlacklistAPI) Add added in v0.4.1

func (*BasicBlacklistAPI) AddMaster added in v0.4.1

func (api *BasicBlacklistAPI) AddMaster(ctx context.Context, key *ecdsa.PrivateKey, root common.Address) (*types.Transaction, error)

func (*BasicBlacklistAPI) Check added in v0.4.1

func (api *BasicBlacklistAPI) Check(ctx context.Context, who, whom common.Address) (bool, error)

func (*BasicBlacklistAPI) Remove added in v0.4.1

func (api *BasicBlacklistAPI) Remove(ctx context.Context, key *ecdsa.PrivateKey, whom common.Address) error

func (*BasicBlacklistAPI) RemoveMaster added in v0.4.1

func (api *BasicBlacklistAPI) RemoveMaster(ctx context.Context, key *ecdsa.PrivateKey, root common.Address) (*types.Transaction, error)

func (*BasicBlacklistAPI) SetMarketAddress added in v0.4.1

func (api *BasicBlacklistAPI) SetMarketAddress(ctx context.Context, key *ecdsa.PrivateKey, market common.Address) (*types.Transaction, error)

type BasicContractRegistry added in v0.4.1

type BasicContractRegistry struct {
	// contains filtered or unexported fields
}

func NewRegistry added in v0.4.1

func NewRegistry(ctx context.Context, address common.Address, opts *chainOpts) (*BasicContractRegistry, error)

func (*BasicContractRegistry) BlacklistAddress added in v0.4.1

func (m *BasicContractRegistry) BlacklistAddress() common.Address

func (*BasicContractRegistry) GatekeeperMasterchainAddress added in v0.4.1

func (m *BasicContractRegistry) GatekeeperMasterchainAddress() common.Address

func (*BasicContractRegistry) GatekeeperSidechainAddress added in v0.4.1

func (m *BasicContractRegistry) GatekeeperSidechainAddress() common.Address

func (*BasicContractRegistry) MarketAddress added in v0.4.1

func (m *BasicContractRegistry) MarketAddress() common.Address

func (*BasicContractRegistry) MasterchainSNMAddress added in v0.4.1

func (m *BasicContractRegistry) MasterchainSNMAddress() common.Address

func (*BasicContractRegistry) OracleMultiSig added in v0.4.1

func (m *BasicContractRegistry) OracleMultiSig() common.Address

func (*BasicContractRegistry) OracleUsdAddress added in v0.4.1

func (m *BasicContractRegistry) OracleUsdAddress() common.Address

func (*BasicContractRegistry) ProfileRegistryAddress added in v0.4.1

func (m *BasicContractRegistry) ProfileRegistryAddress() common.Address

func (*BasicContractRegistry) SidechainSNMAddress added in v0.4.1

func (m *BasicContractRegistry) SidechainSNMAddress() common.Address

func (*BasicContractRegistry) TestnetFaucetAddress added in v0.4.1

func (m *BasicContractRegistry) TestnetFaucetAddress() common.Address

type BasicEventsAPI added in v0.4.1

type BasicEventsAPI struct {
	// contains filtered or unexported fields
}

func (*BasicEventsAPI) GetEvents added in v0.4.1

func (api *BasicEventsAPI) GetEvents(ctx context.Context, filter *EventFilter) (chan *Event, error)

func (*BasicEventsAPI) GetLastBlock added in v0.4.1

func (api *BasicEventsAPI) GetLastBlock(ctx context.Context) (uint64, error)

func (*BasicEventsAPI) GetMarketFilter added in v0.4.1

func (api *BasicEventsAPI) GetMarketFilter(fromBlock *big.Int) *EventFilter

func (*BasicEventsAPI) GetMultiSigFilter added in v0.4.1

func (api *BasicEventsAPI) GetMultiSigFilter(addresses []common.Address, fromBlock *big.Int) *EventFilter

type BasicMarketAPI added in v0.4.1

type BasicMarketAPI struct {
	// contains filtered or unexported fields
}

func (*BasicMarketAPI) Bill added in v0.4.1

func (api *BasicMarketAPI) Bill(ctx context.Context, key *ecdsa.PrivateKey, dealID *big.Int) error

func (*BasicMarketAPI) CancelChangeRequest added in v0.4.1

func (api *BasicMarketAPI) CancelChangeRequest(ctx context.Context, key *ecdsa.PrivateKey, id *big.Int) error

func (*BasicMarketAPI) CancelOrder added in v0.4.1

func (api *BasicMarketAPI) CancelOrder(ctx context.Context, key *ecdsa.PrivateKey, id *big.Int) error

func (*BasicMarketAPI) CloseDeal added in v0.4.1

func (api *BasicMarketAPI) CloseDeal(ctx context.Context, key *ecdsa.PrivateKey, dealID *big.Int, blacklistType sonm.BlacklistType) error

func (*BasicMarketAPI) ConfirmWorker added in v0.4.1

func (api *BasicMarketAPI) ConfirmWorker(ctx context.Context, key *ecdsa.PrivateKey, slave common.Address) error

func (*BasicMarketAPI) CreateChangeRequest added in v0.4.1

func (api *BasicMarketAPI) CreateChangeRequest(ctx context.Context, key *ecdsa.PrivateKey, req *sonm.DealChangeRequest) (*big.Int, error)

func (*BasicMarketAPI) GetDealChangeRequestInfo added in v0.4.1

func (api *BasicMarketAPI) GetDealChangeRequestInfo(ctx context.Context, changeRequestID *big.Int) (*sonm.DealChangeRequest, error)

func (*BasicMarketAPI) GetDealInfo added in v0.4.1

func (api *BasicMarketAPI) GetDealInfo(ctx context.Context, dealID *big.Int) (*sonm.Deal, error)

func (*BasicMarketAPI) GetDealsAmount added in v0.4.1

func (api *BasicMarketAPI) GetDealsAmount(ctx context.Context) (*big.Int, error)

func (*BasicMarketAPI) GetMaster added in v0.4.1

func (api *BasicMarketAPI) GetMaster(ctx context.Context, slave common.Address) (common.Address, error)

func (*BasicMarketAPI) GetNumBenchmarks added in v0.4.1

func (api *BasicMarketAPI) GetNumBenchmarks(ctx context.Context) (uint64, error)

func (*BasicMarketAPI) GetOrderInfo added in v0.4.1

func (api *BasicMarketAPI) GetOrderInfo(ctx context.Context, orderID *big.Int) (*sonm.Order, error)

func (*BasicMarketAPI) GetOrdersAmount added in v0.4.1

func (api *BasicMarketAPI) GetOrdersAmount(ctx context.Context) (*big.Int, error)

func (*BasicMarketAPI) OpenDeal added in v0.4.1

func (api *BasicMarketAPI) OpenDeal(ctx context.Context, key *ecdsa.PrivateKey, askID, bidID *big.Int) (*sonm.Deal, error)

func (*BasicMarketAPI) PlaceOrder added in v0.4.1

func (api *BasicMarketAPI) PlaceOrder(ctx context.Context, key *ecdsa.PrivateKey, order *sonm.Order) (*sonm.Order, error)

func (*BasicMarketAPI) QuickBuy added in v0.4.1

func (api *BasicMarketAPI) QuickBuy(ctx context.Context, key *ecdsa.PrivateKey, askId *big.Int, duration uint64) (*sonm.Deal, error)

func (*BasicMarketAPI) RegisterWorker added in v0.4.1

func (api *BasicMarketAPI) RegisterWorker(ctx context.Context, key *ecdsa.PrivateKey, master common.Address) error

func (*BasicMarketAPI) RemoveWorker added in v0.4.1

func (api *BasicMarketAPI) RemoveWorker(ctx context.Context, key *ecdsa.PrivateKey, master, slave common.Address) error

type BasicMultiSigAPI added in v0.4.1

type BasicMultiSigAPI struct {
	// contains filtered or unexported fields
}

func (*BasicMultiSigAPI) AddOwner added in v0.4.1

func (api *BasicMultiSigAPI) AddOwner(ctx context.Context, key *ecdsa.PrivateKey, owner common.Address) error

func (*BasicMultiSigAPI) ChangeRequirement added in v0.4.1

func (api *BasicMultiSigAPI) ChangeRequirement(ctx context.Context, key *ecdsa.PrivateKey, required *big.Int) error

func (*BasicMultiSigAPI) ConfirmTransaction added in v0.4.1

func (api *BasicMultiSigAPI) ConfirmTransaction(ctx context.Context, key *ecdsa.PrivateKey, transactionID *big.Int) error

func (*BasicMultiSigAPI) ExecuteTransaction added in v0.4.1

func (api *BasicMultiSigAPI) ExecuteTransaction(ctx context.Context, key *ecdsa.PrivateKey, transactionID *big.Int) error

func (*BasicMultiSigAPI) GetConfirmationCount added in v0.4.1

func (api *BasicMultiSigAPI) GetConfirmationCount(ctx context.Context, transactionID *big.Int) (*big.Int, error)

func (*BasicMultiSigAPI) GetConfirmations added in v0.4.1

func (api *BasicMultiSigAPI) GetConfirmations(ctx context.Context, transactionID *big.Int) ([]common.Address, error)

func (*BasicMultiSigAPI) GetOwners added in v0.4.1

func (api *BasicMultiSigAPI) GetOwners(ctx context.Context) ([]common.Address, error)

func (*BasicMultiSigAPI) GetTransaction added in v0.4.1

func (api *BasicMultiSigAPI) GetTransaction(ctx context.Context, transactionID *big.Int) (*MultiSigTransactionData, error)

func (*BasicMultiSigAPI) GetTransactionCount added in v0.4.1

func (api *BasicMultiSigAPI) GetTransactionCount(ctx context.Context, penging bool, executed bool) (*big.Int, error)

func (*BasicMultiSigAPI) GetTransactionIDs added in v0.4.1

func (api *BasicMultiSigAPI) GetTransactionIDs(ctx context.Context, from *big.Int, to *big.Int, pending bool, executed bool) ([]*big.Int, error)

func (*BasicMultiSigAPI) IsConfirmed added in v0.4.1

func (api *BasicMultiSigAPI) IsConfirmed(ctx context.Context, transactionID *big.Int) (bool, error)

func (*BasicMultiSigAPI) RemoveOwner added in v0.4.1

func (api *BasicMultiSigAPI) RemoveOwner(ctx context.Context, key *ecdsa.PrivateKey, owner common.Address) error

func (*BasicMultiSigAPI) ReplaceOwner added in v0.4.1

func (api *BasicMultiSigAPI) ReplaceOwner(ctx context.Context, key *ecdsa.PrivateKey, owner common.Address, newOwner common.Address) error

func (*BasicMultiSigAPI) RevokeConfirmation added in v0.4.1

func (api *BasicMultiSigAPI) RevokeConfirmation(ctx context.Context, key *ecdsa.PrivateKey, transactionID *big.Int) error

func (*BasicMultiSigAPI) SubmitTransaction added in v0.4.1

func (api *BasicMultiSigAPI) SubmitTransaction(ctx context.Context, key *ecdsa.PrivateKey, destination common.Address, value *big.Int, data []byte) error

type BasicSimpleGatekeeper added in v0.4.1

type BasicSimpleGatekeeper struct {
	// contains filtered or unexported fields
}

func (*BasicSimpleGatekeeper) Kill added in v0.4.1

func (*BasicSimpleGatekeeper) PayIn added in v0.4.1

func (api *BasicSimpleGatekeeper) PayIn(ctx context.Context, key *ecdsa.PrivateKey, value *big.Int) error

func (*BasicSimpleGatekeeper) Payout added in v0.4.1

func (api *BasicSimpleGatekeeper) Payout(ctx context.Context, key *ecdsa.PrivateKey, to common.Address, value *big.Int, txNumber *big.Int) (*types.Transaction, error)

type BilledData added in v0.4.1

type BilledData struct {
	DealID     *big.Int `json:"dealID"`
	PaidAmount *big.Int `json:"paidAmount"`
}

type BlacklistAPI added in v0.4.1

type BlacklistAPI interface {
	Check(ctx context.Context, who, whom common.Address) (bool, error)
	Add(ctx context.Context, key *ecdsa.PrivateKey, who, whom common.Address) (*types.Transaction, error)
	Remove(ctx context.Context, key *ecdsa.PrivateKey, whom common.Address) error
	AddMaster(ctx context.Context, key *ecdsa.PrivateKey, root common.Address) (*types.Transaction, error)
	RemoveMaster(ctx context.Context, key *ecdsa.PrivateKey, root common.Address) (*types.Transaction, error)
	SetMarketAddress(ctx context.Context, key *ecdsa.PrivateKey, market common.Address) (*types.Transaction, error)
}

func NewBasicBlacklist added in v0.4.1

func NewBasicBlacklist(address common.Address, opts *chainOpts) (BlacklistAPI, error)

type CertificateCreatedData added in v0.4.1

type CertificateCreatedData struct {
	ID *big.Int
}

type CertificateUpdatedData added in v0.4.10

type CertificateUpdatedData struct {
	ID *big.Int
}

type Config added in v0.4.1

type Config struct {
	Endpoint             url.URL
	SidechainEndpoint    url.URL
	ContractRegistryAddr common.Address
	BlocksBatchSize      uint64
	MasterchainGasPrice  *big.Int
}

Config represents SONM blockchain configuration structure that can act as a building block for more complex configs.

func NewDefaultConfig added in v0.4.1

func NewDefaultConfig() (*Config, error)

func (*Config) UnmarshalYAML added in v0.4.1

func (m *Config) UnmarshalYAML(unmarshal func(interface{}) error) error

type ConfirmationData added in v0.4.1

type ConfirmationData struct {
	Sender        common.Address
	TransactionId *big.Int
}

type ContractRegistry added in v0.4.1

type ContractRegistry interface {
	SidechainSNMAddress() common.Address
	MasterchainSNMAddress() common.Address
	BlacklistAddress() common.Address
	MarketAddress() common.Address
	ProfileRegistryAddress() common.Address
	OracleUsdAddress() common.Address
	GatekeeperMasterchainAddress() common.Address
	GatekeeperSidechainAddress() common.Address
	TestnetFaucetAddress() common.Address
	OracleMultiSig() common.Address
}

type CustomClient added in v0.4.1

type CustomClient struct {
	*ethclient.Client
	// contains filtered or unexported fields
}

func (*CustomClient) GetEthereumBalanceAt added in v0.4.5

func (cc *CustomClient) GetEthereumBalanceAt(ctx context.Context, address common.Address, block *big.Int) (*big.Int, error)

func (*CustomClient) GetLastBlock added in v0.4.1

func (cc *CustomClient) GetLastBlock(ctx context.Context) (*big.Int, error)

func (*CustomClient) GetTransactionReceipt added in v0.4.1

func (cc *CustomClient) GetTransactionReceipt(ctx context.Context, txHash common.Hash) (*Receipt, error)

type CustomEthereumClient added in v0.4.1

type CustomEthereumClient interface {
	EthereumClientBackend
	// GetLastBlock returns number of last mined block
	GetLastBlock(ctx context.Context) (*big.Int, error)
	// GetTransactionReceipt returns receipt of mined transaction or notFound if tx not mined
	GetTransactionReceipt(ctx context.Context, txHash common.Hash) (*Receipt, error)
	// GetEthereumBalanceAt returns amount of ethereum on account at given block
	GetEthereumBalanceAt(ctx context.Context, address common.Address, block *big.Int) (*big.Int, error)
}

CustomEthereumClient extends EthereumClientBackend

func NewClient added in v0.4.1

func NewClient(endpoint string) (CustomEthereumClient, error)

type DealChangeRequestSentData added in v0.4.1

type DealChangeRequestSentData struct {
	ID *big.Int
}

type DealChangeRequestUpdatedData added in v0.4.1

type DealChangeRequestUpdatedData struct {
	ID *big.Int
}

type DealOpenedData added in v0.4.1

type DealOpenedData struct {
	ID *big.Int
}

type DealUpdatedData added in v0.4.1

type DealUpdatedData struct {
	ID *big.Int
}

type ErrorData added in v0.4.1

type ErrorData struct {
	Err   error
	Topic string
}

type EthereumClientBackend added in v0.4.1

type EthereumClientBackend interface {
	bind.ContractBackend
	ethereum.ChainReader
	ethereum.TransactionReader
}

EthereumClientBackend release all methods to execute interaction with Ethereum Blockchain

type Event added in v0.4.1

type Event struct {
	Data         interface{}
	BlockNumber  uint64
	TxIndex      uint64
	ReceiptIndex uint64
	TS           uint64
}

func (*Event) PrecedesOrEquals added in v0.4.5

func (m *Event) PrecedesOrEquals(other *Event) bool

type EventFilter added in v0.4.1

type EventFilter struct {
	// contains filtered or unexported fields
}

func (*EventFilter) WithEmitNoEvents added in v0.4.21

func (m *EventFilter) WithEmitNoEvents() *EventFilter

type EventsAPI added in v0.4.1

type EventsAPI interface {
	GetEvents(ctx context.Context, filter *EventFilter) (chan *Event, error)
	GetLastBlock(ctx context.Context) (uint64, error)
	GetMarketFilter(fromBlock *big.Int) *EventFilter
	GetMultiSigFilter(addresses []common.Address, fromBlock *big.Int) *EventFilter
}

func NewEventsAPI added in v0.4.1

func NewEventsAPI(parent API, opts *chainOpts, logger *zap.Logger, blocksBatchSize uint64) (EventsAPI, error)

type ExecutionData added in v0.4.1

type ExecutionData struct {
	TransactionId *big.Int
}

type ExecutionFailureData added in v0.4.1

type ExecutionFailureData struct {
	TransactionId *big.Int
}

type GasPrice added in v0.4.5

type GasPrice struct {
	*big.Int
}

func (*GasPrice) UnmarshalText added in v0.4.5

func (m *GasPrice) UnmarshalText(text []byte) error

type MarketAPI added in v0.4.1

type MarketAPI interface {
	QuickBuy(ctx context.Context, key *ecdsa.PrivateKey, askId *big.Int, duration uint64) (*sonm.Deal, error)
	OpenDeal(ctx context.Context, key *ecdsa.PrivateKey, askID, bigID *big.Int) (*sonm.Deal, error)
	CloseDeal(ctx context.Context, key *ecdsa.PrivateKey, dealID *big.Int, blacklistType sonm.BlacklistType) error
	GetDealInfo(ctx context.Context, dealID *big.Int) (*sonm.Deal, error)
	GetDealsAmount(ctx context.Context) (*big.Int, error)
	PlaceOrder(ctx context.Context, key *ecdsa.PrivateKey, order *sonm.Order) (*sonm.Order, error)
	CancelOrder(ctx context.Context, key *ecdsa.PrivateKey, id *big.Int) error
	GetOrderInfo(ctx context.Context, orderID *big.Int) (*sonm.Order, error)
	GetOrdersAmount(ctx context.Context) (*big.Int, error)
	Bill(ctx context.Context, key *ecdsa.PrivateKey, dealID *big.Int) error
	RegisterWorker(ctx context.Context, key *ecdsa.PrivateKey, master common.Address) error
	ConfirmWorker(ctx context.Context, key *ecdsa.PrivateKey, slave common.Address) error
	RemoveWorker(ctx context.Context, key *ecdsa.PrivateKey, master, slave common.Address) error
	GetMaster(ctx context.Context, slave common.Address) (common.Address, error)
	GetDealChangeRequestInfo(ctx context.Context, id *big.Int) (*sonm.DealChangeRequest, error)
	CreateChangeRequest(ctx context.Context, key *ecdsa.PrivateKey, request *sonm.DealChangeRequest) (*big.Int, error)
	CancelChangeRequest(ctx context.Context, key *ecdsa.PrivateKey, id *big.Int) error
	GetNumBenchmarks(ctx context.Context) (uint64, error)
}

func NewBasicMarket added in v0.4.1

func NewBasicMarket(address common.Address, token TokenAPI, opts *chainOpts) (MarketAPI, error)

type MultiSigAPI added in v0.4.1

type MultiSigAPI interface {
	AddOwner(ctx context.Context, key *ecdsa.PrivateKey, owner common.Address) error
	RemoveOwner(ctx context.Context, key *ecdsa.PrivateKey, owner common.Address) error
	ReplaceOwner(ctx context.Context, key *ecdsa.PrivateKey, owner common.Address, newOwner common.Address) error
	ChangeRequirement(ctx context.Context, key *ecdsa.PrivateKey, required *big.Int) error
	SubmitTransaction(ctx context.Context, key *ecdsa.PrivateKey, destination common.Address, value *big.Int, data []byte) error
	ConfirmTransaction(ctx context.Context, key *ecdsa.PrivateKey, transactionID *big.Int) error
	RevokeConfirmation(ctx context.Context, key *ecdsa.PrivateKey, transactionID *big.Int) error
	ExecuteTransaction(ctx context.Context, key *ecdsa.PrivateKey, transactionID *big.Int) error
	IsConfirmed(ctx context.Context, transactionID *big.Int) (bool, error)
	GetConfirmationCount(ctx context.Context, transactionID *big.Int) (*big.Int, error)
	GetTransactionCount(ctx context.Context, penging bool, executed bool) (*big.Int, error)
	GetOwners(ctx context.Context) ([]common.Address, error)
	GetConfirmations(ctx context.Context, transactionID *big.Int) ([]common.Address, error)
	GetTransactionIDs(ctx context.Context, from *big.Int, to *big.Int, pending bool, executed bool) ([]*big.Int, error)
	GetTransaction(ctx context.Context, transactionID *big.Int) (*MultiSigTransactionData, error)
}

func NewMultiSigAPI added in v0.4.1

func NewMultiSigAPI(address common.Address, opts *chainOpts) (MultiSigAPI, error)

type MultiSigTransactionData added in v0.4.1

type MultiSigTransactionData struct {
	To       common.Address
	Value    *big.Int
	Data     []byte
	Executed bool
}

type NoEventsData added in v0.4.21

type NoEventsData struct{}

type NumBenchmarksUpdatedData added in v0.4.1

type NumBenchmarksUpdatedData struct {
	NumBenchmarks uint64
}

type Option added in v0.4.1

type Option func(options *options)

func WithBlockConfirmations added in v0.4.1

func WithBlockConfirmations(c int64) Option

func WithBlocksBatchSize added in v0.4.4

func WithBlocksBatchSize(batchSize uint64) Option

func WithConfig added in v0.4.1

func WithConfig(cfg *Config) Option

func WithContractRegistry added in v0.4.1

func WithContractRegistry(address common.Address) Option

func WithMasterchainClient added in v0.4.1

func WithMasterchainClient(c CustomEthereumClient) Option

func WithMasterchainEndpoint added in v0.4.1

func WithMasterchainEndpoint(s string) Option

func WithMasterchainGasPrice added in v0.4.1

func WithMasterchainGasPrice(p *big.Int) Option

func WithNiceMarket added in v0.4.10

func WithNiceMarket() Option

func WithSidechainClient added in v0.4.1

func WithSidechainClient(c CustomEthereumClient) Option

func WithSidechainEndpoint added in v0.4.1

func WithSidechainEndpoint(s string) Option

func WithSidechainGasPrice added in v0.4.1

func WithSidechainGasPrice(p *big.Int) Option

func WithTimeout added in v0.4.1

func WithTimeout(d time.Duration) Option

type OracleAPI added in v0.4.1

type OracleAPI interface {
	// SetCurrentPrice sets current price relation between some currency and SONM token
	SetCurrentPrice(ctx context.Context, key *ecdsa.PrivateKey, price *big.Int) (*types.Transaction, error)
	// GetCurrentPrice returns current price relation between some currency and SONM token
	GetCurrentPrice(ctx context.Context) (*big.Int, error)
	// PackSetCurrentPriceTransactionData pack `SetCurrentPrice` method call
	PackSetCurrentPriceTransactionData(price *big.Int) ([]byte, error)
	// UnpackSetCurrentPriceTransactionData unpack `SetCurrentPrice` method call
	UnpackSetCurrentPriceTransactionData(data []byte) (*big.Int, error)
	// GetOwner get owner address
	GetOwner(ctx context.Context) (common.Address, error)
	// SetOwner set owner address, owner can change oracle price
	SetOwner(ctx context.Context, key *ecdsa.PrivateKey, owner common.Address) error
}

OracleAPI manage price relation between some currency and SNM token

func NewOracleUSDAPI added in v0.4.1

func NewOracleUSDAPI(address common.Address, opts *chainOpts) (OracleAPI, error)

type OracleUSDAPI added in v0.4.1

type OracleUSDAPI struct {
	// contains filtered or unexported fields
}

func (*OracleUSDAPI) GetCurrentPrice added in v0.4.1

func (api *OracleUSDAPI) GetCurrentPrice(ctx context.Context) (*big.Int, error)

func (*OracleUSDAPI) GetOwner added in v0.4.1

func (api *OracleUSDAPI) GetOwner(ctx context.Context) (common.Address, error)

func (*OracleUSDAPI) PackSetCurrentPriceTransactionData added in v0.4.1

func (api *OracleUSDAPI) PackSetCurrentPriceTransactionData(price *big.Int) ([]byte, error)

func (*OracleUSDAPI) SetCurrentPrice added in v0.4.1

func (api *OracleUSDAPI) SetCurrentPrice(ctx context.Context, key *ecdsa.PrivateKey, price *big.Int) (*types.Transaction, error)

func (*OracleUSDAPI) SetOwner added in v0.4.1

func (api *OracleUSDAPI) SetOwner(ctx context.Context, key *ecdsa.PrivateKey, owner common.Address) error

func (*OracleUSDAPI) UnpackSetCurrentPriceTransactionData added in v0.4.1

func (api *OracleUSDAPI) UnpackSetCurrentPriceTransactionData(data []byte) (*big.Int, error)

type OrderPlacedData added in v0.4.1

type OrderPlacedData struct {
	ID *big.Int
}

type OrderUpdatedData added in v0.4.1

type OrderUpdatedData struct {
	ID *big.Int
}

type OwnerAdditionData added in v0.4.1

type OwnerAdditionData struct {
	Owner common.Address
}

type OwnerRemovalData added in v0.4.1

type OwnerRemovalData struct {
	Owner common.Address
}

type ProfileRegistry added in v0.4.1

type ProfileRegistry struct {
	// contains filtered or unexported fields
}

func (*ProfileRegistry) AddValidator added in v0.4.1

func (api *ProfileRegistry) AddValidator(ctx context.Context, key *ecdsa.PrivateKey, validator common.Address, level int8) (*types.Transaction, error)

func (*ProfileRegistry) CreateCertificate added in v0.4.1

func (api *ProfileRegistry) CreateCertificate(ctx context.Context, key *ecdsa.PrivateKey, owner common.Address, attributeType *big.Int, value []byte) (*types.Transaction, error)

func (*ProfileRegistry) GetAttributeCount added in v0.4.1

func (api *ProfileRegistry) GetAttributeCount(ctx context.Context, owner common.Address, attributeType *big.Int) (*big.Int, error)

func (*ProfileRegistry) GetAttributeValue added in v0.4.1

func (api *ProfileRegistry) GetAttributeValue(ctx context.Context, owner common.Address, attributeType *big.Int) ([]byte, error)

func (*ProfileRegistry) GetCertificate added in v0.4.1

func (api *ProfileRegistry) GetCertificate(ctx context.Context, certificateID *big.Int) (*sonm.Certificate, error)

func (*ProfileRegistry) GetProfileLevel added in v0.4.1

func (api *ProfileRegistry) GetProfileLevel(ctx context.Context, owner common.Address) (sonm.IdentityLevel, error)

func (*ProfileRegistry) GetValidator added in v0.4.1

func (api *ProfileRegistry) GetValidator(ctx context.Context, validatorID common.Address) (*sonm.Validator, error)

func (*ProfileRegistry) GetValidatorLevel added in v0.4.1

func (api *ProfileRegistry) GetValidatorLevel(ctx context.Context, validatorID common.Address) (int8, error)

func (*ProfileRegistry) RemoveCertificate added in v0.4.1

func (api *ProfileRegistry) RemoveCertificate(ctx context.Context, key *ecdsa.PrivateKey, id *big.Int) error

func (*ProfileRegistry) RemoveValidator added in v0.4.1

func (api *ProfileRegistry) RemoveValidator(ctx context.Context, key *ecdsa.PrivateKey, validator common.Address) (*types.Transaction, error)

type ProfileRegistryAPI added in v0.4.1

type ProfileRegistryAPI interface {
	AddValidator(ctx context.Context, key *ecdsa.PrivateKey, validator common.Address, level int8) (*types.Transaction, error)
	RemoveValidator(ctx context.Context, key *ecdsa.PrivateKey, validator common.Address) (*types.Transaction, error)
	GetValidator(ctx context.Context, validatorID common.Address) (*sonm.Validator, error)
	GetValidatorLevel(ctx context.Context, validatorID common.Address) (int8, error)
	CreateCertificate(ctx context.Context, key *ecdsa.PrivateKey, owner common.Address, attributeType *big.Int, value []byte) (*types.Transaction, error)
	RemoveCertificate(ctx context.Context, key *ecdsa.PrivateKey, id *big.Int) error
	GetCertificate(ctx context.Context, certificateID *big.Int) (*sonm.Certificate, error)
	GetAttributeCount(ctx context.Context, owner common.Address, attributeType *big.Int) (*big.Int, error)
	GetAttributeValue(ctx context.Context, owner common.Address, attributeType *big.Int) ([]byte, error)
	GetProfileLevel(ctx context.Context, owner common.Address) (sonm.IdentityLevel, error)
}

func NewProfileRegistry added in v0.4.1

func NewProfileRegistry(address common.Address, opts *chainOpts) (ProfileRegistryAPI, error)

type Receipt added in v0.4.1

type Receipt struct {
	*types.Receipt
	BlockNumber      int64
	BlockHash        common.Hash
	From             common.Address
	To               common.Address
	TransactionIndex uint64
}

Receipt extends transaction receipt with block number on which this transaction was mined.

func WaitTransactionReceipt added in v0.4.1

func WaitTransactionReceipt(ctx context.Context, client CustomEthereumClient, confirmations int64, logParsePeriod time.Duration, tx *types.Transaction) (*Receipt, error)

WaitTransactionReceipt await transaction with confirmations returns Receipt of completed transaction

func (*Receipt) UnmarshalJSON added in v0.4.1

func (r *Receipt) UnmarshalJSON(input []byte) error

UnmarshalJSON calls parent unmarshaller for Receipt and also unmarshall block number and associate it with the struct.

type RemovedFromBlacklistData added in v0.4.1

type RemovedFromBlacklistData struct {
	RemoverID common.Address
	RemoveeID common.Address
}

type RevocationData added in v0.4.1

type RevocationData struct {
	Sender        common.Address
	TransactionId *big.Int
}

type SimpleGateTransaction added in v0.4.1

type SimpleGateTransaction struct {
	To       common.Address
	Value    *big.Int
	TxNumber *big.Int
}

type SimpleGatekeeperAPI added in v0.4.1

type SimpleGatekeeperAPI interface {
	// PayIn grab sender tokens and signal gate to transfer it to mirrored chain.
	// On Masterchain ally as `Deposit`
	// On Sidecain ally as `Withdraw`
	PayIn(ctx context.Context, key *ecdsa.PrivateKey, value *big.Int) error
	// Payout release payout transaction from mirrored chain.
	// Accessible only by owner.
	Payout(ctx context.Context, key *ecdsa.PrivateKey, to common.Address, value *big.Int, txNumber *big.Int) (*types.Transaction, error)
	// Kill calls contract to suicide, all ether and tokens funds transfer to owner.
	// Accessible only by owner.
	Kill(ctx context.Context, key *ecdsa.PrivateKey) (*types.Transaction, error)
}

SimpleGatekeeperAPI facade to interact with deposit/withdraw functions through gates

func NewSimpleGatekeeper added in v0.4.1

func NewSimpleGatekeeper(address common.Address, opts *chainOpts) (SimpleGatekeeperAPI, error)

type StandardTokenApi added in v0.4.1

type StandardTokenApi struct {
	// contains filtered or unexported fields
}

func (*StandardTokenApi) AllowanceOf added in v0.4.1

func (api *StandardTokenApi) AllowanceOf(ctx context.Context, from, to common.Address) (*big.Int, error)

func (*StandardTokenApi) Approve added in v0.4.1

func (api *StandardTokenApi) Approve(ctx context.Context, key *ecdsa.PrivateKey, to common.Address, amount *big.Int) error

func (*StandardTokenApi) ApproveAtLeast added in v0.4.1

func (api *StandardTokenApi) ApproveAtLeast(ctx context.Context, key *ecdsa.PrivateKey, to common.Address, amount *big.Int) error

func (*StandardTokenApi) BalanceOf added in v0.4.1

func (api *StandardTokenApi) BalanceOf(ctx context.Context, address common.Address) (*Balance, error)

func (*StandardTokenApi) DecreaseApproval added in v0.4.1

func (api *StandardTokenApi) DecreaseApproval(ctx context.Context, key *ecdsa.PrivateKey, spender common.Address, value *big.Int) error

func (*StandardTokenApi) IncreaseApproval added in v0.4.1

func (api *StandardTokenApi) IncreaseApproval(ctx context.Context, key *ecdsa.PrivateKey, spender common.Address, value *big.Int) error

func (*StandardTokenApi) TotalSupply added in v0.4.1

func (api *StandardTokenApi) TotalSupply(ctx context.Context) (*big.Int, error)

func (*StandardTokenApi) Transfer added in v0.4.1

func (api *StandardTokenApi) Transfer(ctx context.Context, key *ecdsa.PrivateKey, to common.Address, amount *big.Int) error

func (*StandardTokenApi) TransferFrom added in v0.4.1

func (api *StandardTokenApi) TransferFrom(ctx context.Context, key *ecdsa.PrivateKey, from common.Address, to common.Address, amount *big.Int) (*types.Transaction, error)

type SubmissionData added in v0.4.1

type SubmissionData struct {
	TransactionId *big.Int
}

type TokenAPI added in v0.4.1

type TokenAPI interface {
	// Approve allows managing some amount of your tokens by given address.
	// Note that setting an allowance value is prohibited if current allowance value is non-zero.
	// This behavior will persist until migrate our token to the ERC827 standard.
	// You're forced to reset current allowance value for your address, then set a new value.
	// This method performs resetting an old allowance value and setting a new one.
	Approve(ctx context.Context, key *ecdsa.PrivateKey, to common.Address, amount *big.Int) error
	// ApproveAtLeast acts as Approve, but change allowance only if it less than required.
	ApproveAtLeast(ctx context.Context, key *ecdsa.PrivateKey, to common.Address, amount *big.Int) error
	// Transfer token from caller
	Transfer(ctx context.Context, key *ecdsa.PrivateKey, to common.Address, amount *big.Int) error
	// TransferFrom fallback function for contracts to transfer you allowance
	TransferFrom(ctx context.Context, key *ecdsa.PrivateKey, from common.Address, to common.Address, amount *big.Int) (*types.Transaction, error)
	// BalanceOf returns balance of given address
	BalanceOf(ctx context.Context, address common.Address) (*Balance, error)
	// AllowanceOf returns allowance of given address to spender account
	AllowanceOf(ctx context.Context, from, to common.Address) (*big.Int, error)
	// TotalSupply - all amount of emitted token
	TotalSupply(ctx context.Context) (*big.Int, error)
	// IncreaseApproval increase the amount of tokens that an owner allowed to a spender
	// approve should be called when current allowance = 0. To increment
	// allowed value is better to use this function to avoid 2 calls (and wait until the first transaction is mined)
	IncreaseApproval(ctx context.Context, key *ecdsa.PrivateKey, spender common.Address, value *big.Int) error
	// DecreaseApproval - decrease the amount of tokens that an owner allowed to a spender
	// approve should be called when current allowance = 0. To decrement
	// allowed value is better to use this function to avoid 2 calls (and wait until the first transaction is mined)
	DecreaseApproval(ctx context.Context, key *ecdsa.PrivateKey, spender common.Address, value *big.Int) error
}

TokenAPI is a go implementation of ERC20-compatibility token with full functionality high-level interface standard description with placed: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md

func NewStandardToken added in v0.4.1

func NewStandardToken(address common.Address, opts *chainOpts) (TokenAPI, error)

type Unit added in v0.4.5

type Unit struct {
	*big.Int
}

func UnitFromString added in v0.4.5

func UnitFromString(v string) (Unit, error)

type ValidatorCreatedData added in v0.4.1

type ValidatorCreatedData struct {
	ID common.Address
}

type ValidatorDeletedData added in v0.4.1

type ValidatorDeletedData struct {
	ID common.Address
}

type WorkerAnnouncedData added in v0.4.1

type WorkerAnnouncedData struct {
	WorkerID common.Address
	MasterID common.Address
}

type WorkerConfirmedData added in v0.4.1

type WorkerConfirmedData struct {
	WorkerID common.Address
	MasterID common.Address
}

type WorkerRemovedData added in v0.4.1

type WorkerRemovedData struct {
	WorkerID common.Address
	MasterID common.Address
}

Directories

Path Synopsis
source
api

Jump to

Keyboard shortcuts

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