registry

package
v0.0.0-...-c97221a Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: GPL-3.0 Imports: 21 Imported by: 5

Documentation

Index

Constants

View Source
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")
)
View Source
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")
)
View Source
const AppTopicIdentityRegistration = "registration_event_topic"

AppTopicIdentityRegistration represents the registration event topic.

View Source
const AppTopicTransactorRegistration = "transactor_identity_registration"

AppTopicTransactorRegistration represents the registration topic to which events regarding registration attempts on transactor will occur

Variables

View Source
var AppTopicEthereumClientReconnected = "ether-client-reconnect"

AppTopicEthereumClientReconnected indicates that the ethereum client has reconnected.

View Source
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

func Chains() map[int64]string

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

func NewRegistrationDataProvider(ks *keystore.KeyStore) *keystoreRegistrationDataProvider

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 ChannelStatus

type ChannelStatus = string

ChannelStatus represents status of the channel

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

type FeesResponse struct {
	Fee        *big.Int  `json:"fee"`
	ValidUntil time.Time `json:"valid_until"`
}

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

Get fetches the promise for the given hermes.

func (*RegistrationStatusStorage) GetAll

GetAll fetches all the registration statuses

func (*RegistrationStatusStorage) Store

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

FromEvent constructs a stored registration status from transactor.IdentityRegistrationRequest

type TokenRewardResponse

type TokenRewardResponse struct {
	Reward *big.Int `json:"reward"`
}

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

func (t *Transactor) DecreaseStake(id string, chainID int64, amount, transactorFee *big.Int) error

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.

Jump to

Keyboard shortcuts

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