diff --git a/docs/specs/Bet/01_Overview.md b/docs/specs/Bet/01_Overview.md index 822ac577..be87ee09 100644 --- a/docs/specs/Bet/01_Overview.md +++ b/docs/specs/Bet/01_Overview.md @@ -1,5 +1,5 @@ # **Overview** -The Bet module is responsible for receiving and processing requests to place and settle bets. In the case of placement, it validates the request and places the bet. +The Bet module is responsible for receiving and processing requests to wager and settle bets. In the case of wagering, it validates the request and places the bet. For the settlement, blockchain automatically queries resolved markets then for each of these markets, checks the result of the market, determines the bet result, and settles the bet using `orderbook` module. diff --git a/docs/specs/Bet/02_Concepts.md b/docs/specs/Bet/02_Concepts.md index 0ba69dfb..ce8f5107 100644 --- a/docs/specs/Bet/02_Concepts.md +++ b/docs/specs/Bet/02_Concepts.md @@ -2,7 +2,7 @@ Bet module is tasked with placement and settlement of the bets. the user can place bet on a same market multiple times with different or equal odds through commandline or singing and broadcasting the bet placement message. -> Bet Placement will be done using a ticket containing odds info signed by a trusted source. Verifying this ticket will be done in the placement state itself. +> Wagering will be done using a ticket containing odds info signed by a trusted source. Verifying this ticket will be done in the placement state itself. > Bet amount can not be less than a minimum amount which is defined for each market. A module parameter is used for this purpose. > Also, a betting fee has been defined for each market, A module parameter is used for this purpose. @@ -24,7 +24,7 @@ Before accepting bet some validation should take place: - If Ignore is false in bet ticket payload, then the status of kyc approval should be true and tx signer and kyc id should be same for a bet to be placed. - If Ignore is true in bet ticket payload, then kyc validation is not required and bet can be placed without kyc check. -Placement Assumptions: +Wager Assumptions: - For bet placement user can raise a request to place a single bet, it can be done for a single bet only. - When a user is raising a transaction to place a bet, the creator of the transaction is the owner of the bet. @@ -33,7 +33,7 @@ After a bet is accepted: - Bet amount transfer to the `orderbook_liquidity_pool` module account this is done by the `orderbook` module. - Betting fee will be transferred to the `bet_fee_collector` module account. this is done by the `orderbook` module. -- Bet fulfillments are being processed by `orderbook` module in the `ProcessBetPlacement` keeper's method. +- Bet fulfillments are being processed by `orderbook` module in the `ProcessWager` keeper's method. ## Supported Odds Types diff --git a/docs/specs/Bet/03_Accounts.md b/docs/specs/Bet/03_Accounts.md index f1aa66f0..d1f5b4fd 100644 --- a/docs/specs/Bet/03_Accounts.md +++ b/docs/specs/Bet/03_Accounts.md @@ -6,7 +6,7 @@ There is one account in the Bet module. During bet placement, betting fee is transferred from the bettor's account to the bet module account in the Bet module. -## Placement Transfer +## Wager Transfer The bet amount (deducted by betting fee) is transferred to the `orderbook_liquidity_pool` module account in `orderbook` module. diff --git a/docs/specs/Bet/05_State_Transitions.md b/docs/specs/Bet/05_State_Transitions.md index dacf0e36..a649becf 100644 --- a/docs/specs/Bet/05_State_Transitions.md +++ b/docs/specs/Bet/05_State_Transitions.md @@ -2,7 +2,7 @@ This section defines the state transitions of the bet module's KVStore in all scenarios: -## **Place bet** +## **Wager** When this is processed: diff --git a/docs/specs/Bet/06_Messages.md b/docs/specs/Bet/06_Messages.md index 6fa3b4a1..8a56520a 100644 --- a/docs/specs/Bet/06_Messages.md +++ b/docs/specs/Bet/06_Messages.md @@ -6,27 +6,27 @@ handler endpoints is as follows ```proto // Msg defines the Msg service. service Msg { - // PlaceBet defines a method to place a bet with the given data - rpc PlaceBet(MsgPlaceBet) returns (MsgPlaceBetResponse); + // Wager defines a method to place a bet with the given data + rpc Wager(MsgWager) returns (MsgWagerResponse); } ``` -## **MsgPlaceBet** +## **MsgWager** Within this message, the user specifies the bet information they wish to place. ```proto -// MsgPlaceBet defines a message to place a bet with the given data -message MsgPlaceBet { +// MsgWager defines a message to place a bet with the given data +message MsgWager { // creator is the bettor address string creator = 1; - // bet is the info of bet to place - PlaceBetFields bet = 2; + // props is the info of bet to place + WagerProps props = 2; } -// PlaceBetFields contains attributes which come in Place bet tx request. -message PlaceBetFields { +// WagerProps contains attributes which come in wager tx request. +message WagerProps { // uid is the universal unique identifier assigned to bet. string uid = 1 [ (gogoproto.customname) = "UID", @@ -44,12 +44,12 @@ message PlaceBetFields { string ticket = 3; } -// MsgPlaceBetResponse is the returning value in the response -// of MsgPlaceBet request. -message MsgPlaceBetResponse { PlaceBetFields bet = 1; } +// MsgWagerResponse is the returning value in the response +// of MsgWager request. +message MsgWagerResponse { WagerProps props = 1; } ``` -### **Sample Place bet ticket** +### **Sample Wager ticket** ```json { @@ -72,7 +72,7 @@ message MsgPlaceBetResponse { PlaceBetFields bet = 1; } } ``` -### **Placement Failure cases** +### **Wager Failure cases** The transaction will fail if: @@ -92,7 +92,7 @@ The transaction will fail if: - The market does not contain the selected odds - Bet amount is less than minimum allowed amount - The creator address is not valid -- There is an error in `ProcessBetPlacement` in `orderbook` module +- There is an error in `ProcessWager` in `orderbook` module ### **What Happens if bet placement fails** diff --git a/docs/specs/Bet/07_Events.md b/docs/specs/Bet/07_Events.md index 7edde010..793d7e59 100644 --- a/docs/specs/Bet/07_Events.md +++ b/docs/specs/Bet/07_Events.md @@ -2,7 +2,7 @@ The Bet module emits the following events -## *MsgPlaceBet* +## *MsgWager* | Type | Attribute Key| Attribute Value | |:-------------:|:-------------:|:---------------------:| diff --git a/docs/specs/Market/03_Messages.md b/docs/specs/Market/03_Messages.md index d9247735..69214648 100644 --- a/docs/specs/Market/03_Messages.md +++ b/docs/specs/Market/03_Messages.md @@ -9,20 +9,20 @@ The Market module exposes the following services: ```proto // Msg defines the Msg service. service Msg { - rpc AddMarket(MsgAddMarket) returns (MarketResponse); - rpc ResolveMarket(MsgResolveMarket) returns (MarketResponse); - rpc UpdateMarket(MsgUpdateMarket) returns (MarketResponse); + rpc Add(MsgAdd) returns (MarketResponse); + rpc Resolve(MsgResolve) returns (MarketResponse); + rpc Update(MsgUpdate) returns (MarketResponse); } ``` --- -## **MsgAddMarket** +## **MsgAdd** This message is used to add new market to the chain ```proto -message MsgAddMarket { +message MsgAdd { string creator = 1; string ticket = 2; } @@ -97,14 +97,14 @@ message MarketAddTicketPayload { --- -## **MsgUpdateMarket** +## **MsgUpdate** This message is used to update already existent markets on the chain ```proto -// MsgUpdateMarket is the message type for updating market data. +// MsgUpdate is the message type for updating market data. // in the state -message MsgUpdateMarket { +message MsgUpdate { // creator is the address of the creator account of the market. string creator = 1; // ticket is the jwt ticket data. @@ -160,8 +160,8 @@ message MarketUpdateTicketPayload { This is the common response to all the messages ```proto -// MsgAddMarketResponse response for adding market. -message MsgAddMarketResponse { +// MsgAddResponse response for adding market. +message MsgAddResponse { // error contains an error if adding a market faces any issues. string error = 1 [ (gogoproto.nullable) = true ]; // data is the data of market. @@ -171,13 +171,13 @@ message MsgAddMarketResponse { --- -## **MsgResolveMarket** +## **MsgResolve** This message is used to resolve already existent markets on the chain ```proto -// MsgResolveMarket is the message type for resolving a market. -message MsgResolveMarket { +// MsgResolve is the message type for resolving a market. +message MsgResolve { // creator is the address of the creator account of the market. string creator = 1; // ticket is the jwt ticket data. diff --git a/docs/specs/Market/05_Events.md b/docs/specs/Market/05_Events.md index 4178c201..8301ca84 100644 --- a/docs/specs/Market/05_Events.md +++ b/docs/specs/Market/05_Events.md @@ -2,7 +2,7 @@ The Market module emits the following events: -## *MsgAddMarket* +## *MsgAdd* | **Type** | **Attribute Key** | **Attribute Value** | |----------------------------|---------------------------|-----------------------| @@ -14,7 +14,7 @@ The Market module emits the following events: --- -## *MsgUpdateMarket* +## *MsgUpdate* | **Type** | **Attribute Key** | **Attribute Value** | |:------------------------:|:---------------------------:|:---------------------:| @@ -25,7 +25,7 @@ The Market module emits the following events: --- -## *MsgResolveMarket* +## *MsgResolve* | **Type** | **Attribute Key** | **Attribute Value** | |---------------------------|--------------------------|-----------------------| diff --git a/docs/specs/OrderBook/04_State_Transitions.md b/docs/specs/OrderBook/04_State_Transitions.md index bdd33df4..7ebef2aa 100644 --- a/docs/specs/OrderBook/04_State_Transitions.md +++ b/docs/specs/OrderBook/04_State_Transitions.md @@ -36,7 +36,7 @@ When a user deposits tokens: --- -## **Process Bet Placement** +## **Process Wager** 1. Get order book and odds exposures. 2. Check all fulfillment queue items: diff --git a/proto/sge/bet/ticket.proto b/proto/sge/bet/ticket.proto index b579ab34..886be576 100644 --- a/proto/sge/bet/ticket.proto +++ b/proto/sge/bet/ticket.proto @@ -9,8 +9,8 @@ import "sge/bet/odds_type.proto"; option go_package = "github.com/sge-network/sge/x/bet/types"; -// BetPlacementTicketPayload indicates data of bet placement ticket. -message BetPlacementTicketPayload { +// WagerTicketPayload indicates data of bet placement ticket. +message WagerTicketPayload { // selected_odds is the user-selected odds to place bet. BetOdds selected_odds = 1; // kyc_data contains the details of user kyc. diff --git a/proto/sge/bet/tx.proto b/proto/sge/bet/tx.proto index ddcaa3f3..7e50f848 100644 --- a/proto/sge/bet/tx.proto +++ b/proto/sge/bet/tx.proto @@ -1,25 +1,25 @@ syntax = "proto3"; package sgenetwork.sge.bet; -import "sge/bet/place_bet_fields.proto"; +import "sge/bet/wager.proto"; option go_package = "github.com/sge-network/sge/x/bet/types"; // Msg defines the Msg service. service Msg { - // PlaceBet defines a method to place a bet with the given data. - rpc PlaceBet(MsgPlaceBet) returns (MsgPlaceBetResponse); + // Wager defines a method to place a bet with the given data. + rpc Wager(MsgWager) returns (MsgWagerResponse); } -// MsgPlaceBet defines a message to place a bet with the given data. -message MsgPlaceBet { +// MsgWager defines a message to place a bet with the given data. +message MsgWager { // creator is the bettor address. string creator = 1; - // PlaceBetFields contains bet fields. - PlaceBetFields bet = 2; + // props contains bet properties. + WagerProps props = 2; } -// MsgPlaceBetResponse is the returning value in the response -// of MsgPlaceBet request. -message MsgPlaceBetResponse { PlaceBetFields bet = 1; } +// MsgWagerResponse is the returning value in the response +// of MsgWagerResponse request. +message MsgWagerResponse { WagerProps props = 1; } diff --git a/proto/sge/bet/place_bet_fields.proto b/proto/sge/bet/wager.proto similarity index 85% rename from proto/sge/bet/place_bet_fields.proto rename to proto/sge/bet/wager.proto index 865f12ed..7b536162 100644 --- a/proto/sge/bet/place_bet_fields.proto +++ b/proto/sge/bet/wager.proto @@ -5,8 +5,8 @@ import "gogoproto/gogo.proto"; option go_package = "github.com/sge-network/sge/x/bet/types"; -// PlaceBetFields contains attributes which come in Place bet tx request. -message PlaceBetFields { +// WagerProps contains attributes which come in wager tx request. +message WagerProps { // uid is the universal unique identifier assigned to bet. string uid = 1 [ (gogoproto.customname) = "UID", diff --git a/proto/sge/market/tx.proto b/proto/sge/market/tx.proto index 9d73f69c..bb2e7c2b 100644 --- a/proto/sge/market/tx.proto +++ b/proto/sge/market/tx.proto @@ -8,58 +8,58 @@ option go_package = "github.com/sge-network/sge/x/market/types"; // Msg defines the Msg service. service Msg { - // AddMarket defines a method to add the market with the given data. - rpc AddMarket(MsgAddMarket) returns (MsgAddMarketResponse); - // ResolveMarket defines a method to resolve the market. - rpc ResolveMarket(MsgResolveMarket) returns (MsgResolveMarketResponse); - // UpdateMarket defines a method to update a market. - rpc UpdateMarket(MsgUpdateMarket) returns (MsgUpdateMarketResponse); + // Add defines a method to add the market with the given data. + rpc Add(MsgAdd) returns (MsgAddResponse); + // Resolve defines a method to resolve the market. + rpc Resolve(MsgResolve) returns (MsgResolveResponse); + // Update defines a method to update a market. + rpc Update(MsgUpdate) returns (MsgUpdateResponse); } -// MsgAddMarket is the message type for adding the market into the +// MsgAdd is the message type for adding the market into the // state. -message MsgAddMarket { +message MsgAdd { // creator is the address of the creator account of the market. string creator = 1; // ticket is the jwt ticket data. string ticket = 2; } -// MsgAddMarketResponse response for adding market. -message MsgAddMarketResponse { +// MsgAddResponse response for adding market. +message MsgAddResponse { // error contains an error if adding a market faces any issues. string error = 1 [ (gogoproto.nullable) = true ]; // data is the data of market. Market data = 2 [ (gogoproto.nullable) = true ]; } -// MsgResolveMarket is the message type for resolving a market. -message MsgResolveMarket { +// MsgResolve is the message type for resolving a market. +message MsgResolve { // creator is the address of the creator account of the market. string creator = 1; // ticket is the jwt ticket data. string ticket = 2; } -// MsgResolveMarketResponse response for resolving a market. -message MsgResolveMarketResponse { +// MsgResolveResponse response for resolving a market. +message MsgResolveResponse { // error contains an error if resolving a market faces any issues. string error = 1 [ (gogoproto.nullable) = true ]; // data is the data of market. Market data = 2 [ (gogoproto.nullable) = true ]; } -// MsgUpdateMarket is the message type for updating market data. +// MsgUpdate is the message type for updating market data. // in the state -message MsgUpdateMarket { +message MsgUpdate { // creator is the address of the creator account of the market. string creator = 1; // ticket is the jwt ticket data. string ticket = 2; } -// MsgUpdateMarketResponse response for updating a market. -message MsgUpdateMarketResponse { +// MsgUpdateResponse response for updating a market. +message MsgUpdateResponse { // error contains an error if updating a market faces any issues. string error = 1 [ (gogoproto.nullable) = true ]; // data is the data of market diff --git a/proto/sge/orderbook/orderbookevent.proto b/proto/sge/orderbook/orderbookevent.proto index 463f8f91..555d3ac9 100644 --- a/proto/sge/orderbook/orderbookevent.proto +++ b/proto/sge/orderbook/orderbookevent.proto @@ -8,9 +8,11 @@ option go_package = "github.com/sge-network/sge/x/orderbook/types"; // OrderBookEvent to publish the order book event message OrderBookEvent { - // ParticipationExposure to publish the order book event, participation exposure + // ParticipationExposure to publish the order book event, participation + // exposure repeated ParticipationExposure participation_exposure = 1; - // OrderBookOddsExposure to publish the order book event, order book odds exposure + // OrderBookOddsExposure to publish the order book event, order book odds + // exposure repeated OrderBookOddsExposure order_book_odds_exposure = 2; } diff --git a/x/bet/client/cli/tx.go b/x/bet/client/cli/tx.go index c1ad211a..577740a6 100644 --- a/x/bet/client/cli/tx.go +++ b/x/bet/client/cli/tx.go @@ -24,7 +24,7 @@ func GetTxCmd() *cobra.Command { RunE: client.ValidateCmd, } - cmd.AddCommand(CmdPlaceBet()) + cmd.AddCommand(CmdWager()) return cmd } diff --git a/x/bet/client/cli/tx_bet.go b/x/bet/client/cli/tx_bet.go index a040e977..75fbf9a4 100644 --- a/x/bet/client/cli/tx_bet.go +++ b/x/bet/client/cli/tx_bet.go @@ -9,12 +9,12 @@ import ( "github.com/spf13/cobra" ) -// CmdPlaceBet implements a command to place and store a single bet -func CmdPlaceBet() *cobra.Command { +// CmdWager implements a command to place and store a single bet +func CmdWager() *cobra.Command { cmd := &cobra.Command{ - Use: "place-bet [uid] [amount] [ticket]", - Short: "Place bet", - Long: "Place bet uuid, amount and ticket required.", + Use: "wager [uid] [amount] [ticket]", + Short: "Wager on an odds", + Long: "Wager on an odds. the uuid, amount and ticket required.", Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) (err error) { // Get value arguments @@ -32,9 +32,9 @@ func CmdPlaceBet() *cobra.Command { return err } - msg := types.NewMsgPlaceBet( + msg := types.NewMsgWager( clientCtx.GetFromAddress().String(), - types.PlaceBetFields{ + types.WagerProps{ UID: uid, Amount: argAmountCosmosInt, Ticket: argTicket, diff --git a/x/bet/client/cli/tx_bet_test.go b/x/bet/client/cli/tx_bet_test.go index 68ebfd69..e5cf85f0 100644 --- a/x/bet/client/cli/tx_bet_test.go +++ b/x/bet/client/cli/tx_bet_test.go @@ -29,7 +29,7 @@ func TestTXBetCLI(t *testing.T) { ), } - t.Run("Place bet", func(t *testing.T) { + t.Run("wager", func(t *testing.T) { for _, tc := range []struct { desc string uid string @@ -71,7 +71,7 @@ func TestTXBetCLI(t *testing.T) { tc.ticket, } args = append(args, commonArgs...) - out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdPlaceBet(), args) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdWager(), args) if tc.err != nil { require.NotNil(t, err) } else { diff --git a/x/bet/handler.go b/x/bet/handler.go index 6a4fe914..b5004f5f 100644 --- a/x/bet/handler.go +++ b/x/bet/handler.go @@ -17,8 +17,8 @@ func NewHandler(k keeper.Keeper) sdk.Handler { ctx = ctx.WithEventManager(sdk.NewEventManager()) switch msg := msg.(type) { - case *types.MsgPlaceBet: - res, err := msgServer.PlaceBet(sdk.WrapSDKContext(ctx), msg) + case *types.MsgWager: + res, err := msgServer.Wager(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) default: errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) diff --git a/x/bet/keeper/keeper_test.go b/x/bet/keeper/keeper_test.go index 52ef8619..26cde5a9 100644 --- a/x/bet/keeper/keeper_test.go +++ b/x/bet/keeper/keeper_test.go @@ -35,8 +35,8 @@ var ( MaxLossMultiplier: sdk.MustNewDecFromStr("0.1"), } testCreator string - testBet *types.MsgPlaceBet - testAddMarket *markettypes.MsgAddMarket + testBet *types.MsgWager + testAddMarket *markettypes.MsgAdd testMarket = markettypes.Market{ UID: testMarketUID, @@ -76,13 +76,13 @@ func addTestMarket(t testing.TB, tApp *simappUtil.TestApp, ctx sdk.Context) { testAddMarketTicket, err := createJwtTicket(testAddMarketClaim) require.Nil(t, err) - testAddMarket = &markettypes.MsgAddMarket{ + testAddMarket = &markettypes.MsgAdd{ Creator: testCreator, Ticket: testAddMarketTicket, } wctx := sdk.WrapSDKContext(ctx) marketSrv := marketkeeper.NewMsgServerImpl(*tApp.MarketKeeper) - resAddMarket, err := marketSrv.AddMarket(wctx, testAddMarket) + resAddMarket, err := marketSrv.Add(wctx, testAddMarket) require.Nil(t, err) require.NotNil(t, resAddMarket) } @@ -110,13 +110,13 @@ func addTestMarketBatch( testAddMarketTicket, err := createJwtTicket(testAddMarketClaim) require.Nil(t, err) - testAddMarket = &markettypes.MsgAddMarket{ + testAddMarket = &markettypes.MsgAdd{ Creator: testCreator, Ticket: testAddMarketTicket, } wctx := sdk.WrapSDKContext(ctx) marketSrv := marketkeeper.NewMsgServerImpl(*tApp.MarketKeeper) - resAddMarket, err := marketSrv.AddMarket(wctx, testAddMarket) + resAddMarket, err := marketSrv.Add(wctx, testAddMarket) require.Nil(t, err) require.NotNil(t, resAddMarket) } @@ -143,27 +143,27 @@ func placeTestBet( selectedOdds = testSelectedBetOdds } - testPlaceBetClaim := jwt.MapClaims{ + testWagerClaim := jwt.MapClaims{ "exp": 9999999999, "iat": 7777777777, "selected_odds": selectedOdds, "kyc_data": testKyc, "odds_type": 1, } - testPlaceBetTicket, err := createJwtTicket(testPlaceBetClaim) + testWagerTicket, err := createJwtTicket(testWagerClaim) require.Nil(t, err) - testBet = &types.MsgPlaceBet{ + testBet = &types.MsgWager{ Creator: testCreator, - Bet: &types.PlaceBetFields{ + Props: &types.WagerProps{ UID: betUID, Amount: sdk.NewInt(1000000), - Ticket: testPlaceBetTicket, + Ticket: testWagerTicket, }, } - resPlaceBet, err := betSrv.PlaceBet(wctx, testBet) + resWagerBet, err := betSrv.Wager(wctx, testBet) require.Nil(t, err) - require.NotNil(t, resPlaceBet) + require.NotNil(t, resWagerBet) } func createJwtTicket(claim jwt.MapClaims) (string, error) { diff --git a/x/bet/keeper/msg_server_bet.go b/x/bet/keeper/msg_server_bet.go index 38e5a79e..f6d18c9e 100644 --- a/x/bet/keeper/msg_server_bet.go +++ b/x/bet/keeper/msg_server_bet.go @@ -8,20 +8,20 @@ import ( "github.com/sge-network/sge/x/bet/types" ) -func (k msgServer) PlaceBet( +func (k msgServer) Wager( goCtx context.Context, - msg *types.MsgPlaceBet, -) (*types.MsgPlaceBetResponse, error) { + msg *types.MsgWager, +) (*types.MsgWagerResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) // Check if the value already exists - _, isFound := k.GetBetID(ctx, msg.Bet.UID) + _, isFound := k.GetBetID(ctx, msg.Props.UID) if isFound { - return nil, sdkerrors.Wrapf(types.ErrDuplicateUID, "%s", msg.Bet.UID) + return nil, sdkerrors.Wrapf(types.ErrDuplicateUID, "%s", msg.Props.UID) } - payload := &types.BetPlacementTicketPayload{} - err := k.ovmKeeper.VerifyTicketUnmarshal(sdk.WrapSDKContext(ctx), msg.Bet.Ticket, &payload) + payload := &types.WagerTicketPayload{} + err := k.ovmKeeper.VerifyTicketUnmarshal(sdk.WrapSDKContext(ctx), msg.Props.Ticket, &payload) if err != nil { return nil, sdkerrors.Wrapf(types.ErrInTicketVerification, "%s", err) } @@ -30,13 +30,13 @@ func (k msgServer) PlaceBet( return nil, sdkerrors.Wrapf(types.ErrInTicketValidation, "%s", err) } - bet := types.NewBet(msg.Creator, msg.Bet, payload.OddsType, payload.SelectedOdds) + bet := types.NewBet(msg.Creator, msg.Props, payload.OddsType, payload.SelectedOdds) - if err := k.Keeper.PlaceBet(ctx, bet); err != nil { - return nil, sdkerrors.Wrapf(types.ErrInBetPlacement, "%s", err) + if err := k.Keeper.Wager(ctx, bet); err != nil { + return nil, sdkerrors.Wrapf(types.ErrInWager, "%s", err) } msg.EmitEvent(&ctx) - return &types.MsgPlaceBetResponse{Bet: msg.Bet}, nil + return &types.MsgWagerResponse{Props: msg.Props}, nil } diff --git a/x/bet/keeper/msg_server_bet_test.go b/x/bet/keeper/msg_server_bet_test.go index b242e7f0..86a46a79 100644 --- a/x/bet/keeper/msg_server_bet_test.go +++ b/x/bet/keeper/msg_server_bet_test.go @@ -14,36 +14,36 @@ import ( markettypes "github.com/sge-network/sge/x/market/types" ) -func TestBetMsgServerPlaceBet(t *testing.T) { +func TestBetMsgServerWager(t *testing.T) { tApp, k, msgk, ctx, wctx := setupMsgServerAndApp(t) creator := simappUtil.TestParamUsers["user1"] var err error t.Run("Redundant UID", func(t *testing.T) { betItem := types.Bet{UID: "betUID"} - inputMsg := &types.MsgPlaceBet{ + inputMsg := &types.MsgWager{ Creator: creator.Address.String(), - Bet: &types.PlaceBetFields{ + Props: &types.WagerProps{ UID: betItem.UID, }, } k.SetBet(ctx, betItem, 1) - _, err := msgk.PlaceBet(wctx, inputMsg) + _, err := msgk.Wager(wctx, inputMsg) require.ErrorIs(t, types.ErrDuplicateUID, err) }) t.Run("Error in verifying ticket", func(t *testing.T) { - inputBet := &types.MsgPlaceBet{ + inputBet := &types.MsgWager{ Creator: creator.Address.String(), - Bet: &types.PlaceBetFields{ + Props: &types.WagerProps{ UID: "betUID_1", Amount: sdk.NewInt(500), Ticket: "wrongTicket", }, } - _, err = msgk.PlaceBet(wctx, inputBet) + _, err = msgk.Wager(wctx, inputBet) require.ErrorIs(t, types.ErrInTicketVerification, err) }) @@ -55,26 +55,26 @@ func TestBetMsgServerPlaceBet(t *testing.T) { Approved: true, ID: creator.Address.String(), } - placeBetClaim := jwt.MapClaims{ + wagerClaim := jwt.MapClaims{ "exp": 9999999999, "iat": 1111111111, "selected_odds": selectedBetOdds, "kyc_data": testKyc, } - placeBetTicket, err := createJwtTicket(placeBetClaim) + wagerTicket, err := createJwtTicket(wagerClaim) require.Nil(t, err) - inputBet := &types.MsgPlaceBet{ + inputBet := &types.MsgWager{ Creator: creator.Address.String(), - Bet: &types.PlaceBetFields{ + Props: &types.WagerProps{ UID: "betUID_1", Amount: sdk.NewInt(500), - Ticket: placeBetTicket, + Ticket: wagerTicket, }, } - _, err = msgk.PlaceBet(wctx, inputBet) + _, err = msgk.Wager(wctx, inputBet) require.ErrorIs(t, types.ErrInTicketValidation, err) }) @@ -83,28 +83,28 @@ func TestBetMsgServerPlaceBet(t *testing.T) { Approved: true, ID: creator.Address.String(), } - placeBetClaim := jwt.MapClaims{ + wagerClaim := jwt.MapClaims{ "exp": 9999999999, "iat": 1111111111, "selected_odds": testSelectedBetOdds, "kyc_data": testKyc, "odds_type": types.OddsType_ODDS_TYPE_DECIMAL, } - placeBetTicket, err := createJwtTicket(placeBetClaim) + wagerTicket, err := createJwtTicket(wagerClaim) require.Nil(t, err) - inputBet := &types.MsgPlaceBet{ + inputBet := &types.MsgWager{ Creator: creator.Address.String(), - Bet: &types.PlaceBetFields{ + Props: &types.WagerProps{ UID: "betUID_1", Amount: sdk.NewInt(500), - Ticket: placeBetTicket, + Ticket: wagerTicket, }, } - _, err = msgk.PlaceBet(wctx, inputBet) - require.ErrorIs(t, types.ErrInBetPlacement, err) + _, err = msgk.Wager(wctx, inputBet) + require.ErrorIs(t, types.ErrInWager, err) }) t.Run("Success", func(t *testing.T) { @@ -112,22 +112,22 @@ func TestBetMsgServerPlaceBet(t *testing.T) { Approved: true, ID: creator.Address.String(), } - placeBetClaim := jwt.MapClaims{ + wagerClaim := jwt.MapClaims{ "exp": 9999999999, "iat": 1111111111, "selected_odds": testSelectedBetOdds, "kyc_data": testKyc, "odds_type": types.OddsType_ODDS_TYPE_DECIMAL, } - placeBetTicket, err := createJwtTicket(placeBetClaim) + wagerTicket, err := createJwtTicket(wagerClaim) require.Nil(t, err) - inputBet := &types.MsgPlaceBet{ + inputBet := &types.MsgWager{ Creator: creator.Address.String(), - Bet: &types.PlaceBetFields{ + Props: &types.WagerProps{ UID: "BetUID_2", Amount: sdk.NewInt(1000000), - Ticket: placeBetTicket, + Ticket: wagerTicket, }, } @@ -158,7 +158,7 @@ func TestBetMsgServerPlaceBet(t *testing.T) { ) require.NoError(t, err) - _, err = msgk.PlaceBet(wctx, inputBet) + _, err = msgk.Wager(wctx, inputBet) require.NoError(t, err) rst, found := k.GetBet(ctx, creator.Address.String(), @@ -167,15 +167,15 @@ func TestBetMsgServerPlaceBet(t *testing.T) { require.True(t, found) require.Equal(t, inputBet.Creator, rst.Creator) - uid2ID, found := k.GetBetID(ctx, inputBet.Bet.UID) + uid2ID, found := k.GetBetID(ctx, inputBet.Props.UID) require.True(t, found) - require.Equal(t, types.UID2ID{UID: inputBet.Bet.UID, ID: 1}, uid2ID) + require.Equal(t, types.UID2ID{UID: inputBet.Props.UID, ID: 1}, uid2ID) stats := k.GetBetStats(ctx) require.Equal(t, types.BetStats{Count: 1}, stats) - inputBet.Bet.UID = "BetUID_3" - _, err = msgk.PlaceBet(wctx, inputBet) + inputBet.Props.UID = "BetUID_3" + _, err = msgk.Wager(wctx, inputBet) require.NoError(t, err) rst, found = k.GetBet(ctx, creator.Address.String(), @@ -184,9 +184,9 @@ func TestBetMsgServerPlaceBet(t *testing.T) { require.True(t, found) require.Equal(t, inputBet.Creator, rst.Creator) - uid2ID, found = k.GetBetID(ctx, inputBet.Bet.UID) + uid2ID, found = k.GetBetID(ctx, inputBet.Props.UID) require.True(t, found) - require.Equal(t, types.UID2ID{UID: inputBet.Bet.UID, ID: 2}, uid2ID) + require.Equal(t, types.UID2ID{UID: inputBet.Props.UID, ID: 2}, uid2ID) stats = k.GetBetStats(ctx) require.Equal(t, types.BetStats{Count: 2}, stats) diff --git a/x/bet/keeper/params.go b/x/bet/keeper/params.go index 3a52adfd..29e1d916 100644 --- a/x/bet/keeper/params.go +++ b/x/bet/keeper/params.go @@ -16,7 +16,7 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { k.paramstore.SetParamSet(ctx, ¶ms) } -// GetConstraints get bet constraint values of the bet placement constraints +// GetConstraints get bet constraint values of the bet wager constraints func (k Keeper) GetConstraints(ctx sdk.Context) (params types.Constraints) { return k.GetParams(ctx).Constraints } diff --git a/x/bet/keeper/bet_settle.go b/x/bet/keeper/settle.go similarity index 93% rename from x/bet/keeper/bet_settle.go rename to x/bet/keeper/settle.go index 2d261fbb..d674f180 100644 --- a/x/bet/keeper/bet_settle.go +++ b/x/bet/keeper/settle.go @@ -13,8 +13,8 @@ import ( // singlePageNum used to return single page result in pagination. const singlePageNum = 1 -// SettleBet settles a single bet and updates it in KVStore -func (k Keeper) SettleBet(ctx sdk.Context, bettorAddressStr, betUID string) error { +// Settle settles a single bet and updates it in KVStore +func (k Keeper) Settle(ctx sdk.Context, bettorAddressStr, betUID string) error { if !utils.IsValidUID(betUID) { return types.ErrInvalidBetUID } @@ -73,7 +73,7 @@ func (k Keeper) SettleBet(ctx sdk.Context, bettorAddressStr, betUID string) erro return err } - if err := k.settleResolvedBet(ctx, &bet); err != nil { + if err := k.settleResolved(ctx, &bet); err != nil { return err } @@ -101,9 +101,9 @@ func (k Keeper) updateSettlementState(ctx sdk.Context, bet types.Bet, betID uint k.SetSettledBet(ctx, types.NewSettledBet(bet.UID, bet.Creator), betID, ctx.BlockHeight()) } -// settleResolvedBet settles a bet by calling order book functions to unlock fund and payout +// settleResolved settles a bet by calling order book functions to unlock fund and payout // based on bet's result, and updates status of bet to settled -func (k Keeper) settleResolvedBet(ctx sdk.Context, bet *types.Bet) error { +func (k Keeper) settleResolved(ctx sdk.Context, bet *types.Bet) error { bettorAddress, err := sdk.AccAddressFromBech32(bet.Creator) if err != nil { return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "%s", err) @@ -196,7 +196,7 @@ func (k Keeper) batchMarketSettlement( var val types.PendingBet k.cdc.MustUnmarshal(iterator.Value(), &val) - err = k.SettleBet(ctx, val.Creator, val.UID) + err = k.Settle(ctx, val.Creator, val.UID) if err != nil { return } diff --git a/x/bet/keeper/bet_settle_test.go b/x/bet/keeper/settle_test.go similarity index 96% rename from x/bet/keeper/bet_settle_test.go rename to x/bet/keeper/settle_test.go index 32355ba9..67bf0b9a 100644 --- a/x/bet/keeper/bet_settle_test.go +++ b/x/bet/keeper/settle_test.go @@ -196,7 +196,7 @@ func TestSettleBet(t *testing.T) { } } - err := k.SettleBet(ctx, tc.bet.Creator, betUID) + err := k.Settle(ctx, tc.bet.Creator, betUID) if tc.err != nil { require.ErrorIs(t, err, tc.err) return @@ -260,7 +260,7 @@ func TestBatchSettleBet(t *testing.T) { for _, marketUID := range marketUIDs[:len(marketUIDs)-2] { market, found := tApp.MarketKeeper.GetMarket(ctx, marketUID) require.True(t, found) - tApp.MarketKeeper.ResolveMarket(ctx, market, &markettypes.MarketResolutionTicketPayload{ + tApp.MarketKeeper.Resolve(ctx, market, &markettypes.MarketResolutionTicketPayload{ UID: marketUID, ResolutionTS: uint64(ctx.BlockTime().Unix()) + 10000, WinnerOddsUIDs: []string{testOddsUID1, testOddsUID2, testOddsUID3}, @@ -270,7 +270,7 @@ func TestBatchSettleBet(t *testing.T) { market, found := tApp.MarketKeeper.GetMarket(ctx, marketUIDs[len(marketUIDs)-2]) require.True(t, found) - tApp.MarketKeeper.ResolveMarket(ctx, market, &markettypes.MarketResolutionTicketPayload{ + tApp.MarketKeeper.Resolve(ctx, market, &markettypes.MarketResolutionTicketPayload{ UID: marketUIDs[len(marketUIDs)-2], ResolutionTS: uint64(ctx.BlockTime().Unix()) + 10000, Status: markettypes.MarketStatus_MARKET_STATUS_CANCELED, @@ -278,7 +278,7 @@ func TestBatchSettleBet(t *testing.T) { market, found = tApp.MarketKeeper.GetMarket(ctx, marketUIDs[len(marketUIDs)-1]) require.True(t, found) - tApp.MarketKeeper.ResolveMarket(ctx, market, &markettypes.MarketResolutionTicketPayload{ + tApp.MarketKeeper.Resolve(ctx, market, &markettypes.MarketResolutionTicketPayload{ UID: marketUIDs[len(marketUIDs)-1], ResolutionTS: uint64(ctx.BlockTime().Unix()) + 10000, Status: markettypes.MarketStatus_MARKET_STATUS_ABORTED, diff --git a/x/bet/keeper/bet_place.go b/x/bet/keeper/wager.go similarity index 90% rename from x/bet/keeper/bet_place.go rename to x/bet/keeper/wager.go index bdc30978..a59a6825 100644 --- a/x/bet/keeper/bet_place.go +++ b/x/bet/keeper/wager.go @@ -8,8 +8,8 @@ import ( "github.com/spf13/cast" ) -// PlaceBet stores a new bet in KVStore -func (k Keeper) PlaceBet(ctx sdk.Context, bet *types.Bet) error { +// Wager stores a new bet in KVStore +func (k Keeper) Wager(ctx sdk.Context, bet *types.Bet) error { bettorAddress, err := sdk.AccAddressFromBech32(bet.Creator) if err != nil { return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "%s", err) @@ -45,12 +45,12 @@ func (k Keeper) PlaceBet(ctx sdk.Context, bet *types.Bet) error { stats.Count++ betID := stats.Count - betFulfillment, err := k.orderbookKeeper.ProcessBetPlacement( + betFulfillment, err := k.orderbookKeeper.ProcessWager( ctx, bet.UID, bet.MarketUID, bet.OddsUID, bet.MaxLossMultiplier, bet.Amount, payoutProfit, bettorAddress, bet.Fee, bet.OddsType, bet.OddsValue, betID, ) if err != nil { - return sdkerrors.Wrapf(types.ErrInOBPlacementProcessing, "%s", err) + return sdkerrors.Wrapf(types.ErrInOBWagerProcessing, "%s", err) } // set bet as placed diff --git a/x/bet/keeper/bet_place_test.go b/x/bet/keeper/wager_test.go similarity index 98% rename from x/bet/keeper/bet_place_test.go rename to x/bet/keeper/wager_test.go index 6bca9858..08c7e671 100644 --- a/x/bet/keeper/bet_place_test.go +++ b/x/bet/keeper/wager_test.go @@ -12,7 +12,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestPlaceBet(t *testing.T) { +func TestWager(t *testing.T) { tApp, k, ctx := setupKeeperAndApp(t) ctx = ctx.WithBlockTime(time.Now()) tcs := []struct { @@ -193,7 +193,7 @@ func TestPlaceBet(t *testing.T) { } } - err := k.PlaceBet(ctx, tc.bet) + err := k.Wager(ctx, tc.bet) if tc.err != nil { require.ErrorIs(t, err, tc.err) return diff --git a/x/bet/module_simulation.go b/x/bet/module_simulation.go index 0266a52e..80ead42a 100644 --- a/x/bet/module_simulation.go +++ b/x/bet/module_simulation.go @@ -26,9 +26,9 @@ var ( const ( //#nosec - opWeightMsgPlaceBet = "op_weight_msg_bet" + opWeightMsgWager = "op_weight_msg_wager" // TODO: Determine the simulation weight value - defaultWeightMsgPlaceBet int = 100 + defaultWeightMsgWager int = 100 ) // GenerateGenesisState creates a randomized GenState of the module @@ -55,15 +55,15 @@ func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { operations := make([]simtypes.WeightedOperation, 0) - var weightMsgPlaceBet int - simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgPlaceBet, &weightMsgPlaceBet, nil, + var weightMsgWager int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgWager, &weightMsgWager, nil, func(_ *rand.Rand) { - weightMsgPlaceBet = defaultWeightMsgPlaceBet + weightMsgWager = defaultWeightMsgWager }, ) operations = append(operations, simulation.NewWeightedOperation( - weightMsgPlaceBet, - betsimulation.SimulateMsgPlaceBet(am.accountKeeper, am.bankKeeper, am.keeper), + weightMsgWager, + betsimulation.SimulateMsgWager(am.accountKeeper, am.bankKeeper, am.keeper), )) return operations diff --git a/x/bet/simulation/bet.go b/x/bet/simulation/bet.go index 5239b7ed..13c04fc0 100644 --- a/x/bet/simulation/bet.go +++ b/x/bet/simulation/bet.go @@ -14,8 +14,8 @@ import ( "github.com/spf13/cast" ) -// SimulateMsgPlaceBet returns an Operation function to run a state machine transition -func SimulateMsgPlaceBet( +// SimulateMsgWager returns an Operation function to run a state machine transition +func SimulateMsgWager( ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper, @@ -25,9 +25,9 @@ func SimulateMsgPlaceBet( simAccount, _ := simtypes.RandomAcc(r, accs) i := r.Int() - msg := &types.MsgPlaceBet{ + msg := &types.MsgWager{ Creator: simAccount.Address.String(), - Bet: &types.PlaceBetFields{ + Props: &types.WagerProps{ UID: cast.ToString(i), }, } diff --git a/x/bet/simulation/decoder_test.go b/x/bet/simulation/decoder_test.go index 2b240a6c..d77694a9 100644 --- a/x/bet/simulation/decoder_test.go +++ b/x/bet/simulation/decoder_test.go @@ -21,7 +21,7 @@ func TestDecodeStore(t *testing.T) { bet := types.NewBet( sample.AccAddress(), - &types.PlaceBetFields{ + &types.WagerProps{ UID: uuid.NewString(), Amount: sdk.NewInt(10), Ticket: "", diff --git a/x/bet/types/codec.go b/x/bet/types/codec.go index 19581474..b09f7fac 100644 --- a/x/bet/types/codec.go +++ b/x/bet/types/codec.go @@ -10,13 +10,13 @@ import ( // RegisterCodec registers module codec to the app codec func RegisterCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(&MsgPlaceBet{}, "bet/PlaceBet", nil) + cdc.RegisterConcrete(&MsgWager{}, "bet/Wager", nil) } // RegisterInterfaces registers the module interface types func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), - &MsgPlaceBet{}, + &MsgWager{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/bet/types/errors.go b/x/bet/types/errors.go index b88f626f..bc76fce1 100644 --- a/x/bet/types/errors.go +++ b/x/bet/types/errors.go @@ -10,7 +10,7 @@ import ( var ( ErrInTicketVerification = sdkerrors.Register(ModuleName, 2001, "ticket verification failed") ErrInTicketValidation = sdkerrors.Register(ModuleName, 2002, "ticket validation failed") - ErrInBetPlacement = sdkerrors.Register(ModuleName, 2003, "bet placement failed") + ErrInWager = sdkerrors.Register(ModuleName, 2003, "bet placement failed") ErrInvalidBetUID = sdkerrors.Register(ModuleName, 2004, "invalid Bet Uid") ErrBetIsCanceled = sdkerrors.Register(ModuleName, 2005, "bet is already canceled") ErrBetIsSettled = sdkerrors.Register(ModuleName, 2006, "bet is already settled") @@ -25,7 +25,7 @@ var ( ErrNoMatchingBet = sdkerrors.Register(ModuleName, 2015, "bet not found") ErrResultNotDeclared = sdkerrors.Register(ModuleName, 2016, "market result is not declared") ErrDuplicateUID = sdkerrors.Register(ModuleName, 2017, "UID is already set") - ErrInOBPlacementProcessing = sdkerrors.Register(ModuleName, 2018, "internal error in processing bet placement in orderbook") + ErrInOBWagerProcessing = sdkerrors.Register(ModuleName, 2018, "internal error in processing bet placement in orderbook") ErrEndTSIsPassed = sdkerrors.Register(ModuleName, 2019, "market is expired") ErrOddsUIDNotExist = sdkerrors.Register(ModuleName, 2020, "market does not have this odds UID") ErrInOBRefund = sdkerrors.Register(ModuleName, 2021, "internal error in refunding user in Orderbook") diff --git a/x/bet/types/expected_keepers.go b/x/bet/types/expected_keepers.go index e0b62734..15166905 100644 --- a/x/bet/types/expected_keepers.go +++ b/x/bet/types/expected_keepers.go @@ -34,7 +34,7 @@ type OVMKeeper interface { // OrderbookKeeper defines the expected interface needed to process bet placement type OrderbookKeeper interface { - ProcessBetPlacement( + ProcessWager( ctx sdk.Context, betUID, bookUID, oddsUID string, maxLossMultiplier sdk.Dec, diff --git a/x/bet/types/messages_bet.go b/x/bet/types/messages_bet.go index 485e9a6c..9a684e1d 100644 --- a/x/bet/types/messages_bet.go +++ b/x/bet/types/messages_bet.go @@ -9,31 +9,31 @@ import ( ) const ( - // typeMsgPlaceBet is type of message MsgPlaceBet - typeMsgPlaceBet = "bet_place" + // typeMsgWager is type of message MsgWager + typeMsgWager = "bet_wager" ) -var _ sdk.Msg = &MsgPlaceBet{} +var _ sdk.Msg = &MsgWager{} -// NewMsgPlaceBet returns a MsgPlaceBet using given data -func NewMsgPlaceBet( +// NewMsgWager returns a MsgWager using given data +func NewMsgWager( creator string, - bet PlaceBetFields, -) *MsgPlaceBet { - return &MsgPlaceBet{ + props WagerProps, +) *MsgWager { + return &MsgWager{ Creator: creator, - Bet: &bet, + Props: &props, } } // Route returns the module's message router key. -func (*MsgPlaceBet) Route() string { return RouterKey } +func (*MsgWager) Route() string { return RouterKey } // Type returns type of its message -func (*MsgPlaceBet) Type() string { return typeMsgPlaceBet } +func (*MsgWager) Type() string { return typeMsgWager } // GetSigners returns the signers of its message -func (msg *MsgPlaceBet) GetSigners() []sdk.AccAddress { +func (msg *MsgWager) GetSigners() []sdk.AccAddress { creator, err := sdk.AccAddressFromBech32(msg.Creator) if err != nil { panic(err) @@ -42,40 +42,40 @@ func (msg *MsgPlaceBet) GetSigners() []sdk.AccAddress { } // GetSignBytes returns sortJson form of its message -func (msg *MsgPlaceBet) GetSignBytes() []byte { +func (msg *MsgWager) GetSignBytes() []byte { bz := ModuleCdc.MustMarshalJSON(msg) return sdk.MustSortJSON(bz) } // ValidateBasic does some validate checks on its message -func (msg *MsgPlaceBet) ValidateBasic() error { +func (msg *MsgWager) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(msg.Creator) if err != nil || msg.Creator == "" || strings.Contains(msg.Creator, " ") { return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "%s", err) } - return BetFieldsValidation(msg.Bet) + return WagerValidation(msg.Props) } // EmitEvent emits the event for the message success. -func (msg *MsgPlaceBet) EmitEvent(ctx *sdk.Context) { +func (msg *MsgWager) EmitEvent(ctx *sdk.Context) { emitter := utils.NewEventEmitter(ctx, attributeValueCategory) - emitter.AddMsg(typeMsgPlaceBet, msg.Creator, + emitter.AddMsg(typeMsgWager, msg.Creator, sdk.NewAttribute(attributeKeyBetCreator, msg.Creator), - sdk.NewAttribute(attributeKeyBetUID, msg.Bet.UID), + sdk.NewAttribute(attributeKeyBetUID, msg.Props.UID), ) emitter.Emit() } // NewBet creates and returns a new bet from given message -func NewBet(creator string, bet *PlaceBetFields, oddsType OddsType, odds *BetOdds) *Bet { +func NewBet(creator string, props *WagerProps, oddsType OddsType, odds *BetOdds) *Bet { return &Bet{ Creator: creator, - UID: bet.UID, + UID: props.UID, MarketUID: odds.MarketUID, OddsUID: odds.UID, OddsValue: odds.Value, - Amount: bet.Amount, + Amount: props.Amount, OddsType: oddsType, MaxLossMultiplier: odds.MaxLossMultiplier, } diff --git a/x/bet/types/messages_bet_test.go b/x/bet/types/messages_bet_test.go index 70a38d03..8d9e45dd 100644 --- a/x/bet/types/messages_bet_test.go +++ b/x/bet/types/messages_bet_test.go @@ -10,24 +10,24 @@ import ( "github.com/stretchr/testify/require" ) -func TestMsgPlaceBetValidateBasic(t *testing.T) { +func TestMsgWagerValidateBasic(t *testing.T) { tests := []struct { name string - msg types.MsgPlaceBet + msg types.MsgWager err error }{ { name: "invalid creator", - msg: types.MsgPlaceBet{ + msg: types.MsgWager{ Creator: "invalid_address", }, err: sdkerrors.ErrInvalidAddress, }, { name: "valid bet message", - msg: types.MsgPlaceBet{ + msg: types.MsgWager{ Creator: sample.AccAddress(), - Bet: &types.PlaceBetFields{ + Props: &types.WagerProps{ UID: "6e31c60f-2025-48ce-ae79-1dc110f16355", Amount: sdk.NewInt(int64(10)), Ticket: "Ticket", @@ -36,9 +36,9 @@ func TestMsgPlaceBetValidateBasic(t *testing.T) { }, { name: "invalid bet UID", - msg: types.MsgPlaceBet{ + msg: types.MsgWager{ Creator: sample.AccAddress(), - Bet: &types.PlaceBetFields{ + Props: &types.WagerProps{ UID: "Invalid UID", }, }, @@ -59,7 +59,7 @@ func TestMsgPlaceBetValidateBasic(t *testing.T) { func TestNewBet(t *testing.T) { t.Run("valid", func(t *testing.T) { - inputBet := &types.PlaceBetFields{ + inputBet := &types.WagerProps{ UID: "betUid", Ticket: "ticket", Amount: sdk.NewInt(int64(10)), diff --git a/x/bet/types/params.go b/x/bet/types/params.go index 1b194011..d738d567 100644 --- a/x/bet/types/params.go +++ b/x/bet/types/params.go @@ -28,9 +28,9 @@ var ( // the queryable bets by UID list. keyMaxBetByUIDQueryCount = []byte("MaxBetByUidQueryCount") - // keyPlacementConstraints is the default bet placement + // keyWagerConstraints is the default bet placement // constraints. - keyPlacementConstraints = []byte("PlacementConstraints") + keyWagerConstraints = []byte("WagerConstraints") ) var _ paramtypes.ParamSet = (*Params)(nil) @@ -71,7 +71,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { validateMaxBetByUIDQueryCount, ), paramtypes.NewParamSetPair( - keyPlacementConstraints, + keyWagerConstraints, &p.Constraints, validateConstraints, ), diff --git a/x/bet/types/place_bet_fields.go b/x/bet/types/place_bet_fields.go deleted file mode 100644 index b96d0672..00000000 --- a/x/bet/types/place_bet_fields.go +++ /dev/null @@ -1,24 +0,0 @@ -package types - -import ( - "strings" - - "github.com/sge-network/sge/utils" -) - -// BetFieldsValidation validates fields of the given bet -func BetFieldsValidation(bet *PlaceBetFields) error { - if !utils.IsValidUID(bet.UID) { - return ErrInvalidBetUID - } - - if bet.Amount.IsNil() || !bet.Amount.IsPositive() { - return ErrInvalidAmount - } - - if bet.Ticket == "" || strings.Contains(bet.Ticket, " ") { - return ErrInvalidTicket - } - - return nil -} diff --git a/x/bet/types/ticket.go b/x/bet/types/ticket.go index 2c43d955..19b43bfc 100644 --- a/x/bet/types/ticket.go +++ b/x/bet/types/ticket.go @@ -9,7 +9,7 @@ import ( ) // Validate validates fields of the given ticketData -func (payload *BetPlacementTicketPayload) Validate(creator string) error { +func (payload *WagerTicketPayload) Validate(creator string) error { if payload.SelectedOdds == nil { return ErrOddsDataNotFound } diff --git a/x/bet/types/ticket.pb.go b/x/bet/types/ticket.pb.go index 8566fa2b..e183ad41 100644 --- a/x/bet/types/ticket.pb.go +++ b/x/bet/types/ticket.pb.go @@ -24,8 +24,8 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// BetPlacementTicketPayload indicates data of bet placement ticket. -type BetPlacementTicketPayload struct { +// WagerTicketPayload indicates data of bet placement ticket. +type WagerTicketPayload struct { // selected_odds is the user-selected odds to place bet. SelectedOdds *BetOdds `protobuf:"bytes,1,opt,name=selected_odds,json=selectedOdds,proto3" json:"selected_odds,omitempty"` // kyc_data contains the details of user kyc. @@ -35,18 +35,18 @@ type BetPlacementTicketPayload struct { OddsType OddsType `protobuf:"varint,3,opt,name=odds_type,json=oddsType,proto3,enum=sgenetwork.sge.bet.OddsType" json:"odds_type,omitempty"` } -func (m *BetPlacementTicketPayload) Reset() { *m = BetPlacementTicketPayload{} } -func (m *BetPlacementTicketPayload) String() string { return proto.CompactTextString(m) } -func (*BetPlacementTicketPayload) ProtoMessage() {} -func (*BetPlacementTicketPayload) Descriptor() ([]byte, []int) { +func (m *WagerTicketPayload) Reset() { *m = WagerTicketPayload{} } +func (m *WagerTicketPayload) String() string { return proto.CompactTextString(m) } +func (*WagerTicketPayload) ProtoMessage() {} +func (*WagerTicketPayload) Descriptor() ([]byte, []int) { return fileDescriptor_cf6959e7db451613, []int{0} } -func (m *BetPlacementTicketPayload) XXX_Unmarshal(b []byte) error { +func (m *WagerTicketPayload) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *BetPlacementTicketPayload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *WagerTicketPayload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_BetPlacementTicketPayload.Marshal(b, m, deterministic) + return xxx_messageInfo_WagerTicketPayload.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -56,33 +56,33 @@ func (m *BetPlacementTicketPayload) XXX_Marshal(b []byte, deterministic bool) ([ return b[:n], nil } } -func (m *BetPlacementTicketPayload) XXX_Merge(src proto.Message) { - xxx_messageInfo_BetPlacementTicketPayload.Merge(m, src) +func (m *WagerTicketPayload) XXX_Merge(src proto.Message) { + xxx_messageInfo_WagerTicketPayload.Merge(m, src) } -func (m *BetPlacementTicketPayload) XXX_Size() int { +func (m *WagerTicketPayload) XXX_Size() int { return m.Size() } -func (m *BetPlacementTicketPayload) XXX_DiscardUnknown() { - xxx_messageInfo_BetPlacementTicketPayload.DiscardUnknown(m) +func (m *WagerTicketPayload) XXX_DiscardUnknown() { + xxx_messageInfo_WagerTicketPayload.DiscardUnknown(m) } -var xxx_messageInfo_BetPlacementTicketPayload proto.InternalMessageInfo +var xxx_messageInfo_WagerTicketPayload proto.InternalMessageInfo -func (m *BetPlacementTicketPayload) GetSelectedOdds() *BetOdds { +func (m *WagerTicketPayload) GetSelectedOdds() *BetOdds { if m != nil { return m.SelectedOdds } return nil } -func (m *BetPlacementTicketPayload) GetKycData() types.KycDataPayload { +func (m *WagerTicketPayload) GetKycData() types.KycDataPayload { if m != nil { return m.KycData } return types.KycDataPayload{} } -func (m *BetPlacementTicketPayload) GetOddsType() OddsType { +func (m *WagerTicketPayload) GetOddsType() OddsType { if m != nil { return m.OddsType } @@ -90,36 +90,35 @@ func (m *BetPlacementTicketPayload) GetOddsType() OddsType { } func init() { - proto.RegisterType((*BetPlacementTicketPayload)(nil), "sgenetwork.sge.bet.BetPlacementTicketPayload") + proto.RegisterType((*WagerTicketPayload)(nil), "sgenetwork.sge.bet.WagerTicketPayload") } func init() { proto.RegisterFile("sge/bet/ticket.proto", fileDescriptor_cf6959e7db451613) } var fileDescriptor_cf6959e7db451613 = []byte{ - // 307 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0xcf, 0x4e, 0x32, 0x31, - 0x14, 0xc5, 0xa7, 0xdf, 0x67, 0x14, 0xc7, 0x3f, 0x8b, 0x09, 0x51, 0x44, 0x53, 0x89, 0x26, 0x86, - 0x8d, 0x6d, 0x82, 0x2b, 0x77, 0x64, 0xc2, 0xce, 0x85, 0x84, 0xb0, 0x72, 0x43, 0x3a, 0xed, 0x4d, - 0x25, 0x03, 0x74, 0x42, 0xaf, 0xd1, 0xbe, 0x85, 0x8f, 0xc5, 0x92, 0xa5, 0x2b, 0x62, 0xe0, 0x45, - 0x4c, 0x3b, 0x83, 0x0b, 0x75, 0x77, 0xe6, 0xdc, 0x7b, 0xce, 0xfd, 0x65, 0x1a, 0xd7, 0xad, 0x06, - 0x9e, 0x01, 0x72, 0x1c, 0xcb, 0x1c, 0x90, 0x15, 0x73, 0x83, 0x26, 0x49, 0xac, 0x86, 0x19, 0xe0, - 0xab, 0x99, 0xe7, 0xcc, 0x6a, 0x60, 0x19, 0x60, 0xb3, 0xae, 0x8d, 0x36, 0x61, 0xcc, 0xbd, 0x2a, - 0x37, 0x9b, 0x7e, 0x93, 0xa3, 0x2b, 0x80, 0xe7, 0x4e, 0x56, 0xde, 0xc9, 0xb6, 0x33, 0x03, 0x1c, - 0x19, 0xa5, 0x6c, 0xe5, 0x9f, 0x6e, 0x7d, 0xef, 0x8d, 0x7c, 0xa8, 0x1c, 0x5c, 0xad, 0x48, 0x7c, - 0x96, 0x02, 0xf6, 0x27, 0x42, 0xc2, 0x14, 0x66, 0x38, 0x0c, 0x2c, 0x7d, 0xe1, 0x26, 0x46, 0xa8, - 0xa4, 0x1b, 0x1f, 0x59, 0x98, 0x80, 0x44, 0x50, 0xa1, 0xad, 0x41, 0x5a, 0xa4, 0x7d, 0xd0, 0x39, - 0x67, 0xbf, 0x21, 0x59, 0x0a, 0xf8, 0xa8, 0x94, 0x1d, 0x1c, 0x6e, 0x13, 0xfe, 0x2b, 0xe9, 0xc5, - 0xb5, 0xdc, 0xc9, 0x91, 0x12, 0x28, 0x1a, 0xff, 0x42, 0xf8, 0xfa, 0x67, 0x38, 0xd0, 0x3c, 0x38, - 0xd9, 0x13, 0x28, 0xaa, 0xc3, 0xe9, 0xce, 0x62, 0x75, 0x19, 0x0d, 0xf6, 0xf2, 0xd2, 0x4d, 0xee, - 0xe3, 0xfd, 0x6f, 0xf0, 0xc6, 0xff, 0x16, 0x69, 0x1f, 0x77, 0x2e, 0xfe, 0x62, 0xf0, 0x27, 0x87, - 0xae, 0x80, 0x41, 0xcd, 0x54, 0x2a, 0xed, 0x2e, 0xd6, 0x94, 0x2c, 0xd7, 0x94, 0x7c, 0xae, 0x29, - 0x79, 0xdf, 0xd0, 0x68, 0xb9, 0xa1, 0xd1, 0xc7, 0x86, 0x46, 0x4f, 0x37, 0x7a, 0x8c, 0xcf, 0x2f, - 0x19, 0x93, 0x66, 0xca, 0xad, 0x86, 0xdb, 0xaa, 0xcc, 0x6b, 0xfe, 0x56, 0x3e, 0x8c, 0x2b, 0xc0, - 0x66, 0xbb, 0xe1, 0x4f, 0xdd, 0x7d, 0x05, 0x00, 0x00, 0xff, 0xff, 0xe5, 0x3a, 0xe0, 0x84, 0xb0, - 0x01, 0x00, 0x00, + // 301 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0x4f, 0x4b, 0x03, 0x31, + 0x10, 0xc5, 0x37, 0x2a, 0x5a, 0xd7, 0x3f, 0x87, 0x50, 0xb4, 0x54, 0x89, 0x45, 0x41, 0x7a, 0x31, + 0x81, 0x7a, 0xf2, 0x56, 0x4a, 0x6f, 0x1e, 0x94, 0x52, 0x10, 0xbc, 0x94, 0x6c, 0x32, 0xc4, 0xb2, + 0xd5, 0x2c, 0xcd, 0x88, 0xe6, 0x5b, 0xf8, 0xb1, 0x7a, 0xec, 0x4d, 0x4f, 0x22, 0xed, 0x17, 0x91, + 0x64, 0xb7, 0x1e, 0xd4, 0xdb, 0xdb, 0x37, 0xf3, 0xde, 0xfc, 0xd8, 0xa4, 0x75, 0x67, 0x40, 0x64, + 0x80, 0x02, 0xc7, 0x2a, 0x07, 0xe4, 0xc5, 0xd4, 0xa2, 0xa5, 0xd4, 0x19, 0x78, 0x02, 0x7c, 0xb1, + 0xd3, 0x9c, 0x3b, 0x03, 0x3c, 0x03, 0x6c, 0xd6, 0x8d, 0x35, 0x36, 0x8e, 0x45, 0x50, 0xe5, 0x66, + 0x33, 0x6c, 0x0a, 0xf4, 0x05, 0x88, 0xdc, 0xab, 0xca, 0x3b, 0x58, 0x75, 0x66, 0x80, 0x23, 0xab, + 0xb5, 0xab, 0xfc, 0xc3, 0x95, 0x1f, 0xbc, 0x51, 0x08, 0x95, 0x83, 0xd3, 0x77, 0x92, 0xd2, 0x3b, + 0x69, 0x60, 0x3a, 0x8c, 0x10, 0xb7, 0xd2, 0x4f, 0xac, 0xd4, 0xb4, 0x9b, 0xee, 0x39, 0x98, 0x80, + 0x42, 0xd0, 0xb1, 0xa6, 0x41, 0x5a, 0xa4, 0xbd, 0xd3, 0x39, 0xe2, 0x7f, 0xe9, 0x78, 0x0f, 0xf0, + 0x46, 0x6b, 0x37, 0xd8, 0x5d, 0x25, 0xc2, 0x17, 0xed, 0xa7, 0xb5, 0xdc, 0xab, 0x91, 0x96, 0x28, + 0x1b, 0x6b, 0x31, 0x7c, 0xf6, 0x3b, 0x1c, 0x31, 0xae, 0xbd, 0xea, 0x4b, 0x94, 0xd5, 0xe1, 0xde, + 0xc6, 0xec, 0xf3, 0x24, 0x19, 0x6c, 0xe5, 0xa5, 0x4b, 0xaf, 0xd2, 0xed, 0x1f, 0xe2, 0xc6, 0x7a, + 0x8b, 0xb4, 0xf7, 0x3b, 0xc7, 0xff, 0x31, 0x84, 0x93, 0x43, 0x5f, 0xc0, 0xa0, 0x66, 0x2b, 0xd5, + 0xeb, 0xce, 0x16, 0x8c, 0xcc, 0x17, 0x8c, 0x7c, 0x2d, 0x18, 0x79, 0x5b, 0xb2, 0x64, 0xbe, 0x64, + 0xc9, 0xc7, 0x92, 0x25, 0xf7, 0xe7, 0x66, 0x8c, 0x0f, 0xcf, 0x19, 0x57, 0xf6, 0x51, 0x38, 0x03, + 0x17, 0x55, 0x59, 0xd0, 0xe2, 0xb5, 0x7c, 0x11, 0x5f, 0x80, 0xcb, 0x36, 0xe3, 0x2f, 0xba, 0xfc, + 0x0e, 0x00, 0x00, 0xff, 0xff, 0x55, 0x90, 0x94, 0x38, 0xa9, 0x01, 0x00, 0x00, } -func (m *BetPlacementTicketPayload) Marshal() (dAtA []byte, err error) { +func (m *WagerTicketPayload) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -129,12 +128,12 @@ func (m *BetPlacementTicketPayload) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *BetPlacementTicketPayload) MarshalTo(dAtA []byte) (int, error) { +func (m *WagerTicketPayload) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *BetPlacementTicketPayload) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *WagerTicketPayload) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -180,7 +179,7 @@ func encodeVarintTicket(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *BetPlacementTicketPayload) Size() (n int) { +func (m *WagerTicketPayload) Size() (n int) { if m == nil { return 0 } @@ -204,7 +203,7 @@ func sovTicket(x uint64) (n int) { func sozTicket(x uint64) (n int) { return sovTicket(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *BetPlacementTicketPayload) Unmarshal(dAtA []byte) error { +func (m *WagerTicketPayload) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -227,10 +226,10 @@ func (m *BetPlacementTicketPayload) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: BetPlacementTicketPayload: wiretype end group for non-group") + return fmt.Errorf("proto: WagerTicketPayload: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: BetPlacementTicketPayload: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: WagerTicketPayload: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: diff --git a/x/bet/types/ticket_test.go b/x/bet/types/ticket_test.go index fecc0500..4ca2618a 100644 --- a/x/bet/types/ticket_test.go +++ b/x/bet/types/ticket_test.go @@ -106,7 +106,7 @@ func TestTicketFieldsValidation(t *testing.T) { } for _, tc := range tcs { t.Run(tc.desc, func(t *testing.T) { - p := types.BetPlacementTicketPayload{ + p := types.WagerTicketPayload{ SelectedOdds: tc.betOdds, KycData: tc.kyc, OddsType: tc.oddsType, diff --git a/x/bet/types/tx.pb.go b/x/bet/types/tx.pb.go index 5658561f..bba6e06b 100644 --- a/x/bet/types/tx.pb.go +++ b/x/bet/types/tx.pb.go @@ -27,26 +27,26 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// MsgPlaceBet defines a message to place a bet with the given data. -type MsgPlaceBet struct { +// MsgWager defines a message to place a bet with the given data. +type MsgWager struct { // creator is the bettor address. Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - // PlaceBetFields contains bet fields. - Bet *PlaceBetFields `protobuf:"bytes,2,opt,name=bet,proto3" json:"bet,omitempty"` + // props contains bet properties. + Props *WagerProps `protobuf:"bytes,2,opt,name=props,proto3" json:"props,omitempty"` } -func (m *MsgPlaceBet) Reset() { *m = MsgPlaceBet{} } -func (m *MsgPlaceBet) String() string { return proto.CompactTextString(m) } -func (*MsgPlaceBet) ProtoMessage() {} -func (*MsgPlaceBet) Descriptor() ([]byte, []int) { +func (m *MsgWager) Reset() { *m = MsgWager{} } +func (m *MsgWager) String() string { return proto.CompactTextString(m) } +func (*MsgWager) ProtoMessage() {} +func (*MsgWager) Descriptor() ([]byte, []int) { return fileDescriptor_38b4167f68c2a7f8, []int{0} } -func (m *MsgPlaceBet) XXX_Unmarshal(b []byte) error { +func (m *MsgWager) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgPlaceBet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgWager) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgPlaceBet.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgWager.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -56,50 +56,50 @@ func (m *MsgPlaceBet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } -func (m *MsgPlaceBet) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgPlaceBet.Merge(m, src) +func (m *MsgWager) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgWager.Merge(m, src) } -func (m *MsgPlaceBet) XXX_Size() int { +func (m *MsgWager) XXX_Size() int { return m.Size() } -func (m *MsgPlaceBet) XXX_DiscardUnknown() { - xxx_messageInfo_MsgPlaceBet.DiscardUnknown(m) +func (m *MsgWager) XXX_DiscardUnknown() { + xxx_messageInfo_MsgWager.DiscardUnknown(m) } -var xxx_messageInfo_MsgPlaceBet proto.InternalMessageInfo +var xxx_messageInfo_MsgWager proto.InternalMessageInfo -func (m *MsgPlaceBet) GetCreator() string { +func (m *MsgWager) GetCreator() string { if m != nil { return m.Creator } return "" } -func (m *MsgPlaceBet) GetBet() *PlaceBetFields { +func (m *MsgWager) GetProps() *WagerProps { if m != nil { - return m.Bet + return m.Props } return nil } -// MsgPlaceBetResponse is the returning value in the response -// of MsgPlaceBet request. -type MsgPlaceBetResponse struct { - Bet *PlaceBetFields `protobuf:"bytes,1,opt,name=bet,proto3" json:"bet,omitempty"` +// MsgWagerResponse is the returning value in the response +// of MsgWagerResponse request. +type MsgWagerResponse struct { + Props *WagerProps `protobuf:"bytes,1,opt,name=props,proto3" json:"props,omitempty"` } -func (m *MsgPlaceBetResponse) Reset() { *m = MsgPlaceBetResponse{} } -func (m *MsgPlaceBetResponse) String() string { return proto.CompactTextString(m) } -func (*MsgPlaceBetResponse) ProtoMessage() {} -func (*MsgPlaceBetResponse) Descriptor() ([]byte, []int) { +func (m *MsgWagerResponse) Reset() { *m = MsgWagerResponse{} } +func (m *MsgWagerResponse) String() string { return proto.CompactTextString(m) } +func (*MsgWagerResponse) ProtoMessage() {} +func (*MsgWagerResponse) Descriptor() ([]byte, []int) { return fileDescriptor_38b4167f68c2a7f8, []int{1} } -func (m *MsgPlaceBetResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgWagerResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgPlaceBetResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgWagerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgPlaceBetResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgWagerResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -109,50 +109,49 @@ func (m *MsgPlaceBetResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *MsgPlaceBetResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgPlaceBetResponse.Merge(m, src) +func (m *MsgWagerResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgWagerResponse.Merge(m, src) } -func (m *MsgPlaceBetResponse) XXX_Size() int { +func (m *MsgWagerResponse) XXX_Size() int { return m.Size() } -func (m *MsgPlaceBetResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgPlaceBetResponse.DiscardUnknown(m) +func (m *MsgWagerResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgWagerResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgPlaceBetResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgWagerResponse proto.InternalMessageInfo -func (m *MsgPlaceBetResponse) GetBet() *PlaceBetFields { +func (m *MsgWagerResponse) GetProps() *WagerProps { if m != nil { - return m.Bet + return m.Props } return nil } func init() { - proto.RegisterType((*MsgPlaceBet)(nil), "sgenetwork.sge.bet.MsgPlaceBet") - proto.RegisterType((*MsgPlaceBetResponse)(nil), "sgenetwork.sge.bet.MsgPlaceBetResponse") + proto.RegisterType((*MsgWager)(nil), "sgenetwork.sge.bet.MsgWager") + proto.RegisterType((*MsgWagerResponse)(nil), "sgenetwork.sge.bet.MsgWagerResponse") } func init() { proto.RegisterFile("sge/bet/tx.proto", fileDescriptor_38b4167f68c2a7f8) } var fileDescriptor_38b4167f68c2a7f8 = []byte{ - // 251 bytes of a gzipped FileDescriptorProto + // 239 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x28, 0x4e, 0x4f, 0xd5, 0x4f, 0x4a, 0x2d, 0xd1, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x2a, 0x4e, 0x4f, 0xcd, 0x4b, 0x2d, 0x29, 0xcf, 0x2f, 0xca, 0xd6, 0x2b, 0x4e, 0x4f, 0xd5, 0x4b, 0x4a, 0x2d, - 0x91, 0x92, 0x83, 0xa9, 0x2a, 0xc8, 0x49, 0x4c, 0x4e, 0x8d, 0x4f, 0x4a, 0x2d, 0x89, 0x4f, 0xcb, - 0x4c, 0xcd, 0x49, 0x29, 0x86, 0xe8, 0x51, 0x8a, 0xe5, 0xe2, 0xf6, 0x2d, 0x4e, 0x0f, 0x00, 0x49, - 0x3a, 0xa5, 0x96, 0x08, 0x49, 0x70, 0xb1, 0x27, 0x17, 0xa5, 0x26, 0x96, 0xe4, 0x17, 0x49, 0x30, - 0x2a, 0x30, 0x6a, 0x70, 0x06, 0xc1, 0xb8, 0x42, 0x26, 0x5c, 0xcc, 0x49, 0xa9, 0x25, 0x12, 0x4c, - 0x0a, 0x8c, 0x1a, 0xdc, 0x46, 0x4a, 0x7a, 0x98, 0x56, 0xe9, 0xc1, 0x0c, 0x71, 0x03, 0x9b, 0x1f, - 0x04, 0x52, 0xae, 0xe4, 0xcd, 0x25, 0x8c, 0x64, 0x7c, 0x50, 0x6a, 0x71, 0x41, 0x7e, 0x5e, 0x71, - 0x2a, 0xcc, 0x30, 0x46, 0x92, 0x0c, 0x33, 0x8a, 0xe6, 0x62, 0xf6, 0x2d, 0x4e, 0x17, 0x0a, 0xe1, - 0xe2, 0x80, 0xbb, 0x57, 0x1e, 0x9b, 0x5e, 0x24, 0x1b, 0xa5, 0xd4, 0x09, 0x28, 0x80, 0x39, 0xc9, - 0xc9, 0xe1, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, - 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0xd4, 0xd2, 0x33, 0x4b, - 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x8b, 0xd3, 0x53, 0x75, 0xa1, 0xa6, 0x81, 0xd8, - 0xfa, 0x15, 0x90, 0x18, 0xa8, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0x87, 0xa8, 0x31, 0x20, 0x00, - 0x00, 0xff, 0xff, 0x88, 0xf7, 0xde, 0xca, 0x99, 0x01, 0x00, 0x00, + 0x91, 0x12, 0x86, 0xa9, 0x2a, 0x4f, 0x4c, 0x4f, 0x2d, 0x82, 0x28, 0x54, 0x8a, 0xe2, 0xe2, 0xf0, + 0x2d, 0x4e, 0x0f, 0x07, 0x89, 0x08, 0x49, 0x70, 0xb1, 0x27, 0x17, 0xa5, 0x26, 0x96, 0xe4, 0x17, + 0x49, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x06, 0xc1, 0xb8, 0x42, 0x26, 0x5c, 0xac, 0x05, 0x45, 0xf9, + 0x05, 0xc5, 0x12, 0x4c, 0x0a, 0x8c, 0x1a, 0xdc, 0x46, 0x72, 0x7a, 0x98, 0xc6, 0xeb, 0x81, 0xcd, + 0x08, 0x00, 0xa9, 0x0a, 0x82, 0x28, 0x56, 0xf2, 0xe0, 0x12, 0x80, 0x99, 0x1d, 0x94, 0x5a, 0x5c, + 0x90, 0x9f, 0x57, 0x9c, 0x8a, 0x30, 0x89, 0x91, 0x04, 0x93, 0x8c, 0x82, 0xb8, 0x98, 0x7d, 0x8b, + 0xd3, 0x85, 0xbc, 0xb9, 0x58, 0x21, 0x2e, 0x95, 0xc1, 0xa6, 0x0d, 0x66, 0x97, 0x94, 0x0a, 0x3e, + 0x59, 0x98, 0x4b, 0x9c, 0x1c, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, + 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, + 0x2d, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0xbf, 0x38, 0x3d, 0x55, 0x17, + 0x6a, 0x14, 0x88, 0xad, 0x5f, 0x01, 0x09, 0xe7, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0x70, 0x10, + 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x41, 0x9b, 0xc2, 0x84, 0x7f, 0x01, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -167,8 +166,8 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { - // PlaceBet defines a method to place a bet with the given data. - PlaceBet(ctx context.Context, in *MsgPlaceBet, opts ...grpc.CallOption) (*MsgPlaceBetResponse, error) + // Wager defines a method to place a bet with the given data. + Wager(ctx context.Context, in *MsgWager, opts ...grpc.CallOption) (*MsgWagerResponse, error) } type msgClient struct { @@ -179,9 +178,9 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } -func (c *msgClient) PlaceBet(ctx context.Context, in *MsgPlaceBet, opts ...grpc.CallOption) (*MsgPlaceBetResponse, error) { - out := new(MsgPlaceBetResponse) - err := c.cc.Invoke(ctx, "/sgenetwork.sge.bet.Msg/PlaceBet", in, out, opts...) +func (c *msgClient) Wager(ctx context.Context, in *MsgWager, opts ...grpc.CallOption) (*MsgWagerResponse, error) { + out := new(MsgWagerResponse) + err := c.cc.Invoke(ctx, "/sgenetwork.sge.bet.Msg/Wager", in, out, opts...) if err != nil { return nil, err } @@ -190,36 +189,36 @@ func (c *msgClient) PlaceBet(ctx context.Context, in *MsgPlaceBet, opts ...grpc. // MsgServer is the server API for Msg service. type MsgServer interface { - // PlaceBet defines a method to place a bet with the given data. - PlaceBet(context.Context, *MsgPlaceBet) (*MsgPlaceBetResponse, error) + // Wager defines a method to place a bet with the given data. + Wager(context.Context, *MsgWager) (*MsgWagerResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. type UnimplementedMsgServer struct { } -func (*UnimplementedMsgServer) PlaceBet(ctx context.Context, req *MsgPlaceBet) (*MsgPlaceBetResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method PlaceBet not implemented") +func (*UnimplementedMsgServer) Wager(ctx context.Context, req *MsgWager) (*MsgWagerResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Wager not implemented") } func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } -func _Msg_PlaceBet_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgPlaceBet) +func _Msg_Wager_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgWager) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).PlaceBet(ctx, in) + return srv.(MsgServer).Wager(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/sgenetwork.sge.bet.Msg/PlaceBet", + FullMethod: "/sgenetwork.sge.bet.Msg/Wager", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).PlaceBet(ctx, req.(*MsgPlaceBet)) + return srv.(MsgServer).Wager(ctx, req.(*MsgWager)) } return interceptor(ctx, in, info, handler) } @@ -229,15 +228,15 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "PlaceBet", - Handler: _Msg_PlaceBet_Handler, + MethodName: "Wager", + Handler: _Msg_Wager_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "sge/bet/tx.proto", } -func (m *MsgPlaceBet) Marshal() (dAtA []byte, err error) { +func (m *MsgWager) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -247,19 +246,19 @@ func (m *MsgPlaceBet) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgPlaceBet) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgWager) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgPlaceBet) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgWager) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Bet != nil { + if m.Props != nil { { - size, err := m.Bet.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Props.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -279,7 +278,7 @@ func (m *MsgPlaceBet) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgPlaceBetResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgWagerResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -289,19 +288,19 @@ func (m *MsgPlaceBetResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgPlaceBetResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgWagerResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgPlaceBetResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgWagerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Bet != nil { + if m.Props != nil { { - size, err := m.Bet.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Props.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -325,7 +324,7 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *MsgPlaceBet) Size() (n int) { +func (m *MsgWager) Size() (n int) { if m == nil { return 0 } @@ -335,21 +334,21 @@ func (m *MsgPlaceBet) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if m.Bet != nil { - l = m.Bet.Size() + if m.Props != nil { + l = m.Props.Size() n += 1 + l + sovTx(uint64(l)) } return n } -func (m *MsgPlaceBetResponse) Size() (n int) { +func (m *MsgWagerResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.Bet != nil { - l = m.Bet.Size() + if m.Props != nil { + l = m.Props.Size() n += 1 + l + sovTx(uint64(l)) } return n @@ -361,7 +360,7 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *MsgPlaceBet) Unmarshal(dAtA []byte) error { +func (m *MsgWager) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -384,10 +383,10 @@ func (m *MsgPlaceBet) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgPlaceBet: wiretype end group for non-group") + return fmt.Errorf("proto: MsgWager: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgPlaceBet: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgWager: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -424,7 +423,7 @@ func (m *MsgPlaceBet) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Bet", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Props", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -451,10 +450,10 @@ func (m *MsgPlaceBet) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Bet == nil { - m.Bet = &PlaceBetFields{} + if m.Props == nil { + m.Props = &WagerProps{} } - if err := m.Bet.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Props.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -479,7 +478,7 @@ func (m *MsgPlaceBet) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgPlaceBetResponse) Unmarshal(dAtA []byte) error { +func (m *MsgWagerResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -502,15 +501,15 @@ func (m *MsgPlaceBetResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgPlaceBetResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgWagerResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgPlaceBetResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgWagerResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Bet", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Props", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -537,10 +536,10 @@ func (m *MsgPlaceBetResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Bet == nil { - m.Bet = &PlaceBetFields{} + if m.Props == nil { + m.Props = &WagerProps{} } - if err := m.Bet.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Props.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/bet/types/wager.go b/x/bet/types/wager.go new file mode 100644 index 00000000..9b11070c --- /dev/null +++ b/x/bet/types/wager.go @@ -0,0 +1,24 @@ +package types + +import ( + "strings" + + "github.com/sge-network/sge/utils" +) + +// WagerValidation validates fields of the given bet +func WagerValidation(props *WagerProps) error { + if !utils.IsValidUID(props.UID) { + return ErrInvalidBetUID + } + + if props.Amount.IsNil() || !props.Amount.IsPositive() { + return ErrInvalidAmount + } + + if props.Ticket == "" || strings.Contains(props.Ticket, " ") { + return ErrInvalidTicket + } + + return nil +} diff --git a/x/bet/types/place_bet_fields.pb.go b/x/bet/types/wager.pb.go similarity index 56% rename from x/bet/types/place_bet_fields.pb.go rename to x/bet/types/wager.pb.go index f8d193ed..2123470c 100644 --- a/x/bet/types/place_bet_fields.pb.go +++ b/x/bet/types/wager.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: sge/bet/place_bet_fields.proto +// source: sge/bet/wager.proto package types @@ -24,8 +24,8 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// PlaceBetFields contains attributes which come in Place bet tx request. -type PlaceBetFields struct { +// WagerProps contains attributes which come in wager tx request. +type WagerProps struct { // uid is the universal unique identifier assigned to bet. UID string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid"` // amount is the wager amount. @@ -34,18 +34,18 @@ type PlaceBetFields struct { Ticket string `protobuf:"bytes,3,opt,name=ticket,proto3" json:"ticket,omitempty"` } -func (m *PlaceBetFields) Reset() { *m = PlaceBetFields{} } -func (m *PlaceBetFields) String() string { return proto.CompactTextString(m) } -func (*PlaceBetFields) ProtoMessage() {} -func (*PlaceBetFields) Descriptor() ([]byte, []int) { - return fileDescriptor_d186d55bc7cfa5da, []int{0} +func (m *WagerProps) Reset() { *m = WagerProps{} } +func (m *WagerProps) String() string { return proto.CompactTextString(m) } +func (*WagerProps) ProtoMessage() {} +func (*WagerProps) Descriptor() ([]byte, []int) { + return fileDescriptor_b14a4fe747361920, []int{0} } -func (m *PlaceBetFields) XXX_Unmarshal(b []byte) error { +func (m *WagerProps) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *PlaceBetFields) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *WagerProps) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_PlaceBetFields.Marshal(b, m, deterministic) + return xxx_messageInfo_WagerProps.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -55,26 +55,26 @@ func (m *PlaceBetFields) XXX_Marshal(b []byte, deterministic bool) ([]byte, erro return b[:n], nil } } -func (m *PlaceBetFields) XXX_Merge(src proto.Message) { - xxx_messageInfo_PlaceBetFields.Merge(m, src) +func (m *WagerProps) XXX_Merge(src proto.Message) { + xxx_messageInfo_WagerProps.Merge(m, src) } -func (m *PlaceBetFields) XXX_Size() int { +func (m *WagerProps) XXX_Size() int { return m.Size() } -func (m *PlaceBetFields) XXX_DiscardUnknown() { - xxx_messageInfo_PlaceBetFields.DiscardUnknown(m) +func (m *WagerProps) XXX_DiscardUnknown() { + xxx_messageInfo_WagerProps.DiscardUnknown(m) } -var xxx_messageInfo_PlaceBetFields proto.InternalMessageInfo +var xxx_messageInfo_WagerProps proto.InternalMessageInfo -func (m *PlaceBetFields) GetUID() string { +func (m *WagerProps) GetUID() string { if m != nil { return m.UID } return "" } -func (m *PlaceBetFields) GetTicket() string { +func (m *WagerProps) GetTicket() string { if m != nil { return m.Ticket } @@ -82,33 +82,32 @@ func (m *PlaceBetFields) GetTicket() string { } func init() { - proto.RegisterType((*PlaceBetFields)(nil), "sgenetwork.sge.bet.PlaceBetFields") + proto.RegisterType((*WagerProps)(nil), "sgenetwork.sge.bet.WagerProps") } -func init() { proto.RegisterFile("sge/bet/place_bet_fields.proto", fileDescriptor_d186d55bc7cfa5da) } +func init() { proto.RegisterFile("sge/bet/wager.proto", fileDescriptor_b14a4fe747361920) } -var fileDescriptor_d186d55bc7cfa5da = []byte{ - // 260 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2b, 0x4e, 0x4f, 0xd5, - 0x4f, 0x4a, 0x2d, 0xd1, 0x2f, 0xc8, 0x49, 0x4c, 0x4e, 0x8d, 0x4f, 0x4a, 0x2d, 0x89, 0x4f, 0xcb, - 0x4c, 0xcd, 0x49, 0x29, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x2a, 0x4e, 0x4f, 0xcd, - 0x4b, 0x2d, 0x29, 0xcf, 0x2f, 0xca, 0xd6, 0x2b, 0x4e, 0x4f, 0xd5, 0x4b, 0x4a, 0x2d, 0x91, 0x12, - 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x4b, 0xeb, 0x83, 0x58, 0x10, 0x95, 0x4a, 0x93, 0x18, 0xb9, 0xf8, - 0x02, 0x40, 0x86, 0x38, 0xa5, 0x96, 0xb8, 0x81, 0x8d, 0x10, 0x52, 0xe0, 0x62, 0x2e, 0xcd, 0x4c, - 0x91, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x74, 0xe2, 0x7b, 0x74, 0x4f, 0x9e, 0x39, 0xd4, 0xd3, 0xe5, - 0xd5, 0x3d, 0x79, 0x90, 0x68, 0x10, 0x88, 0x10, 0x72, 0xe3, 0x62, 0x4b, 0xcc, 0xcd, 0x2f, 0xcd, - 0x2b, 0x91, 0x60, 0x02, 0x2b, 0xd2, 0x3b, 0x71, 0x4f, 0x9e, 0xe1, 0xd6, 0x3d, 0x79, 0xb5, 0xf4, - 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xfd, 0xe4, 0xfc, 0xe2, 0xdc, 0xfc, 0x62, - 0x28, 0xa5, 0x5b, 0x9c, 0x92, 0xad, 0x5f, 0x52, 0x59, 0x90, 0x5a, 0xac, 0xe7, 0x99, 0x57, 0x12, - 0x04, 0xd5, 0x2d, 0x24, 0xc6, 0xc5, 0x56, 0x92, 0x99, 0x9c, 0x9d, 0x5a, 0x22, 0xc1, 0x0c, 0x32, - 0x27, 0x08, 0xca, 0x73, 0x72, 0x38, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, - 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, - 0x64, 0x1b, 0x8a, 0xd3, 0x53, 0x75, 0xa1, 0x9e, 0x04, 0xb1, 0xf5, 0x2b, 0xc0, 0x21, 0x02, 0xb6, - 0x25, 0x89, 0x0d, 0xec, 0x3b, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x5a, 0x70, 0x4e, 0x4f, - 0x29, 0x01, 0x00, 0x00, +var fileDescriptor_b14a4fe747361920 = []byte{ + // 247 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2e, 0x4e, 0x4f, 0xd5, + 0x4f, 0x4a, 0x2d, 0xd1, 0x2f, 0x4f, 0x4c, 0x4f, 0x2d, 0xd2, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, + 0x12, 0x2a, 0x4e, 0x4f, 0xcd, 0x4b, 0x2d, 0x29, 0xcf, 0x2f, 0xca, 0xd6, 0x2b, 0x4e, 0x4f, 0xd5, + 0x4b, 0x4a, 0x2d, 0x91, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x4b, 0xeb, 0x83, 0x58, 0x10, 0x95, + 0x4a, 0x7d, 0x8c, 0x5c, 0x5c, 0xe1, 0x20, 0x9d, 0x01, 0x45, 0xf9, 0x05, 0xc5, 0x42, 0x0a, 0x5c, + 0xcc, 0xa5, 0x99, 0x29, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x4e, 0x7c, 0x8f, 0xee, 0xc9, 0x33, + 0x87, 0x7a, 0xba, 0xbc, 0xba, 0x27, 0x0f, 0x12, 0x0d, 0x02, 0x11, 0x42, 0x6e, 0x5c, 0x6c, 0x89, + 0xb9, 0xf9, 0xa5, 0x79, 0x25, 0x12, 0x4c, 0x60, 0x45, 0x7a, 0x27, 0xee, 0xc9, 0x33, 0xdc, 0xba, + 0x27, 0xaf, 0x96, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x9f, 0x9c, 0x5f, + 0x9c, 0x9b, 0x5f, 0x0c, 0xa5, 0x74, 0x8b, 0x53, 0xb2, 0xf5, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, 0xf5, + 0x3c, 0xf3, 0x4a, 0x82, 0xa0, 0xba, 0x85, 0xc4, 0xb8, 0xd8, 0x4a, 0x32, 0x93, 0xb3, 0x53, 0x4b, + 0x24, 0x98, 0x41, 0xe6, 0x04, 0x41, 0x79, 0x4e, 0x0e, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, + 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, + 0x2c, 0xc7, 0x10, 0x85, 0x6c, 0x43, 0x71, 0x7a, 0xaa, 0x2e, 0xd4, 0x83, 0x20, 0xb6, 0x7e, 0x05, + 0x38, 0x08, 0xc0, 0xb6, 0x24, 0xb1, 0x81, 0x7d, 0x66, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x5d, + 0x87, 0x3f, 0x36, 0x1a, 0x01, 0x00, 0x00, } -func (m *PlaceBetFields) Marshal() (dAtA []byte, err error) { +func (m *WagerProps) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -118,12 +117,12 @@ func (m *PlaceBetFields) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *PlaceBetFields) MarshalTo(dAtA []byte) (int, error) { +func (m *WagerProps) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *PlaceBetFields) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *WagerProps) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -131,7 +130,7 @@ func (m *PlaceBetFields) MarshalToSizedBuffer(dAtA []byte) (int, error) { if len(m.Ticket) > 0 { i -= len(m.Ticket) copy(dAtA[i:], m.Ticket) - i = encodeVarintPlaceBetFields(dAtA, i, uint64(len(m.Ticket))) + i = encodeVarintWager(dAtA, i, uint64(len(m.Ticket))) i-- dAtA[i] = 0x1a } @@ -141,22 +140,22 @@ func (m *PlaceBetFields) MarshalToSizedBuffer(dAtA []byte) (int, error) { if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { return 0, err } - i = encodeVarintPlaceBetFields(dAtA, i, uint64(size)) + i = encodeVarintWager(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x12 if len(m.UID) > 0 { i -= len(m.UID) copy(dAtA[i:], m.UID) - i = encodeVarintPlaceBetFields(dAtA, i, uint64(len(m.UID))) + i = encodeVarintWager(dAtA, i, uint64(len(m.UID))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func encodeVarintPlaceBetFields(dAtA []byte, offset int, v uint64) int { - offset -= sovPlaceBetFields(v) +func encodeVarintWager(dAtA []byte, offset int, v uint64) int { + offset -= sovWager(v) base := offset for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) @@ -166,7 +165,7 @@ func encodeVarintPlaceBetFields(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *PlaceBetFields) Size() (n int) { +func (m *WagerProps) Size() (n int) { if m == nil { return 0 } @@ -174,24 +173,24 @@ func (m *PlaceBetFields) Size() (n int) { _ = l l = len(m.UID) if l > 0 { - n += 1 + l + sovPlaceBetFields(uint64(l)) + n += 1 + l + sovWager(uint64(l)) } l = m.Amount.Size() - n += 1 + l + sovPlaceBetFields(uint64(l)) + n += 1 + l + sovWager(uint64(l)) l = len(m.Ticket) if l > 0 { - n += 1 + l + sovPlaceBetFields(uint64(l)) + n += 1 + l + sovWager(uint64(l)) } return n } -func sovPlaceBetFields(x uint64) (n int) { +func sovWager(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } -func sozPlaceBetFields(x uint64) (n int) { - return sovPlaceBetFields(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +func sozWager(x uint64) (n int) { + return sovWager(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *PlaceBetFields) Unmarshal(dAtA []byte) error { +func (m *WagerProps) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -199,7 +198,7 @@ func (m *PlaceBetFields) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowPlaceBetFields + return ErrIntOverflowWager } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -214,10 +213,10 @@ func (m *PlaceBetFields) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: PlaceBetFields: wiretype end group for non-group") + return fmt.Errorf("proto: WagerProps: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: PlaceBetFields: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: WagerProps: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -227,7 +226,7 @@ func (m *PlaceBetFields) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowPlaceBetFields + return ErrIntOverflowWager } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -241,11 +240,11 @@ func (m *PlaceBetFields) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthPlaceBetFields + return ErrInvalidLengthWager } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthPlaceBetFields + return ErrInvalidLengthWager } if postIndex > l { return io.ErrUnexpectedEOF @@ -259,7 +258,7 @@ func (m *PlaceBetFields) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowPlaceBetFields + return ErrIntOverflowWager } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -273,11 +272,11 @@ func (m *PlaceBetFields) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthPlaceBetFields + return ErrInvalidLengthWager } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthPlaceBetFields + return ErrInvalidLengthWager } if postIndex > l { return io.ErrUnexpectedEOF @@ -293,7 +292,7 @@ func (m *PlaceBetFields) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowPlaceBetFields + return ErrIntOverflowWager } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -307,11 +306,11 @@ func (m *PlaceBetFields) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthPlaceBetFields + return ErrInvalidLengthWager } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthPlaceBetFields + return ErrInvalidLengthWager } if postIndex > l { return io.ErrUnexpectedEOF @@ -320,12 +319,12 @@ func (m *PlaceBetFields) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipPlaceBetFields(dAtA[iNdEx:]) + skippy, err := skipWager(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthPlaceBetFields + return ErrInvalidLengthWager } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -339,7 +338,7 @@ func (m *PlaceBetFields) Unmarshal(dAtA []byte) error { } return nil } -func skipPlaceBetFields(dAtA []byte) (n int, err error) { +func skipWager(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 depth := 0 @@ -347,7 +346,7 @@ func skipPlaceBetFields(dAtA []byte) (n int, err error) { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowPlaceBetFields + return 0, ErrIntOverflowWager } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -364,7 +363,7 @@ func skipPlaceBetFields(dAtA []byte) (n int, err error) { case 0: for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowPlaceBetFields + return 0, ErrIntOverflowWager } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -380,7 +379,7 @@ func skipPlaceBetFields(dAtA []byte) (n int, err error) { var length int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowPlaceBetFields + return 0, ErrIntOverflowWager } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -393,14 +392,14 @@ func skipPlaceBetFields(dAtA []byte) (n int, err error) { } } if length < 0 { - return 0, ErrInvalidLengthPlaceBetFields + return 0, ErrInvalidLengthWager } iNdEx += length case 3: depth++ case 4: if depth == 0 { - return 0, ErrUnexpectedEndOfGroupPlaceBetFields + return 0, ErrUnexpectedEndOfGroupWager } depth-- case 5: @@ -409,7 +408,7 @@ func skipPlaceBetFields(dAtA []byte) (n int, err error) { return 0, fmt.Errorf("proto: illegal wireType %d", wireType) } if iNdEx < 0 { - return 0, ErrInvalidLengthPlaceBetFields + return 0, ErrInvalidLengthWager } if depth == 0 { return iNdEx, nil @@ -419,7 +418,7 @@ func skipPlaceBetFields(dAtA []byte) (n int, err error) { } var ( - ErrInvalidLengthPlaceBetFields = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowPlaceBetFields = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupPlaceBetFields = fmt.Errorf("proto: unexpected end of group") + ErrInvalidLengthWager = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowWager = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupWager = fmt.Errorf("proto: unexpected end of group") ) diff --git a/x/bet/types/place_bet_fields_test.go b/x/bet/types/wager_test.go similarity index 84% rename from x/bet/types/place_bet_fields_test.go rename to x/bet/types/wager_test.go index bf797118..a3b33acd 100644 --- a/x/bet/types/place_bet_fields_test.go +++ b/x/bet/types/wager_test.go @@ -11,12 +11,12 @@ import ( func TestBetFieldsValidation(t *testing.T) { tcs := []struct { desc string - bet *types.PlaceBetFields + bet *types.WagerProps err error }{ { desc: "space in UID", - bet: &types.PlaceBetFields{ + bet: &types.WagerProps{ UID: " ", Amount: sdk.NewInt(int64(10)), Ticket: "Ticket", @@ -25,7 +25,7 @@ func TestBetFieldsValidation(t *testing.T) { }, { desc: "invalid UID", - bet: &types.PlaceBetFields{ + bet: &types.WagerProps{ UID: "invalidUID", Amount: sdk.NewInt(int64(10)), Ticket: "Ticket", @@ -34,7 +34,7 @@ func TestBetFieldsValidation(t *testing.T) { }, { desc: "invalid amount", - bet: &types.PlaceBetFields{ + bet: &types.WagerProps{ UID: "6e31c60f-2025-48ce-ae79-1dc110f16355", Amount: sdk.NewInt(int64(-1)), Ticket: "Ticket", @@ -43,7 +43,7 @@ func TestBetFieldsValidation(t *testing.T) { }, { desc: "empty amount", - bet: &types.PlaceBetFields{ + bet: &types.WagerProps{ UID: "6e31c60f-2025-48ce-ae79-1dc110f16355", Ticket: "Ticket", }, @@ -51,7 +51,7 @@ func TestBetFieldsValidation(t *testing.T) { }, { desc: "space in ticket", - bet: &types.PlaceBetFields{ + bet: &types.WagerProps{ UID: "6e31c60f-2025-48ce-ae79-1dc110f16355", Amount: sdk.NewInt(int64(10)), Ticket: " ", @@ -60,7 +60,7 @@ func TestBetFieldsValidation(t *testing.T) { }, { desc: "valid message", - bet: &types.PlaceBetFields{ + bet: &types.WagerProps{ UID: "6e31c60f-2025-48ce-ae79-1dc110f16355", Amount: sdk.NewInt(int64(10)), Ticket: "Ticket", @@ -69,7 +69,7 @@ func TestBetFieldsValidation(t *testing.T) { } for _, tc := range tcs { t.Run(tc.desc, func(t *testing.T) { - err := types.BetFieldsValidation(tc.bet) + err := types.WagerValidation(tc.bet) if tc.err != nil { require.ErrorIs(t, err, tc.err) return diff --git a/x/house/types/codec.go b/x/house/types/codec.go index eb68186f..39be4517 100644 --- a/x/house/types/codec.go +++ b/x/house/types/codec.go @@ -12,8 +12,8 @@ import ( // RegisterLegacyAminoCodec registers the necessary x/house interfaces and concrete types // on the provided LegacyAmino codec. These types are used for Amino JSON serialization. func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(&MsgDeposit{}, "house/MsgDeposit", nil) - cdc.RegisterConcrete(&MsgWithdraw{}, "house/MsgWithdraw", nil) + cdc.RegisterConcrete(&MsgDeposit{}, "house/Deposit", nil) + cdc.RegisterConcrete(&MsgWithdraw{}, "house/Withdraw", nil) } // RegisterInterfaces registers the x/house interfaces types with the interface registry diff --git a/x/market/client/cli/tx.go b/x/market/client/cli/tx.go index f05c80f6..7edfc47c 100644 --- a/x/market/client/cli/tx.go +++ b/x/market/client/cli/tx.go @@ -22,9 +22,9 @@ func GetTxCmd() *cobra.Command { } cmd.AddCommand( - CmdAddMarket(), - CmdResolveMarket(), - CmdUpdateMarket(), + CmdAdd(), + CmdResolve(), + CmdUpdate(), ) return cmd diff --git a/x/market/client/cli/tx_market.go b/x/market/client/cli/tx_market.go index 87820a8f..7a0ff78d 100644 --- a/x/market/client/cli/tx_market.go +++ b/x/market/client/cli/tx_market.go @@ -9,7 +9,7 @@ import ( ) // CmdAddMarket CLI registration for add market command -func CmdAddMarket() *cobra.Command { +func CmdAdd() *cobra.Command { cmd := &cobra.Command{ Use: "add [ticket]", Short: "create new market", @@ -21,7 +21,7 @@ func CmdAddMarket() *cobra.Command { return err } - msg := types.NewMsgAddMarket( + msg := types.NewMsgAdd( clientCtx.GetFromAddress().String(), args[0], ) @@ -38,7 +38,7 @@ func CmdAddMarket() *cobra.Command { } // CmdUpdateMarket returns query for updating market transaction -func CmdUpdateMarket() *cobra.Command { +func CmdUpdate() *cobra.Command { cmd := &cobra.Command{ Use: "update [ticket]", Short: "update market", @@ -50,7 +50,7 @@ func CmdUpdateMarket() *cobra.Command { return err } - msg := types.NewMsgUpdateMarket( + msg := types.NewMsgUpdate( clientCtx.GetFromAddress().String(), args[0], ) diff --git a/x/market/client/cli/tx_resolve_market.go b/x/market/client/cli/tx_resolve_market.go index 8d86d00f..af2ef113 100644 --- a/x/market/client/cli/tx_resolve_market.go +++ b/x/market/client/cli/tx_resolve_market.go @@ -9,7 +9,7 @@ import ( ) // CmdResolveMarket registers the resolve market command -func CmdResolveMarket() *cobra.Command { +func CmdResolve() *cobra.Command { cmd := &cobra.Command{ Use: "resolve [ticket]", Short: "set resolution of a market", @@ -21,7 +21,7 @@ func CmdResolveMarket() *cobra.Command { return err } - msg := types.NewMsgResolveMarket( + msg := types.NewMsgResolve( clientCtx.GetFromAddress().String(), args[0], ) diff --git a/x/market/handler.go b/x/market/handler.go index c0f48c14..4a235182 100644 --- a/x/market/handler.go +++ b/x/market/handler.go @@ -18,14 +18,14 @@ func NewHandler(k keeper.Keeper) sdk.Handler { _ = ctx switch msg := msg.(type) { - case *types.MsgAddMarket: - res, err := msgServer.AddMarket(sdk.WrapSDKContext(ctx), msg) + case *types.MsgAdd: + res, err := msgServer.Add(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgResolveMarket: - res, err := msgServer.ResolveMarket(sdk.WrapSDKContext(ctx), msg) + case *types.MsgResolve: + res, err := msgServer.Resolve(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgUpdateMarket: - res, err := msgServer.UpdateMarket(sdk.WrapSDKContext(ctx), msg) + case *types.MsgUpdate: + res, err := msgServer.Update(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) default: errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) diff --git a/x/market/keeper/market.go b/x/market/keeper/market.go index 53d7dd9a..dec3f8c7 100644 --- a/x/market/keeper/market.go +++ b/x/market/keeper/market.go @@ -50,8 +50,8 @@ func (k Keeper) GetMarkets(ctx sdk.Context) (list []types.Market, err error) { return } -// ResolveMarket updates a market with its resolution -func (k Keeper) ResolveMarket( +// Resolve updates a market with its resolution +func (k Keeper) Resolve( ctx sdk.Context, storedMarket types.Market, resolutionMarket *types.MarketResolutionTicketPayload, diff --git a/x/market/keeper/market_test.go b/x/market/keeper/market_test.go index fad1cde2..ca18fe0d 100644 --- a/x/market/keeper/market_test.go +++ b/x/market/keeper/market_test.go @@ -87,7 +87,7 @@ func TestResolveMarkets(t *testing.T) { WinnerOddsUIDs: []string{"oddsUID1", "oddsUID2"}, Status: types.MarketStatus_MARKET_STATUS_RESULT_DECLARED, } - k.ResolveMarket(ctx, item, &resMarketsIn) + k.Resolve(ctx, item, &resMarketsIn) val, found := k.GetMarket(ctx, item.UID) require.True(t, found) require.Equal(t, resMarketsIn.ResolutionTS, val.ResolutionTS) diff --git a/x/market/keeper/msg_server_market.go b/x/market/keeper/msg_server_market.go index f61f8556..00e5f550 100644 --- a/x/market/keeper/msg_server_market.go +++ b/x/market/keeper/msg_server_market.go @@ -8,11 +8,11 @@ import ( "github.com/sge-network/sge/x/market/types" ) -// AddMarket accepts ticket containing creation market and return response after processing -func (k msgServer) AddMarket( +// Add accepts ticket containing creation market and return response after processing +func (k msgServer) Add( goCtx context.Context, - msg *types.MsgAddMarket, -) (*types.MsgAddMarketResponse, error) { + msg *types.MsgAdd, +) (*types.MsgAddResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) var addPayload types.MarketAddTicketPayload @@ -53,17 +53,17 @@ func (k msgServer) AddMarket( msg.EmitEvent(&ctx, market.UID, market.BookUID) - return &types.MsgAddMarketResponse{ + return &types.MsgAddResponse{ Error: "", Data: &market, }, nil } -// UpdateMarket accepts ticket containing update market and return response after processing -func (k msgServer) UpdateMarket( +// Update accepts ticket containing update market and return response after processing +func (k msgServer) Update( goCtx context.Context, - msg *types.MsgUpdateMarket, -) (*types.MsgUpdateMarketResponse, error) { + msg *types.MsgUpdate, +) (*types.MsgUpdateResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) var updatePayload types.MarketUpdateTicketPayload @@ -97,5 +97,5 @@ func (k msgServer) UpdateMarket( msg.EmitEvent(&ctx, market.UID) - return &types.MsgUpdateMarketResponse{Data: &market}, nil + return &types.MsgUpdateResponse{Data: &market}, nil } diff --git a/x/market/keeper/msg_server_market_resolve.go b/x/market/keeper/msg_server_market_resolve.go index bf23b24b..b520d77d 100644 --- a/x/market/keeper/msg_server_market_resolve.go +++ b/x/market/keeper/msg_server_market_resolve.go @@ -8,11 +8,11 @@ import ( "github.com/sge-network/sge/x/market/types" ) -// ResolveMarket accepts ticket containing resolution markets and return response after processing -func (k msgServer) ResolveMarket( +// Resolve accepts ticket containing resolution markets and return response after processing +func (k msgServer) Resolve( goCtx context.Context, - msg *types.MsgResolveMarket, -) (*types.MsgResolveMarketResponse, error) { + msg *types.MsgResolve, +) (*types.MsgResolveResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) var resolutionPayload types.MarketResolutionTicketPayload @@ -38,11 +38,11 @@ func (k msgServer) ResolveMarket( return nil, sdkerrors.Wrapf(types.ErrInvalidWinnerOdds, "%s", err) } - resolvedMarket := k.Keeper.ResolveMarket(ctx, market, &resolutionPayload) + resolvedMarket := k.Keeper.Resolve(ctx, market, &resolutionPayload) msg.EmitEvent(&ctx, market.UID) - return &types.MsgResolveMarketResponse{ + return &types.MsgResolveResponse{ Data: resolvedMarket, }, nil } diff --git a/x/market/keeper/msg_server_market_resolve_test.go b/x/market/keeper/msg_server_market_resolve_test.go index b8e71045..37fd3dd9 100644 --- a/x/market/keeper/msg_server_market_resolve_test.go +++ b/x/market/keeper/msg_server_market_resolve_test.go @@ -12,10 +12,10 @@ import ( "github.com/stretchr/testify/require" ) -func TestMsgServerResolveMarket(t *testing.T) { +func TestMsgServerResolve(t *testing.T) { k, msgk, ctx, wctx := setupMsgServerAndKeeper(t) type args struct { - msg *types.MsgResolveMarket + msg *types.MsgResolve } u1 := uuid.NewString() @@ -27,13 +27,13 @@ func TestMsgServerResolveMarket(t *testing.T) { tests := []struct { name string args args - want *types.MsgResolveMarketResponse + want *types.MsgResolveResponse wantErr error }{ { name: "test the empty or invalid format ticket", args: args{ - msg: types.NewMsgResolveMarket(sample.AccAddress(), ""), + msg: types.NewMsgResolve(sample.AccAddress(), ""), }, want: nil, wantErr: types.ErrInTicketVerification, @@ -41,7 +41,7 @@ func TestMsgServerResolveMarket(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - got, err := msgk.ResolveMarket(wctx, tt.args.msg) + got, err := msgk.Resolve(wctx, tt.args.msg) require.ErrorIs(t, err, tt.wantErr) require.EqualValues(t, got, tt.want) }) @@ -74,9 +74,9 @@ func TestMsgServerResolveMarketResponse(t *testing.T) { validEmptyTicket, err := createJwtTicket(validEmptyTicketClaims) require.NoError(t, err) - response, err := msgk.ResolveMarket( + response, err := msgk.Resolve( wctx, - types.NewMsgResolveMarket(sample.AccAddress(), validEmptyTicket), + types.NewMsgResolve(sample.AccAddress(), validEmptyTicket), ) assert.ErrorIs(t, err, types.ErrInTicketPayloadValidation) assert.Nil(t, response) @@ -94,9 +94,9 @@ func TestMsgServerResolveMarketResponse(t *testing.T) { validEmptyTicket, err := createJwtTicket(validEmptyTicketClaims) require.NoError(t, err) - response, err := msgk.ResolveMarket( + response, err := msgk.Resolve( wctx, - types.NewMsgResolveMarket(sample.AccAddress(), validEmptyTicket), + types.NewMsgResolve(sample.AccAddress(), validEmptyTicket), ) assert.ErrorIs(t, err, types.ErrMarketNotFound) assert.Nil(t, response) @@ -114,9 +114,9 @@ func TestMsgServerResolveMarketResponse(t *testing.T) { validEmptyTicket, err := createJwtTicket(validEmptyTicketClaims) require.NoError(t, err) - response, err := msgk.ResolveMarket( + response, err := msgk.Resolve( wctx, - types.NewMsgResolveMarket(sample.AccAddress(), validEmptyTicket), + types.NewMsgResolve(sample.AccAddress(), validEmptyTicket), ) assert.ErrorIs(t, err, types.ErrMarketResolutionNotAllowed) assert.Nil(t, response) @@ -134,9 +134,9 @@ func TestMsgServerResolveMarketResponse(t *testing.T) { validEmptyTicket, err := createJwtTicket(validEmptyTicketClaims) require.NoError(t, err) - response, err := msgk.ResolveMarket( + response, err := msgk.Resolve( wctx, - types.NewMsgResolveMarket(sample.AccAddress(), validEmptyTicket), + types.NewMsgResolve(sample.AccAddress(), validEmptyTicket), ) assert.ErrorIs(t, err, types.ErrInTicketPayloadValidation) assert.Nil(t, response) @@ -154,9 +154,9 @@ func TestMsgServerResolveMarketResponse(t *testing.T) { validEmptyTicket, err := createJwtTicket(validEmptyTicketClaims) require.NoError(t, err) - response, err := msgk.ResolveMarket( + response, err := msgk.Resolve( wctx, - types.NewMsgResolveMarket(sample.AccAddress(), validEmptyTicket), + types.NewMsgResolve(sample.AccAddress(), validEmptyTicket), ) assert.ErrorIs(t, err, types.ErrInTicketPayloadValidation) assert.Nil(t, response) @@ -174,9 +174,9 @@ func TestMsgServerResolveMarketResponse(t *testing.T) { validEmptyTicket, err := createJwtTicket(validEmptyTicketClaims) require.NoError(t, err) - response, err := msgk.ResolveMarket( + response, err := msgk.Resolve( wctx, - types.NewMsgResolveMarket(sample.AccAddress(), validEmptyTicket), + types.NewMsgResolve(sample.AccAddress(), validEmptyTicket), ) assert.ErrorIs(t, err, types.ErrInTicketPayloadValidation) assert.Nil(t, response) @@ -194,9 +194,9 @@ func TestMsgServerResolveMarketResponse(t *testing.T) { validEmptyTicket, err := createJwtTicket(validEmptyTicketClaims) require.NoError(t, err) - response, err := msgk.ResolveMarket( + response, err := msgk.Resolve( wctx, - types.NewMsgResolveMarket(sample.AccAddress(), validEmptyTicket), + types.NewMsgResolve(sample.AccAddress(), validEmptyTicket), ) assert.ErrorIs(t, err, types.ErrInvalidWinnerOdds) assert.Nil(t, response) diff --git a/x/market/keeper/msg_server_market_test.go b/x/market/keeper/msg_server_market_test.go index 44a4eb56..a8793601 100644 --- a/x/market/keeper/msg_server_market_test.go +++ b/x/market/keeper/msg_server_market_test.go @@ -12,10 +12,10 @@ import ( "github.com/stretchr/testify/require" ) -func TestMsgServerAddMarket(t *testing.T) { +func TestMsgServerAdd(t *testing.T) { k, msgk, ctx, wctx := setupMsgServerAndKeeper(t) type args struct { - msg *types.MsgAddMarket + msg *types.MsgAdd } u1 := uuid.NewString() @@ -27,13 +27,13 @@ func TestMsgServerAddMarket(t *testing.T) { tests := []struct { name string args args - want *types.MsgAddMarketResponse + want *types.MsgAddResponse wantErr error }{ { name: "test the empty or invalid format ticket", args: args{ - msg: types.NewMsgAddMarket(sample.AccAddress(), ""), + msg: types.NewMsgAdd(sample.AccAddress(), ""), }, want: nil, wantErr: types.ErrInTicketVerification, @@ -41,7 +41,7 @@ func TestMsgServerAddMarket(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - got, err := msgk.AddMarket(wctx, tt.args.msg) + got, err := msgk.Add(wctx, tt.args.msg) require.ErrorIs(t, err, tt.wantErr) require.EqualValues(t, got, tt.want) }) @@ -67,9 +67,9 @@ func TestMsgServerAddMarketResponse(t *testing.T) { validEmptyTicket, err := createJwtTicket(validEmptyTicketClaims) require.NoError(t, err) - response, err := msgk.AddMarket( + response, err := msgk.Add( wctx, - types.NewMsgAddMarket(sample.AccAddress(), validEmptyTicket), + types.NewMsgAdd(sample.AccAddress(), validEmptyTicket), ) assert.ErrorIs(t, err, types.ErrInTicketPayloadValidation) assert.Nil(t, response) @@ -92,19 +92,19 @@ func TestMsgServerAddMarketResponse(t *testing.T) { validEmptyTicket, err := createJwtTicket(validEmptyTicketClaims) require.NoError(t, err) - response, err := msgk.AddMarket( + response, err := msgk.Add( wctx, - types.NewMsgAddMarket(sample.AccAddress(), validEmptyTicket), + types.NewMsgAdd(sample.AccAddress(), validEmptyTicket), ) assert.ErrorIs(t, err, types.ErrMarketAlreadyExist) assert.Nil(t, response) }) } -func TestMsgServerUpdateMarket(t *testing.T) { +func TestMsgServerUpdate(t *testing.T) { k, msgk, ctx, wctx := setupMsgServerAndKeeper(t) type args struct { - msg *types.MsgUpdateMarket + msg *types.MsgUpdate } u1 := uuid.NewString() @@ -116,13 +116,13 @@ func TestMsgServerUpdateMarket(t *testing.T) { tests := []struct { name string args args - want *types.MsgUpdateMarketResponse + want *types.MsgUpdateResponse wantErr error }{ { name: "test the empty or invalid format ticket", args: args{ - msg: types.NewMsgUpdateMarket(sample.AccAddress(), ""), + msg: types.NewMsgUpdate(sample.AccAddress(), ""), }, want: nil, wantErr: types.ErrInTicketVerification, @@ -130,7 +130,7 @@ func TestMsgServerUpdateMarket(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - got, err := msgk.UpdateMarket(wctx, tt.args.msg) + got, err := msgk.Update(wctx, tt.args.msg) require.ErrorIs(t, err, tt.wantErr) require.EqualValues(t, got, tt.want) }) @@ -160,9 +160,9 @@ func TestMsgServerUpdateMarketResponse(t *testing.T) { validEmptyTicket, err := createJwtTicket(validEmptyTicketClaims) require.NoError(t, err) - response, err := msgk.UpdateMarket( + response, err := msgk.Update( wctx, - types.NewMsgUpdateMarket(sample.AccAddress(), validEmptyTicket), + types.NewMsgUpdate(sample.AccAddress(), validEmptyTicket), ) assert.ErrorIs(t, err, types.ErrMarketNotFound) assert.Nil(t, response) @@ -178,9 +178,9 @@ func TestMsgServerUpdateMarketResponse(t *testing.T) { validEmptyTicket, err := createJwtTicket(validEmptyTicketClaims) require.NoError(t, err) - response, err := msgk.UpdateMarket( + response, err := msgk.Update( wctx, - types.NewMsgUpdateMarket(sample.AccAddress(), validEmptyTicket), + types.NewMsgUpdate(sample.AccAddress(), validEmptyTicket), ) assert.ErrorIs(t, err, types.ErrMarketCanNotBeAltered) assert.Nil(t, response) diff --git a/x/market/module_simulation.go b/x/market/module_simulation.go index 48bff416..b6e1bbc7 100644 --- a/x/market/module_simulation.go +++ b/x/market/module_simulation.go @@ -26,16 +26,16 @@ var ( const ( //#nosec - opWeightMsgAddMarket = "op_weight_msg_create_chain" - defaultWeightMsgAddMarket int = 100 + opWeightMsgAdd = "op_weight_msg_create_chain" + defaultWeightMsgAdd int = 100 //#nosec - opWeightMsgResolveMarket = "op_weight_msg_create_chain" - defaultWeightMsgResolveMarket int = 100 + opWeightMsgResolve = "op_weight_msg_create_chain" + defaultWeightMsgResolve int = 100 //#nosec - opWeightMsgUpdateMarket = "op_weight_msg_create_chain" - defaultWeightMsgUpdateMarket int = 100 + opWeightMsgUpdate = "op_weight_msg_create_chain" + defaultWeightMsgUpdate int = 100 ) // GenerateGenesisState creates a randomized GenState of the module @@ -62,41 +62,41 @@ func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { operations := make([]simtypes.WeightedOperation, 0) - var weightMsgAddMarket int - simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgAddMarket, &weightMsgAddMarket, nil, + var weightMsgAdd int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgAdd, &weightMsgAdd, nil, func(_ *rand.Rand) { - weightMsgAddMarket = defaultWeightMsgAddMarket + weightMsgAdd = defaultWeightMsgAdd }, ) operations = append(operations, simulation.NewWeightedOperation( - weightMsgAddMarket, - marketsimulation.SimulateMsgAddMarket(am.accountKeeper, am.bankKeeper, am.keeper), + weightMsgAdd, + marketsimulation.SimulateMsgAdd(am.accountKeeper, am.bankKeeper, am.keeper), )) - var weightMsgResolveMarket int + var weightMsgResolve int simState.AppParams.GetOrGenerate( simState.Cdc, - opWeightMsgResolveMarket, - &weightMsgResolveMarket, + opWeightMsgResolve, + &weightMsgResolve, nil, func(_ *rand.Rand) { - weightMsgResolveMarket = defaultWeightMsgResolveMarket + weightMsgResolve = defaultWeightMsgResolve }, ) operations = append(operations, simulation.NewWeightedOperation( - weightMsgResolveMarket, - marketsimulation.SimulateMsgResolveMarket(am.accountKeeper, am.bankKeeper, am.keeper), + weightMsgResolve, + marketsimulation.SimulateMsgResolve(am.accountKeeper, am.bankKeeper, am.keeper), )) - var weightMsgUpdateMarket int - simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgUpdateMarket, &weightMsgUpdateMarket, nil, + var weightMsgUpdate int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgUpdate, &weightMsgUpdate, nil, func(_ *rand.Rand) { - weightMsgUpdateMarket = defaultWeightMsgUpdateMarket + weightMsgUpdate = defaultWeightMsgUpdate }, ) operations = append(operations, simulation.NewWeightedOperation( - weightMsgUpdateMarket, - marketsimulation.SimulateMsgUpdateMarket(am.accountKeeper, am.bankKeeper, am.keeper), + weightMsgUpdate, + marketsimulation.SimulateMsgUpdate(am.accountKeeper, am.bankKeeper, am.keeper), )) return operations diff --git a/x/market/simulation/market.go b/x/market/simulation/market.go index b5d44e0b..8a529691 100644 --- a/x/market/simulation/market.go +++ b/x/market/simulation/market.go @@ -11,8 +11,8 @@ import ( "github.com/sge-network/sge/x/market/types" ) -// SimulateMsgAddMarket simulates the add market flow -func SimulateMsgAddMarket( +// SimulateMsgAdd simulates the add market flow +func SimulateMsgAdd( _ types.AccountKeeper, _ types.BankKeeper, _ keeper.Keeper, @@ -20,7 +20,7 @@ func SimulateMsgAddMarket( return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { simAccount, _ := simtypes.RandomAcc(r, accs) - msg := &types.MsgAddMarket{ + msg := &types.MsgAdd{ Creator: simAccount.Address.String(), } @@ -34,8 +34,8 @@ func SimulateMsgAddMarket( } } -// SimulateMsgResolveMarket simulates the resolve market flow -func SimulateMsgResolveMarket( +// SimulateMsgResolve simulates the resolve market flow +func SimulateMsgResolve( _ types.AccountKeeper, _ types.BankKeeper, _ keeper.Keeper, @@ -43,7 +43,7 @@ func SimulateMsgResolveMarket( return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { simAccount, _ := simtypes.RandomAcc(r, accs) - msg := &types.MsgResolveMarket{ + msg := &types.MsgResolve{ Creator: simAccount.Address.String(), } diff --git a/x/market/simulation/market_update.go b/x/market/simulation/market_update.go index def2cf1d..329aeec3 100644 --- a/x/market/simulation/market_update.go +++ b/x/market/simulation/market_update.go @@ -11,8 +11,8 @@ import ( "github.com/sge-network/sge/x/market/types" ) -// SimulateMsgUpdateMarket simulates update market message -func SimulateMsgUpdateMarket( +// SimulateMsgUpdate simulates update market message +func SimulateMsgUpdate( _ types.AccountKeeper, _ types.BankKeeper, _ keeper.Keeper, @@ -20,7 +20,7 @@ func SimulateMsgUpdateMarket( return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { simAccount, _ := simtypes.RandomAcc(r, accs) - msg := &types.MsgUpdateMarket{ + msg := &types.MsgUpdate{ Creator: simAccount.Address.String(), } diff --git a/x/market/types/codec.go b/x/market/types/codec.go index 02b90aff..bcee1258 100644 --- a/x/market/types/codec.go +++ b/x/market/types/codec.go @@ -10,22 +10,22 @@ import ( // RegisterCodec registers module codec to the app codec func RegisterCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(&MsgAddMarket{}, "market/AddMarket", nil) - cdc.RegisterConcrete(&MsgResolveMarket{}, "market/ResolveMarket", nil) - cdc.RegisterConcrete(&MsgUpdateMarket{}, "market/UpdateMarket", nil) + cdc.RegisterConcrete(&MsgAdd{}, "market/Add", nil) + cdc.RegisterConcrete(&MsgResolve{}, "market/Resolve", nil) + cdc.RegisterConcrete(&MsgUpdate{}, "market/Update", nil) } // RegisterInterfaces registers the module interface types func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil)) registry.RegisterImplementations((*sdk.Msg)(nil), - &MsgAddMarket{}, + &MsgAdd{}, ) registry.RegisterImplementations((*sdk.Msg)(nil), - &MsgResolveMarket{}, + &MsgResolve{}, ) registry.RegisterImplementations((*sdk.Msg)(nil), - &MsgUpdateMarket{}, + &MsgUpdate{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/market/types/message_market.go b/x/market/types/message_market.go index 30b5a13d..4abb7715 100644 --- a/x/market/types/message_market.go +++ b/x/market/types/message_market.go @@ -6,26 +6,26 @@ import ( "github.com/sge-network/sge/utils" ) -const typeMsgAddMarket = "market_add" +const typeMsgAdd = "market_add" -var _ sdk.Msg = &MsgAddMarket{} +var _ sdk.Msg = &MsgAdd{} -// NewMsgAddMarket creates the new input for adding a market to blockchain -func NewMsgAddMarket(creator string, ticket string) *MsgAddMarket { - return &MsgAddMarket{ +// NewMsgAdd creates the new input for adding a market to blockchain +func NewMsgAdd(creator string, ticket string) *MsgAdd { + return &MsgAdd{ Creator: creator, Ticket: ticket, } } // Route return the message route for slashing -func (*MsgAddMarket) Route() string { return RouterKey } +func (*MsgAdd) Route() string { return RouterKey } // Type returns the msg add market type -func (*MsgAddMarket) Type() string { return typeMsgAddMarket } +func (*MsgAdd) Type() string { return typeMsgAdd } // GetSigners return the creators address -func (msg *MsgAddMarket) GetSigners() []sdk.AccAddress { +func (msg *MsgAdd) GetSigners() []sdk.AccAddress { creator, err := sdk.AccAddressFromBech32(msg.Creator) if err != nil { panic(err) @@ -34,13 +34,13 @@ func (msg *MsgAddMarket) GetSigners() []sdk.AccAddress { } // GetSignBytes return the marshalled bytes of the msg -func (msg *MsgAddMarket) GetSignBytes() []byte { +func (msg *MsgAdd) GetSignBytes() []byte { bz := ModuleCdc.MustMarshalJSON(msg) return sdk.MustSortJSON(bz) } // ValidateBasic validates the input creation market -func (msg *MsgAddMarket) ValidateBasic() error { +func (msg *MsgAdd) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(msg.Creator) if err != nil { return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) @@ -53,36 +53,36 @@ func (msg *MsgAddMarket) ValidateBasic() error { } // EmitEvent emits the event for the message success. -func (msg *MsgAddMarket) EmitEvent(ctx *sdk.Context, marketUID, bookUID string) { +func (msg *MsgAdd) EmitEvent(ctx *sdk.Context, marketUID, bookUID string) { emitter := utils.NewEventEmitter(ctx, attributeValueCategory) - emitter.AddMsg(typeMsgAddMarket, msg.Creator, + emitter.AddMsg(typeMsgAdd, msg.Creator, sdk.NewAttribute(attributeKeyMarketUID, marketUID), sdk.NewAttribute(attributeKeyMarketOrderBookUID, bookUID), ) emitter.Emit() } -// typeMsgUpdateMarket is the market name of update market -const typeMsgUpdateMarket = "market_update" +// typeMsgUpdate is the market name of update market +const typeMsgUpdate = "market_update" -var _ sdk.Msg = &MsgUpdateMarket{} +var _ sdk.Msg = &MsgUpdate{} -// NewMsgUpdateMarket accepts the params to create new update body -func NewMsgUpdateMarket(creator, ticket string) *MsgUpdateMarket { - return &MsgUpdateMarket{ +// NewMsgUpdate accepts the params to create new update body +func NewMsgUpdate(creator, ticket string) *MsgUpdate { + return &MsgUpdate{ Creator: creator, Ticket: ticket, } } // Route return the message route for slashing -func (*MsgUpdateMarket) Route() string { return RouterKey } +func (*MsgUpdate) Route() string { return RouterKey } // Type return the update market type -func (*MsgUpdateMarket) Type() string { return typeMsgUpdateMarket } +func (*MsgUpdate) Type() string { return typeMsgUpdate } // GetSigners return the creators address -func (msg *MsgUpdateMarket) GetSigners() []sdk.AccAddress { +func (msg *MsgUpdate) GetSigners() []sdk.AccAddress { creator, err := sdk.AccAddressFromBech32(msg.Creator) if err != nil { panic(err) @@ -91,13 +91,13 @@ func (msg *MsgUpdateMarket) GetSigners() []sdk.AccAddress { } // GetSignBytes return the marshalled bytes of the msg -func (msg *MsgUpdateMarket) GetSignBytes() []byte { +func (msg *MsgUpdate) GetSignBytes() []byte { bz := ModuleCdc.MustMarshalJSON(msg) return sdk.MustSortJSON(bz) } // ValidateBasic validates the input update market -func (msg *MsgUpdateMarket) ValidateBasic() error { +func (msg *MsgUpdate) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(msg.Creator) if err != nil { return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) @@ -111,9 +111,9 @@ func (msg *MsgUpdateMarket) ValidateBasic() error { } // EmitEvent emits the event for the message success. -func (msg *MsgUpdateMarket) EmitEvent(ctx *sdk.Context, marketUID string) { +func (msg *MsgUpdate) EmitEvent(ctx *sdk.Context, marketUID string) { emitter := utils.NewEventEmitter(ctx, attributeValueCategory) - emitter.AddMsg(typeMsgUpdateMarket, msg.Creator, + emitter.AddMsg(typeMsgUpdate, msg.Creator, sdk.NewAttribute(attributeKeyMarketUID, marketUID), ) emitter.Emit() diff --git a/x/market/types/message_market_resolve.go b/x/market/types/message_market_resolve.go index 232a2a97..47774dc2 100644 --- a/x/market/types/message_market_resolve.go +++ b/x/market/types/message_market_resolve.go @@ -6,26 +6,26 @@ import ( "github.com/sge-network/sge/utils" ) -const typeMsgResolveMarket = "market_resolve" +const typeMsgResolve = "market_resolve" -var _ sdk.Msg = &MsgResolveMarket{} +var _ sdk.Msg = &MsgResolve{} -// NewMsgResolveMarket accepts the params to create new resolution body -func NewMsgResolveMarket(creator, ticket string) *MsgResolveMarket { - return &MsgResolveMarket{ +// NewMsgResolve accepts the params to create new resolution body +func NewMsgResolve(creator, ticket string) *MsgResolve { + return &MsgResolve{ Creator: creator, Ticket: ticket, } } // Route return the message route for slashing -func (*MsgResolveMarket) Route() string { return RouterKey } +func (*MsgResolve) Route() string { return RouterKey } // Type return the resolve market type -func (*MsgResolveMarket) Type() string { return typeMsgResolveMarket } +func (*MsgResolve) Type() string { return typeMsgResolve } // GetSigners return the creators address -func (msg *MsgResolveMarket) GetSigners() []sdk.AccAddress { +func (msg *MsgResolve) GetSigners() []sdk.AccAddress { creator, err := sdk.AccAddressFromBech32(msg.Creator) if err != nil { panic(err) @@ -34,13 +34,13 @@ func (msg *MsgResolveMarket) GetSigners() []sdk.AccAddress { } // GetSignBytes return the marshalled bytes of the msg -func (msg *MsgResolveMarket) GetSignBytes() []byte { +func (msg *MsgResolve) GetSignBytes() []byte { bz := ModuleCdc.MustMarshalJSON(msg) return sdk.MustSortJSON(bz) } // ValidateBasic validates the input resolution market -func (msg *MsgResolveMarket) ValidateBasic() error { +func (msg *MsgResolve) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(msg.Creator) if err != nil { return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) @@ -54,9 +54,9 @@ func (msg *MsgResolveMarket) ValidateBasic() error { } // EmitEvent emits the event for the message success. -func (msg *MsgResolveMarket) EmitEvent(ctx *sdk.Context, marketUID string) { +func (msg *MsgResolve) EmitEvent(ctx *sdk.Context, marketUID string) { emitter := utils.NewEventEmitter(ctx, attributeValueCategory) - emitter.AddMsg(typeMsgResolveMarket, msg.Creator, + emitter.AddMsg(typeMsgResolve, msg.Creator, sdk.NewAttribute(attributeKeyMarketUID, marketUID), ) emitter.Emit() diff --git a/x/market/types/message_market_resolve_test.go b/x/market/types/message_market_resolve_test.go index 9f22089c..fb5d355d 100644 --- a/x/market/types/message_market_resolve_test.go +++ b/x/market/types/message_market_resolve_test.go @@ -10,29 +10,29 @@ import ( "github.com/stretchr/testify/require" ) -func TestMsgResolveMarketValidateBasic(t *testing.T) { +func TestMsgResolveValidateBasic(t *testing.T) { tests := []struct { name string - msg types.MsgResolveMarket + msg types.MsgResolve err error }{ { name: "invalid creator", - msg: types.MsgResolveMarket{ + msg: types.MsgResolve{ Creator: "invalid_address", }, err: sdkerrors.ErrInvalidAddress, }, { name: "valid", - msg: types.MsgResolveMarket{ + msg: types.MsgResolve{ Creator: sample.AccAddress(), Ticket: "Ticket", }, }, { name: "no ticket", - msg: types.MsgResolveMarket{ + msg: types.MsgResolve{ Creator: sample.AccAddress(), }, err: sdkerrors.ErrInvalidRequest, @@ -50,13 +50,13 @@ func TestMsgResolveMarketValidateBasic(t *testing.T) { } } -func TestNewResolveMarket(t *testing.T) { +func TestNewResolve(t *testing.T) { t.Run("valid", func(t *testing.T) { - expected := &types.MsgResolveMarket{ + expected := &types.MsgResolve{ Creator: uuid.NewString(), Ticket: "Ticket", } - res := types.NewMsgResolveMarket( + res := types.NewMsgResolve( expected.Creator, expected.Ticket, ) diff --git a/x/market/types/message_market_test.go b/x/market/types/message_market_test.go index 7539d389..4ee00521 100644 --- a/x/market/types/message_market_test.go +++ b/x/market/types/message_market_test.go @@ -10,29 +10,29 @@ import ( "github.com/stretchr/testify/require" ) -func TestMsgAddMarketValidateBasic(t *testing.T) { +func TestMsgAddValidateBasic(t *testing.T) { tests := []struct { name string - msg types.MsgAddMarket + msg types.MsgAdd err error }{ { name: "invalid creator", - msg: types.MsgAddMarket{ + msg: types.MsgAdd{ Creator: "invalid_address", }, err: sdkerrors.ErrInvalidAddress, }, { name: "valid", - msg: types.MsgAddMarket{ + msg: types.MsgAdd{ Creator: sample.AccAddress(), Ticket: "Ticket", }, }, { name: "no ticket", - msg: types.MsgAddMarket{ + msg: types.MsgAdd{ Creator: sample.AccAddress(), }, err: sdkerrors.ErrInvalidRequest, @@ -50,13 +50,13 @@ func TestMsgAddMarketValidateBasic(t *testing.T) { } } -func TestNewAddMarket(t *testing.T) { +func TestNewAdd(t *testing.T) { t.Run("valid", func(t *testing.T) { - expected := &types.MsgAddMarket{ + expected := &types.MsgAdd{ Creator: uuid.NewString(), Ticket: "Ticket", } - res := types.NewMsgAddMarket( + res := types.NewMsgAdd( expected.Creator, expected.Ticket, ) @@ -64,29 +64,29 @@ func TestNewAddMarket(t *testing.T) { }) } -func TestMsgUpdateMarketValidateBasic(t *testing.T) { +func TestMsgUpdateValidateBasic(t *testing.T) { tests := []struct { name string - msg types.MsgUpdateMarket + msg types.MsgUpdate err error }{ { name: "invalid creator", - msg: types.MsgUpdateMarket{ + msg: types.MsgUpdate{ Creator: "invalid_address", }, err: sdkerrors.ErrInvalidAddress, }, { name: "valid", - msg: types.MsgUpdateMarket{ + msg: types.MsgUpdate{ Creator: sample.AccAddress(), Ticket: "Ticket", }, }, { name: "no ticket", - msg: types.MsgUpdateMarket{ + msg: types.MsgUpdate{ Creator: sample.AccAddress(), }, err: sdkerrors.ErrInvalidRequest, @@ -104,13 +104,13 @@ func TestMsgUpdateMarketValidateBasic(t *testing.T) { } } -func TestNewUpdateMarket(t *testing.T) { +func TestNewUpdate(t *testing.T) { t.Run("valid", func(t *testing.T) { - expected := &types.MsgUpdateMarket{ + expected := &types.MsgUpdate{ Creator: uuid.NewString(), Ticket: "Ticket", } - res := types.NewMsgUpdateMarket( + res := types.NewMsgUpdate( expected.Creator, expected.Ticket, ) diff --git a/x/market/types/tx.pb.go b/x/market/types/tx.pb.go index 227db5bf..4417dde6 100644 --- a/x/market/types/tx.pb.go +++ b/x/market/types/tx.pb.go @@ -28,27 +28,27 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// MsgAddMarket is the message type for adding the market into the +// MsgAdd is the message type for adding the market into the // state. -type MsgAddMarket struct { +type MsgAdd struct { // creator is the address of the creator account of the market. Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` // ticket is the jwt ticket data. Ticket string `protobuf:"bytes,2,opt,name=ticket,proto3" json:"ticket,omitempty"` } -func (m *MsgAddMarket) Reset() { *m = MsgAddMarket{} } -func (m *MsgAddMarket) String() string { return proto.CompactTextString(m) } -func (*MsgAddMarket) ProtoMessage() {} -func (*MsgAddMarket) Descriptor() ([]byte, []int) { +func (m *MsgAdd) Reset() { *m = MsgAdd{} } +func (m *MsgAdd) String() string { return proto.CompactTextString(m) } +func (*MsgAdd) ProtoMessage() {} +func (*MsgAdd) Descriptor() ([]byte, []int) { return fileDescriptor_d0e875658c4f19fd, []int{0} } -func (m *MsgAddMarket) XXX_Unmarshal(b []byte) error { +func (m *MsgAdd) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgAddMarket) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgAdd) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgAddMarket.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgAdd.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -58,52 +58,52 @@ func (m *MsgAddMarket) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } -func (m *MsgAddMarket) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgAddMarket.Merge(m, src) +func (m *MsgAdd) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAdd.Merge(m, src) } -func (m *MsgAddMarket) XXX_Size() int { +func (m *MsgAdd) XXX_Size() int { return m.Size() } -func (m *MsgAddMarket) XXX_DiscardUnknown() { - xxx_messageInfo_MsgAddMarket.DiscardUnknown(m) +func (m *MsgAdd) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAdd.DiscardUnknown(m) } -var xxx_messageInfo_MsgAddMarket proto.InternalMessageInfo +var xxx_messageInfo_MsgAdd proto.InternalMessageInfo -func (m *MsgAddMarket) GetCreator() string { +func (m *MsgAdd) GetCreator() string { if m != nil { return m.Creator } return "" } -func (m *MsgAddMarket) GetTicket() string { +func (m *MsgAdd) GetTicket() string { if m != nil { return m.Ticket } return "" } -// MsgAddMarketResponse response for adding market. -type MsgAddMarketResponse struct { +// MsgAddResponse response for adding market. +type MsgAddResponse struct { // error contains an error if adding a market faces any issues. Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"` // data is the data of market. Data *Market `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` } -func (m *MsgAddMarketResponse) Reset() { *m = MsgAddMarketResponse{} } -func (m *MsgAddMarketResponse) String() string { return proto.CompactTextString(m) } -func (*MsgAddMarketResponse) ProtoMessage() {} -func (*MsgAddMarketResponse) Descriptor() ([]byte, []int) { +func (m *MsgAddResponse) Reset() { *m = MsgAddResponse{} } +func (m *MsgAddResponse) String() string { return proto.CompactTextString(m) } +func (*MsgAddResponse) ProtoMessage() {} +func (*MsgAddResponse) Descriptor() ([]byte, []int) { return fileDescriptor_d0e875658c4f19fd, []int{1} } -func (m *MsgAddMarketResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgAddResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgAddMarketResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgAddResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgAddMarketResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgAddResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -113,52 +113,52 @@ func (m *MsgAddMarketResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte return b[:n], nil } } -func (m *MsgAddMarketResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgAddMarketResponse.Merge(m, src) +func (m *MsgAddResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAddResponse.Merge(m, src) } -func (m *MsgAddMarketResponse) XXX_Size() int { +func (m *MsgAddResponse) XXX_Size() int { return m.Size() } -func (m *MsgAddMarketResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgAddMarketResponse.DiscardUnknown(m) +func (m *MsgAddResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAddResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgAddMarketResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgAddResponse proto.InternalMessageInfo -func (m *MsgAddMarketResponse) GetError() string { +func (m *MsgAddResponse) GetError() string { if m != nil { return m.Error } return "" } -func (m *MsgAddMarketResponse) GetData() *Market { +func (m *MsgAddResponse) GetData() *Market { if m != nil { return m.Data } return nil } -// MsgResolveMarket is the message type for resolving a market. -type MsgResolveMarket struct { +// MsgResolve is the message type for resolving a market. +type MsgResolve struct { // creator is the address of the creator account of the market. Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` // ticket is the jwt ticket data. Ticket string `protobuf:"bytes,2,opt,name=ticket,proto3" json:"ticket,omitempty"` } -func (m *MsgResolveMarket) Reset() { *m = MsgResolveMarket{} } -func (m *MsgResolveMarket) String() string { return proto.CompactTextString(m) } -func (*MsgResolveMarket) ProtoMessage() {} -func (*MsgResolveMarket) Descriptor() ([]byte, []int) { +func (m *MsgResolve) Reset() { *m = MsgResolve{} } +func (m *MsgResolve) String() string { return proto.CompactTextString(m) } +func (*MsgResolve) ProtoMessage() {} +func (*MsgResolve) Descriptor() ([]byte, []int) { return fileDescriptor_d0e875658c4f19fd, []int{2} } -func (m *MsgResolveMarket) XXX_Unmarshal(b []byte) error { +func (m *MsgResolve) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgResolveMarket) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgResolve) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgResolveMarket.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgResolve.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -168,52 +168,52 @@ func (m *MsgResolveMarket) XXX_Marshal(b []byte, deterministic bool) ([]byte, er return b[:n], nil } } -func (m *MsgResolveMarket) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgResolveMarket.Merge(m, src) +func (m *MsgResolve) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgResolve.Merge(m, src) } -func (m *MsgResolveMarket) XXX_Size() int { +func (m *MsgResolve) XXX_Size() int { return m.Size() } -func (m *MsgResolveMarket) XXX_DiscardUnknown() { - xxx_messageInfo_MsgResolveMarket.DiscardUnknown(m) +func (m *MsgResolve) XXX_DiscardUnknown() { + xxx_messageInfo_MsgResolve.DiscardUnknown(m) } -var xxx_messageInfo_MsgResolveMarket proto.InternalMessageInfo +var xxx_messageInfo_MsgResolve proto.InternalMessageInfo -func (m *MsgResolveMarket) GetCreator() string { +func (m *MsgResolve) GetCreator() string { if m != nil { return m.Creator } return "" } -func (m *MsgResolveMarket) GetTicket() string { +func (m *MsgResolve) GetTicket() string { if m != nil { return m.Ticket } return "" } -// MsgResolveMarketResponse response for resolving a market. -type MsgResolveMarketResponse struct { +// MsgResolveResponse response for resolving a market. +type MsgResolveResponse struct { // error contains an error if resolving a market faces any issues. Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"` // data is the data of market. Data *Market `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` } -func (m *MsgResolveMarketResponse) Reset() { *m = MsgResolveMarketResponse{} } -func (m *MsgResolveMarketResponse) String() string { return proto.CompactTextString(m) } -func (*MsgResolveMarketResponse) ProtoMessage() {} -func (*MsgResolveMarketResponse) Descriptor() ([]byte, []int) { +func (m *MsgResolveResponse) Reset() { *m = MsgResolveResponse{} } +func (m *MsgResolveResponse) String() string { return proto.CompactTextString(m) } +func (*MsgResolveResponse) ProtoMessage() {} +func (*MsgResolveResponse) Descriptor() ([]byte, []int) { return fileDescriptor_d0e875658c4f19fd, []int{3} } -func (m *MsgResolveMarketResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgResolveResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgResolveMarketResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgResolveResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgResolveMarketResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgResolveResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -223,53 +223,53 @@ func (m *MsgResolveMarketResponse) XXX_Marshal(b []byte, deterministic bool) ([] return b[:n], nil } } -func (m *MsgResolveMarketResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgResolveMarketResponse.Merge(m, src) +func (m *MsgResolveResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgResolveResponse.Merge(m, src) } -func (m *MsgResolveMarketResponse) XXX_Size() int { +func (m *MsgResolveResponse) XXX_Size() int { return m.Size() } -func (m *MsgResolveMarketResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgResolveMarketResponse.DiscardUnknown(m) +func (m *MsgResolveResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgResolveResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgResolveMarketResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgResolveResponse proto.InternalMessageInfo -func (m *MsgResolveMarketResponse) GetError() string { +func (m *MsgResolveResponse) GetError() string { if m != nil { return m.Error } return "" } -func (m *MsgResolveMarketResponse) GetData() *Market { +func (m *MsgResolveResponse) GetData() *Market { if m != nil { return m.Data } return nil } -// MsgUpdateMarket is the message type for updating market data. +// MsgUpdate is the message type for updating market data. // in the state -type MsgUpdateMarket struct { +type MsgUpdate struct { // creator is the address of the creator account of the market. Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` // ticket is the jwt ticket data. Ticket string `protobuf:"bytes,2,opt,name=ticket,proto3" json:"ticket,omitempty"` } -func (m *MsgUpdateMarket) Reset() { *m = MsgUpdateMarket{} } -func (m *MsgUpdateMarket) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateMarket) ProtoMessage() {} -func (*MsgUpdateMarket) Descriptor() ([]byte, []int) { +func (m *MsgUpdate) Reset() { *m = MsgUpdate{} } +func (m *MsgUpdate) String() string { return proto.CompactTextString(m) } +func (*MsgUpdate) ProtoMessage() {} +func (*MsgUpdate) Descriptor() ([]byte, []int) { return fileDescriptor_d0e875658c4f19fd, []int{4} } -func (m *MsgUpdateMarket) XXX_Unmarshal(b []byte) error { +func (m *MsgUpdate) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgUpdateMarket) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgUpdate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgUpdateMarket.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgUpdate.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -279,52 +279,52 @@ func (m *MsgUpdateMarket) XXX_Marshal(b []byte, deterministic bool) ([]byte, err return b[:n], nil } } -func (m *MsgUpdateMarket) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateMarket.Merge(m, src) +func (m *MsgUpdate) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdate.Merge(m, src) } -func (m *MsgUpdateMarket) XXX_Size() int { +func (m *MsgUpdate) XXX_Size() int { return m.Size() } -func (m *MsgUpdateMarket) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateMarket.DiscardUnknown(m) +func (m *MsgUpdate) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdate.DiscardUnknown(m) } -var xxx_messageInfo_MsgUpdateMarket proto.InternalMessageInfo +var xxx_messageInfo_MsgUpdate proto.InternalMessageInfo -func (m *MsgUpdateMarket) GetCreator() string { +func (m *MsgUpdate) GetCreator() string { if m != nil { return m.Creator } return "" } -func (m *MsgUpdateMarket) GetTicket() string { +func (m *MsgUpdate) GetTicket() string { if m != nil { return m.Ticket } return "" } -// MsgUpdateMarketResponse response for updating a market. -type MsgUpdateMarketResponse struct { +// MsgUpdateResponse response for updating a market. +type MsgUpdateResponse struct { // error contains an error if updating a market faces any issues. Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"` // data is the data of market Data *Market `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` } -func (m *MsgUpdateMarketResponse) Reset() { *m = MsgUpdateMarketResponse{} } -func (m *MsgUpdateMarketResponse) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateMarketResponse) ProtoMessage() {} -func (*MsgUpdateMarketResponse) Descriptor() ([]byte, []int) { +func (m *MsgUpdateResponse) Reset() { *m = MsgUpdateResponse{} } +func (m *MsgUpdateResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateResponse) ProtoMessage() {} +func (*MsgUpdateResponse) Descriptor() ([]byte, []int) { return fileDescriptor_d0e875658c4f19fd, []int{5} } -func (m *MsgUpdateMarketResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgUpdateResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgUpdateMarketResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgUpdateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgUpdateMarketResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgUpdateResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -334,26 +334,26 @@ func (m *MsgUpdateMarketResponse) XXX_Marshal(b []byte, deterministic bool) ([]b return b[:n], nil } } -func (m *MsgUpdateMarketResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateMarketResponse.Merge(m, src) +func (m *MsgUpdateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateResponse.Merge(m, src) } -func (m *MsgUpdateMarketResponse) XXX_Size() int { +func (m *MsgUpdateResponse) XXX_Size() int { return m.Size() } -func (m *MsgUpdateMarketResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateMarketResponse.DiscardUnknown(m) +func (m *MsgUpdateResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgUpdateMarketResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgUpdateResponse proto.InternalMessageInfo -func (m *MsgUpdateMarketResponse) GetError() string { +func (m *MsgUpdateResponse) GetError() string { if m != nil { return m.Error } return "" } -func (m *MsgUpdateMarketResponse) GetData() *Market { +func (m *MsgUpdateResponse) GetData() *Market { if m != nil { return m.Data } @@ -361,41 +361,40 @@ func (m *MsgUpdateMarketResponse) GetData() *Market { } func init() { - proto.RegisterType((*MsgAddMarket)(nil), "sgenetwork.sge.market.MsgAddMarket") - proto.RegisterType((*MsgAddMarketResponse)(nil), "sgenetwork.sge.market.MsgAddMarketResponse") - proto.RegisterType((*MsgResolveMarket)(nil), "sgenetwork.sge.market.MsgResolveMarket") - proto.RegisterType((*MsgResolveMarketResponse)(nil), "sgenetwork.sge.market.MsgResolveMarketResponse") - proto.RegisterType((*MsgUpdateMarket)(nil), "sgenetwork.sge.market.MsgUpdateMarket") - proto.RegisterType((*MsgUpdateMarketResponse)(nil), "sgenetwork.sge.market.MsgUpdateMarketResponse") + proto.RegisterType((*MsgAdd)(nil), "sgenetwork.sge.market.MsgAdd") + proto.RegisterType((*MsgAddResponse)(nil), "sgenetwork.sge.market.MsgAddResponse") + proto.RegisterType((*MsgResolve)(nil), "sgenetwork.sge.market.MsgResolve") + proto.RegisterType((*MsgResolveResponse)(nil), "sgenetwork.sge.market.MsgResolveResponse") + proto.RegisterType((*MsgUpdate)(nil), "sgenetwork.sge.market.MsgUpdate") + proto.RegisterType((*MsgUpdateResponse)(nil), "sgenetwork.sge.market.MsgUpdateResponse") } func init() { proto.RegisterFile("sge/market/tx.proto", fileDescriptor_d0e875658c4f19fd) } var fileDescriptor_d0e875658c4f19fd = []byte{ - // 360 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2e, 0x4e, 0x4f, 0xd5, - 0xcf, 0x4d, 0x2c, 0xca, 0x4e, 0x2d, 0xd1, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, - 0x12, 0x2d, 0x4e, 0x4f, 0xcd, 0x4b, 0x2d, 0x29, 0xcf, 0x2f, 0xca, 0xd6, 0x2b, 0x4e, 0x4f, 0xd5, - 0x83, 0xc8, 0x4b, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x55, 0xe8, 0x83, 0x58, 0x10, 0xc5, 0x52, - 0xe2, 0x48, 0x26, 0x40, 0x28, 0x88, 0x84, 0x92, 0x03, 0x17, 0x8f, 0x6f, 0x71, 0xba, 0x63, 0x4a, - 0x8a, 0x2f, 0x58, 0x54, 0x48, 0x82, 0x8b, 0x3d, 0xb9, 0x28, 0x35, 0xb1, 0x24, 0xbf, 0x48, 0x82, - 0x51, 0x81, 0x51, 0x83, 0x33, 0x08, 0xc6, 0x15, 0x12, 0xe3, 0x62, 0x2b, 0xc9, 0x4c, 0xce, 0x4e, - 0x2d, 0x91, 0x60, 0x02, 0x4b, 0x40, 0x79, 0x4a, 0xd9, 0x5c, 0x22, 0xc8, 0x26, 0x04, 0xa5, 0x16, - 0x17, 0xe4, 0xe7, 0x15, 0xa7, 0x0a, 0x49, 0x71, 0xb1, 0xa6, 0x16, 0x15, 0xc1, 0xcc, 0x71, 0x62, - 0x39, 0x71, 0x4f, 0x9e, 0x31, 0x08, 0x22, 0x24, 0x64, 0xce, 0xc5, 0x92, 0x92, 0x58, 0x92, 0x08, - 0x36, 0x89, 0xdb, 0x48, 0x56, 0x0f, 0xab, 0x57, 0xf4, 0x20, 0x06, 0x42, 0x75, 0x82, 0x35, 0x28, - 0xb9, 0x70, 0x09, 0xf8, 0x16, 0xa7, 0x07, 0xa5, 0x16, 0xe7, 0xe7, 0x94, 0xa5, 0x92, 0xed, 0xe4, - 0x7c, 0x2e, 0x09, 0x74, 0x53, 0x68, 0xeb, 0x6c, 0x67, 0x2e, 0x7e, 0xdf, 0xe2, 0xf4, 0xd0, 0x82, - 0x94, 0xc4, 0x12, 0xf2, 0x5d, 0x9d, 0xc7, 0x25, 0x8e, 0x66, 0x08, 0x4d, 0x1d, 0x6d, 0xb4, 0x9d, - 0x89, 0x8b, 0xd9, 0xb7, 0x38, 0x5d, 0x28, 0x96, 0x8b, 0x13, 0x91, 0x3e, 0x94, 0x71, 0xe9, 0x47, - 0x4a, 0x02, 0x52, 0xda, 0x44, 0x28, 0x82, 0xbb, 0x3d, 0x93, 0x8b, 0x17, 0x35, 0x3e, 0xd5, 0x71, - 0xeb, 0x46, 0x51, 0x28, 0xa5, 0x4f, 0xa4, 0x42, 0xb8, 0x55, 0x69, 0x5c, 0x3c, 0x28, 0x71, 0xa0, - 0x86, 0xdb, 0x00, 0x64, 0x75, 0x52, 0x7a, 0xc4, 0xa9, 0x83, 0xd9, 0xe3, 0xe4, 0x7c, 0xe2, 0x91, - 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, - 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x9a, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, - 0xc9, 0xf9, 0xb9, 0xfa, 0xc5, 0xe9, 0xa9, 0xba, 0x50, 0x43, 0x41, 0x6c, 0xfd, 0x0a, 0x78, 0x16, - 0xaf, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0x67, 0x50, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, - 0x54, 0x0c, 0x40, 0x72, 0xfd, 0x03, 0x00, 0x00, + // 352 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x93, 0xcf, 0x4a, 0xf3, 0x40, + 0x14, 0xc5, 0x9b, 0xb6, 0x5f, 0x4a, 0xef, 0x07, 0x82, 0xe3, 0xbf, 0x12, 0x30, 0xd6, 0x82, 0xd0, + 0x2e, 0x9c, 0x40, 0x5d, 0x08, 0x82, 0x82, 0x75, 0x29, 0xd9, 0x04, 0x45, 0x70, 0x97, 0x36, 0x97, + 0x69, 0xa9, 0xed, 0x84, 0x99, 0x51, 0xeb, 0xd2, 0x37, 0xf0, 0xb1, 0xba, 0xec, 0xd2, 0x95, 0x48, + 0xfb, 0x22, 0xd2, 0x99, 0x24, 0xba, 0xb0, 0x16, 0x0a, 0x5d, 0xcd, 0x4c, 0xce, 0xf9, 0x1d, 0x0e, + 0xb9, 0x5c, 0xd8, 0x92, 0x0c, 0xbd, 0x41, 0x28, 0xfa, 0xa8, 0x3c, 0x35, 0xa2, 0xb1, 0xe0, 0x8a, + 0x93, 0x1d, 0xc9, 0x70, 0x88, 0xea, 0x99, 0x8b, 0x3e, 0x95, 0x0c, 0xa9, 0xd1, 0x9d, 0x6d, 0xc6, + 0x19, 0xd7, 0x0e, 0x6f, 0x7e, 0x33, 0x66, 0x67, 0xef, 0x47, 0x82, 0x39, 0x8c, 0x50, 0x3b, 0x03, + 0xdb, 0x97, 0xec, 0x32, 0x8a, 0x48, 0x05, 0x4a, 0x1d, 0x81, 0xa1, 0xe2, 0xa2, 0x62, 0x55, 0xad, + 0x7a, 0x39, 0x48, 0x9f, 0x64, 0x17, 0x6c, 0xd5, 0xeb, 0xf4, 0x51, 0x55, 0xf2, 0x5a, 0x48, 0x5e, + 0x35, 0x84, 0x0d, 0xc3, 0x06, 0x28, 0x63, 0x3e, 0x94, 0x48, 0x1c, 0xf8, 0x87, 0x42, 0xa4, 0x09, + 0xad, 0xe2, 0xf8, 0xe3, 0xc0, 0x0a, 0xcc, 0x27, 0x72, 0x0a, 0xc5, 0x28, 0x54, 0xa1, 0xce, 0xf8, + 0xdf, 0xdc, 0xa7, 0xbf, 0xd6, 0xa7, 0xbe, 0x3e, 0x12, 0x52, 0x03, 0xb5, 0x0b, 0x00, 0x5f, 0xb2, + 0x00, 0x25, 0x7f, 0x78, 0xc2, 0x15, 0x6a, 0xf6, 0x80, 0x7c, 0xf3, 0xeb, 0xad, 0x7a, 0x0e, 0x65, + 0x5f, 0xb2, 0xdb, 0x38, 0x0a, 0xd5, 0x2a, 0x4d, 0xbb, 0xb0, 0x99, 0xe1, 0x6b, 0x2d, 0xda, 0x7c, + 0xcd, 0x43, 0xc1, 0x97, 0x8c, 0x5c, 0x43, 0x61, 0x3e, 0xfb, 0x85, 0xa4, 0x1e, 0xaf, 0x73, 0xf4, + 0xa7, 0x9c, 0x35, 0xbd, 0x83, 0x52, 0x3a, 0xa5, 0xc3, 0xc5, 0x44, 0x62, 0x71, 0x1a, 0x4b, 0x2d, + 0x59, 0xf0, 0x0d, 0xd8, 0xc9, 0x3f, 0xad, 0x2e, 0x86, 0x8c, 0xc3, 0xa9, 0x2f, 0x73, 0xa4, 0xa9, + 0xad, 0xab, 0xf1, 0xd4, 0xb5, 0x26, 0x53, 0xd7, 0xfa, 0x9c, 0xba, 0xd6, 0xdb, 0xcc, 0xcd, 0x4d, + 0x66, 0x6e, 0xee, 0x7d, 0xe6, 0xe6, 0xee, 0x1b, 0xac, 0xa7, 0xba, 0x8f, 0x6d, 0xda, 0xe1, 0x03, + 0x4f, 0x32, 0x3c, 0x4e, 0xe2, 0xe6, 0x77, 0x6f, 0x94, 0x2d, 0xe2, 0x4b, 0x8c, 0xb2, 0x6d, 0xeb, + 0x35, 0x3a, 0xf9, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x86, 0xc7, 0x1d, 0xcf, 0xa3, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -410,12 +409,12 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { - // AddMarket defines a method to add the market with the given data. - AddMarket(ctx context.Context, in *MsgAddMarket, opts ...grpc.CallOption) (*MsgAddMarketResponse, error) - // ResolveMarket defines a method to resolve the market. - ResolveMarket(ctx context.Context, in *MsgResolveMarket, opts ...grpc.CallOption) (*MsgResolveMarketResponse, error) - // UpdateMarket defines a method to update a market. - UpdateMarket(ctx context.Context, in *MsgUpdateMarket, opts ...grpc.CallOption) (*MsgUpdateMarketResponse, error) + // Add defines a method to add the market with the given data. + Add(ctx context.Context, in *MsgAdd, opts ...grpc.CallOption) (*MsgAddResponse, error) + // Resolve defines a method to resolve the market. + Resolve(ctx context.Context, in *MsgResolve, opts ...grpc.CallOption) (*MsgResolveResponse, error) + // Update defines a method to update a market. + Update(ctx context.Context, in *MsgUpdate, opts ...grpc.CallOption) (*MsgUpdateResponse, error) } type msgClient struct { @@ -426,27 +425,27 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } -func (c *msgClient) AddMarket(ctx context.Context, in *MsgAddMarket, opts ...grpc.CallOption) (*MsgAddMarketResponse, error) { - out := new(MsgAddMarketResponse) - err := c.cc.Invoke(ctx, "/sgenetwork.sge.market.Msg/AddMarket", in, out, opts...) +func (c *msgClient) Add(ctx context.Context, in *MsgAdd, opts ...grpc.CallOption) (*MsgAddResponse, error) { + out := new(MsgAddResponse) + err := c.cc.Invoke(ctx, "/sgenetwork.sge.market.Msg/Add", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *msgClient) ResolveMarket(ctx context.Context, in *MsgResolveMarket, opts ...grpc.CallOption) (*MsgResolveMarketResponse, error) { - out := new(MsgResolveMarketResponse) - err := c.cc.Invoke(ctx, "/sgenetwork.sge.market.Msg/ResolveMarket", in, out, opts...) +func (c *msgClient) Resolve(ctx context.Context, in *MsgResolve, opts ...grpc.CallOption) (*MsgResolveResponse, error) { + out := new(MsgResolveResponse) + err := c.cc.Invoke(ctx, "/sgenetwork.sge.market.Msg/Resolve", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *msgClient) UpdateMarket(ctx context.Context, in *MsgUpdateMarket, opts ...grpc.CallOption) (*MsgUpdateMarketResponse, error) { - out := new(MsgUpdateMarketResponse) - err := c.cc.Invoke(ctx, "/sgenetwork.sge.market.Msg/UpdateMarket", in, out, opts...) +func (c *msgClient) Update(ctx context.Context, in *MsgUpdate, opts ...grpc.CallOption) (*MsgUpdateResponse, error) { + out := new(MsgUpdateResponse) + err := c.cc.Invoke(ctx, "/sgenetwork.sge.market.Msg/Update", in, out, opts...) if err != nil { return nil, err } @@ -455,82 +454,82 @@ func (c *msgClient) UpdateMarket(ctx context.Context, in *MsgUpdateMarket, opts // MsgServer is the server API for Msg service. type MsgServer interface { - // AddMarket defines a method to add the market with the given data. - AddMarket(context.Context, *MsgAddMarket) (*MsgAddMarketResponse, error) - // ResolveMarket defines a method to resolve the market. - ResolveMarket(context.Context, *MsgResolveMarket) (*MsgResolveMarketResponse, error) - // UpdateMarket defines a method to update a market. - UpdateMarket(context.Context, *MsgUpdateMarket) (*MsgUpdateMarketResponse, error) + // Add defines a method to add the market with the given data. + Add(context.Context, *MsgAdd) (*MsgAddResponse, error) + // Resolve defines a method to resolve the market. + Resolve(context.Context, *MsgResolve) (*MsgResolveResponse, error) + // Update defines a method to update a market. + Update(context.Context, *MsgUpdate) (*MsgUpdateResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. type UnimplementedMsgServer struct { } -func (*UnimplementedMsgServer) AddMarket(ctx context.Context, req *MsgAddMarket) (*MsgAddMarketResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method AddMarket not implemented") +func (*UnimplementedMsgServer) Add(ctx context.Context, req *MsgAdd) (*MsgAddResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Add not implemented") } -func (*UnimplementedMsgServer) ResolveMarket(ctx context.Context, req *MsgResolveMarket) (*MsgResolveMarketResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ResolveMarket not implemented") +func (*UnimplementedMsgServer) Resolve(ctx context.Context, req *MsgResolve) (*MsgResolveResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Resolve not implemented") } -func (*UnimplementedMsgServer) UpdateMarket(ctx context.Context, req *MsgUpdateMarket) (*MsgUpdateMarketResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateMarket not implemented") +func (*UnimplementedMsgServer) Update(ctx context.Context, req *MsgUpdate) (*MsgUpdateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Update not implemented") } func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } -func _Msg_AddMarket_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgAddMarket) +func _Msg_Add_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgAdd) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).AddMarket(ctx, in) + return srv.(MsgServer).Add(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/sgenetwork.sge.market.Msg/AddMarket", + FullMethod: "/sgenetwork.sge.market.Msg/Add", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).AddMarket(ctx, req.(*MsgAddMarket)) + return srv.(MsgServer).Add(ctx, req.(*MsgAdd)) } return interceptor(ctx, in, info, handler) } -func _Msg_ResolveMarket_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgResolveMarket) +func _Msg_Resolve_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgResolve) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).ResolveMarket(ctx, in) + return srv.(MsgServer).Resolve(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/sgenetwork.sge.market.Msg/ResolveMarket", + FullMethod: "/sgenetwork.sge.market.Msg/Resolve", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).ResolveMarket(ctx, req.(*MsgResolveMarket)) + return srv.(MsgServer).Resolve(ctx, req.(*MsgResolve)) } return interceptor(ctx, in, info, handler) } -func _Msg_UpdateMarket_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateMarket) +func _Msg_Update_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdate) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).UpdateMarket(ctx, in) + return srv.(MsgServer).Update(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/sgenetwork.sge.market.Msg/UpdateMarket", + FullMethod: "/sgenetwork.sge.market.Msg/Update", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateMarket(ctx, req.(*MsgUpdateMarket)) + return srv.(MsgServer).Update(ctx, req.(*MsgUpdate)) } return interceptor(ctx, in, info, handler) } @@ -540,23 +539,23 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "AddMarket", - Handler: _Msg_AddMarket_Handler, + MethodName: "Add", + Handler: _Msg_Add_Handler, }, { - MethodName: "ResolveMarket", - Handler: _Msg_ResolveMarket_Handler, + MethodName: "Resolve", + Handler: _Msg_Resolve_Handler, }, { - MethodName: "UpdateMarket", - Handler: _Msg_UpdateMarket_Handler, + MethodName: "Update", + Handler: _Msg_Update_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "sge/market/tx.proto", } -func (m *MsgAddMarket) Marshal() (dAtA []byte, err error) { +func (m *MsgAdd) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -566,12 +565,12 @@ func (m *MsgAddMarket) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgAddMarket) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgAdd) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgAddMarket) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgAdd) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -593,7 +592,7 @@ func (m *MsgAddMarket) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgAddMarketResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgAddResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -603,12 +602,12 @@ func (m *MsgAddMarketResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgAddMarketResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgAddResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgAddMarketResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgAddResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -635,7 +634,7 @@ func (m *MsgAddMarketResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgResolveMarket) Marshal() (dAtA []byte, err error) { +func (m *MsgResolve) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -645,12 +644,12 @@ func (m *MsgResolveMarket) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgResolveMarket) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgResolve) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgResolveMarket) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgResolve) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -672,7 +671,7 @@ func (m *MsgResolveMarket) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgResolveMarketResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgResolveResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -682,12 +681,12 @@ func (m *MsgResolveMarketResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgResolveMarketResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgResolveResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgResolveMarketResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgResolveResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -714,7 +713,7 @@ func (m *MsgResolveMarketResponse) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } -func (m *MsgUpdateMarket) Marshal() (dAtA []byte, err error) { +func (m *MsgUpdate) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -724,12 +723,12 @@ func (m *MsgUpdateMarket) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgUpdateMarket) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUpdate) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgUpdateMarket) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -751,7 +750,7 @@ func (m *MsgUpdateMarket) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgUpdateMarketResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgUpdateResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -761,12 +760,12 @@ func (m *MsgUpdateMarketResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgUpdateMarketResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUpdateResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgUpdateMarketResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -804,7 +803,7 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *MsgAddMarket) Size() (n int) { +func (m *MsgAdd) Size() (n int) { if m == nil { return 0 } @@ -821,7 +820,7 @@ func (m *MsgAddMarket) Size() (n int) { return n } -func (m *MsgAddMarketResponse) Size() (n int) { +func (m *MsgAddResponse) Size() (n int) { if m == nil { return 0 } @@ -838,7 +837,7 @@ func (m *MsgAddMarketResponse) Size() (n int) { return n } -func (m *MsgResolveMarket) Size() (n int) { +func (m *MsgResolve) Size() (n int) { if m == nil { return 0 } @@ -855,7 +854,7 @@ func (m *MsgResolveMarket) Size() (n int) { return n } -func (m *MsgResolveMarketResponse) Size() (n int) { +func (m *MsgResolveResponse) Size() (n int) { if m == nil { return 0 } @@ -872,7 +871,7 @@ func (m *MsgResolveMarketResponse) Size() (n int) { return n } -func (m *MsgUpdateMarket) Size() (n int) { +func (m *MsgUpdate) Size() (n int) { if m == nil { return 0 } @@ -889,7 +888,7 @@ func (m *MsgUpdateMarket) Size() (n int) { return n } -func (m *MsgUpdateMarketResponse) Size() (n int) { +func (m *MsgUpdateResponse) Size() (n int) { if m == nil { return 0 } @@ -912,7 +911,7 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *MsgAddMarket) Unmarshal(dAtA []byte) error { +func (m *MsgAdd) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -935,10 +934,10 @@ func (m *MsgAddMarket) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgAddMarket: wiretype end group for non-group") + return fmt.Errorf("proto: MsgAdd: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgAddMarket: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgAdd: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1026,7 +1025,7 @@ func (m *MsgAddMarket) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgAddMarketResponse) Unmarshal(dAtA []byte) error { +func (m *MsgAddResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1049,10 +1048,10 @@ func (m *MsgAddMarketResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgAddMarketResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgAddResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgAddMarketResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgAddResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1144,7 +1143,7 @@ func (m *MsgAddMarketResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgResolveMarket) Unmarshal(dAtA []byte) error { +func (m *MsgResolve) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1167,10 +1166,10 @@ func (m *MsgResolveMarket) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgResolveMarket: wiretype end group for non-group") + return fmt.Errorf("proto: MsgResolve: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgResolveMarket: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgResolve: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1258,7 +1257,7 @@ func (m *MsgResolveMarket) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgResolveMarketResponse) Unmarshal(dAtA []byte) error { +func (m *MsgResolveResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1281,10 +1280,10 @@ func (m *MsgResolveMarketResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgResolveMarketResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgResolveResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgResolveMarketResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgResolveResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1376,7 +1375,7 @@ func (m *MsgResolveMarketResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdateMarket) Unmarshal(dAtA []byte) error { +func (m *MsgUpdate) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1399,10 +1398,10 @@ func (m *MsgUpdateMarket) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateMarket: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUpdate: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateMarket: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUpdate: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1490,7 +1489,7 @@ func (m *MsgUpdateMarket) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdateMarketResponse) Unmarshal(dAtA []byte) error { +func (m *MsgUpdateResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1513,10 +1512,10 @@ func (m *MsgUpdateMarketResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateMarketResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUpdateResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateMarketResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUpdateResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: diff --git a/x/orderbook/keeper/bet_place.go b/x/orderbook/keeper/bet_place.go index e550d98c..ea4e1698 100644 --- a/x/orderbook/keeper/bet_place.go +++ b/x/orderbook/keeper/bet_place.go @@ -10,8 +10,8 @@ import ( "github.com/spf13/cast" ) -// ProcessBetPlacement processes bet placement -func (k Keeper) ProcessBetPlacement( +// ProcessWager processes bet placement +func (k Keeper) ProcessWager( ctx sdk.Context, betUID, bookUID, oddsUID string, maxLossMultiplier sdk.Dec, @@ -92,7 +92,7 @@ func (k Keeper) PublishOrderBookEvent(ctx sdk.Context, orderBookUID string) { event.Emit(ctx) } -// fulfillBetByParticipationQueue fulfills the bet placement payout using the participations +// fulfillBetByParticipationQueue fulfills the bet wagering payout using the participations // that is stored in the state. func (k Keeper) fulfillBetByParticipationQueue( ctx sdk.Context, diff --git a/x/orderbook/keeper/bet_place_test.go b/x/orderbook/keeper/bet_place_test.go index 6b592f23..1fa6c6b6 100644 --- a/x/orderbook/keeper/bet_place_test.go +++ b/x/orderbook/keeper/bet_place_test.go @@ -17,7 +17,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestBetPlacement(t *testing.T) { +func TestWager(t *testing.T) { ts := newTestBetSuite(t) ts.placeBetsAndTest() } @@ -178,16 +178,16 @@ func (ts *testBetSuite) placeBetsAndTest() ([]bettypes.Bet, sdk.Dec, sdk.Dec) { ) winner1Bet.BetFulfillment = winner1BetFulfillment ts.tApp.BetKeeper.SetBet(ts.ctx, winner1Bet, winner1BetID) - winner1BalAfterPlacement := ts.tApp.BankKeeper.GetBalance( + winner1BalAfterWager := ts.tApp.BankKeeper.GetBalance( ts.ctx, winner1BettorAddr, params.DefaultBondDenom, ) - expWinner1BalanceAfterPlacement := winner1Bal.Amount.Sub(winner1Bet.Amount).Sub(winner1Bet.Fee) + expWinner1BalanceAfterWager := winner1Bal.Amount.Sub(winner1Bet.Amount).Sub(winner1Bet.Fee) require.Equal( ts.t, - expWinner1BalanceAfterPlacement.Int64(), - winner1BalAfterPlacement.Amount.Int64(), + expWinner1BalanceAfterWager.Int64(), + winner1BalAfterWager.Amount.Int64(), ) oddsExposures, found = ts.k.GetOrderBookOddsExposure( @@ -216,16 +216,16 @@ func (ts *testBetSuite) placeBetsAndTest() ([]bettypes.Bet, sdk.Dec, sdk.Dec) { winner2Bet.BetFulfillment = winner2BetFulfillment ts.tApp.BetKeeper.SetBet(ts.ctx, winner2Bet, winner2BetID) - winner2BalAfterPlacement := ts.tApp.BankKeeper.GetBalance( + winner2BalAfterWager := ts.tApp.BankKeeper.GetBalance( ts.ctx, winner1BettorAddr, params.DefaultBondDenom, ) - expWinner2BalanceAfterPlacement := winner2Bal.Amount.Sub(winner2Bet.Amount).Sub(winner2Bet.Fee) + expWinner2BalanceAfterWager := winner2Bal.Amount.Sub(winner2Bet.Amount).Sub(winner2Bet.Fee) require.Equal( ts.t, - expWinner2BalanceAfterPlacement.Int64(), - winner2BalAfterPlacement.Amount.Int64(), + expWinner2BalanceAfterWager.Int64(), + winner2BalAfterWager.Amount.Int64(), ) oddsExposures, found = ts.k.GetOrderBookOddsExposure( ts.ctx, @@ -267,13 +267,13 @@ func (ts *testBetSuite) placeBetsAndTest() ([]bettypes.Bet, sdk.Dec, sdk.Dec) { ) loserBet.BetFulfillment = loserBetFulfillment ts.tApp.BetKeeper.SetBet(ts.ctx, loserBet, loserBetID) - loserBalAfterPlacement := ts.tApp.BankKeeper.GetBalance( + loserBalAfterWager := ts.tApp.BankKeeper.GetBalance( ts.ctx, loserBettorAddr, params.DefaultBondDenom, ) - expLoserBalanceAfterPlacement := loserBal.Amount.Sub(loserBet.Amount).Sub(loserBet.Fee) - require.Equal(ts.t, expLoserBalanceAfterPlacement, loserBalAfterPlacement.Amount) + expLoserBalanceAfterWager := loserBal.Amount.Sub(loserBet.Amount).Sub(loserBet.Fee) + require.Equal(ts.t, expLoserBalanceAfterWager, loserBalAfterWager.Amount) return []bettypes.Bet{ winner1Bet, @@ -307,18 +307,18 @@ func (ts *testBetSuite) placeTestBet( payoutProfit, err := bettypes.CalculatePayoutProfit(bet.OddsType, bet.OddsValue, bet.Amount) require.NoError(ts.t, err) - betFeeCollectorBalanceBeforePlacement := ts.tApp.BankKeeper.GetBalance( + betFeeCollectorBalanceBeforeWager := ts.tApp.BankKeeper.GetBalance( ts.ctx, ts.tApp.AccountKeeper.GetModuleAddress(bettypes.BetFeeCollectorFunder{}.GetModuleAcc()), params.DefaultBondDenom, ) - liquidityPoolBalanceBeforePlacement := ts.tApp.BankKeeper.GetBalance( + liquidityPoolBalanceBeforeWager := ts.tApp.BankKeeper.GetBalance( ts.ctx, ts.tApp.AccountKeeper.GetModuleAddress(types.OrderBookLiquidityFunder{}.GetModuleAcc()), params.DefaultBondDenom, ) - betFulfillment, err := ts.k.ProcessBetPlacement( + betFulfillment, err := ts.k.ProcessWager( ts.ctx, bet.UID, bet.MarketUID, bet.OddsUID, bet.MaxLossMultiplier, bet.Amount, payoutProfit, bettorAddr, bet.Fee, bet.OddsType, bet.OddsValue, 1, ) @@ -329,11 +329,11 @@ func (ts *testBetSuite) placeTestBet( ts.tApp.BetKeeper.SetBet(ts.ctx, bet, betID) ts.tApp.BetKeeper.SetPendingBet(ts.ctx, &bettypes.PendingBet{Creator: bet.Creator, UID: bet.UID}, betID, marketUID) - betFeeCollectorBalanceAfterPlacement := ts.tApp.BankKeeper.GetBalance(ts.ctx, ts.tApp.AccountKeeper.GetModuleAddress(bettypes.BetFeeCollectorFunder{}.GetModuleAcc()), params.DefaultBondDenom) - require.Equal(ts.t, bet.Fee.Int64(), betFeeCollectorBalanceAfterPlacement.Sub(betFeeCollectorBalanceBeforePlacement).Amount.Int64()) + betFeeCollectorBalanceAfterWager := ts.tApp.BankKeeper.GetBalance(ts.ctx, ts.tApp.AccountKeeper.GetModuleAddress(bettypes.BetFeeCollectorFunder{}.GetModuleAcc()), params.DefaultBondDenom) + require.Equal(ts.t, bet.Fee.Int64(), betFeeCollectorBalanceAfterWager.Sub(betFeeCollectorBalanceBeforeWager).Amount.Int64()) - liquidityPoolBalanceAfterPlacement := ts.tApp.BankKeeper.GetBalance(ts.ctx, ts.tApp.AccountKeeper.GetModuleAddress(types.OrderBookLiquidityFunder{}.GetModuleAcc()), params.DefaultBondDenom) - require.Equal(ts.t, bet.Amount.Int64(), liquidityPoolBalanceAfterPlacement.Sub(liquidityPoolBalanceBeforePlacement).Amount.Int64()) + liquidityPoolBalanceAfterWager := ts.tApp.BankKeeper.GetBalance(ts.ctx, ts.tApp.AccountKeeper.GetModuleAddress(types.OrderBookLiquidityFunder{}.GetModuleAcc()), params.DefaultBondDenom) + require.Equal(ts.t, bet.Amount.Int64(), liquidityPoolBalanceAfterWager.Sub(liquidityPoolBalanceBeforeWager).Amount.Int64()) } return bet, payoutProfit, betFulfillment diff --git a/x/orderbook/keeper/bet_settle_test.go b/x/orderbook/keeper/bet_settle_test.go index 4cbf95f7..725de2b0 100644 --- a/x/orderbook/keeper/bet_settle_test.go +++ b/x/orderbook/keeper/bet_settle_test.go @@ -20,17 +20,17 @@ func (ts *testBetSuite) settleBetsAndTest( bets []bettypes.Bet, winner1PayoutProfit, winner2PayoutProfit sdk.Dec, ) { - winner1BalAfterPlacement := ts.tApp.BankKeeper.GetBalance( + winner1BalAfterWager := ts.tApp.BankKeeper.GetBalance( ts.ctx, sdk.MustAccAddressFromBech32(bets[0].Creator), params.DefaultBondDenom, ).Amount - winner2BalAfterPlacement := ts.tApp.BankKeeper.GetBalance( + winner2BalAfterWager := ts.tApp.BankKeeper.GetBalance( ts.ctx, sdk.MustAccAddressFromBech32(bets[1].Creator), params.DefaultBondDenom, ).Amount - loserBalanceAfterPlacement := ts.tApp.BankKeeper.GetBalance( + loserBalanceAfterWager := ts.tApp.BankKeeper.GetBalance( ts.ctx, sdk.MustAccAddressFromBech32(bets[2].Creator), params.DefaultBondDenom, @@ -38,7 +38,7 @@ func (ts *testBetSuite) settleBetsAndTest( // resolve market // - ts.tApp.MarketKeeper.ResolveMarket(ts.ctx, ts.market, &markettypes.MarketResolutionTicketPayload{ + ts.tApp.MarketKeeper.Resolve(ts.ctx, ts.market, &markettypes.MarketResolutionTicketPayload{ UID: ts.market.UID, ResolutionTS: ts.market.StartTS + 10, WinnerOddsUIDs: []string{ts.market.Odds[0].UID, ts.market.Odds[1].UID}, @@ -54,7 +54,7 @@ func (ts *testBetSuite) settleBetsAndTest( sdk.MustAccAddressFromBech32(bets[0].Creator), params.DefaultBondDenom, ) - expWinner1BalanceAfterSettlement := winner1BalAfterPlacement.Add(bets[0].Amount). + expWinner1BalanceAfterSettlement := winner1BalAfterWager.Add(bets[0].Amount). Add(winner1PayoutProfit.TruncateInt()) require.Equal( ts.t, @@ -67,7 +67,7 @@ func (ts *testBetSuite) settleBetsAndTest( sdk.MustAccAddressFromBech32(bets[1].Creator), params.DefaultBondDenom, ) - expWinner2BalanceAfterSettlement := winner2BalAfterPlacement.Add(bets[1].Amount). + expWinner2BalanceAfterSettlement := winner2BalAfterWager.Add(bets[1].Amount). Add(winner2PayoutProfit.TruncateInt()) require.Equal( ts.t, @@ -82,7 +82,7 @@ func (ts *testBetSuite) settleBetsAndTest( ) require.Equal( ts.t, - loserBalanceAfterPlacement.Int64(), + loserBalanceAfterWager.Int64(), loserBettorBalAfterSettlement.Amount.Int64(), ) } diff --git a/x/orderbook/keeper/grpc_query_participation_bet_test.go b/x/orderbook/keeper/grpc_query_participation_bet_test.go index 361ad07d..ab7f88f7 100644 --- a/x/orderbook/keeper/grpc_query_participation_bet_test.go +++ b/x/orderbook/keeper/grpc_query_participation_bet_test.go @@ -33,7 +33,7 @@ func TestParticipationFulfilledBetsQueryPaginated(t *testing.T) { t.Run("ByOffset", func(t *testing.T) { step := 2 for i := 0; i < len(msgs); i += step { - resp, err := k.ParticipationFulfilledBets(wctx, request(nil, uint64(i), uint64(step), false)) + resp, err := k.ProcessWager(wctx, request(nil, uint64(i), uint64(step), false)) require.NoError(t, err) require.LessOrEqual(t, len(resp.ParticipationBets), step) require.Subset(t, @@ -46,7 +46,7 @@ func TestParticipationFulfilledBetsQueryPaginated(t *testing.T) { step := 2 var next []byte for i := 0; i < len(msgs); i += step { - resp, err := k.ParticipationFulfilledBets(wctx, request(next, 0, uint64(step), false)) + resp, err := k.ProcessWager(wctx, request(next, 0, uint64(step), false)) require.NoError(t, err) require.LessOrEqual(t, len(resp.ParticipationBets), step) require.Subset(t, @@ -57,7 +57,7 @@ func TestParticipationFulfilledBetsQueryPaginated(t *testing.T) { } }) t.Run("Total", func(t *testing.T) { - resp, err := k.ParticipationFulfilledBets(wctx, request(nil, 0, 0, true)) + resp, err := k.ProcessWager(wctx, request(nil, 0, 0, true)) require.NoError(t, err) require.Equal(t, len(msgs), int(resp.Pagination.Total)) require.ElementsMatch(t, @@ -66,7 +66,7 @@ func TestParticipationFulfilledBetsQueryPaginated(t *testing.T) { ) }) t.Run("InvalidRequest", func(t *testing.T) { - _, err := k.ParticipationFulfilledBets(wctx, nil) + _, err := k.ProcessWager(wctx, nil) require.ErrorIs(t, err, status.Error(codes.InvalidArgument, consts.ErrTextInvalidRequest)) }) } diff --git a/x/orderbook/module_simulation.go b/x/orderbook/module_simulation.go index 554ff601..be771e5f 100644 --- a/x/orderbook/module_simulation.go +++ b/x/orderbook/module_simulation.go @@ -26,8 +26,8 @@ var ( const ( //#nosec - opWeightMsgAddMarket = "op_weight_msg_create_chain" - defaultWeightMsgAddMarket int = 100 + opWeightMsgAdd = "op_weight_msg_create_chain" + defaultWeightMsgAdd int = 100 ) // GenerateGenesisState creates a randomized GenState of the module @@ -54,10 +54,10 @@ func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { func (AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { operations := make([]simtypes.WeightedOperation, 0) - var weightMsgAddMarket int - simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgAddMarket, &weightMsgAddMarket, nil, + var weightMsgAdd int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgAdd, &weightMsgAdd, nil, func(_ *rand.Rand) { - weightMsgAddMarket = defaultWeightMsgAddMarket + weightMsgAdd = defaultWeightMsgAdd }, ) diff --git a/x/orderbook/types/orderbookevent.pb.go b/x/orderbook/types/orderbookevent.pb.go index 20cb9e48..2e568798 100644 --- a/x/orderbook/types/orderbookevent.pb.go +++ b/x/orderbook/types/orderbookevent.pb.go @@ -24,9 +24,11 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // OrderBookEvent to publish the order book event type OrderBookEvent struct { - // ParticipationExposure to publish the order book event, participation exposure + // ParticipationExposure to publish the order book event, participation + // exposure ParticipationExposure []*ParticipationExposure `protobuf:"bytes,1,rep,name=participation_exposure,json=participationExposure,proto3" json:"participation_exposure,omitempty"` - // OrderBookOddsExposure to publish the order book event, order book odds exposure + // OrderBookOddsExposure to publish the order book event, order book odds + // exposure OrderBookOddsExposure []*OrderBookOddsExposure `protobuf:"bytes,2,rep,name=order_book_odds_exposure,json=orderBookOddsExposure,proto3" json:"order_book_odds_exposure,omitempty"` }