Documentation ¶
Overview ¶
Package swap wraps the 'swap' Ethereum smart contract. It is an abstraction layer to hide implementation details about the different Swap contract iterations (Simple Swap, Soft Swap, etc.)
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotASwapContract is given when an address is verified not to have a SWAP contract based on its bytecode ErrNotASwapContract = errors.New("not a swap contract") // ErrTransactionReverted is given when the transaction that cashes a cheque is reverted ErrTransactionReverted = errors.New("Transaction reverted") )
var WaitFunc = waitForTx
WaitFunc is the default function to wait for transactions We can overwrite this in tests so that we don't need to wait for mining
Functions ¶
func ValidateCode ¶
ValidateCode checks that the on-chain code at address matches the expected swap contract code.
Types ¶
type Backend ¶
type Backend interface { bind.ContractBackend TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error) }
Backend wraps all methods required for contract deployment.
type CashChequeResult ¶
type CashChequeResult struct { Beneficiary common.Address // beneficiary of the cheque Recipient common.Address // address which received the funds Caller common.Address // caller of cashCheque TotalPayout *big.Int // total amount that was paid out in this call CumulativePayout *big.Int // cumulative payout of the cheque that was cashed CallerPayout *big.Int // payout for the caller of cashCheque Bounced bool // indicates wether parts of the cheque bounced }
CashChequeResult summarizes the result of a CashCheque or CashChequeBeneficiary call
type Contract ¶
type Contract interface { // CashChequeBeneficiary cashes the cheque by the beneficiary CashChequeBeneficiary(auth *bind.TransactOpts, backend Backend, beneficiary common.Address, cumulativePayout *big.Int, ownerSig []byte) (*CashChequeResult, *types.Receipt, error) // ContractParams returns contract info (e.g. deployed address) ContractParams() *Params // Issuer returns the contract owner from the blockchain Issuer(opts *bind.CallOpts) (common.Address, error) // PaidOut returns the total paid out amount for the given address PaidOut(opts *bind.CallOpts, addr common.Address) (*big.Int, error) }
Contract interface defines the methods exported from the underlying go-bindings for the smart contract
func Deploy ¶
func Deploy(auth *bind.TransactOpts, backend bind.ContractBackend, owner common.Address, harddepositTimeout time.Duration) (Contract, *types.Transaction, error)
Deploy deploys an instance of the underlying contract and returns its instance and the transaction identifier
func InstanceAt ¶
InstanceAt creates a new instance of a contract at a specific address. It assumes that there is an existing contract instance at the given address, or an error is returned This function is needed to communicate with remote Swap contracts (e.g. sending a cheque)