service

package
v0.0.1-alpha-8 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Contracts

type Contracts interface {
	// GetBridgeContractAddress returns the bridge contract address
	GetBridgeContractAddress() common.Address
	// GetServiceFee returns the current service fee configured in the Bridge contract
	GetServiceFee() *big.Int
	// 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)
	// SubmitSignatures signs and broadcasts an Ethereum TX authorising the mint operation on the Ethereum network
	SubmitSignatures(opts *bind.TransactOpts, txId, wrappedToken, ethAddress, amount, fee string, signatures [][]byte) (*types.Transaction, error)
	// Check whether a specific asset has a valid bridge token address. Returns the erc20 token address if token is valid. Returns an empty string if not.
	ParseToken(nativeTokenId string) (string, error)
}

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

type Fees

type Fees interface {
	GetEstimatedTxFeeFromGWei(gasPriceGWei string) (string, error)
	ValidateExecutionFee(transferFee string, transferAmount string, gasPriceWei string) (bool, error)
}

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)
	// VerifyEthereumTxAuthenticity performs the validation required prior handling the topic message
	// (verifies the submitted TX against the required target contract and arguments passed)
	VerifyEthereumTxAuthenticity(tm message.Message) (bool, error)
	// ProcessSignature processes the signature message, verifying and updating all necessary fields in the DB
	ProcessSignature(tm message.Message) error
	// ScheduleForSubmission computes the execution slot and schedules the Ethereum Mint TX for submission
	ScheduleEthereumTxForSubmission(transferID string) error
	// ProcessEthereumTxMessage
	ProcessEthereumTxMessage(tm message.Message) error
}

type Scheduler

type Scheduler interface {
	// Schedule - Schedules new Transaction for execution at the right leader elected slot
	Schedule(id string, firstTimestamp, slot int64, task func()) error
	// Cancel - Removes and cancels an already scheduled Transaction
	Cancel(id string)
}

Scheduler provides the required scheduling logic for submitting Ethereum transactions using a slot-based algorithm

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"`
	Amount       string   `json:"amount"`
	NativeToken  string   `json:"nativeToken"`
	WrappedToken string   `json:"wrappedToken"`
	Fee          string   `json:"fee"`
	GasPrice     string   `json:"gasPrice"`
	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) (*memo.Memo, error)
	// SaveRecoveredTxn creates new Transaction record persisting the recovered Transfer TXn
	SaveRecoveredTxn(txId, amount, nativeToken, wrappedToken string, m memo.Memo) error
	// InitiateNewTransfer Stores the incoming transfer message into the Database
	// aware of already processed transfers
	InitiateNewTransfer(tm transfer.Transfer) (*entity.Transfer, error)
	// VerifyFee verifies that the provided TX reimbursement fee is enough. Returns error if TX processing must be stopped
	// If no error is returned the TX can be processed
	VerifyFee(tm transfer.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