Documentation ¶
Index ¶
- Constants
- Variables
- type AccountParams
- type AccountParamsWithHexKey
- type ClientChannelInfo
- type GetAgentChannelsResult
- type GetAgentOfferingsResult
- type GetClientChannelsResult
- type GetClientOfferingsFilterParamsResult
- type GetClientOfferingsResult
- type GetClientOfferingsResultItem
- type GetEthTransactionsResult
- type GetJobsResult
- type GetLogsResult
- type Handler
- func (h *Handler) AcceptOffering(tkn string, account data.HexString, offering string, deposit, gasPrice uint64) (*string, error)
- func (h *Handler) ChangeChannelStatus(tkn, channel, action string) error
- func (h *Handler) ChangeOfferingStatus(tkn, offering, action string, gasPrice uint64) error
- func (h *Handler) CreateOffering(tkn string, offering *data.Offering) (*string, error)
- func (h *Handler) CreateProduct(tkn string, product data.Product) (*string, error)
- func (h *Handler) CreateTemplate(tkn string, template *data.Template) (*string, error)
- func (h *Handler) ExportPrivateKey(tkn, account string) ([]byte, error)
- func (h *Handler) GenerateAccount(tkn string, params *AccountParams) (*string, error)
- func (h *Handler) GetAccounts(tkn string) ([]data.Account, error)
- func (h *Handler) GetAgentChannels(tkn string, channelStatus, serviceStatus []string, offset, limit uint) (*GetAgentChannelsResult, error)
- func (h *Handler) GetAgentOfferings(tkn, product string, statuses []string, offset, limit uint) (*GetAgentOfferingsResult, error)
- func (h *Handler) GetChannelsUsage(tkn string, ids []string) (map[string]Usage, error)
- func (h *Handler) GetClientChannels(tkn string, channelStatus, serviceStatus []string, offset, limit uint) (*GetClientChannelsResult, error)
- func (h *Handler) GetClientOfferings(tkn string, agent data.HexString, minUnitPrice, maxUnitPrice uint64, ...) (*GetClientOfferingsResult, error)
- func (h *Handler) GetClientOfferingsFilterParams(tkn string) (*GetClientOfferingsFilterParamsResult, error)
- func (h *Handler) GetEndpoints(tkn, channel, template string) ([]data.Endpoint, error)
- func (h *Handler) GetEthTransactions(tkn, relType, relID string, offset, limit uint) (*GetEthTransactionsResult, error)
- func (h *Handler) GetGUISettings(tkn string) (map[string]interface{}, error)
- func (h *Handler) GetJobs(tkn, jtype, dfrom, dto string, statuses []string, offset, limit uint) (*GetJobsResult, error)
- func (h *Handler) GetLastBlockNumber(tkn string) (*uint64, error)
- func (h *Handler) GetLogs(tkn string, levels []string, searchText, dateFrom, dateTo string, ...) (*GetLogsResult, error)
- func (h *Handler) GetObject(tkn, objectType, id string) (json.RawMessage, error)
- func (h *Handler) GetObjectByHash(tkn, objectType, hash string) (json.RawMessage, error)
- func (h *Handler) GetOfferingIncome(tkn, offeringID string) (*uint, error)
- func (h *Handler) GetOfferingUsage(password, offeringID string) (*uint, error)
- func (h *Handler) GetProductIncome(tkn, productID string) (*uint, error)
- func (h *Handler) GetProductUsage(password, productID string) (*uint, error)
- func (h *Handler) GetProducts(tkn string) ([]data.Product, error)
- func (h *Handler) GetSessions(tkn, channel string) ([]data.Session, error)
- func (h *Handler) GetSettings(tkn string) (map[string]SettingUI, error)
- func (h *Handler) GetTemplates(tkn, tplType string) ([]data.Template, error)
- func (h *Handler) GetToken(password string) (*string, error)
- func (h *Handler) GetTotalIncome(tkn string) (*uint, error)
- func (h *Handler) GetUserRole() (*string, error)
- func (h *Handler) ImportAccountFromHex(tkn string, params *AccountParamsWithHexKey) (*string, error)
- func (h *Handler) ImportAccountFromJSON(tkn string, params *AccountParams, jsonBlob json.RawMessage, ...) (*string, error)
- func (h *Handler) IncreaseTxGasPrice(tkn, id string, gasPrice uint64) error
- func (h *Handler) ObjectChange(ctx context.Context, tkn, objectType string, objectIDs []string) (*rpc.Subscription, error)
- func (h *Handler) PingOfferings(tkn string, ids []string) (map[string]bool, error)
- func (h *Handler) ReactivateJob(tkn, id string) error
- func (h *Handler) SetGUISettings(tkn string, v map[string]interface{}) error
- func (h *Handler) SetPassword(password string) error
- func (h *Handler) SuggestGasPrice(token string) (uint64, error)
- func (h *Handler) TopUpChannel(tkn, channel string, deposit, gasPrice uint64) error
- func (h *Handler) TransferTokens(tkn, account, destination string, amount, gasPrice uint64) error
- func (h *Handler) UpdateAccount(tkn, account, name string, isDefault, inUse bool) error
- func (h *Handler) UpdateBalance(tkn, account string) error
- func (h *Handler) UpdateOffering(tkn string, offering *data.Offering) error
- func (h *Handler) UpdatePassword(current, new string) error
- func (h *Handler) UpdateProduct(tkn string, product data.Product) error
- func (h *Handler) UpdateSettings(tkn string, items map[string]string) error
- type ObjectChangeResult
- type SettingUI
- type SimpleToken
- type Suggestor
- type TokenMakeChecker
- type Usage
Constants ¶
const ( ChannelTerminateAction = "terminate" ChannelPauseAction = "pause" ChannelResumeAction = "resume" ChannelCloseAction = "close" // Client only. )
Actions that change a status of a channel.
const ( // CRC16("github.com/privatix/dappctrl/ui") = 0x2F5D ErrAccessDenied errors.Error = 0x2F5D<<8 + iota ErrInternal ErrObjectNotFound ErrAccountNotFound ErrChannelNotFound ErrTemplateNotFound ErrDefaultGasPriceNotFound ErrEmptyPassword ErrMinConfirmationsNotFound ErrOfferingNotFound ErrPasswordExists ErrProductNotFound ErrInvalidTemplateType ErrMalformedTemplate ErrDepositTooSmall ErrBadUnitPriceRange ErrBadUnitType ErrBillingType ErrBadOfferingStatusAction ErrBadObjectType ErrFailedToDecodePrivateKey ErrFailedToDecryptPKey ErrPrivateKeyNotFound ErrTokenAmountTooSmall ErrBadDestination ErrBadAction ErrNotAllowedForAgent ErrJobNotFound ErrBadServiceEndpointAddress ErrInvalidValueForSetting ErrInconsistentSOMCSwitch ErrSOMCIsNotAvailable ErrTxNotFound ErrTxIsUnderpriced ErrSuccessJobNonReactivatable ErrAlreadyActiveJob )
Errors.
const ( TypeAccount = "account" TypeUser = "user" TypeTemplate = "template" TypeProduct = "product" TypeOffering = "offering" TypeChannel = "channel" TypeSession = "session" TypeContract = "contract" TypeEndpoint = "endpoint" TypeJob = "job" TypeEthTx = "ethTx" )
Objects types.
const ( PublishOffering = "publish" PopupOffering = "popup" DeactivateOffering = "deactivate" )
Actions for Agent that change offerings state.
const AccountAggregatedType = "accountAggregated"
AccountAggregatedType is related type to aggregate transactions for a specific account.
Variables ¶
var OfferingChangeActions = map[string]string{ PublishOffering: data.JobAgentPreOfferingMsgBCPublish, PopupOffering: data.JobAgentPreOfferingPopUp, DeactivateOffering: data.JobAgentPreOfferingDelete, }
OfferingChangeActions associates an action with a job type.
var PermissionsToString = map[int]string{ data.ReadOnly: "readOnly", data.ReadWrite: "readWrite", }
PermissionsToString associates a setting permissions with a title.
Functions ¶
This section is empty.
Types ¶
type AccountParams ¶
type AccountParams struct { Name string `json:"name"` IsDefault bool `json:"isDefault"` InUse bool `json:"inUse"` }
AccountParams is format of input to create an account.
type AccountParamsWithHexKey ¶
type AccountParamsWithHexKey struct { AccountParams PrivateKeyHex data.HexString `json:"privateKeyHex"` }
AccountParamsWithHexKey is format of input to create account with given key.
type ClientChannelInfo ¶
type ClientChannelInfo struct { ID string `json:"id"` Agent string `json:"agent"` Client string `json:"client"` Offering string `json:"offering"` OfferingHash data.HexString `json:"offeringHash"` TotalDeposit uint64 `json:"totalDeposit"` ChStat chanStatusBlock `json:"channelStatus"` Job jobBlock `json:"job"` Usage *Usage `json:"usage"` }
ClientChannelInfo is information of client channel.
type GetAgentChannelsResult ¶
type GetAgentChannelsResult struct { Items []data.Channel `json:"items"` TotalItems int `json:"totalItems"` }
GetAgentChannelsResult is result of GetAgentChannels method.
type GetAgentOfferingsResult ¶
type GetAgentOfferingsResult struct { Items []data.Offering `json:"items"` TotalItems int `json:"totalItems"` }
GetAgentOfferingsResult is result of GetAgentOfferings method.
type GetClientChannelsResult ¶
type GetClientChannelsResult struct { Items []ClientChannelInfo `json:"items"` TotalItems int `json:"totalItems"` }
GetClientChannelsResult is result of GetClientChannels method.
type GetClientOfferingsFilterParamsResult ¶
type GetClientOfferingsFilterParamsResult struct { Countries []string `json:"countries"` MinPrice uint64 `json:"minPrice"` MaxPrice uint64 `json:"maxPrice"` MaxRating uint64 `json:"maxRating"` }
GetClientOfferingsFilterParamsResult is result of GetClientOfferingsFilterParams method.
type GetClientOfferingsResult ¶
type GetClientOfferingsResult struct { Items []GetClientOfferingsResultItem `json:"items"` TotalItems int `json:"totalItems"` }
GetClientOfferingsResult is result of GetClientOfferings method.
type GetClientOfferingsResultItem ¶ added in v1.0.0
type GetClientOfferingsResultItem struct { Offering data.Offering `json:"offering"` Rating uint64 `json:"rating"` }
GetClientOfferingsResultItem is items of GetClientOfferingsResult.
type GetEthTransactionsResult ¶
type GetEthTransactionsResult struct { Items []data.EthTx `json:"items"` TotalItems int `json:"totalItems"` }
GetEthTransactionsResult is result of GetEthTransactions method.
type GetJobsResult ¶ added in v1.2.0
GetJobsResult is a jobs list after applying all filtering and paginations.
type GetLogsResult ¶
type GetLogsResult struct { Items []data.LogEvent `json:"items"` TotalItems int `json:"totalItems"` }
GetLogsResult is result of GetLogs method.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler is an UI RPC handler.
func NewHandler ¶
func NewHandler(logger log.Logger, db *reform.DB, queue job.Queue, pwdStorage data.PWDGetSetter, encryptKeyFunc data.EncryptedKeyFunc, userRole string, processor *proc.Processor, somcClientBuilder somc.ClientBuilderInterface, token TokenMakeChecker, suggestor Suggestor) *Handler
NewHandler creates a new handler.
func (*Handler) AcceptOffering ¶
func (h *Handler) AcceptOffering(tkn string, account data.HexString, offering string, deposit, gasPrice uint64) (*string, error)
AcceptOffering initiates JobClientPreChannelCreate job.
func (*Handler) ChangeChannelStatus ¶
ChangeChannelStatus updates channel state.
func (*Handler) ChangeOfferingStatus ¶
ChangeOfferingStatus initiates JobAgentPreOfferingMsgBCPublish, JobAgentPreOfferingPopUp or JobAgentPreOfferingDelete job, depending on a selected action.
func (*Handler) CreateOffering ¶
CreateOffering creates an offering.
func (*Handler) CreateProduct ¶
CreateProduct creates new product.
func (*Handler) CreateTemplate ¶
CreateTemplate creates template.
func (*Handler) ExportPrivateKey ¶
ExportPrivateKey returns a private key in base64 encoding by account id.
func (*Handler) GenerateAccount ¶
func (h *Handler) GenerateAccount( tkn string, params *AccountParams) (*string, error)
GenerateAccount generates new private key and creates new account.
func (*Handler) GetAccounts ¶
GetAccounts returns accounts.
func (*Handler) GetAgentChannels ¶
func (h *Handler) GetAgentChannels(tkn string, channelStatus, serviceStatus []string, offset, limit uint) (*GetAgentChannelsResult, error)
GetAgentChannels gets channels for agent.
func (*Handler) GetAgentOfferings ¶
func (h *Handler) GetAgentOfferings(tkn, product string, statuses []string, offset, limit uint) (*GetAgentOfferingsResult, error)
GetAgentOfferings returns active offerings available for a agent.
func (*Handler) GetChannelsUsage ¶
GetChannelsUsage returns detailed usage on channels.
func (*Handler) GetClientChannels ¶
func (h *Handler) GetClientChannels(tkn string, channelStatus, serviceStatus []string, offset, limit uint) (*GetClientChannelsResult, error)
GetClientChannels gets client channel information.
func (*Handler) GetClientOfferings ¶
func (h *Handler) GetClientOfferings(tkn string, agent data.HexString, minUnitPrice, maxUnitPrice uint64, countries, ipTypes []string, offset, limit uint) (*GetClientOfferingsResult, error)
GetClientOfferings returns active offerings available for a client.
func (*Handler) GetClientOfferingsFilterParams ¶
func (h *Handler) GetClientOfferingsFilterParams( tkn string) (*GetClientOfferingsFilterParamsResult, error)
GetClientOfferingsFilterParams returns offerings filter parameters for client.
func (*Handler) GetEndpoints ¶
GetEndpoints returns endpoints.
func (*Handler) GetEthTransactions ¶
func (h *Handler) GetEthTransactions(tkn, relType, relID string, offset, limit uint) (*GetEthTransactionsResult, error)
GetEthTransactions returns transactions by related object.
func (*Handler) GetGUISettings ¶
GetGUISettings returns gui settings.
func (*Handler) GetJobs ¶ added in v1.2.0
func (h *Handler) GetJobs(tkn, jtype, dfrom, dto string, statuses []string, offset, limit uint) (*GetJobsResult, error)
GetJobs returns list of jobs for given params.
func (*Handler) GetLastBlockNumber ¶
GetLastBlockNumber returns last known block number.
func (*Handler) GetLogs ¶
func (h *Handler) GetLogs(tkn string, levels []string, searchText, dateFrom, dateTo string, offset, limit uint) (*GetLogsResult, error)
GetLogs returns back end log, paginated.
func (*Handler) GetObject ¶
func (h *Handler) GetObject( tkn, objectType, id string) (json.RawMessage, error)
GetObject finds object in a database by id, then returns an object on raw JSON format.
func (*Handler) GetObjectByHash ¶
func (h *Handler) GetObjectByHash( tkn, objectType, hash string) (json.RawMessage, error)
GetObjectByHash finds object in a database by hash, then returns an object on raw JSON format.
func (*Handler) GetOfferingIncome ¶
GetOfferingIncome returns total receipt balance from all channels of offering with given id.
func (*Handler) GetOfferingUsage ¶
GetOfferingUsage returns total units used for all channels with a given offering.
func (*Handler) GetProductIncome ¶
GetProductIncome returns total receipt balance from all channels of all offerings with given product id.
func (*Handler) GetProductUsage ¶
GetProductUsage returns total units used in all channel of all offerings with given product.
func (*Handler) GetProducts ¶
GetProducts returns all products available to the agent.
func (*Handler) GetSessions ¶
GetSessions returns sessions.
func (*Handler) GetSettings ¶
GetSettings returns settings.
func (*Handler) GetTemplates ¶
GetTemplates returns templates.
func (*Handler) GetTotalIncome ¶
GetTotalIncome returns total receipt balance from all channels.
func (*Handler) GetUserRole ¶
GetUserRole returns user role.
func (*Handler) ImportAccountFromHex ¶
func (h *Handler) ImportAccountFromHex( tkn string, params *AccountParamsWithHexKey) (*string, error)
ImportAccountFromHex imports private key from hex, creates account and initiates JobAccountUpdateBalances job.
func (*Handler) ImportAccountFromJSON ¶
func (h *Handler) ImportAccountFromJSON( tkn string, params *AccountParams, jsonBlob json.RawMessage, jsonKeyStorePassword string) (*string, error)
ImportAccountFromJSON imports private key from JSON blob with password, creates account and initiates JobAccountUpdateBalances job.
func (*Handler) IncreaseTxGasPrice ¶ added in v1.2.0
IncreaseTxGasPrice creates a increaseTxGasPrice job.
func (*Handler) ObjectChange ¶
func (h *Handler) ObjectChange(ctx context.Context, tkn, objectType string, objectIDs []string) (*rpc.Subscription, error)
ObjectChange subscribes to changes for objects of a given type.
func (*Handler) PingOfferings ¶
PingOfferings given offerings ids pings each of them and returns result of the test.
func (*Handler) ReactivateJob ¶ added in v1.2.0
ReactivateJob resets job to be run again.
func (*Handler) SetGUISettings ¶
SetGUISettings sets gui settings.
func (*Handler) SetPassword ¶
SetPassword sets the password only on the first call. Returns error if password already exists.
func (*Handler) SuggestGasPrice ¶ added in v1.1.0
SuggestGasPrice returns currently suggested gas price.
func (*Handler) TopUpChannel ¶
TopUpChannel initiates JobClientPreChannelTopUp job.
func (*Handler) TransferTokens ¶
TransferTokens initiates JobPreAccountAddBalanceApprove or JobPreAccountReturnBalance job depending on the direction of the transfer.
func (*Handler) UpdateAccount ¶
UpdateAccount updates an account.
func (*Handler) UpdateBalance ¶
UpdateBalance initiates JobAccountUpdateBalances job.
func (*Handler) UpdateOffering ¶
UpdateOffering updates an offering.
func (*Handler) UpdatePassword ¶
UpdatePassword updates the password.
func (*Handler) UpdateProduct ¶
UpdateProduct updates a product.
type ObjectChangeResult ¶
type ObjectChangeResult struct { Object json.RawMessage `json:"object,omitempty"` Job *data.Job `json:"job"` Error *rpcsrv.Error `json:"error,omitempty"` }
ObjectChangeResult is an ObjectChange notification result.
type SimpleToken ¶
type SimpleToken struct {
// contains filtered or unexported fields
}
SimpleToken is a in memory random token.
func (*SimpleToken) Check ¶
func (t *SimpleToken) Check(s string) bool
Check returns true if given string matches stored.
func (*SimpleToken) Make ¶
func (t *SimpleToken) Make() (string, error)
Make makes new random token.
type TokenMakeChecker ¶
TokenMakeChecker is token maker and checker.