Documentation ¶
Index ¶
- Variables
- func Retry(executionFunction func() <-chan retry.Result, retries int) (interface{}, error)
- type Assets
- type BurnEvent
- type Contracts
- type Distributor
- type Fee
- type FungibleTransferData
- type LockEvent
- type Messages
- type NonFungibleTransferData
- type Pricing
- type Prometheus
- type ReadOnly
- type Scheduled
- type Signer
- type TransferData
- type Transfers
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("not found")
Functions ¶
func Retry ¶ added in v1.4.0
Retry executes two functions in race condition ({@param executionFunction} and timeout function). It takes the first result from both functions. If timeout function finishes first, it will retry the same mechanism {@param retries} times. If {@param executionFunction} finishes first, it will directly resolve its result. This function finds usability in the execution of EVM queries, which from time to time do not return response - the query is stuck forever and breaks the business logic. This way, if the query takes more than sleepPeriod, it will retry the query {@param retries} times. If {@param retries} is reached, it will return an error.
Types ¶
type Assets ¶ added in v1.4.0
type Assets interface { // FungibleNetworkAssets Gets all Fungible Assets by Network ID FungibleNetworkAssets() map[uint64][]string // NativeToWrappedAssets Gets all Native assets with their Wrapped assets by Network ID NativeToWrappedAssets() map[uint64]map[string]map[uint64]string // WrappedFromNative Gets All Wrapped Assets for passed Native Asset's address WrappedFromNative(nativeChainId uint64, nativeAssetAddress string) map[uint64]string // NativeToWrapped Gets Wrapped Asset for passed Native Asset's address and Target Chain ID NativeToWrapped(nativeAssetAddress string, nativeChainId, targetChainId uint64) string // WrappedToNative Gets Native Asset from passed Wrapped Asset's address and Wrapped Chain ID WrappedToNative(wrappedAssetAddress string, wrappedChainId uint64) *assetModel.NativeAsset // FungibleNetworkAssetsByChainId Gets all Fungible assets for passed Chain ID FungibleNetworkAssetsByChainId(chainId uint64) []string // FungibleNativeAsset Gets NativeAsset for passed chainId and assetAddress FungibleNativeAsset(chainId uint64, nativeAssetAddress string) *assetModel.NativeAsset // IsNative Returns flag showing if the passed Asset's Address is Native for the passed Chain ID IsNative(chainId uint64, assetAddress string) bool // OppositeAsset Gets Opposite asset for passed chain IDs and assetAddress OppositeAsset(sourceChainId uint64, targetChainId uint64, assetAddress string) string // FungibleAssetInfo Gets FungibleAssetInfo FungibleAssetInfo(networkId uint64, assetAddress string) (assetInfo assetModel.FungibleAssetInfo, exist bool) }
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(transfer transfer.Transfer) // 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 // ReloadMembers triggers to fetch all the members from the Router Contract ReloadMembers() // GetClient returns the Contracts Service corresponding EVM Client GetClient() client.Core // IsMember returns true/false depending on whether the provided address is a Bridge member or not IsMember(address string) bool // HasValidSignaturesLength returns whether the signatures are enough for submission HasValidSignaturesLength(*big.Int) (bool, error) // ParseMintLog parses a general typed log to a RouterMint event ParseMintLog(log types.Log) (*abi.RouterMint, error) // ParseBurnLog parses a general typed log to a RouterBurn event ParseBurnLog(log types.Log) (*abi.RouterBurn, error) // ParseLockLog parses a general typed log to a RouterLock event ParseLockLog(log types.Log) (*abi.RouterLock, error) // ParseUnlockLog parses a general typed log to a RouterUnlock event ParseUnlockLog(log types.Log) (*abi.RouterUnlock, error) // ParseBurnERC721Log parses a general typed log to a BurnERC721event ParseBurnERC721Log(log types.Log) (*abi.RouterBurnERC721, error) // WatchBurnEventLogs creates a subscription for Burn Events emitted in the Bridge contract WatchBurnEventLogs(opts *bind.WatchOpts, sink chan<- *abi.RouterBurn) (event.Subscription, error) // WatchLockEventLogs creates a subscription for Lock Events emitted in the Bridge contract WatchLockEventLogs(opts *bind.WatchOpts, sink chan<- *abi.RouterLock) (event.Subscription, error) }
Contracts interface is implemented by the Contracts Service providing business logic access to the EVM SmartContracts and other related utility functions
type Distributor ¶ added in v1.4.0
type Distributor interface { // PrepareTransfers Returns an equally divided array of transfers to each member PrepareTransfers(fee int64, token string) ([]model.Transfer, error) // 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, based on a specified token fee percentage CalculateFee(token string, amount int64) (fee, remainder int64) }
Fee interface is implemented by the Calculator Service
type FungibleTransferData ¶ added in v1.4.0
type FungibleTransferData struct { TransferData Amount string `json:"amount"` }
type LockEvent ¶ added in v1.4.0
type LockEvent interface { // ProcessEvent processes the lock event by submitting the appropriate // Scheduled Token Mint and Transfer transactions ProcessEvent(event transfer.Transfer) }
LockEvent is the major service used for processing BurnEvent operations
type Messages ¶
type Messages interface { // SanityCheckFungibleSignature performs any validation required prior handling the topic message // (verifies input data against the corresponding Transaction record) SanityCheckFungibleSignature(tm *proto.TopicEthSignatureMessage) (bool, error) // SanityCheckNftSignature performs any validation required prior handling the topic message // (verifies input data against the corresponding Transaction record) SanityCheckNftSignature(tm *proto.TopicEthNftSignatureMessage) (bool, error) // ProcessSignature processes the signature message, verifying and updating all necessary fields in the DB ProcessSignature(transferID, signature string, targetChainId uint64, timestamp int64, authMsg []byte) error // SignFungibleMessage signs a Fungible message based on Transfer SignFungibleMessage(transfer model.Transfer) ([]byte, error) // SignNftMessage signs an NFT messaged based on Transfer SignNftMessage(transfer model.Transfer) ([]byte, error) }
type NonFungibleTransferData ¶ added in v1.4.0
type NonFungibleTransferData struct { TransferData TokenId int64 `json:"tokenId"` Metadata string `json:"metadata"` }
type Pricing ¶ added in v1.4.0
type Pricing interface { // GetTokenPriceInfo gets price for token with the passed networkId and tokenAddressOrId GetTokenPriceInfo(networkId uint64, tokenAddressOrId string) (priceInfo pricing.TokenPriceInfo, exist bool) // FetchAndUpdateUsdPrices fetches all prices from the Web APIs and updates them in the mapping FetchAndUpdateUsdPrices() error // GetMinAmountsForAPI getting all prices by networkId GetMinAmountsForAPI() map[uint64]map[string]string }
type Prometheus ¶ added in v1.4.0
type Prometheus interface { // CreateGaugeIfNotExists creates new Gauge Metric and registers it in Prometheus if not exists CreateGaugeIfNotExists(opts prometheus.GaugeOpts) prometheus.Gauge // CreateSuccessRateGaugeIfNotExists creates new Gauge Metric for Success Rate and registers it in Prometheus if not exists CreateSuccessRateGaugeIfNotExists(transactionId string, sourceChainId, targetChainId uint64, asset, metricNameSuffix, metricHelp string) (prometheus.Gauge, error) // GetGauge retrieves Gauge by name with flag for existence GetGauge(name string) prometheus.Gauge // DeleteGauge unregisters and deletes Gauge with the passed name DeleteGauge(name string) // CreateCounterIfNotExists creates new Counter Metric and registers it in Prometheus CreateCounterIfNotExists(opts prometheus.CounterOpts) prometheus.Counter // GetCounter retrieves Counter by name with flag for existence GetCounter(name string) prometheus.Counter // DeleteCounter unregisters and deletes Counter with the passed name DeleteCounter(name string) // ConstructMetricName constructing name for metric ConstructMetricName(sourceNetworkId, targetNetworkId uint64, asset, transactionId, metricTarget string) (string, error) // GetIsMonitoringEnabled returns if the monitoring is enabled GetIsMonitoringEnabled() bool }
type ReadOnly ¶ added in v1.4.0
type ReadOnly interface { FindTransfer(transferID string, fetch func() (*mirror_node.Response, error), save func(transactionID, scheduleID, status string) error) FindAssetTransfer(transferID string, asset string, transfers []model.Hedera, fetch func() (*mirror_node.Response, error), save func(transactionID, scheduleID, status string) error) FindNftTransfer(transferID string, tokenID string, serialNum int64, sender string, receiver string, save func(transactionID, scheduleID, status string) error) }
type Scheduled ¶ added in v1.4.0
type Scheduled interface { // ExecuteScheduledTransferTransaction submits a scheduled transfer transaction and executes provided functions when necessary ExecuteScheduledTransferTransaction(id, asset string, transfers []transfer.Hedera, onExecutionSuccess func(transactionID, scheduleID string), onExecutionFail, onSuccess, onFail func(transactionID string)) // ExecuteScheduledMintTransaction submits a scheduled mint transaction and executes provided functions when necessary ExecuteScheduledMintTransaction(id, asset string, amount int64, status *chan string, onExecutionSuccess func(transactionID, scheduleID string), onExecutionFail, onSuccess, onFail func(transactionID string)) // ExecuteScheduledBurnTransaction submits a scheduled burn transaction and executes provided functions when necessary ExecuteScheduledBurnTransaction(id, asset string, amount int64, status *chan string, onExecutionSuccess func(transactionID, scheduleID string), onExecutionFail, onSuccess, onFail func(transactionID string)) // ExecuteScheduledNftTransferTransaction submits a scheduled nft transfer transaction and executes provided functions when necessary ExecuteScheduledNftTransferTransaction(id string, nftID hedera.NftID, sender hedera.AccountID, receiving hedera.AccountID, 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 TransferData ¶
type TransferData struct { IsNft bool `json:"isNft"` Recipient string `json:"recipient"` RouterAddress string `json:"routerAddress"` SourceChainId uint64 `json:"sourceChainId"` TargetChainId uint64 `json:"targetChainId"` SourceAsset string `json:"sourceAsset"` NativeAsset string `json:"nativeAsset"` TargetAsset 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 model.Transaction) (uint64, string, error) // InitiateNewTransfer Stores the incoming transfer message into the Database // aware of already processed transfers InitiateNewTransfer(tm transfer.Transfer) (*entity.Transfer, error) // ProcessNativeTransfer processes the native fungible transfer message by signing the required // authorisation signature submitting it into the required HCS Topic ProcessNativeTransfer(tm transfer.Transfer) error // ProcessNativeNftTransfer processes the native nft transfer message by signing the required // authorisation signature submitting it into the required HCS Topic ProcessNativeNftTransfer(tm transfer.Transfer) error // ProcessWrappedTransfer processes the wrapped transfer message by signing the required // authorisation signature submitting it into the required HCS Topic ProcessWrappedTransfer(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) (interface{}, error) }
Transfers is the major service used for processing Transfers operations