This section elaborates on the transaction message handler methods being exposed by the Bet module.
Wager
When a wager transaction is processed, the following things happen:
If KYC is not ignored, KYC validation of the user should be approved and KYC ID should be equal to the creator's address.
Then, invoke the OVM module to validate the ticket.
After the ticket validation, the Order Book module is invoked to manage the transfer of funds involved in the process and distribute the participation exposures.
Then, a new bet will be created with the given data and stored in the bet module's KVStore, in the following way:
newBet :=&types.Bet{ Creator: msg.Creator, Uid: msg.Uid, MarketUid: <msg.Ticket.MarketUid>, OddsUid: <msg.Ticket.OddsUid>, OddsValue: <msg.Ticket.OddsValue>, OddsType: <msg.OddsType>, Amount: msg.Amount, Fee <bet fee of the event>, Status: types.Bet_STATUS_PLACED, Result: types.Bet_RESULT_PENDING CreatedAt: <current block time>, MaxLossMultiplier: <selected odds max loss multiplier>, BetFulfillment: <calculated by the order book module>,}
RPC
The RPC for adding a market is as follows:
// Wager defines a method to place a bet with the given data.
rpc Wager(MsgWager) returns (MsgWagerResponse);
Request Message
The request message for Wager is MsgWager. The proto for the request message is as follows:
// MsgWager defines a message to place a bet with the given data.
message MsgWager {
// creator is the bettor address.
string creator = 1;
// props contains bet properties.
WagerProps props = 2;
}
Response Message
The response message Wager is MsgWagerResponse. The proto for the request message is as follows:
// MsgWagerResponse is the returning value in the response
// of MsgWagerResponse request.
message MsgWagerResponse { WagerProps props = 1; }