Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Refactor / Remove Redundant function and types name appendixes #221

Merged
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions docs/specs/Bet/06_Messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ handler endpoints is as follows
// Msg defines the Msg service.
service Msg {
// PlaceBet defines a method to place a bet with the given data
rpc PlaceBet(MsgPlaceBet) returns (MsgPlaceBetResponse);
rpc Place(MsgPlace) returns (MsgPlaceResponse);
3eyedraga marked this conversation as resolved.
Show resolved Hide resolved
}
```

## **MsgPlaceBet**
## **MsgPlace**

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 {
// MsgPlace defines a message to place a bet with the given data
message MsgPlace {
// creator is the bettor address
string creator = 1;

Expand All @@ -44,9 +44,9 @@ message PlaceBetFields {
string ticket = 3;
}

// MsgPlaceBetResponse is the returning value in the response
// of MsgPlaceBet request.
message MsgPlaceBetResponse { PlaceBetFields bet = 1; }
// MsgPlaceResponse is the returning value in the response
// of MsgPlace request.
message MsgPlaceResponse { PlaceBetFields bet = 1; }
```

### **Sample Place bet ticket**
Expand Down
2 changes: 1 addition & 1 deletion docs/specs/Bet/07_Events.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The Bet module emits the following events

## *MsgPlaceBet*
## *MsgPlace*

| Type | Attribute Key| Attribute Value |
|:-------------:|:-------------:|:---------------------:|
Expand Down
26 changes: 13 additions & 13 deletions docs/specs/Market/03_Messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions docs/specs/Market/05_Events.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The Market module emits the following events:

## *MsgAddMarket*
## *MsgAdd*

| **Type** | **Attribute Key** | **Attribute Value** |
|----------------------------|---------------------------|-----------------------|
Expand All @@ -14,7 +14,7 @@ The Market module emits the following events:

---

## *MsgUpdateMarket*
## *MsgUpdate*

| **Type** | **Attribute Key** | **Attribute Value** |
|:------------------------:|:---------------------------:|:---------------------:|
Expand All @@ -25,7 +25,7 @@ The Market module emits the following events:

---

## *MsgResolveMarket*
## *MsgResolve*

| **Type** | **Attribute Key** | **Attribute Value** |
|---------------------------|--------------------------|-----------------------|
Expand Down
4 changes: 2 additions & 2 deletions proto/sge/bet/ticket.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
// PlacementTicketPayload indicates data of bet placement ticket.
message PlacementTicketPayload {
3eyedraga marked this conversation as resolved.
Show resolved Hide resolved
// selected_odds is the user-selected odds to place bet.
BetOdds selected_odds = 1;
// kyc_data contains the details of user kyc.
Expand Down
14 changes: 7 additions & 7 deletions proto/sge/bet/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ 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);
// Place defines a method to place a bet with the given data.
rpc Place(MsgPlace) returns (MsgPlaceResponse);
}

// MsgPlaceBet defines a message to place a bet with the given data.
message MsgPlaceBet {
// MsgPlace defines a message to place a bet with the given data.
message MsgPlace {
// creator is the bettor address.
string creator = 1;
// PlaceBetFields contains bet fields.
PlaceBetFields bet = 2;
}

// MsgPlaceBetResponse is the returning value in the response
// of MsgPlaceBet request.
message MsgPlaceBetResponse { PlaceBetFields bet = 1; }
// MsgPlaceResponse is the returning value in the response
// of MsgPlaceResponse request.
message MsgPlaceResponse { PlaceBetFields bet = 1; }
36 changes: 18 additions & 18 deletions proto/sge/market/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion x/bet/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func GetTxCmd() *cobra.Command {
RunE: client.ValidateCmd,
}

cmd.AddCommand(CmdPlaceBet())
cmd.AddCommand(CmdPlace())

return cmd
}
8 changes: 4 additions & 4 deletions x/bet/client/cli/tx_bet.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
"github.com/spf13/cobra"
)

// CmdPlaceBet implements a command to place and store a single bet
func CmdPlaceBet() *cobra.Command {
// CmdPlace implements a command to place and store a single bet
func CmdPlace() *cobra.Command {
cmd := &cobra.Command{
Use: "place-bet [uid] [amount] [ticket]",
Use: "place [uid] [amount] [ticket]",
Short: "Place bet",
Long: "Place bet uuid, amount and ticket required.",
Args: cobra.ExactArgs(3),
Expand All @@ -32,7 +32,7 @@ func CmdPlaceBet() *cobra.Command {
return err
}

msg := types.NewMsgPlaceBet(
msg := types.NewMsgPlace(
clientCtx.GetFromAddress().String(),
types.PlaceBetFields{
UID: uid,
Expand Down
2 changes: 1 addition & 1 deletion x/bet/client/cli/tx_bet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.CmdPlace(), args)
if tc.err != nil {
require.NotNil(t, err)
} else {
Expand Down
4 changes: 2 additions & 2 deletions x/bet/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.MsgPlace:
res, err := msgServer.Place(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
default:
errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg)
Expand Down
16 changes: 8 additions & 8 deletions x/bet/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ var (
MaxLossMultiplier: sdk.MustNewDecFromStr("0.1"),
}
testCreator string
testBet *types.MsgPlaceBet
testAddMarket *markettypes.MsgAddMarket
testBet *types.MsgPlace
testAddMarket *markettypes.MsgAdd

testMarket = markettypes.Market{
UID: testMarketUID,
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -153,15 +153,15 @@ func placeTestBet(
testPlaceBetTicket, err := createJwtTicket(testPlaceBetClaim)
require.Nil(t, err)

testBet = &types.MsgPlaceBet{
testBet = &types.MsgPlace{
Creator: testCreator,
Bet: &types.PlaceBetFields{
UID: betUID,
Amount: sdk.NewInt(1000000),
Ticket: testPlaceBetTicket,
},
}
resPlaceBet, err := betSrv.PlaceBet(wctx, testBet)
resPlaceBet, err := betSrv.Place(wctx, testBet)
require.Nil(t, err)
require.NotNil(t, resPlaceBet)
}
Expand Down
Loading