Documentation ¶
Index ¶
- Variables
- func Retry(executionFunction func() <-chan retry.Result, retries int) (interface{}, error)
- type Assets
- type BridgeConfig
- type BridgeTxId
- 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
- type Utils
Constants ¶
This section is empty.
Variables ¶
var ErrBadRequestTransferTargetNetworkNoSignaturesRequired = errors.New("transfer target network does not require signatures")
var ErrNotFound = errors.New("not found")
var ErrWrongQuery = errors.New("wrong query parameter")
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 // NonFungibleNetworkAssets Gets all Non-Fungible Assets by Network ID NonFungibleNetworkAssets() 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) // NonFungibleAssetInfo Gets NonFungibleAssetInfo NonFungibleAssetInfo(networkId uint64, assetAddressOrId string) (assetInfo *assetModel.NonFungibleAssetInfo, exist bool) // FetchHederaTokenReserveAmount Gets Hedera's Token Reserve Amount FetchHederaTokenReserveAmount(assetId string, mirrorNode client.MirrorNode, isNative bool, hederaTokenBalances map[string]int) (reserveAmount *big.Int, err error) // FetchEvmFungibleReserveAmount Gets EVM's Fungible Token Reserve Amount FetchEvmFungibleReserveAmount(networkId uint64, assetAddress string, isNative bool, evmTokenClient client.EvmFungibleToken, routerContractAddress string) (inLowestDenomination *big.Int, err error) // FetchEvmNonFungibleReserveAmount Gets EVM's Non-Fungible Token Reserve Amount FetchEvmNonFungibleReserveAmount(networkId uint64, assetAddress string, isNative bool, evmTokenClient client.EvmNft, routerContractAddress string) (inLowestDenomination *big.Int, err error) }
type BridgeConfig ¶ added in v1.4.0
type BridgeConfig interface { // ProcessLatestConfig processes the latest bridge config from HCS Topic ProcessLatestConfig(topicID hedera.TopicID) (*parser.Bridge, error) }
BridgeConfig is the service used for processing HCS messages containing the Bridge Config
type BridgeTxId ¶ added in v1.4.0
type BridgeTxId struct {
BridgeTxId string `json:"hederaTxId"`
}
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 payload.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) ([]transaction.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 payload.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 payload.Transfer) ([]byte, error) // SignNftMessage signs an NFT messaged based on Transfer SignNftMessage(transfer payload.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 // GetHederaNftFee returns the nft fee for Hedera NFTs based on token id GetHederaNftFee(token string) (int64, bool) // GetHederaNftPrevFee returns the previous nft fee for Hedera NFTs based on token id GetHederaNftPrevFee(token string) (int64, bool) NftFees() map[uint64]map[string]pricing.NonFungibleFee }
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) FindScheduledNftAllowanceApprove( t *payload.Transfer, sender hedera.AccountID, 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, approved bool, onExecutionSuccess func(transactionID, scheduleID string), onExecutionFail, onSuccess, onFail func(transactionID string)) // ExecuteScheduledNftAllowTransaction submits a scheduled NFT allow transaction and executes provided functions when necessary ExecuteScheduledNftAllowTransaction( id string, nftID hedera.NftID, owner hedera.AccountID, spender hedera.AccountID, onExecutionSuccess func(txId, scheduleId string), onExecutionFail, onSuccess, onFail func(txId 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 transaction.Transaction) model.SanityCheckResult // InitiateNewTransfer Stores the incoming transfer message into the Database // aware of already processed transfers InitiateNewTransfer(tm payload.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 payload.Transfer) error // ProcessNativeNftTransfer processes the native nft transfer message by signing the required // authorisation signature submitting it into the required HCS Topic ProcessNativeNftTransfer(tm payload.Transfer) error // ProcessWrappedTransfer processes the wrapped transfer message by signing the required // authorisation signature submitting it into the required HCS Topic ProcessWrappedTransfer(tm payload.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) // Paged returns a paginated list of all transfers Paged(filter *model.PagedRequest) (*model.Paged, error) // UpdateTransferStatusCompleted updates the transfer status to completed UpdateTransferStatusCompleted(txId string) error }
Transfers is the major service used for processing Transfers operations