Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Selected Odds in Bet Meta #274

Merged
merged 18 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions proto/sge/bet/bet.proto
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ message Bet {
// bet_fulfillment is the fulfillment data.
repeated BetFulfillment bet_fulfillment = 14;

// meta is metadata for bet
MetaData meta = 15;
3eyedraga marked this conversation as resolved.
Show resolved Hide resolved

// Status of the Bet.
enum Status {
// the invalid or unknown
Expand Down Expand Up @@ -174,3 +177,11 @@ message BetFulfillment {
(gogoproto.moretags) = "yaml:\"payout_profit\""
];
}

// metadata for bet
message MetaData {
// selected_odds_type is metadata for bet
sgenetwork.sge.bet.OddsType selected_odds_type = 1;
// selected_odds_value is metadata for bet
string selected_odds_value = 2;
}
3 changes: 3 additions & 0 deletions proto/sge/bet/ticket.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package sgenetwork.sge.bet;
import "gogoproto/gogo.proto";
import "sge/type/kyc.proto";
import "sge/bet/bet_odds.proto";
import "sge/bet/bet.proto";
import "sge/bet/odds_type.proto";

option go_package = "github.com/sge-network/sge/x/bet/types";
Expand All @@ -21,4 +22,6 @@ message WagerTicketPayload {
sgenetwork.sge.bet.OddsType odds_type = 3;
// all odds for the selected market.
repeated BetOddsCompact all_odds = 4;
// meta is metadata for bet placement
MetaData meta = 5;
}
2 changes: 1 addition & 1 deletion x/bet/keeper/msg_server_bet.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (k msgServer) Wager(
return nil, sdkerrors.Wrapf(types.ErrInTicketValidation, "%s", err)
}

bet := types.NewBet(msg.Creator, msg.Props, payload.OddsType, payload.SelectedOdds)
bet := types.NewBet(msg.Creator, msg.Props, payload.OddsType, payload.SelectedOdds, payload.Meta)

if err := k.Keeper.Wager(ctx, bet, payload.OddsMap()); err != nil {
return nil, sdkerrors.Wrapf(types.ErrInWager, "%s", err)
Expand Down
7 changes: 6 additions & 1 deletion x/bet/simulation/decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ func TestDecodeStore(t *testing.T) {
MarketUID: uuid.NewString(),
Value: "100",
MaxLossMultiplier: sdk.NewDec(1),
})
},
&types.MetaData{
SelectedOddsType: types.OddsType_ODDS_TYPE_DECIMAL,
SelectedOddsValue: "1.5",
},
)

betUID := types.UID2ID{
UID: bet.UID,
Expand Down
385 changes: 329 additions & 56 deletions x/bet/types/bet.pb.go

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion x/bet/types/messages_bet.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (msg *MsgWager) EmitEvent(ctx *sdk.Context) {
}

// NewBet creates and returns a new bet from given message
func NewBet(creator string, props *WagerProps, oddsType OddsType, odds *BetOdds) *Bet {
func NewBet(creator string, props *WagerProps, oddsType OddsType, odds *BetOdds, meta *MetaData) *Bet {
return &Bet{
Creator: creator,
UID: props.UID,
Expand All @@ -78,5 +78,6 @@ func NewBet(creator string, props *WagerProps, oddsType OddsType, odds *BetOdds)
Amount: props.Amount,
OddsType: oddsType,
MaxLossMultiplier: odds.MaxLossMultiplier,
Meta: meta,
}
}
14 changes: 13 additions & 1 deletion x/bet/types/messages_bet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,20 @@ func TestNewBet(t *testing.T) {
OddsValue: inputBetOdds.Value,
Amount: inputBet.Amount,
OddsType: types.OddsType_ODDS_TYPE_DECIMAL,
Meta: &types.MetaData{
SelectedOddsType: types.OddsType_ODDS_TYPE_DECIMAL,
SelectedOddsValue: "1.5",
},
}
res := types.NewBet(creator, inputBet, types.OddsType_ODDS_TYPE_DECIMAL, inputBetOdds)
res := types.NewBet(creator,
inputBet,
types.OddsType_ODDS_TYPE_DECIMAL,
inputBetOdds,
&types.MetaData{
SelectedOddsType: types.OddsType_ODDS_TYPE_DECIMAL,
SelectedOddsValue: "1.5",
},
)
require.Equal(t, expectedBet, res)
})
}
107 changes: 85 additions & 22 deletions x/bet/types/ticket.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading