service

package
v0.0.1-alpha-10 Latest Latest
Warning

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

Go to latest
Published: May 19, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

Functions

This section is empty.

Types

type BurnEvent added in v1.4.0

type BurnEvent interface {
	// ProcessEvent processes the burn event by submitting the appropriate
	// scheduled transaction, leaving the synchronization of the actual transfer on HCS
	ProcessEvent(event burn_event.BurnEvent)
	// TransactionID returns the corresponding Scheduled Transaction paying out the
	// fees to validators and the amount being bridged to the receiver address
	TransactionID(id string) (string, error)
}

BurnEvent is the major service used for processing BurnEvent operations

type Contracts

type Contracts interface {
	// Address returns the address of the contract instance
	Address() common.Address
	// GetMembers returns the array of bridge members currently set in the Bridge contract
	GetMembers() []string
	// IsMember returns true/false depending on whether the provided address is a Bridge member or not
	IsMember(address string) bool
	// WatchBurnEventLogs creates a subscription for Burn Events emitted in the Bridge contract
	WatchBurnEventLogs(opts *bind.WatchOpts, sink chan<- *abi.RouterBurn) (event.Subscription, error)
	// Check whether a specific asset has a valid bridge token address. Returns the erc20 token address if native asset is valid. Returns an empty string if not.
	ToWrapped(native string) (string, error)
	// Checks whether a specific wrapped token has a corresponding native token. Returns the native token as string
	ToNative(wrapped common.Address) (string, error)
}

Contracts interface is implemented by the Contracts Service providing business logic access to the Ethereum SmartContracts and other related utility functions

type Distributor added in v1.4.0

type Distributor interface {
	// CalculateMemberDistribution Returns an equally divided to each member
	CalculateMemberDistribution(validFee int64) ([]transfer.Hedera, error)
	// ValidAmount Returns the closest amount, which can be equally divided to members
	ValidAmount(amount int64) int64
}

Distributor interface is implemented by the Distributor Service Handles distribution of proportional amounts to members

type Fee added in v1.4.0

type Fee interface {
	// CalculateFee calculates the fee and remainder of a given amount
	CalculateFee(amount int64) (fee, remainder int64)
}

Fee interface is implemented by the Calculator Service

type Messages

type Messages interface {
	// SanityCheckSignature performs any validation required prior handling the topic message
	// (verifies metadata against the corresponding Transaction record)
	SanityCheckSignature(tm message.Message) (bool, error)
	// ProcessSignature processes the signature message, verifying and updating all necessary fields in the DB
	ProcessSignature(tm message.Message) error
}

type Scheduled added in v1.4.0

type Scheduled interface {
	// Execute submits a scheduled transaction and executes provided functions when necessary
	Execute(id, nativeAsset string, transfers []transfer.Hedera, onExecutionSuccess func(transactionID, scheduleID string), onExecutionFail, onSuccess, onFail func(transactionID string))
}

Scheduled interface is implemented by the Scheduled Service Provides business logic for execution of Scheduled Transactions

type Signer

type Signer interface {
	Sign(msg []byte) ([]byte, error)
	NewKeyTransactor(chainId *big.Int) (*bind.TransactOpts, error)
	Address() string
}

type TransferData

type TransferData struct {
	Recipient     string   `json:"recipient"`
	RouterAddress string   `json:"routerAddress"`
	Amount        string   `json:"amount"`
	NativeAsset   string   `json:"nativeAsset"`
	WrappedAsset  string   `json:"wrappedAsset"`
	Signatures    []string `json:"signatures"`
	Majority      bool     `json:"majority"`
}

type Transfers

type Transfers interface {
	// SanityCheckTransfer performs any validation required prior to handling the transaction
	// (memo, state proof verification)
	SanityCheckTransfer(tx mirror_node.Transaction) (string, error)
	// SaveRecoveredTxn creates new Transaction record persisting the recovered Transfer TXn
	SaveRecoveredTxn(txId, amount, nativeAsset, wrappedAsset string, m string) error
	// InitiateNewTransfer Stores the incoming transfer message into the Database
	// aware of already processed transfers
	InitiateNewTransfer(tm transfer.Transfer) (*entity.Transfer, error)
	// ProcessTransfer processes the transfer message by signing the required
	// authorisation signature submitting it into the required HCS Topic
	ProcessTransfer(tm transfer.Transfer) error
	// TransferData returns from the database the given transfer, its signatures and
	// calculates if its messages have reached super majority
	TransferData(txId string) (TransferData, error)
}

Transfers is the major service used for processing Transfers operations

Jump to

Keyboard shortcuts

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