Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( WithdrawalAssetInvalid = problem.P{ Type: "withdrawal_asset_invalid", Title: "Withdrawal Asset Invalid", Status: http.StatusBadRequest, Detail: "Withdrawing the requested asset is not supported by the bridge." + "Refund the deposit once the withdrawal period has expired.", } WithdrawalAmountInvalid = problem.P{ Type: "withdrawal_amount_invalid", Title: "Withdrawal Amount Invalid", Status: http.StatusBadRequest, Detail: "Withdrawing the requested amount is not supported by the bridge." + "Refund the deposit once the withdrawal period has expired.", } )
var ( InvalidEthereumRecipient = problem.P{ Type: "invalid_ethereum_recipient", Title: "Invalid Ethereum Recipient", Status: http.StatusBadRequest, Detail: "The recipient of the deposit is not a valid Ethereum address.", } EthereumNodeBehind = problem.P{ Type: "ethereum_node_behind", Title: "Ethereum Node Behind", Status: http.StatusUnprocessableEntity, Detail: "The ethereum node used by the validator is still catching up.", } )
var ( WithdrawalWindowExpired = problem.P{ Type: "withdrawal_window_expired", Title: "Withdrawal Window Expired", Status: http.StatusBadRequest, Detail: "The withdrawal window has expired. Only refunds are allowed at this point.", } WithdrawalAlreadyExecuted = problem.P{ Type: "withdrawal_already_executed", Title: "Withdrawal Already Executed", Status: http.StatusBadRequest, Detail: "The withdrawal has already been executed.", } InvalidStellarRecipient = problem.P{ Type: "invalid_stellar_recipient", Title: "Invalid Stellar Recipient", Status: http.StatusBadRequest, Detail: "The recipient of the deposit is not a valid Stellar address.", } )
var RefundAlreadyExecuted = problem.P{ Type: "refund_already_executed", Title: "Refund Already Executed", Status: http.StatusBadRequest, Detail: "The refund has already been executed.", }
var WithdrawalWindowStillActive = problem.P{ Type: "withdrawal_window_still_active", Title: "Withdrawal Window Still Active", Status: http.StatusBadRequest, Detail: "The withdrawal window is still active." + " Wait until the withdrawal window has closed before attempting a refund.", }
Functions ¶
This section is empty.
Types ¶
type AssetConverter ¶
type AssetConverter struct {
// contains filtered or unexported fields
}
AssetConverter maps assets from Stellar to their equivalent tokens on Ethereum and vice versa.
func NewAssetConverter ¶
func NewAssetConverter(configEntries []AssetMappingConfigEntry) (AssetConverter, error)
NewAssetConverter constructs a new instance of AssetConverter
func (AssetConverter) ToEthereum ¶
func (c AssetConverter) ToEthereum(asset string, assetAmount string) (common.Address, *big.Int, error)
ToEthereum returns the Ethereum token and amount for the given Stellar asset
type AssetMappingConfigEntry ¶
type AssetMappingConfigEntry struct { StellarAsset string `toml:"stellar_asset" valid:"-"` EthereumToken string `toml:"ethereum_token" valid:"-"` StellarToEthereum string `toml:"stellar_to_ethereum" valid:"-"` }
AssetMappingConfigEntry is the toml representation of a mapping between a Stellar asset and an Ethereum token
type EthereumRefundValidator ¶
type EthereumRefundValidator struct { Session db.SessionInterface WithdrawalWindow time.Duration }
EthereumRefundValidator checks if it is possible to refund a deposit to the ethereum bridge smart contract.
func (EthereumRefundValidator) CanRefund ¶
func (s EthereumRefundValidator) CanRefund(ctx context.Context, deposit store.EthereumDeposit) error
type EthereumWithdrawalDetails ¶
type EthereumWithdrawalDetails struct { // Deadline is the deadline for executing the withdrawal // transaction on Ethereum. Deadline time.Time // Recipient is the Ethereum address which should receive the // withdrawal. Recipient common.Address // Token is the address of the Ethereum tokens which will be // transferred to the recipient. Token common.Address // Amount is the amount of tokens which will be transferred to // the recipient. Amount *big.Int }
EthereumWithdrawalDetails includes metadata about the validation result.
type EthereumWithdrawalValidator ¶
type EthereumWithdrawalValidator struct { Observer ethereum.Observer EthereumFinalityBuffer uint64 WithdrawalWindow time.Duration Converter AssetConverter }
EthereumWithdrawalValidator checks if it is possible to withdraw a deposit to the Stellar bridge account.
func (EthereumWithdrawalValidator) CanWithdraw ¶
func (s EthereumWithdrawalValidator) CanWithdraw(ctx context.Context, deposit store.StellarDeposit) (EthereumWithdrawalDetails, error)
type StellarRefundDetails ¶
type StellarRefundDetails struct { // LedgerSequence is the sequence number of the Stellar ledger // for which the validation result is accurate. LedgerSequence uint32 }
StellarRefundDetails includes metadata about the validation result.
type StellarRefundValidator ¶
type StellarRefundValidator struct { Session db.SessionInterface WithdrawalWindow time.Duration Observer ethereum.Observer EthereumFinalityBuffer uint64 }
StellarRefundValidator checks if it is possible to refund a deposit to depositor's Stellar account.
func (StellarRefundValidator) CanRefund ¶
func (s StellarRefundValidator) CanRefund(ctx context.Context, deposit store.StellarDeposit) (StellarRefundDetails, error)
type StellarWithdrawalDetails ¶
type StellarWithdrawalDetails struct { // Deadline is the deadline for executing the withdrawal // transaction on Stellar. Deadline time.Time // Recipient is the Stellar account which should receive the // withdrawal. Recipient string // LedgerSequence is the sequence number of the Stellar ledger // for which the validation result is accurate. LedgerSequence uint32 // Asset is the Stellar asset which will be transferred to the // recipient. Asset string // Amount is the amount which will be transferred to the recipient. Amount int64 }
StellarWithdrawalDetails includes metadata about the validation result.
type StellarWithdrawalValidator ¶
type StellarWithdrawalValidator struct { Session db.SessionInterface WithdrawalWindow time.Duration Converter AssetConverter }
StellarWithdrawalValidator checks if it is possible to withdraw a deposit to the ethereum bridge smart contract on Stellar.
func (StellarWithdrawalValidator) CanWithdraw ¶
func (s StellarWithdrawalValidator) CanWithdraw(ctx context.Context, deposit store.EthereumDeposit) (StellarWithdrawalDetails, error)
type Worker ¶
type Worker struct { Store *store.DB StellarClient *horizonclient.Client StellarBuilder *txbuilder.Builder StellarSigner *signer.Signer StellarObserver *txobserver.Observer StellarWithdrawalValidator StellarWithdrawalValidator StellarRefundValidator StellarRefundValidator EthereumRefundValidator EthereumRefundValidator EthereumWithdrawalValidator EthereumWithdrawalValidator EthereumSigner ethereum.Signer // contains filtered or unexported fields }