beneficiary

package
v0.0.0-...-365054f Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidAddress = errors.New("invalid address")
	ErrNotFound       = errors.New("beneficiary not found")
)

ErrInvalidAddress represents invalid address error

Functions

This section is empty.

Types

type AddressStorage

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

AddressStorage handles storing of beneficiary address

func NewAddressStorage

func NewAddressStorage(storage localStorage) *AddressStorage

NewAddressStorage constructor

func (*AddressStorage) Address

func (as *AddressStorage) Address(identity string) (string, error)

Address retrieve beneficiary address for identity

func (*AddressStorage) Save

func (as *AddressStorage) Save(identity, address string) error

Save beneficiary address for identity

type BeneficiaryStorage

type BeneficiaryStorage interface {
	Address(identity string) (string, error)
	Save(identity, address string) error
}

BeneficiaryStorage handles storing of beneficiary address

type ChangeStatus

type ChangeStatus struct {
	ChangeTo string
	State    SettleState
	Error    string
}

ChangeStatus holds Beneficiary settlement transaction information

type Provider

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

Provider describes a beneficiary provider.

func NewProvider

func NewProvider(currentChain int64, ad addressProvider, st storage, bc multiChainBC) *Provider

NewProvider returns a new beneficiary handler according to the given chain.

func (*Provider) GetBeneficiary

func (b *Provider) GetBeneficiary(identity common.Address) (common.Address, error)

GetBeneficiary looks up beneficiary address in the blockchain.

type Saver

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

Saver saves a given beneficiary and tracks its progress.

func NewSaver

func NewSaver(currentChain int64, ad addressProvider, st storage, bc multiChainBC, set settler) *Saver

NewSaver returns a new beneficiary saver according to the given chain.

func (Saver) CleanupAndGetChangeStatus

func (bcs Saver) CleanupAndGetChangeStatus(id identity.Identity, currentBeneficiary string) (*ChangeStatus, error)

CleanupAndGetChangeStatus cleans up current change status and returns it.

Cleanup is done using the provided currentBeneficiary, if the beneficiaries match and transaction is still in state "Pending" it will be bumped to completed, else nothing is done.

func (Saver) GetChangeStatus

func (bcs Saver) GetChangeStatus(id identity.Identity) (*ChangeStatus, error)

GetChangeStatus returns current change transaction status.

func (*Saver) SettleAndSaveBeneficiary

func (b *Saver) SettleAndSaveBeneficiary(id identity.Identity, hermeses []common.Address, beneficiary common.Address) error

SettleAndSaveBeneficiary executes a settlement transaction saving the beneficiary to the blockchain.

type SettleState

type SettleState string

SettleState represents the state of settle with beneficiary transaction

const (
	// Pending transaction is pending
	Pending SettleState = "pending"
	// Completed transaction is completed
	Completed SettleState = "completed"
	// NotFound transaction state
	NotFound SettleState = "not_found"
)

Jump to

Keyboard shortcuts

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