Documentation
¶
Index ¶
- Constants
- Variables
- func Chains() map[int64]string
- func NewIdentityRegistryContract(ethClient paymentClient.EtherClient, ap AddressProvider, ...) (*contractRegistry, error)
- func NewRegistrationDataProvider(ks *keystore.KeyStore) *keystoreRegistrationDataProvider
- type AddressProvider
- type Affiliator
- type AppEventIdentityRegistration
- type ChannelStatus
- type ChannelStatusRequest
- type ChannelStatusResponse
- type CombinedFeesResponse
- type DecreaseProviderStakeRequest
- type EligibilityResponse
- type FakeRegistry
- type Fees
- type FeesResponse
- type FreeRegistrar
- type IdentityRegistrationRequest
- type IdentityRegistry
- type IdentityRegistryConfig
- type OpenChannelRequest
- type PayAndSettlePayload
- type PromiseSettlementRequest
- type QueueResponse
- type RegistrationStatus
- type RegistrationStatusStorage
- type SettleResponse
- type SettleWithBeneficiaryRequest
- type StoredRegistrationStatus
- type TokenRewardResponse
- type Transactor
- func (t *Transactor) ChannelStatus(chainID int64, id, hermesID, registryAddress string) (ChannelStatusResponse, error)
- func (t *Transactor) DecreaseStake(id string, chainID int64, amount, transactorFee *big.Int) error
- func (t *Transactor) FetchCombinedFees(chainID int64) (CombinedFeesResponse, error)
- func (t *Transactor) FetchRegistrationFees(chainID int64) (FeesResponse, error)
- func (t *Transactor) FetchRegistrationStatus(id string) ([]TransactorStatusResponse, error)
- func (t *Transactor) FetchSettleFees(chainID int64) (FeesResponse, error)
- func (t *Transactor) FetchStakeDecreaseFee(chainID int64) (FeesResponse, error)
- func (t *Transactor) GetFreeProviderRegistrationEligibility() (bool, error)
- func (t *Transactor) GetFreeRegistrationEligibility(identity identity.Identity) (bool, error)
- func (t *Transactor) GetQueueStatus(ID string) (QueueResponse, error)
- func (t *Transactor) OpenChannel(chainID int64, id, hermesID, registryAddress string) error
- func (t *Transactor) PayAndSettle(hermesID, providerID string, promise pc.Promise, beneficiary string, ...) (string, error)
- func (t *Transactor) RegisterIdentity(id string, stake, fee *big.Int, beneficiary string, chainID int64, ...) error
- func (t *Transactor) RegisterProviderIdentity(id string, stake, fee *big.Int, beneficiary string, chainID int64, ...) error
- func (t *Transactor) SettleAndRebalance(hermesID, providerID string, promise pc.Promise) (string, error)
- func (t *Transactor) SettleIntoStake(hermesID, providerID string, promise pc.Promise) (string, error)
- func (t *Transactor) SettleWithBeneficiary(id, beneficiary, hermesID string, promise pc.Promise) (string, error)
- type TransactorRegistrationEntryStatus
- type TransactorStatusResponse
Constants ¶
const ( // ChannelStatusNotFound channel is not opened and the request was not sent ChannelStatusNotFound = ChannelStatus("not_found") // ChannelStatusOpen channel successfully opened ChannelStatusOpen = ChannelStatus("open") // ChannelStatusFail channel open transaction fails ChannelStatusFail = ChannelStatus("fail") // ChannelStatusInProgress channel opening is in progress ChannelStatusInProgress = ChannelStatus("in_progress") )
const ( // TransactorRegistrationEntryStatusCreated tells us that the registration is created. TransactorRegistrationEntryStatusCreated = TransactorRegistrationEntryStatus("created") // TransactorRegistrationEntryStatusPriceIncreased tells us that registration was requeued with an increased price. TransactorRegistrationEntryStatusPriceIncreased = TransactorRegistrationEntryStatus("priceIncreased") // TransactorRegistrationEntryStatusFailed tells us that the registration has failed. TransactorRegistrationEntryStatusFailed = TransactorRegistrationEntryStatus("failed") // TransactorRegistrationEntryStatusSucceed tells us that the registration has succeeded. TransactorRegistrationEntryStatusSucceed = TransactorRegistrationEntryStatus("succeed") )
const AppTopicIdentityRegistration = "registration_event_topic"
AppTopicIdentityRegistration represents the registration event topic.
const AppTopicTransactorRegistration = "transactor_identity_registration"
AppTopicTransactorRegistration represents the registration topic to which events regarding registration attempts on transactor will occur
Variables ¶
var AppTopicEthereumClientReconnected = "ether-client-reconnect"
AppTopicEthereumClientReconnected indicates that the ethereum client has reconnected.
var ErrNotFound = errors.New("no info for provided identity available in storage")
ErrNotFound represents an error where no info could be found in storage
Functions ¶
func Chains ¶
Chains returns chainID to name map. Source: https://chainlist.org/
func NewIdentityRegistryContract ¶
func NewIdentityRegistryContract(ethClient paymentClient.EtherClient, ap AddressProvider, registryStorage registryStorage, publisher eventbus.Publisher, caller hermesCaller, transactor transactor, selector identity_selector.Handler, cfg IdentityRegistryConfig) (*contractRegistry, error)
NewIdentityRegistryContract creates identity registry service which uses blockchain for information
func NewRegistrationDataProvider ¶
NewRegistrationDataProvider creates registration data provider backed up by identity which is managed by keystore
Types ¶
type AddressProvider ¶
type AddressProvider interface { GetActiveChannelImplementation(chainID int64) (common.Address, error) GetActiveHermes(chainID int64) (common.Address, error) GetRegistryAddress(chainID int64) (common.Address, error) GetKnownHermeses(chainID int64) ([]common.Address, error) GetChannelImplementationForHermes(chainID int64, hermes common.Address) (common.Address, error) GetMystAddress(chainID int64) (common.Address, error) }
AddressProvider provides sc addresses.
type Affiliator ¶
type Affiliator struct {
// contains filtered or unexported fields
}
Affiliator allows for convenient calls to the affiliator service
func NewAffiliator ¶
func NewAffiliator(httpClient *requests.HTTPClient, endpointAddress string) *Affiliator
NewAffiliator creates and returns new Affiliator instance
func (*Affiliator) RegistrationTokenReward ¶
func (t *Affiliator) RegistrationTokenReward(token string) (*big.Int, error)
RegistrationTokenReward returns the amount of MYST rewarder for token used.
type AppEventIdentityRegistration ¶
type AppEventIdentityRegistration struct { ID identity.Identity Status RegistrationStatus ChainID int64 }
AppEventIdentityRegistration represents the registration event payload.
type ChannelStatusRequest ¶
type ChannelStatusRequest struct { Identity string `json:"identity"` HermesID string `json:"hermesID"` ChainID int64 `json:"chainID"` RegistryAddress string `json:"registry_address"` }
ChannelStatusRequest request for channel status
type ChannelStatusResponse ¶
type ChannelStatusResponse struct {
Status ChannelStatus `json:"status"`
}
ChannelStatusResponse represents response with channel status
type CombinedFeesResponse ¶
type CombinedFeesResponse struct { Current Fees `json:"current"` Last Fees `json:"last"` ServerTime time.Time `json:"server_time"` }
CombinedFeesResponse represents the combined fees response.
type DecreaseProviderStakeRequest ¶
type DecreaseProviderStakeRequest struct { ChannelID string `json:"channel_id,omitempty"` Nonce uint64 `json:"nonce,omitempty"` HermesID string `json:"hermes_id,omitempty"` Amount uint64 `json:"amount,omitempty"` TransactorFee uint64 `json:"transactor_fee,omitempty"` Signature string `json:"signature,omitempty"` ChainID int64 `json:"chain_id"` ProviderID string `json:"providerID"` }
DecreaseProviderStakeRequest represents all the parameters required for decreasing provider stake.
type EligibilityResponse ¶
type EligibilityResponse struct {
Eligible bool `json:"eligible"`
}
EligibilityResponse shows if one is eligible for free registration.
type FakeRegistry ¶
type FakeRegistry struct { RegistrationStatus RegistrationStatus RegistrationCheckError error }
FakeRegistry fake register
func (*FakeRegistry) GetRegistrationStatus ¶
func (registry *FakeRegistry) GetRegistrationStatus(chainID int64, id identity.Identity) (RegistrationStatus, error)
GetRegistrationStatus returns fake identity registration status within payments contract
func (*FakeRegistry) Subscribe ¶
func (registry *FakeRegistry) Subscribe(eventbus.Subscriber) error
Subscribe does nothing
type Fees ¶
type Fees struct { DecreaseStake *big.Int `json:"decreaseStake"` Settle *big.Int `json:"settle"` Register *big.Int `json:"register"` ValidUntil time.Time `json:"valid_until"` }
Fees represents fees for a given time frame.
type FeesResponse ¶
FeesResponse represents fees applied by Transactor
func (FeesResponse) IsValid ¶
func (fr FeesResponse) IsValid() bool
IsValid returns false if the fee has already expired and should be re-requested
type FreeRegistrar ¶
type FreeRegistrar struct {
// contains filtered or unexported fields
}
FreeRegistrar is responsible for registering default identity for free
func NewFreeRegistrar ¶
func NewFreeRegistrar(selector identity_selector.Handler, transactor transactor, contractRegistry IdentityRegistry, freeRegistrationEnabled bool) *FreeRegistrar
NewFreeRegistrar creates new free registrar
func (*FreeRegistrar) Subscribe ¶
func (f *FreeRegistrar) Subscribe(eb eventbus.Subscriber) error
Subscribe subscribes to Node events
type IdentityRegistrationRequest ¶
type IdentityRegistrationRequest struct { RegistryAddress string `json:"registryAddress"` HermesID string `json:"hermesID"` // Stake is used by Provider, default 0 Stake *big.Int `json:"stake"` // Fee: negotiated fee with transactor Fee *big.Int `json:"fee"` // Beneficiary: Provider channelID by default, optionally set during Identity registration. // Can be updated later through transactor. We can check it's value directly from SC. // Its a cache out address Beneficiary string `json:"beneficiary"` // Signature from fields above Signature string `json:"signature"` Identity string `json:"identity"` ChainID int64 `json:"chainID"` }
IdentityRegistrationRequest represents the identity registration request body
type IdentityRegistry ¶
type IdentityRegistry interface { Subscribe(eventbus.Subscriber) error GetRegistrationStatus(chainID int64, id identity.Identity) (RegistrationStatus, error) }
IdentityRegistry enables identity registration actions
type IdentityRegistryConfig ¶
type IdentityRegistryConfig struct { TransactorPollInterval time.Duration TransactorPollTimeout time.Duration }
IdentityRegistryConfig contains the configuration for registry contract.
type OpenChannelRequest ¶
type OpenChannelRequest struct { TransactorFee *big.Int `json:"transactorFee"` Signature string `json:"signature"` HermesID string `json:"hermesID"` ChainID int64 `json:"chainID"` RegistryAddress string `json:"registry_address"` }
OpenChannelRequest represents the open consumer channel request body
type PayAndSettlePayload ¶
type PayAndSettlePayload struct { PromiseSettlementRequest Beneficiary string `json:"beneficiary"` BeneficiarySignature string `json:"beneficiarySignature"` }
PayAndSettlePayload represents the pay and settle payload.
type PromiseSettlementRequest ¶
type PromiseSettlementRequest struct { HermesID string `json:"hermesID"` ChannelID string `json:"channelID"` Amount *big.Int `json:"amount"` TransactorFee *big.Int `json:"fee"` Preimage string `json:"preimage"` Signature string `json:"signature"` ProviderID string `json:"providerID"` ChainID int64 `json:"chainID"` }
PromiseSettlementRequest represents the settlement request body
type QueueResponse ¶
type QueueResponse struct { ID string `json:"id"` Hash string `json:"tx_hash"` State string `json:"state"` Error string `json:"error"` }
QueueResponse represents the queue response from transactor.
type RegistrationStatus ¶
type RegistrationStatus int
RegistrationStatus represents all the possible registration statuses
const ( // Registered represents a registration Registered RegistrationStatus = iota // Unregistered represents an unregistered identity Unregistered // InProgress shows that registration is still in progress InProgress // RegistrationError shows that an error occurred during registration RegistrationError // Unknown is returned when there was an error fetching registration status and it is now // impossible to determine. A request should be retried to get the status again. Unknown )
func (RegistrationStatus) Registered ¶
func (rs RegistrationStatus) Registered() bool
Registered returns flag if registration is in successful status
func (RegistrationStatus) String ¶
func (rs RegistrationStatus) String() string
String converts registration to human readable notation
type RegistrationStatusStorage ¶
type RegistrationStatusStorage struct {
// contains filtered or unexported fields
}
RegistrationStatusStorage allows for storing of registration statuses.
func NewRegistrationStatusStorage ¶
func NewRegistrationStatusStorage(bolt persistentStorage) *RegistrationStatusStorage
NewRegistrationStatusStorage returns a new instance of the registration status storage
func (*RegistrationStatusStorage) Get ¶
func (rss *RegistrationStatusStorage) Get(chainID int64, identity identity.Identity) (StoredRegistrationStatus, error)
Get fetches the promise for the given hermes.
func (*RegistrationStatusStorage) GetAll ¶
func (rss *RegistrationStatusStorage) GetAll() ([]StoredRegistrationStatus, error)
GetAll fetches all the registration statuses
func (*RegistrationStatusStorage) Store ¶
func (rss *RegistrationStatusStorage) Store(status StoredRegistrationStatus) error
Store stores the given promise for the given hermes.
type SettleResponse ¶
type SettleResponse struct {
ID string `json:"id"`
}
SettleResponse represents the settle response from transactor.
type SettleWithBeneficiaryRequest ¶
type SettleWithBeneficiaryRequest struct { Promise PromiseSettlementRequest Beneficiary string `json:"beneficiary"` Nonce *big.Int `json:"nonce"` Signature string `json:"signature"` ProviderID string `json:"providerID"` ChainID int64 `json:"chainID"` Registry string `json:"registry"` }
SettleWithBeneficiaryRequest represent the request for setting new beneficiary address.
type StoredRegistrationStatus ¶
type StoredRegistrationStatus struct { RegistrationStatus RegistrationStatus Identity identity.Identity ChainID int64 RegistrationRequest IdentityRegistrationRequest UpdatedAt time.Time }
StoredRegistrationStatus represents a registration status that is being stored in our local DB
func (StoredRegistrationStatus) FromEvent ¶
func (srs StoredRegistrationStatus) FromEvent(status RegistrationStatus, ev IdentityRegistrationRequest) StoredRegistrationStatus
FromEvent constructs a stored registration status from transactor.IdentityRegistrationRequest
type TokenRewardResponse ¶
TokenRewardResponse represents the token reward response.
type Transactor ¶
type Transactor struct {
// contains filtered or unexported fields
}
Transactor allows for convenient calls to the transactor service
func NewTransactor ¶
func NewTransactor(httpClient *requests.HTTPClient, endpointAddress string, addresser AddressProvider, signerFactory identity.SignerFactory, publisher eventbus.Publisher, bc channelProvider, feesValidTime time.Duration) *Transactor
NewTransactor creates and returns new Transactor instance
func (*Transactor) ChannelStatus ¶
func (t *Transactor) ChannelStatus(chainID int64, id, hermesID, registryAddress string) (ChannelStatusResponse, error)
ChannelStatus check the status of the channel
func (*Transactor) DecreaseStake ¶
DecreaseStake requests the transactor to decrease stake.
func (*Transactor) FetchCombinedFees ¶
func (t *Transactor) FetchCombinedFees(chainID int64) (CombinedFeesResponse, error)
FetchCombinedFees fetches current transactor fees.
func (*Transactor) FetchRegistrationFees ¶
func (t *Transactor) FetchRegistrationFees(chainID int64) (FeesResponse, error)
FetchRegistrationFees fetches current transactor registration fees
func (*Transactor) FetchRegistrationStatus ¶
func (t *Transactor) FetchRegistrationStatus(id string) ([]TransactorStatusResponse, error)
FetchRegistrationStatus fetches current transactor registration status for given identity.
func (*Transactor) FetchSettleFees ¶
func (t *Transactor) FetchSettleFees(chainID int64) (FeesResponse, error)
FetchSettleFees fetches current transactor settlement fees
func (*Transactor) FetchStakeDecreaseFee ¶
func (t *Transactor) FetchStakeDecreaseFee(chainID int64) (FeesResponse, error)
FetchStakeDecreaseFee fetches current transactor stake decrease fees.
func (*Transactor) GetFreeProviderRegistrationEligibility ¶
func (t *Transactor) GetFreeProviderRegistrationEligibility() (bool, error)
GetFreeProviderRegistrationEligibility determines if there are any free provider registrations available.
func (*Transactor) GetFreeRegistrationEligibility ¶
func (t *Transactor) GetFreeRegistrationEligibility(identity identity.Identity) (bool, error)
GetFreeRegistrationEligibility determines if the identity is eligible for free registration.
func (*Transactor) GetQueueStatus ¶
func (t *Transactor) GetQueueStatus(ID string) (QueueResponse, error)
GetQueueStatus returns the queued transaction status from transactor.
func (*Transactor) OpenChannel ¶
func (t *Transactor) OpenChannel(chainID int64, id, hermesID, registryAddress string) error
OpenChannel opens payment channel for consumer for certain Hermes
func (*Transactor) PayAndSettle ¶
func (t *Transactor) PayAndSettle(hermesID, providerID string, promise pc.Promise, beneficiary string, beneficiarySignature string) (string, error)
PayAndSettle requests the transactor to withdraw money into l1.
func (*Transactor) RegisterIdentity ¶
func (t *Transactor) RegisterIdentity(id string, stake, fee *big.Int, beneficiary string, chainID int64, referralToken *string) error
RegisterIdentity instructs Transactor to register identity on behalf of a client identified by 'id'
func (*Transactor) RegisterProviderIdentity ¶
func (t *Transactor) RegisterProviderIdentity(id string, stake, fee *big.Int, beneficiary string, chainID int64, referralToken *string) error
RegisterProviderIdentity instructs Transactor to register Provider on behalf of a client identified by 'id'
func (*Transactor) SettleAndRebalance ¶
func (t *Transactor) SettleAndRebalance(hermesID, providerID string, promise pc.Promise) (string, error)
SettleAndRebalance requests the transactor to settle and rebalance the given channel
func (*Transactor) SettleIntoStake ¶
func (t *Transactor) SettleIntoStake(hermesID, providerID string, promise pc.Promise) (string, error)
SettleIntoStake requests the transactor to settle and transfer the balance to stake.
func (*Transactor) SettleWithBeneficiary ¶
func (t *Transactor) SettleWithBeneficiary(id, beneficiary, hermesID string, promise pc.Promise) (string, error)
SettleWithBeneficiary instructs Transactor to set beneficiary on behalf of a client identified by 'id'
type TransactorRegistrationEntryStatus ¶
type TransactorRegistrationEntryStatus string
TransactorRegistrationEntryStatus represents the registration status.
type TransactorStatusResponse ¶
type TransactorStatusResponse struct { IdentityID string `json:"identity_id"` Status TransactorRegistrationEntryStatus `json:"status"` TxHash string `json:"tx_hash"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` BountyAmount *big.Int `json:"bounty_amount"` ChainID int64 `json:"chain_id"` }
TransactorStatusResponse represents the current registration status.