diff --git a/proto/sge/house/params.proto b/proto/sge/house/params.proto index d8c8bd91..6881fbb0 100644 --- a/proto/sge/house/params.proto +++ b/proto/sge/house/params.proto @@ -25,6 +25,6 @@ message Params { // max_withdrawal_count is the maximum number of withdrawals allowed // per participation index. - uint64 max_withdrawal_count = 3 - [ (gogoproto.moretags) = "yaml:\"max_withdrawal_count\""]; + uint64 max_withdrawal_count = 3 + [ (gogoproto.moretags) = "yaml:\"max_withdrawal_count\"" ]; } diff --git a/proto/sge/reward/genesis.proto b/proto/sge/reward/genesis.proto index 77971854..937a59bb 100644 --- a/proto/sge/reward/genesis.proto +++ b/proto/sge/reward/genesis.proto @@ -14,6 +14,8 @@ message GenesisState { Params params = 1 [ (gogoproto.nullable) = false ]; repeated Campaign campaign_list = 2 [ (gogoproto.nullable) = false ]; repeated Reward reward_list = 3 [ (gogoproto.nullable) = false ]; - repeated RewardByCategory reward_by_category_list = 4 [ (gogoproto.nullable) = false ]; - repeated RewardByCampaign reward_by_campaign_list = 5 [ (gogoproto.nullable) = false ]; + repeated RewardByCategory reward_by_category_list = 4 + [ (gogoproto.nullable) = false ]; + repeated RewardByCampaign reward_by_campaign_list = 5 + [ (gogoproto.nullable) = false ]; } diff --git a/proto/sge/subaccount/params.proto b/proto/sge/subaccount/params.proto index 8f87618e..3cc657f4 100644 --- a/proto/sge/subaccount/params.proto +++ b/proto/sge/subaccount/params.proto @@ -6,4 +6,11 @@ import "gogoproto/gogo.proto"; option go_package = "github.com/sge-network/sge/x/subaccount/types"; // Params defines the parameters for the module. -message Params { option (gogoproto.goproto_stringer) = false; } +message Params { + option (gogoproto.goproto_stringer) = false; + + // wager_enabled is enable/disable status of wager feature. + bool wager_enabled = 1; + // deposit_enabled is enable/disable status of deposit feature. + bool deposit_enabled = 2; +} diff --git a/proto/sge/subaccount/ticket.proto b/proto/sge/subaccount/ticket.proto new file mode 100644 index 00000000..36770bc2 --- /dev/null +++ b/proto/sge/subaccount/ticket.proto @@ -0,0 +1,24 @@ +syntax = "proto3"; +package sgenetwork.sge.subaccount; + +import "gogoproto/gogo.proto"; + +import "sge/bet/tx.proto"; + +option go_package = "github.com/sge-network/sge/x/subaccount/types"; + +// SubAccWagerTicketPayload indicates data of subaccount wager ticket. +message SubAccWagerTicketPayload { + // msg holds normal wager message + sgenetwork.sge.bet.MsgWager msg = 1; + // mainacc_deduct_amount is amount to be deducted from main account + string mainacc_deduct_amount = 2 [ + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false + ]; + // subacc_deduct_amount is amount to be deducted from sub account + string subacc_deduct_amount = 3 [ + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false + ]; +} \ No newline at end of file diff --git a/proto/sge/subaccount/tx.proto b/proto/sge/subaccount/tx.proto index 83045bc5..c2384ea2 100644 --- a/proto/sge/subaccount/tx.proto +++ b/proto/sge/subaccount/tx.proto @@ -2,8 +2,8 @@ syntax = "proto3"; package sgenetwork.sge.subaccount; import "sge/subaccount/balance.proto"; -import "sge/bet/tx.proto"; import "sge/house/tx.proto"; +import "sge/bet/tx.proto"; import "gogoproto/gogo.proto"; option go_package = "github.com/sge-network/sge/x/subaccount/types"; @@ -78,18 +78,11 @@ message MsgWithdrawUnlockedBalancesResponse {} // MsgWager wraps the MsgWager message. We need it in order not to have // double interface registration conflicts. -message MsgWager { - sgenetwork.sge.bet.MsgWager msg = 1; - // mainacc_deduct_amount is amount to be deducted from main account - string mainacc_deduct_amount = 2 [ - (gogoproto.customtype) = "cosmossdk.io/math.Int", - (gogoproto.nullable) = false - ]; - // subacc_deduct_amount is amount to be deducted from sub account - string subacc_deduct_amount = 3 [ - (gogoproto.customtype) = "cosmossdk.io/math.Int", - (gogoproto.nullable) = false - ]; +message MsgWager { + // creator is the subaccount owner. + string creator = 1; + // ticket is the jwt ticket data. + string ticket = 2; } // MsgWagerResponse wraps the MsgWagerResponse message. We need it in order not diff --git a/x/orderbook/keeper/bet_settle.go b/x/orderbook/keeper/bet_settle.go index 6c725436..cec3ff0f 100644 --- a/x/orderbook/keeper/bet_settle.go +++ b/x/orderbook/keeper/bet_settle.go @@ -27,8 +27,6 @@ func (k Keeper) RefundBettor( return err } - k.hooks.AfterBettorRefund(ctx, bettorAddress, betAmount, betFee) - return nil } @@ -73,8 +71,6 @@ func (k Keeper) BettorWins( k.SetOrderBookParticipation(ctx, orderBookParticipation) } - k.hooks.AfterBettorWin(ctx, bettorAddress, betAmount, payoutProfit) - return nil } @@ -115,7 +111,5 @@ func (k Keeper) BettorLoses( k.SetOrderBookParticipation(ctx, orderBookParticipation) } - k.hooks.AfterBettorLoss(ctx, bettorAddress, betAmount) - return nil } diff --git a/x/orderbook/types/expected_keepers.go b/x/orderbook/types/expected_keepers.go index edcc8ae6..0def41cf 100644 --- a/x/orderbook/types/expected_keepers.go +++ b/x/orderbook/types/expected_keepers.go @@ -80,10 +80,6 @@ type FeeGrantKeeper interface { // OrderBookHooks event hooks for orderbook methods. type OrderBookHooks interface { - AfterBettorWin(ctx sdk.Context, bettor sdk.AccAddress, originalAmount, profit sdkmath.Int) - AfterBettorLoss(ctx sdk.Context, bettor sdk.AccAddress, originalAmount sdkmath.Int) - AfterBettorRefund(ctx sdk.Context, bettor sdk.AccAddress, originalAmount, fee sdkmath.Int) - AfterHouseWin(ctx sdk.Context, house sdk.AccAddress, originalAmount, profit sdkmath.Int) AfterHouseLoss(ctx sdk.Context, house sdk.AccAddress, originalAmount, lostAmt sdkmath.Int) AfterHouseRefund(ctx sdk.Context, house sdk.AccAddress, originalAmount sdkmath.Int) diff --git a/x/orderbook/types/hooks.go b/x/orderbook/types/hooks.go index 51a1e274..b8a3e7af 100644 --- a/x/orderbook/types/hooks.go +++ b/x/orderbook/types/hooks.go @@ -15,27 +15,6 @@ func NewMultiOrderBookHooks(hooks ...OrderBookHooks) MultiOrderBookHooks { return hooks } -// AfterBettorWin registers all of hooks for this method. -func (h MultiOrderBookHooks) AfterBettorWin(ctx sdk.Context, bettor sdk.AccAddress, originalAmount, profit sdkmath.Int) { - for i := range h { - h[i].AfterBettorWin(ctx, bettor, originalAmount, profit) - } -} - -// AfterBettorLoss registers all of hooks for this method. -func (h MultiOrderBookHooks) AfterBettorLoss(ctx sdk.Context, bettor sdk.AccAddress, originalAmount sdkmath.Int) { - for i := range h { - h[i].AfterBettorLoss(ctx, bettor, originalAmount) - } -} - -// AfterBettorRefund registers all of hooks for this method. -func (h MultiOrderBookHooks) AfterBettorRefund(ctx sdk.Context, bettor sdk.AccAddress, originalAmount, fee sdkmath.Int) { - for i := range h { - h[i].AfterBettorRefund(ctx, bettor, originalAmount, fee) - } -} - // AfterHouseWin registers all of hooks for this method. func (h MultiOrderBookHooks) AfterHouseWin(ctx sdk.Context, house sdk.AccAddress, originalAmount, profit sdkmath.Int) { for i := range h { diff --git a/x/subaccount/client/cli/tx.go b/x/subaccount/client/cli/tx.go index b44791d3..b1dee66c 100644 --- a/x/subaccount/client/cli/tx.go +++ b/x/subaccount/client/cli/tx.go @@ -15,7 +15,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" - bettypes "github.com/sge-network/sge/x/bet/types" housetypes "github.com/sge-network/sge/x/house/types" "github.com/sge-network/sge/x/subaccount/types" ) @@ -171,38 +170,27 @@ func TxWithdraw() *cobra.Command { // TxWager implements a command to place and store a single bet func TxWager() *cobra.Command { cmd := &cobra.Command{ - Use: "wager [uid] [amount] [ticket] --from subaccount-owner-key", + Use: "wager [ticket] --from subaccount-owner-key", Short: "Wager on an odds", Long: "Wager on an odds. the uuid, amount and ticket required.", - Args: cobra.ExactArgs(3), + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) (err error) { // Get value arguments - uid := args[0] - argAmount := args[1] - argTicket := args[2] - - argAmountCosmosInt, ok := sdkmath.NewIntFromString(argAmount) - if !ok { - return fmt.Errorf("invalid amount: %s", argAmount) - } + argTicket := args[0] clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err } - msg := bettypes.NewMsgWager( + msg := types.NewMsgWager( clientCtx.GetFromAddress().String(), - bettypes.WagerProps{ - UID: uid, - Amount: argAmountCosmosInt, - Ticket: argTicket, - }, + argTicket, ) if err := msg.ValidateBasic(); err != nil { return err } - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &types.MsgWager{Msg: msg}) + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) }, } diff --git a/x/subaccount/keeper/hooks.go b/x/subaccount/keeper/hooks.go index f4def2ef..7c7d3998 100644 --- a/x/subaccount/keeper/hooks.go +++ b/x/subaccount/keeper/hooks.go @@ -19,59 +19,6 @@ var _ orderbooktypes.OrderBookHooks = Hooks{} // Create new distribution hooks func (k Keeper) Hooks() Hooks { return Hooks{k} } -// AfterBettorWin is subaccount module hook for subaccount bettor winning. -func (h Hooks) AfterBettorWin(ctx sdk.Context, bettor sdk.AccAddress, originalAmount, profit sdkmath.Int) { - balance, exists := h.k.GetAccountSummary(ctx, bettor) - if !exists { - return - } - err := balance.Unspend(originalAmount) - if err != nil { - panic(err) - } - // send profits to subaccount owner - owner, exists := h.k.GetSubAccountOwner(ctx, bettor) - if !exists { - panic("subaccount owner not found") - } - err = h.k.bankKeeper.SendCoins(ctx, bettor, owner, sdk.NewCoins(sdk.NewCoin(params.DefaultBondDenom, profit))) - if err != nil { - panic(err) - } - h.k.SetAccountSummary(ctx, bettor, balance) -} - -// AfterBettorLoss is subaccount module hook for subaccount bettor loss. -func (h Hooks) AfterBettorLoss(ctx sdk.Context, bettor sdk.AccAddress, originalAmount sdkmath.Int) { - balance, exists := h.k.GetAccountSummary(ctx, bettor) - if !exists { - return - } - err := balance.Unspend(originalAmount) - if err != nil { - panic(err) - } - err = balance.AddLoss(originalAmount) - if err != nil { - panic(err) - } - h.k.SetAccountSummary(ctx, bettor, balance) -} - -// AfterBettorRefund is subaccount module hook for subaccount bettor refund. -func (h Hooks) AfterBettorRefund(ctx sdk.Context, bettor sdk.AccAddress, originalAmount, fee sdkmath.Int) { - balance, exists := h.k.GetAccountSummary(ctx, bettor) - if !exists { - return - } - totalUnspent := originalAmount.Add(fee) - err := balance.Unspend(totalUnspent) - if err != nil { - panic(err) - } - h.k.SetAccountSummary(ctx, bettor, balance) -} - // AfterHouseWin is subaccount module hook for house winning over subbacount. func (h Hooks) AfterHouseWin(ctx sdk.Context, house sdk.AccAddress, originalAmount, profit sdkmath.Int) { // update balance diff --git a/x/subaccount/keeper/msg_server_bet.go b/x/subaccount/keeper/msg_server_bet.go index ac2f31d5..60ec3e4e 100644 --- a/x/subaccount/keeper/msg_server_bet.go +++ b/x/subaccount/keeper/msg_server_bet.go @@ -19,36 +19,54 @@ import ( func (k msgServer) Wager(goCtx context.Context, msg *types.MsgWager) (*types.MsgWagerResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - subAccOwner := sdk.MustAccAddressFromBech32(msg.Msg.Creator) + if !k.keeper.GetWagerEnabled(ctx) { + return nil, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "currently the subacount wager tx is not enabled") + } + + subAccOwner := sdk.MustAccAddressFromBech32(msg.Creator) // find subaccount subAccAddr, exists := k.keeper.GetSubAccountByOwner(ctx, subAccOwner) if !exists { return nil, status.Error(codes.NotFound, "subaccount not found") } - bet, oddsMap, err := k.keeper.betKeeper.PrepareBetObject(ctx, msg.Msg.Creator, msg.Msg.Props) + payload := &types.SubAccWagerTicketPayload{} + err := k.keeper.ovmKeeper.VerifyTicketUnmarshal(sdk.WrapSDKContext(ctx), msg.Ticket, &payload) + if err != nil { + return nil, sdkerrors.Wrapf(types.ErrInTicketVerification, "%s", err) + } + + if msg.Creator != payload.Msg.Creator { + return nil, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "message creator should be the same as the sub message creator%s", msg.Creator) + } + + bet, oddsMap, err := k.keeper.betKeeper.PrepareBetObject(ctx, payload.Msg.Creator, payload.Msg.Props) if err != nil { return nil, err } + if err := payload.Validate(bet.Amount); err != nil { + return nil, sdkerrors.Wrapf(types.ErrInTicketPayloadValidation, "%s", err) + } + mainAccBalance := k.keeper.bankKeeper.GetBalance( ctx, sdk.MustAccAddressFromBech32(bet.Creator), params.DefaultBondDenom) - if mainAccBalance.Amount.LT(msg.MainaccDeductAmount) { + if mainAccBalance.Amount.LT(payload.MainaccDeductAmount) { return nil, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "not enough balance in main account") } accSummary, unlockedBalance, _ := k.keeper.getAccountSummary(ctx, subAccAddr) - if unlockedBalance.GTE(msg.SubaccDeductAmount) { + if unlockedBalance.GTE(payload.SubaccDeductAmount) { if err := k.keeper.bankKeeper.SendCoins(ctx, subAccAddr, - sdk.MustAccAddressFromBech32(msg.Msg.Creator), - sdk.NewCoins(sdk.NewCoin(params.DefaultBondDenom, msg.SubaccDeductAmount))); err != nil { + sdk.MustAccAddressFromBech32(msg.Creator), + sdk.NewCoins(sdk.NewCoin(params.DefaultBondDenom, payload.SubaccDeductAmount))); err != nil { return nil, sdkerrors.Wrapf(types.ErrSendCoinError, "error sending coin from subaccount to main account %s", err) } } else { - lockedAmountToWithdraw := msg.SubaccDeductAmount.Sub(unlockedBalance) + lockedAmountToWithdraw := payload.SubaccDeductAmount.Sub(unlockedBalance) if err := accSummary.Withdraw(lockedAmountToWithdraw); err != nil { return nil, sdkerrors.Wrapf(types.ErrWithdrawLocked, "%s", err) @@ -88,19 +106,15 @@ func (k msgServer) Wager(goCtx context.Context, msg *types.MsgWager) (*types.Msg k.keeper.SetLockedBalances(ctx, subAccAddr, updatedLockedBalances) } - // if err := accSummary.Spend(msg.SubaccDeductAmount); err != nil { - // return nil, err - // } - if err := k.keeper.betKeeper.Wager(ctx, bet, oddsMap); err != nil { return nil, err } k.keeper.SetAccountSummary(ctx, subAccAddr, accSummary) - msg.EmitEvent(&ctx, subAccOwner.String()) + msg.EmitEvent(&ctx, payload.Msg, subAccOwner.String()) return &types.MsgWagerResponse{ - Response: &bettypes.MsgWagerResponse{Props: msg.Msg.Props}, + Response: &bettypes.MsgWagerResponse{Props: payload.Msg.Props}, }, nil } diff --git a/x/subaccount/keeper/msg_server_bet_test.go b/x/subaccount/keeper/msg_server_bet_test.go index 5a6cd3f4..e3b75b1f 100644 --- a/x/subaccount/keeper/msg_server_bet_test.go +++ b/x/subaccount/keeper/msg_server_bet_test.go @@ -63,6 +63,10 @@ var ( func TestMsgServer_Bet(t *testing.T) { app, k, msgServer, ctx := setupMsgServerAndApp(t) + parm := k.GetParams(ctx) + parm.WagerEnabled = true + k.SetParams(ctx, parm) + subAccOwner := simapp.TestParamUsers["user2"].Address subAccFunder := simapp.TestParamUsers["user1"].Address @@ -97,13 +101,10 @@ func TestMsgServer_Bet(t *testing.T) { // start betting using the subaccount betAmt := sdkmath.NewInt(1000).Mul(micro) halfBetAmt := betAmt.Quo(sdkmath.NewInt(2)) + _, err = msgServer.Wager( sdk.WrapSDKContext(ctx), - &types.MsgWager{ - Msg: testBet(t, subAccOwner, betAmt), - MainaccDeductAmount: halfBetAmt, - SubaccDeductAmount: halfBetAmt, - }, + testMsgWager(t, subAccOwner, betAmt, halfBetAmt, halfBetAmt), ) require.NoError(t, err) @@ -249,8 +250,8 @@ func createJwtTicket(claim jwt.MapClaims) (string, error) { return token.SignedString(simapp.TestOVMPrivateKeys[0]) } -func testBet(t testing.TB, bettor sdk.AccAddress, amount sdkmath.Int) *bettypes.MsgWager { - ticket, err := createJwtTicket(jwt.MapClaims{ +func testMsgWager(t testing.TB, bettor sdk.AccAddress, amount sdkmath.Int, mainAccDeduct, subAccDeduct sdkmath.Int) *types.MsgWager { + betTicket, err := createJwtTicket(jwt.MapClaims{ "exp": 9999999999, "iat": 7777777777, "selected_odds": testSelectedBetOdds, @@ -262,12 +263,24 @@ func testBet(t testing.TB, bettor sdk.AccAddress, amount sdkmath.Int) *bettypes. }) require.NoError(t, err) - return &bettypes.MsgWager{ - Creator: bettor.String(), - Props: &bettypes.WagerProps{ - UID: uuid.NewString(), - Amount: amount, - Ticket: ticket, + subAccTicket, err := createJwtTicket(jwt.MapClaims{ + "exp": 9999999999, + "iat": 7777777777, + "msg": bettypes.MsgWager{ + Creator: bettor.String(), + Props: &bettypes.WagerProps{ + UID: uuid.NewString(), + Amount: amount, + Ticket: betTicket, + }, }, + "mainacc_deduct_amount": mainAccDeduct, + "subacc_deduct_amount": subAccDeduct, + }) + require.NoError(t, err) + + return &types.MsgWager{ + Creator: bettor.String(), + Ticket: subAccTicket, } } diff --git a/x/subaccount/keeper/msg_server_house.go b/x/subaccount/keeper/msg_server_house.go index 8ee05293..c0548c92 100644 --- a/x/subaccount/keeper/msg_server_house.go +++ b/x/subaccount/keeper/msg_server_house.go @@ -5,6 +5,7 @@ import ( sdkerrors "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrtypes "github.com/cosmos/cosmos-sdk/types/errors" housetypes "github.com/sge-network/sge/x/house/types" "github.com/sge-network/sge/x/subaccount/types" @@ -13,6 +14,10 @@ import ( func (k msgServer) HouseDeposit(goCtx context.Context, msg *types.MsgHouseDeposit) (*types.MsgHouseDepositResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + if !k.keeper.GetDepositEnabled(ctx) { + return nil, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "currently the subacount deposit tx is not enabled") + } + // check if subaccount exists subAccAddr, exists := k.keeper.GetSubAccountByOwner(ctx, sdk.MustAccAddressFromBech32(msg.Msg.Creator)) if !exists { diff --git a/x/subaccount/keeper/msg_server_house_test.go b/x/subaccount/keeper/msg_server_house_test.go index d9e6f27f..1623c88f 100644 --- a/x/subaccount/keeper/msg_server_house_test.go +++ b/x/subaccount/keeper/msg_server_house_test.go @@ -5,6 +5,7 @@ import ( "time" "github.com/golang-jwt/jwt" + "github.com/google/uuid" "github.com/stretchr/testify/require" sdkmath "cosmossdk.io/math" @@ -16,6 +17,7 @@ import ( "github.com/sge-network/sge/testutil/simapp" sgetypes "github.com/sge-network/sge/types" betmodulekeeper "github.com/sge-network/sge/x/bet/keeper" + bettypes "github.com/sge-network/sge/x/bet/types" housetypes "github.com/sge-network/sge/x/house/types" markettypes "github.com/sge-network/sge/x/market/types" "github.com/sge-network/sge/x/subaccount/types" @@ -29,6 +31,10 @@ var ( func TestMsgServer(t *testing.T) { app, k, msgServer, ctx := setupMsgServerAndApp(t) + parm := k.GetParams(ctx) + parm.DepositEnabled = true + k.SetParams(ctx, parm) + subAccOwner := sample.NativeAccAddress() subAccFunder := sample.NativeAccAddress() @@ -80,7 +86,7 @@ func TestMsgServer(t *testing.T) { // place bet betMsgServer := betmodulekeeper.NewMsgServerImpl(*app.BetKeeper) - _, err = betMsgServer.Wager(sdk.WrapSDKContext(ctx), testBet(t, bettor1, bettor1Funds)) + _, err = betMsgServer.Wager(sdk.WrapSDKContext(ctx), testBetMsgWager(t, bettor1, bettor1Funds)) require.NoError(t, err) participateFee := app.HouseKeeper.GetHouseParticipationFee(ctx).Mul(sdk.NewDecFromInt(deposit)).TruncateInt() @@ -205,6 +211,10 @@ func TestMsgServer(t *testing.T) { func TestHouseWithdrawal_MarketRefund(t *testing.T) { app, k, msgServer, ctx := setupMsgServerAndApp(t) + parm := k.GetParams(ctx) + parm.DepositEnabled = true + k.SetParams(ctx, parm) + subAccOwner := sample.NativeAccAddress() subAccFunder := sample.NativeAccAddress() // do subaccount creation @@ -339,3 +349,26 @@ func houseDepositMsg(t *testing.T, owner sdk.AccAddress, uid string, amt sdkmath Msg: inputDeposit, } } + +func testBetMsgWager(t testing.TB, bettor sdk.AccAddress, amount sdkmath.Int) *bettypes.MsgWager { + betTicket, err := createJwtTicket(jwt.MapClaims{ + "exp": 9999999999, + "iat": 7777777777, + "selected_odds": testSelectedBetOdds, + "kyc_data": &sgetypes.KycDataPayload{ + Approved: true, + ID: bettor.String(), + }, + "all_odds": testBetOdds, + }) + require.NoError(t, err) + + return &bettypes.MsgWager{ + Creator: bettor.String(), + Props: &bettypes.WagerProps{ + UID: uuid.NewString(), + Amount: amount, + Ticket: betTicket, + }, + } +} diff --git a/x/subaccount/keeper/params.go b/x/subaccount/keeper/params.go index 01e0b0f9..f1329519 100644 --- a/x/subaccount/keeper/params.go +++ b/x/subaccount/keeper/params.go @@ -16,3 +16,13 @@ func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { k.paramstore.GetParamSet(ctx, ¶ms) return params } + +// GetWagerEnabled returns enable/disable status of wager +func (k Keeper) GetWagerEnabled(ctx sdk.Context) bool { + return k.GetParams(ctx).WagerEnabled +} + +// GetDepositEnabled returns enable/disable status of deposit +func (k Keeper) GetDepositEnabled(ctx sdk.Context) bool { + return k.GetParams(ctx).DepositEnabled +} diff --git a/x/subaccount/types/errors.go b/x/subaccount/types/errors.go index 31d50230..87914209 100644 --- a/x/subaccount/types/errors.go +++ b/x/subaccount/types/errors.go @@ -7,11 +7,13 @@ import ( ) var ( - ErrUnlockTokenTimeExpired = sdkerrors.Register(ModuleName, 1, "unlock time is expired") - ErrSubaccountAlreadyExist = sdkerrors.Register(ModuleName, 2, "account has already sub account") - ErrSubaccountDoesNotExist = sdkerrors.Register(ModuleName, 3, "sub account does not exist") - ErrNothingToWithdraw = sdkerrors.Register(ModuleName, 4, "nothing to withdraw") - ErrInvalidLockedBalance = sdkerrors.Register(ModuleName, 5, "invalid locked balance") - ErrSendCoinError = sdkerrors.Register(ModuleName, 6, "send coin error") - ErrWithdrawLocked = sdkerrors.Register(ModuleName, 7, "withdrawal of locked coins failed") + ErrInTicketVerification = sdkerrors.Register(ModuleName, 8001, "error in ticket verification process") + ErrInTicketPayloadValidation = sdkerrors.Register(ModuleName, 8002, "error in ticket payload validation") + ErrUnlockTokenTimeExpired = sdkerrors.Register(ModuleName, 8003, "unlock time is expired") + ErrSubaccountAlreadyExist = sdkerrors.Register(ModuleName, 8004, "account has already sub account") + ErrSubaccountDoesNotExist = sdkerrors.Register(ModuleName, 8005, "sub account does not exist") + ErrNothingToWithdraw = sdkerrors.Register(ModuleName, 8006, "nothing to withdraw") + ErrInvalidLockedBalance = sdkerrors.Register(ModuleName, 8007, "invalid locked balance") + ErrSendCoinError = sdkerrors.Register(ModuleName, 8008, "send coin error") + ErrWithdrawLocked = sdkerrors.Register(ModuleName, 8009, "withdrawal of locked coins failed") ) diff --git a/x/subaccount/types/messages_bet.go b/x/subaccount/types/messages_bet.go index 36d9f8d8..3a767c72 100644 --- a/x/subaccount/types/messages_bet.go +++ b/x/subaccount/types/messages_bet.go @@ -5,6 +5,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/errors" "github.com/sge-network/sge/utils" + bettypes "github.com/sge-network/sge/x/bet/types" ) const ( @@ -14,6 +15,14 @@ const ( var _ sdk.Msg = &MsgWager{} +// NewMsgWager returns a MsgWager using given data +func NewMsgWager(creator, ticket string) *MsgWager { + return &MsgWager{ + Creator: creator, + Ticket: ticket, + } +} + // Route returns the module's message router key. func (*MsgWager) Route() string { return RouterKey } @@ -21,7 +30,11 @@ func (*MsgWager) Route() string { return RouterKey } func (*MsgWager) Type() string { return typeMsgWager } func (msg *MsgWager) GetSigners() []sdk.AccAddress { - return msg.Msg.GetSigners() + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} } // GetSignBytes returns sortJson form of its message @@ -32,28 +45,20 @@ func (msg *MsgWager) GetSignBytes() []byte { // ValidateBasic validates basic constraints of original msgWager of bet module. func (msg *MsgWager) ValidateBasic() error { - if msg.Msg == nil { - return errors.ErrInvalidRequest.Wrap("msg is nil") - } - - if msg.MainaccDeductAmount.IsNil() || msg.SubaccDeductAmount.IsNil() { - return errors.ErrInvalidRequest.Wrap("main account and subaccount deduction should be set") - } - - if !msg.MainaccDeductAmount.Add(msg.SubaccDeductAmount).Equal(msg.Msg.Props.Amount) { - return errors.ErrInvalidRequest.Wrap("sum of main and sub account deduction should be equal to bet amount") + if msg.Ticket == "" { + return errors.ErrInvalidRequest.Wrap("ticket is nil") } - return msg.Msg.ValidateBasic() + return nil } // EmitEvent emits the event for the message success. -func (msg *MsgWager) EmitEvent(ctx *sdk.Context, accOwnerAddr string) { +func (msg *MsgWager) EmitEvent(ctx *sdk.Context, wagerMsg *bettypes.MsgWager, accOwnerAddr string) { emitter := utils.NewEventEmitter(ctx, attributeValueCategory) - emitter.AddMsg(typeMsgWager, msg.Msg.Creator, - sdk.NewAttribute(attributeKeyBetCreator, msg.Msg.Creator), + emitter.AddMsg(typeMsgWager, wagerMsg.Creator, + sdk.NewAttribute(attributeKeyBetCreator, wagerMsg.Creator), sdk.NewAttribute(attributeKeyBetCreatorOwner, accOwnerAddr), - sdk.NewAttribute(attributeKeyBetUID, msg.Msg.Props.UID), + sdk.NewAttribute(attributeKeyBetUID, wagerMsg.Props.UID), ) emitter.Emit() } diff --git a/x/subaccount/types/params.go b/x/subaccount/types/params.go index d7fda8a3..41846229 100644 --- a/x/subaccount/types/params.go +++ b/x/subaccount/types/params.go @@ -1,13 +1,36 @@ package types import ( + "fmt" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" yaml "gopkg.in/yaml.v2" ) +var ( + defaultWagerEnabled = true + defaultDepositEnabled = false +) + +// parameter store keys +var ( + // keyWagerEnabled is the enable/disable status of subaccount wager tx endpoint. + keyWagerEnabled = []byte("WagerEnabled") + + // keyDepositEnabled is the enable/disable status of subaccount deposit tx endpoint. + keyDepositEnabled = []byte("DepositEnabled") +) + +var _ paramtypes.ParamSet = (*Params)(nil) + // NewParams creates a new Params instance func NewParams() Params { - return Params{} + return Params{ + // TODO: in the next upgrade handler + WagerEnabled: defaultWagerEnabled, + // TODO: in the next upgrade handler + DepositEnabled: defaultDepositEnabled, + } } // DefaultParams returns a default set of parameters. @@ -15,8 +38,33 @@ func DefaultParams() Params { return NewParams() } +// ParamKeyTable for house module +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{} + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair( + keyWagerEnabled, + &p.WagerEnabled, + validateWagerEnabled, + ), + paramtypes.NewParamSetPair( + keyDepositEnabled, + &p.DepositEnabled, + validateDepositEnabled, + ), + } +} + +// Validate validates the set of params +func (p Params) Validate() error { + if err := validateWagerEnabled(p.WagerEnabled); err != nil { + return err + } + + return validateDepositEnabled(p.DepositEnabled) } // String returns a human-readable string representation of the parameters. @@ -28,7 +76,20 @@ func (p Params) String() string { return string(out) } -// ParamKeyTable for house module -func ParamKeyTable() paramtypes.KeyTable { - return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +func validateWagerEnabled(i interface{}) error { + _, ok := i.(bool) + if !ok { + return fmt.Errorf("%s: %T", "invalid parameter type for wager enabled", i) + } + + return nil +} + +func validateDepositEnabled(i interface{}) error { + _, ok := i.(bool) + if !ok { + return fmt.Errorf("%s: %T", "invalid parameter type for deposit enabled", i) + } + + return nil } diff --git a/x/subaccount/types/params.pb.go b/x/subaccount/types/params.pb.go index b1450d8d..56158bff 100644 --- a/x/subaccount/types/params.pb.go +++ b/x/subaccount/types/params.pb.go @@ -25,6 +25,10 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the module. type Params struct { + // wager_enabled is enable/disable status of wager feature. + WagerEnabled bool `protobuf:"varint,1,opt,name=wager_enabled,json=wagerEnabled,proto3" json:"wager_enabled,omitempty"` + // deposit_enabled is enable/disable status of deposit feature. + DepositEnabled bool `protobuf:"varint,2,opt,name=deposit_enabled,json=depositEnabled,proto3" json:"deposit_enabled,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -59,6 +63,20 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo +func (m *Params) GetWagerEnabled() bool { + if m != nil { + return m.WagerEnabled + } + return false +} + +func (m *Params) GetDepositEnabled() bool { + if m != nil { + return m.DepositEnabled + } + return false +} + func init() { proto.RegisterType((*Params)(nil), "sgenetwork.sge.subaccount.Params") } @@ -66,18 +84,21 @@ func init() { func init() { proto.RegisterFile("sge/subaccount/params.proto", fileDescriptor_13721530b9bd8795) } var fileDescriptor_13721530b9bd8795 = []byte{ - // 161 bytes of a gzipped FileDescriptorProto + // 212 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2e, 0x4e, 0x4f, 0xd5, 0x2f, 0x2e, 0x4d, 0x4a, 0x4c, 0x4e, 0xce, 0x2f, 0xcd, 0x2b, 0xd1, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x2c, 0x4e, 0x4f, 0xcd, 0x4b, 0x2d, 0x29, 0xcf, 0x2f, 0xca, 0xd6, 0x2b, 0x4e, 0x4f, 0xd5, 0x43, 0xa8, 0x93, 0x12, 0x49, 0xcf, 0x4f, 0xcf, - 0x07, 0xab, 0xd2, 0x07, 0xb1, 0x20, 0x1a, 0x94, 0xf8, 0xb8, 0xd8, 0x02, 0xc0, 0x06, 0x58, 0xb1, - 0xcc, 0x58, 0x20, 0xcf, 0xe0, 0xe4, 0x7e, 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, 0xba, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0xc5, 0xe9, 0xa9, - 0xba, 0x50, 0x6b, 0x40, 0x6c, 0xfd, 0x0a, 0x64, 0x07, 0x95, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, - 0x81, 0xcd, 0x37, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x12, 0x4a, 0x30, 0x1c, 0xaf, 0x00, 0x00, - 0x00, + 0x07, 0xab, 0xd2, 0x07, 0xb1, 0x20, 0x1a, 0x94, 0x62, 0xb8, 0xd8, 0x02, 0xc0, 0x06, 0x08, 0x29, + 0x73, 0xf1, 0x96, 0x27, 0xa6, 0xa7, 0x16, 0xc5, 0xa7, 0xe6, 0x25, 0x26, 0xe5, 0xa4, 0xa6, 0x48, + 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x04, 0xf1, 0x80, 0x05, 0x5d, 0x21, 0x62, 0x42, 0xea, 0x5c, 0xfc, + 0x29, 0xa9, 0x05, 0xf9, 0xc5, 0x99, 0x25, 0x70, 0x65, 0x4c, 0x60, 0x65, 0x7c, 0x50, 0x61, 0xa8, + 0x42, 0x2b, 0x96, 0x19, 0x0b, 0xe4, 0x19, 0x9c, 0xdc, 0x4f, 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, 0x37, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0xbf, + 0x38, 0x3d, 0x55, 0x17, 0xea, 0x68, 0x10, 0x5b, 0xbf, 0x02, 0xd9, 0x7b, 0x25, 0x95, 0x05, 0xa9, + 0xc5, 0x49, 0x6c, 0x60, 0xd7, 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x20, 0xcb, 0xa6, 0xc3, + 0xfd, 0x00, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -100,6 +121,26 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.DepositEnabled { + i-- + if m.DepositEnabled { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } + if m.WagerEnabled { + i-- + if m.WagerEnabled { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } return len(dAtA) - i, nil } @@ -120,6 +161,12 @@ func (m *Params) Size() (n int) { } var l int _ = l + if m.WagerEnabled { + n += 2 + } + if m.DepositEnabled { + n += 2 + } return n } @@ -158,6 +205,46 @@ func (m *Params) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field WagerEnabled", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.WagerEnabled = bool(v != 0) + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field DepositEnabled", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.DepositEnabled = bool(v != 0) default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/subaccount/types/ticket.go b/x/subaccount/types/ticket.go new file mode 100644 index 00000000..af06934f --- /dev/null +++ b/x/subaccount/types/ticket.go @@ -0,0 +1,19 @@ +package types + +import ( + sdkmath "cosmossdk.io/math" + sdkerrtypes "github.com/cosmos/cosmos-sdk/types/errors" +) + +// Validate validates fields of the given ticketData +func (payload *SubAccWagerTicketPayload) Validate(betAmount sdkmath.Int) error { + if payload.MainaccDeductAmount.IsNil() || payload.SubaccDeductAmount.IsNil() { + return sdkerrtypes.ErrInvalidRequest.Wrap("main account and subaccount deduction should be set") + } + + if !payload.MainaccDeductAmount.Add(payload.SubaccDeductAmount).Equal(betAmount) { + return sdkerrtypes.ErrInvalidRequest.Wrap("sum of main and sub account deduction should be equal to bet amount") + } + + return payload.Msg.ValidateBasic() +} diff --git a/x/subaccount/types/ticket.pb.go b/x/subaccount/types/ticket.pb.go new file mode 100644 index 00000000..d7cc2c90 --- /dev/null +++ b/x/subaccount/types/ticket.pb.go @@ -0,0 +1,433 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: sge/subaccount/ticket.proto + +package types + +import ( + cosmossdk_io_math "cosmossdk.io/math" + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/gogo/protobuf/proto" + types "github.com/sge-network/sge/x/bet/types" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// SubAccWagerTicketPayload indicates data of subaccount wager ticket. +type SubAccWagerTicketPayload struct { + // msg holds normal wager message + Msg *types.MsgWager `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"` + // mainacc_deduct_amount is amount to be deducted from main account + MainaccDeductAmount cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=mainacc_deduct_amount,json=mainaccDeductAmount,proto3,customtype=cosmossdk.io/math.Int" json:"mainacc_deduct_amount"` + // subacc_deduct_amount is amount to be deducted from sub account + SubaccDeductAmount cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=subacc_deduct_amount,json=subaccDeductAmount,proto3,customtype=cosmossdk.io/math.Int" json:"subacc_deduct_amount"` +} + +func (m *SubAccWagerTicketPayload) Reset() { *m = SubAccWagerTicketPayload{} } +func (m *SubAccWagerTicketPayload) String() string { return proto.CompactTextString(m) } +func (*SubAccWagerTicketPayload) ProtoMessage() {} +func (*SubAccWagerTicketPayload) Descriptor() ([]byte, []int) { + return fileDescriptor_70127b4abdfb0944, []int{0} +} +func (m *SubAccWagerTicketPayload) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SubAccWagerTicketPayload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SubAccWagerTicketPayload.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *SubAccWagerTicketPayload) XXX_Merge(src proto.Message) { + xxx_messageInfo_SubAccWagerTicketPayload.Merge(m, src) +} +func (m *SubAccWagerTicketPayload) XXX_Size() int { + return m.Size() +} +func (m *SubAccWagerTicketPayload) XXX_DiscardUnknown() { + xxx_messageInfo_SubAccWagerTicketPayload.DiscardUnknown(m) +} + +var xxx_messageInfo_SubAccWagerTicketPayload proto.InternalMessageInfo + +func (m *SubAccWagerTicketPayload) GetMsg() *types.MsgWager { + if m != nil { + return m.Msg + } + return nil +} + +func init() { + proto.RegisterType((*SubAccWagerTicketPayload)(nil), "sgenetwork.sge.subaccount.SubAccWagerTicketPayload") +} + +func init() { proto.RegisterFile("sge/subaccount/ticket.proto", fileDescriptor_70127b4abdfb0944) } + +var fileDescriptor_70127b4abdfb0944 = []byte{ + // 299 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0x41, 0x4a, 0x03, 0x31, + 0x14, 0x86, 0x27, 0x16, 0x04, 0xc7, 0x8d, 0x8c, 0x2d, 0xd4, 0xaa, 0x69, 0x71, 0xd5, 0x4d, 0x13, + 0xd0, 0x13, 0xb4, 0x08, 0xe2, 0x42, 0xd4, 0x2a, 0x08, 0x6e, 0x4a, 0x92, 0x09, 0xe9, 0x50, 0x33, + 0x29, 0x7d, 0x6f, 0xb0, 0xbd, 0x85, 0xc7, 0xea, 0xb2, 0x4b, 0x71, 0x51, 0x64, 0x66,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x56, 0x39, 0x25, 0x9f, 0x39, 0x25, 0x6f, 0x05, 0x0d, 0x56, 0x05, 0x0d, 0xde, + 0x0b, 0x1a, 0x3c, 0xf7, 0x4c, 0x82, 0xe3, 0x4c, 0x32, 0xe5, 0x2c, 0x07, 0xa3, 0x7b, 0x9b, 0xae, + 0xe5, 0xcc, 0xe7, 0x7f, 0x76, 0xb0, 0x98, 0x6a, 0x90, 0xbb, 0xfe, 0x03, 0x2f, 0xbe, 0x03, 0x00, + 0x00, 0xff, 0xff, 0x4d, 0x0f, 0xd9, 0x3b, 0xa2, 0x01, 0x00, 0x00, +} + +func (m *SubAccWagerTicketPayload) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SubAccWagerTicketPayload) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SubAccWagerTicketPayload) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.SubaccDeductAmount.Size() + i -= size + if _, err := m.SubaccDeductAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTicket(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.MainaccDeductAmount.Size() + i -= size + if _, err := m.MainaccDeductAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTicket(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if m.Msg != nil { + { + size, err := m.Msg.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTicket(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintTicket(dAtA []byte, offset int, v uint64) int { + offset -= sovTicket(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *SubAccWagerTicketPayload) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Msg != nil { + l = m.Msg.Size() + n += 1 + l + sovTicket(uint64(l)) + } + l = m.MainaccDeductAmount.Size() + n += 1 + l + sovTicket(uint64(l)) + l = m.SubaccDeductAmount.Size() + n += 1 + l + sovTicket(uint64(l)) + return n +} + +func sovTicket(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTicket(x uint64) (n int) { + return sovTicket(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *SubAccWagerTicketPayload) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTicket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SubAccWagerTicketPayload: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SubAccWagerTicketPayload: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Msg", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTicket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTicket + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTicket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Msg == nil { + m.Msg = &types.MsgWager{} + } + if err := m.Msg.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MainaccDeductAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTicket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTicket + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTicket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MainaccDeductAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SubaccDeductAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTicket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTicket + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTicket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.SubaccDeductAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTicket(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTicket + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTicket(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTicket + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTicket + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTicket + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTicket + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTicket + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTicket + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTicket = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTicket = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTicket = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/subaccount/types/tx.pb.go b/x/subaccount/types/tx.pb.go index 53edbd1c..0664453b 100644 --- a/x/subaccount/types/tx.pb.go +++ b/x/subaccount/types/tx.pb.go @@ -5,7 +5,6 @@ package types import ( context "context" - cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" @@ -324,11 +323,10 @@ var xxx_messageInfo_MsgWithdrawUnlockedBalancesResponse proto.InternalMessageInf // MsgWager wraps the MsgWager message. We need it in order not to have // double interface registration conflicts. type MsgWager struct { - Msg *types.MsgWager `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"` - // mainacc_deduct_amount is amount to be deducted from main account - MainaccDeductAmount cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=mainacc_deduct_amount,json=mainaccDeductAmount,proto3,customtype=cosmossdk.io/math.Int" json:"mainacc_deduct_amount"` - // subacc_deduct_amount is amount to be deducted from sub account - SubaccDeductAmount cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=subacc_deduct_amount,json=subaccDeductAmount,proto3,customtype=cosmossdk.io/math.Int" json:"subacc_deduct_amount"` + // creator is the subaccount owner. + 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 *MsgWager) Reset() { *m = MsgWager{} } @@ -364,11 +362,18 @@ func (m *MsgWager) XXX_DiscardUnknown() { var xxx_messageInfo_MsgWager proto.InternalMessageInfo -func (m *MsgWager) GetMsg() *types.MsgWager { +func (m *MsgWager) GetCreator() string { if m != nil { - return m.Msg + return m.Creator } - return nil + return "" +} + +func (m *MsgWager) GetTicket() string { + if m != nil { + return m.Ticket + } + return "" } // MsgWagerResponse wraps the MsgWagerResponse message. We need it in order not @@ -619,48 +624,44 @@ func init() { func init() { proto.RegisterFile("sge/subaccount/tx.proto", fileDescriptor_e042e836d366badb) } var fileDescriptor_e042e836d366badb = []byte{ - // 652 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xef, 0x6b, 0xd3, 0x40, - 0x18, 0x6e, 0xac, 0xfb, 0xf5, 0x4e, 0xdd, 0xbc, 0x6d, 0x2c, 0xc6, 0xd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0x86, 0x48, - 0x0c, 0x36, 0xb6, 0xff, 0x02, 0x1c, 0x5f, 0x59, 0xdb, 0x3b, 0xbb, 0x2c, 0x69, 0xe7, 0x97, 0x25, - 0xed, 0xf7, 0x65, 0x49, 0xfb, 0x72, 0x55, 0x2a, 0x9c, 0x5f, 0x95, 0x0a, 0x3f, 0xaf, 0x4a, 0x85, - 0x0f, 0x5b, 0xb4, 0x23, 0xda, 0xdd, 0x96, 0x65, 0x33, 0xb7, 0xc2, 0x29, 0xd9, 0x8a, 0x94, 0xc3, - 0xba, 0x72, 0xda, 0xf7, 0x32, 0x7f, 0xf6, 0x09, 0x6f, 0x4d, 0xca, 0x87, 0x72, 0xfb, 0x4f, 0x00, - 0x00, 0x00, 0xff, 0xff, 0xb8, 0x3d, 0xdf, 0xf4, 0xb8, 0x07, 0x00, 0x00, + // 585 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x95, 0x51, 0x6b, 0xd3, 0x50, + 0x14, 0xc7, 0x1b, 0x6b, 0xbb, 0xed, 0x4c, 0xdd, 0x8c, 0xc3, 0xc5, 0x28, 0xb1, 0x66, 0x13, 0xaa, + 0x73, 0x29, 0xb4, 0xa0, 0x2f, 0x22, 0x52, 0x37, 0xe6, 0x83, 0x7d, 0x29, 0x1b, 0x45, 0x11, 0x46, + 0x92, 0x5e, 0x6e, 0x4b, 0xbb, 0xdc, 0x98, 0x73, 0x4b, 0xe7, 0xb7, 0x50, 0x11, 0xfc, 0x4a, 0x7b, + 0xdc, 0xa3, 0x4f, 0x22, 0xed, 0x17, 0x91, 0xdc, 0x24, 0x77, 0x6d, 0x4a, 0xd3, 0x2a, 0xf8, 0x76, + 0xef, 0xcd, 0xff, 0xff, 0xbf, 0xbf, 0x73, 0xb8, 0x87, 0xc0, 0x36, 0x52, 0x52, 0xc1, 0x81, 0x63, + 0xbb, 0x2e, 0x1b, 0x78, 0xbc, 0xc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0xd8, 0xc3, 0x13, 0x6f, 0xda, + 0x32, 0x9f, 0xdf, 0x7c, 0x0c, 0x3b, 0x19, 0x46, 0x99, 0xff, 0x52, 0x34, 0xa3, 0x65, 0x53, 0x12, + 0x64, 0x34, 0xe3, 0x2e, 0x14, 0x79, 0xd7, 0xed, 0x11, 0x1e, 0xf7, 0x22, 0xde, 0x99, 0xc7, 0x82, + 0x58, 0xb8, 0x93, 0x44, 0xf5, 0x35, 0xac, 0x06, 0xf1, 0x5a, 0xc4, 0xac, 0x57, 0x77, 0xd3, 0x7d, + 0x71, 0x08, 0xb7, 0xd2, 0xbe, 0xa6, 0x74, 0x99, 0x87, 0xb0, 0xd1, 0x40, 0xfa, 0x36, 0x7c, 0x8a, + 0x07, 0xc4, 0x67, 0xd8, 0xe5, 0x6a, 0x15, 0xf2, 0x67, 0x48, 0xe3, 0xbc, 0x52, 0x3a, 0x4f, 0xbc, + 0xda, 0x30, 0x31, 0x96, 0x37, 0x43, 0xb1, 0x79, 0x0a, 0xdb, 0xa9, 0x18, 0xc9, 0x78, 0x30, 0xc3, + 0x58, 0x5e, 0x98, 0x39, 0xcb, 0x79, 0x24, 0xaa, 0x17, 0x17, 0x24, 0x7d, 0x56, 0x6b, 0x93, 0xa0, + 0x8f, 0xe6, 0x86, 0x26, 0xfa, 0x88, 0xd4, 0x06, 0x2d, 0x1d, 0x24, 0x51, 0x0f, 0x67, 0x50, 0x9f, + 0x2c, 0x4e, 0x9d, 0x61, 0xad, 0x7e, 0x2d, 0x40, 0xbe, 0x81, 0x54, 0xfd, 0x08, 0xc5, 0x78, 0x4a, + 0x77, 0x33, 0x5e, 0xab, 0x9c, 0x1a, 0xfd, 0xd9, 0x32, 0x2a, 0x09, 0xfb, 0x1e, 0x0a, 0xd1, 0x5c, + 0xed, 0x64, 0xdb, 0x84, 0x48, 0xdf, 0x5b, 0x42, 0x24, 0xa3, 0xbf, 0x29, 0xa0, 0xcd, 0x1d, 0x83, + 0xe7, 0xd9, 0x49, 0xf3, 0x7c, 0xfa, 0xab, 0x7f, 0xf3, 0x4d, 0xd6, 0x1b, 0x8d, 0xce, 0x82, 0x7a, + 0x85, 0x68, 0x51, 0xbd, 0xd3, 0x63, 0xe4, 0xc1, 0x8d, 0xa9, 0x09, 0x78, 0x9a, 0x6d, 0x9e, 0xd4, + 0xea, 0xd5, 0xe5, 0xb5, 0xf2, 0xbe, 0x4f, 0x70, 0x73, 0xfa, 0x25, 0xef, 0x2d, 0x11, 0x92, 0x88, + 0xf5, 0xda, 0x5f, 0x88, 0x93, 0x2b, 0xeb, 0x47, 0x17, 0x23, 0x43, 0xb9, 0x1c, 0x19, 0xca, 0xef, + 0x91, 0xa1, 0x7c, 0x19, 0x1b, 0xb9, 0xcb, 0xb1, 0x91, 0xfb, 0x39, 0x36, 0x72, 0x1f, 0xf6, 0x69, + 0x97, 0x77, 0x06, 0x8e, 0xe5, 0xb2, 0xb3, 0x0a, 0x52, 0xb2, 0x1f, 0x27, 0x87, 0xeb, 0xca, 0xf9, + 0xd4, 0x6f, 0xef, 0xb3, 0x4f, 0xd0, 0x29, 0x8a, 0xbf, 0x50, 0xed, 0x4f, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x83, 0xde, 0x93, 0x1d, 0x15, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1160,35 +1161,17 @@ func (m *MsgWager) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - { - size := m.SubaccDeductAmount.Size() - i -= size - if _, err := m.SubaccDeductAmount.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - { - size := m.MainaccDeductAmount.Size() - i -= size - if _, err := m.MainaccDeductAmount.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if m.Msg != nil { - { - size, err := m.Msg.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } + if len(m.Ticket) > 0 { + i -= len(m.Ticket) + copy(dAtA[i:], m.Ticket) + i = encodeVarintTx(dAtA, i, uint64(len(m.Ticket))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) i-- dAtA[i] = 0xa } @@ -1473,14 +1456,14 @@ func (m *MsgWager) Size() (n int) { } var l int _ = l - if m.Msg != nil { - l = m.Msg.Size() + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Ticket) + if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = m.MainaccDeductAmount.Size() - n += 1 + l + sovTx(uint64(l)) - l = m.SubaccDeductAmount.Size() - n += 1 + l + sovTx(uint64(l)) return n } @@ -2114,43 +2097,7 @@ func (m *MsgWager) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Msg", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Msg == nil { - m.Msg = &types.MsgWager{} - } - if err := m.Msg.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MainaccDeductAmount", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2178,13 +2125,11 @@ func (m *MsgWager) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.MainaccDeductAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Creator = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SubaccDeductAmount", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Ticket", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2212,9 +2157,7 @@ func (m *MsgWager) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.SubaccDeductAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Ticket = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex