Documentation ¶
Overview ¶
Package book represents all the transactions necessary for the game.
Index ¶
- Constants
- type BetInfo
- type Book
- func (b *Book) AccountBalance(ctx context.Context, accountID string) (BalanceGWei *big.Float, err error)
- func (b *Book) Balance(ctx context.Context) (GWei *big.Float, err error)
- func (b *Book) BetDetails(ctx context.Context, betID string) (BetInfo, error)
- func (b *Book) CancelBetExpired(ctx context.Context, betID string) (*types.Transaction, *types.Receipt, error)
- func (b *Book) CancelBetModerator(ctx context.Context, betID string, cbm CancelBetModerator) (*types.Transaction, *types.Receipt, error)
- func (b *Book) CancelBetOwner(ctx context.Context, betID string, cbo CancelBetOwner) (*types.Transaction, *types.Receipt, error)
- func (b *Book) CancelBetParticipants(ctx context.Context, betID string, cbp CancelBetParticipants) (*types.Transaction, *types.Receipt, error)
- func (b *Book) CheckBalance(ctx context.Context, expBal *big.Float) error
- func (b *Book) Client() *ethereum.Client
- func (b *Book) ContractID() string
- func (b *Book) Deposit(ctx context.Context, amountGWei *big.Float) (*types.Transaction, *types.Receipt, error)
- func (b *Book) Drain(ctx context.Context) (*types.Transaction, *types.Receipt, error)
- func (b *Book) EthereumBalance(ctx context.Context) (wei *big.Int, err error)
- func (b *Book) Nonce(ctx context.Context, accountID string) (*big.Int, error)
- func (b *Book) PlaceBet(ctx context.Context, betID string, pb PlaceBet) (*types.Transaction, *types.Receipt, error)
- func (b *Book) ReconcileBet(ctx context.Context, betID string, rb ReconcileBet) (*types.Transaction, *types.Receipt, error)
- func (b *Book) Sign(betID string, nonce int) ([]byte, error)
- func (b *Book) Withdraw(ctx context.Context) (*types.Transaction, *types.Receipt, error)
- type CancelBetModerator
- type CancelBetOwner
- type CancelBetParticipants
- type PlaceBet
- type ReconcileBet
Constants ¶
const ( StateNotExists = 0 StateLive = 1 StateReconciled = 2 StateCancelled = 3 )
These constants define the different bet states.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BetInfo ¶
type BetInfo struct { State int Participants []common.Address Moderator common.Address AmountBetGWei *big.Float Expiration time.Time }
BetInfo represents information about a bet inside the contract.
type Book ¶
type Book struct {
// contains filtered or unexported fields
}
Book represents a bank that allows for the reconciling of a game and information about account balances.
func New ¶
func New(ctx context.Context, backend ethereum.Backend, privateKey *ecdsa.PrivateKey, contractID string) (*Book, error)
New returns a new bank with the ability to manage the game money.
func (*Book) AccountBalance ¶
func (b *Book) AccountBalance(ctx context.Context, accountID string) (BalanceGWei *big.Float, err error)
AccountBalance will return the balance for the specified account. Only the owner of the smart contract can make this call.
func (*Book) BetDetails ¶
BetDetails will the details for the specied betID.
func (*Book) CancelBetExpired ¶
func (b *Book) CancelBetExpired(ctx context.Context, betID string) (*types.Transaction, *types.Receipt, error)
CancelBetExpired allows any participant to cancel the bet after the bet as expired for 30 days and it isn't reconciled.
func (*Book) CancelBetModerator ¶
func (b *Book) CancelBetModerator(ctx context.Context, betID string, cbm CancelBetModerator) (*types.Transaction, *types.Receipt, error)
CancelBetModerator allows the moderator to sign off on cancelling the bet.
func (*Book) CancelBetOwner ¶
func (b *Book) CancelBetOwner(ctx context.Context, betID string, cbo CancelBetOwner) (*types.Transaction, *types.Receipt, error)
CancelBetOwner allows the owner to sign off on cancelling the bet.
func (*Book) CancelBetParticipants ¶
func (b *Book) CancelBetParticipants(ctx context.Context, betID string, cbp CancelBetParticipants) (*types.Transaction, *types.Receipt, error)
CancelBetParticipants allows the participants to sign off on cancelling the bet.
func (*Book) CheckBalance ¶
CheckBalance pulls and compares the specified balance for a player.
func (*Book) Deposit ¶
func (b *Book) Deposit(ctx context.Context, amountGWei *big.Float) (*types.Transaction, *types.Receipt, error)
Deposit will add the given amount to the account's contract balance.
func (*Book) Drain ¶
Drain will drain the full value of the smart contract and transfer it to the owner address.
func (*Book) EthereumBalance ¶
EthereumBalance returns the current balance for the account connecting this book.
func (*Book) PlaceBet ¶
func (b *Book) PlaceBet(ctx context.Context, betID string, pb PlaceBet) (*types.Transaction, *types.Receipt, error)
PlaceBet adds a new bet to the smart contract. This bet will be live if accepted by the smart contract and all participants will be bound to the bet.
func (*Book) ReconcileBet ¶
func (b *Book) ReconcileBet(ctx context.Context, betID string, rb ReconcileBet) (*types.Transaction, *types.Receipt, error)
ReconcileBet allows the moderator to sign off on the live bet and provide the winning accounts.
type CancelBetModerator ¶
type CancelBetModerator struct { AmountFeeGWei *big.Float Nonce *big.Int Moderator common.Address Signature []byte }
CancelBetModerator represents the input required to cancel a bet by the moderator.
func (CancelBetModerator) Validate ¶
func (cbm CancelBetModerator) Validate() error
Validate verifies the reconcile bet value is properly initialized.
type CancelBetOwner ¶
CancelBetOwner represents the input required to cancel a bet by the contract owner.
func (CancelBetOwner) Validate ¶
func (cbo CancelBetOwner) Validate() error
Validate verifies the reconcile bet value is properly initialized.
type CancelBetParticipants ¶
type CancelBetParticipants struct { AmountFeeGWei *big.Float Nonces []*big.Int Signatures [][]byte }
CancelBetParticipants represents the input required to cancel a bet by the participants.
func (CancelBetParticipants) Validate ¶
func (cbp CancelBetParticipants) Validate() error
Validate verifies the reconcile bet value is properly initialized.
type PlaceBet ¶
type PlaceBet struct { AmountBetGWei *big.Float AmountFeeGWei *big.Float Expiration time.Time Moderator common.Address Participants []common.Address Nonces []*big.Int Signatures [][]byte }
PlaceBet represents the input required to place a bet.
type ReconcileBet ¶
type ReconcileBet struct { Nonce *big.Int Moderator common.Address Signature []byte Winners []common.Address }
ReconcileBet represents the input required to reconcile a bet.
func (ReconcileBet) Validate ¶
func (rb ReconcileBet) Validate() error
Validate verifies the reconcile bet value is properly initialized.