blockchain

package
v0.4.0-alpha1 Latest Latest
Warning

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

Go to latest
Published: May 30, 2018 License: Apache-2.0 Imports: 21 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindLogByTopic added in v0.4.1

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

Types

type API added in v0.4.1

type API interface {
	ProfileRegistry() ProfileRegistryAPI
	Events() EventsAPI
	Market() MarketAPI
	Blacklist() BlacklistAPI
	LiveToken() TokenAPI
	SideToken() TokenAPI
	TestToken() TestTokenAPI
	OracleUSD() OracleAPI
}

func NewAPI

func NewAPI(opts ...Option) (API, error)

type AddedToBlacklistData added in v0.4.1

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

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) Events added in v0.4.1

func (api *BasicAPI) Events() EventsAPI

func (*BasicAPI) LiveToken

func (api *BasicAPI) LiveToken() TokenAPI

func (*BasicAPI) Market added in v0.4.1

func (api *BasicAPI) Market() MarketAPI

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) SideToken

func (api *BasicAPI) SideToken() TokenAPI

func (*BasicAPI) TestToken added in v0.4.1

func (api *BasicAPI) TestToken() TestTokenAPI

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 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, fromBlockInitial *big.Int) (chan *Event, error)

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) <-chan 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) <-chan error

func (*BasicMarketAPI) CloseDeal added in v0.4.1

func (api *BasicMarketAPI) CloseDeal(ctx context.Context, key *ecdsa.PrivateKey, dealID *big.Int, blacklisted bool) <-chan error

func (*BasicMarketAPI) ConfirmWorker added in v0.4.1

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

func (*BasicMarketAPI) CreateChangeRequest added in v0.4.1

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

func (*BasicMarketAPI) GetDealChangeRequestInfo added in v0.4.1

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

func (*BasicMarketAPI) GetDealInfo added in v0.4.1

func (api *BasicMarketAPI) GetDealInfo(ctx context.Context, dealID *big.Int) (*pb.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) (*pb.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) <-chan DealOrError

func (*BasicMarketAPI) PlaceOrder added in v0.4.1

func (api *BasicMarketAPI) PlaceOrder(ctx context.Context, key *ecdsa.PrivateKey, order *pb.Order) <-chan OrderOrError

func (*BasicMarketAPI) RegisterWorker added in v0.4.1

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

func (*BasicMarketAPI) RemoveWorker added in v0.4.1

func (api *BasicMarketAPI) RemoveWorker(ctx context.Context, key *ecdsa.PrivateKey, master, slave common.Address) <-chan 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 Config added in v0.4.1

type Config struct {
	Endpoint          url.URL
	SidechainEndpoint url.URL
}

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

func (*Config) UnmarshalYAML added in v0.4.1

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

type CustomClient added in v0.4.1

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

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)
}

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 DealOrError

type DealOrError struct {
	Deal *pb.Deal
	Err  error
}

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
	TS          uint64
}

type EventsAPI added in v0.4.1

type EventsAPI interface {
	GetEvents(ctx context.Context, fromBlockInitial *big.Int) (chan *Event, error)
}

func NewEventsAPI added in v0.4.1

func NewEventsAPI(opts *chainOpts, logger *zap.Logger) (EventsAPI, error)

type MarketAPI added in v0.4.1

type MarketAPI interface {
	OpenDeal(ctx context.Context, key *ecdsa.PrivateKey, askID, bigID *big.Int) <-chan DealOrError
	CloseDeal(ctx context.Context, key *ecdsa.PrivateKey, dealID *big.Int, blacklisted bool) <-chan error
	GetDealInfo(ctx context.Context, dealID *big.Int) (*pb.Deal, error)
	GetDealsAmount(ctx context.Context) (*big.Int, error)
	PlaceOrder(ctx context.Context, key *ecdsa.PrivateKey, order *pb.Order) <-chan OrderOrError
	CancelOrder(ctx context.Context, key *ecdsa.PrivateKey, id *big.Int) <-chan error
	GetOrderInfo(ctx context.Context, orderID *big.Int) (*pb.Order, error)
	GetOrdersAmount(ctx context.Context) (*big.Int, error)
	Bill(ctx context.Context, key *ecdsa.PrivateKey, dealID *big.Int) <-chan error
	RegisterWorker(ctx context.Context, key *ecdsa.PrivateKey, master common.Address) <-chan error
	ConfirmWorker(ctx context.Context, key *ecdsa.PrivateKey, slave common.Address) <-chan error
	RemoveWorker(ctx context.Context, key *ecdsa.PrivateKey, master, slave common.Address) <-chan error
	GetMaster(ctx context.Context, slave common.Address) (common.Address, error)
	GetDealChangeRequestInfo(ctx context.Context, id *big.Int) (*pb.DealChangeRequest, error)
	CreateChangeRequest(ctx context.Context, key *ecdsa.PrivateKey, request *pb.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, opts *chainOpts) (MarketAPI, error)

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 WithConfig added in v0.4.1

func WithConfig(cfg *Config) Option

func WithLivechainClient

func WithLivechainClient(c CustomEthereumClient) Option

func WithLivechainEndpoint

func WithLivechainEndpoint(s string) Option

func WithLivechainGasPrice

func WithLivechainGasPrice(p int64) 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 int64) 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)
}

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) SetCurrentPrice added in v0.4.1

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

type OrderOrError

type OrderOrError struct {
	Order *pb.Order
	Err   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 ProfileRegistry added in v0.4.1

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

func (*ProfileRegistry) GetCertificate added in v0.4.1

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

func (*ProfileRegistry) GetValidator added in v0.4.1

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

type ProfileRegistryAPI added in v0.4.1

type ProfileRegistryAPI interface {
	GetValidator(ctx context.Context, validatorID common.Address) (*pb.Validator, error)
	GetCertificate(ctx context.Context, certificateID *big.Int) (*pb.Certificate, 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
}

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)

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 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 string, to string) (*big.Int, error)

func (*StandardTokenApi) Approve added in v0.4.1

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

func (*StandardTokenApi) BalanceOf added in v0.4.1

func (api *StandardTokenApi) BalanceOf(ctx context.Context, address string) (*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 string, amount *big.Int) (*types.Transaction, error)

func (*StandardTokenApi) TransferFrom added in v0.4.1

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

type TestTokenAPI added in v0.4.1

type TestTokenAPI interface {
	// GetTokens - send 100 SNMT token for message caller
	// this function added for MVP purposes and has been deleted later
	GetTokens(ctx context.Context, key *ecdsa.PrivateKey) (*types.Transaction, error)
}

func NewTestToken added in v0.4.1

func NewTestToken(address common.Address, opts *chainOpts) (TestTokenAPI, error)

type TestTokenApi added in v0.4.1

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

func (*TestTokenApi) GetTokens added in v0.4.1

func (api *TestTokenApi) GetTokens(ctx context.Context, key *ecdsa.PrivateKey) (*types.Transaction, error)

type TokenAPI added in v0.4.1

type TokenAPI interface {
	// Approve - add allowance from caller to other contract to spend tokens
	Approve(ctx context.Context, key *ecdsa.PrivateKey, to string, amount *big.Int) (*types.Transaction, error)
	// Transfer token from caller
	Transfer(ctx context.Context, key *ecdsa.PrivateKey, to string, amount *big.Int) (*types.Transaction, error)
	// TransferFrom fallback function for contracts to transfer you allowance
	TransferFrom(ctx context.Context, key *ecdsa.PrivateKey, from string, to string, amount *big.Int) (*types.Transaction, error)
	// BalanceOf returns balance of given address
	BalanceOf(ctx context.Context, address string) (*big.Int, error)
	// AllowanceOf returns allowance of given address to spender account
	AllowanceOf(ctx context.Context, from string, to string) (*big.Int, error)
	// TotalSupply - all amount of emitted token
	TotalSupply(ctx context.Context) (*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 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 {
	SlaveID  common.Address
	MasterID common.Address
}

type WorkerConfirmedData added in v0.4.1

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

type WorkerRemovedData added in v0.4.1

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

Directories

Path Synopsis
examples
api

Jump to

Keyboard shortcuts

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