diff --git a/proto/sge/reward/campaign.proto b/proto/sge/reward/campaign.proto index b9605ccd..1f4382c7 100644 --- a/proto/sge/reward/campaign.proto +++ b/proto/sge/reward/campaign.proto @@ -54,13 +54,12 @@ message Campaign { // is_active is the flag to check if the campaign is active or not. bool is_active = 11; - // claims_per_category is the number of times a user can claim a - // reward for category of this campaign. - uint64 claims_per_category = 12; - // meta is the metadata of the campaign. // It is a stringified base64 encoded json. string meta = 13; + + // cap_count is the maximum allowed grant for a certain account. + uint64 cap_count = 14; } // Pool tracks funds assigned and spent to/for a campaign. diff --git a/proto/sge/reward/genesis.proto b/proto/sge/reward/genesis.proto index 937a59bb..58b8568b 100644 --- a/proto/sge/reward/genesis.proto +++ b/proto/sge/reward/genesis.proto @@ -6,6 +6,7 @@ import "gogoproto/gogo.proto"; import "sge/reward/params.proto"; import "sge/reward/campaign.proto"; import "sge/reward/reward.proto"; +import "sge/reward/promoter.proto"; option go_package = "github.com/sge-network/sge/x/reward/types"; @@ -18,4 +19,8 @@ message GenesisState { [ (gogoproto.nullable) = false ]; repeated RewardByCampaign reward_by_campaign_list = 5 [ (gogoproto.nullable) = false ]; + repeated Promoter promoter_list = 6 + [ (gogoproto.nullable) = false ]; + repeated PromoterByAddress promoter_by_address_list = 7 + [ (gogoproto.nullable) = false ]; } diff --git a/proto/sge/reward/promoter.proto b/proto/sge/reward/promoter.proto new file mode 100644 index 00000000..3b717c91 --- /dev/null +++ b/proto/sge/reward/promoter.proto @@ -0,0 +1,51 @@ +syntax = "proto3"; +package sgenetwork.sge.reward; + +import "gogoproto/gogo.proto"; + +import "sge/reward/reward.proto"; + +option go_package = "github.com/sge-network/sge/x/reward/types"; + +// Promoter is type for defining the reward promoter properties and configuration. +message Promoter { + // creator is the address of promoter. + string creator = 1; + + // uid is the unique identifier of a promoter. + string uid = 2 [ + (gogoproto.customname) = "UID", + (gogoproto.jsontag) = "uid", + json_name = "uid" + ]; + + // addresses is the list of account addresses of promoter. + repeated string addresses = 3; + + // conf is the configurations of the current promoter for the reward grant. + PromoterConf conf = 4 [ (gogoproto.nullable) = false ]; +} + +// PromoterConf is type for defining the promoter specific configurations. +message PromoterConf { + // category_cap is the maximium allowed cap for each category. + repeated CategoryCap category_cap = 1 [ (gogoproto.nullable) = false ]; +} + +// CategoryCap is type to define category and its maximum cap. +message CategoryCap { + RewardCategory category = 1; + int32 cap_per_acc = 2; +} + +// PromoterByAddress is type for defining the promoter by address. +message PromoterByAddress { + // promoter_uid is the unique identifier of a certain promoter. + string promoter_uid = 1 [ + (gogoproto.customname) = "PromoterUID", + (gogoproto.jsontag) = "promoter_uid", + json_name = "promoter_uid" + ]; + // address is the address of the promoter account. + string address = 2; +} \ No newline at end of file diff --git a/proto/sge/reward/query.proto b/proto/sge/reward/query.proto index 106e86af..12921ea4 100644 --- a/proto/sge/reward/query.proto +++ b/proto/sge/reward/query.proto @@ -42,7 +42,7 @@ service Query { // Queries list of all Reward items by user address. rpc RewardsByAddress(QueryRewardsByAddressRequest) returns (QueryRewardsByAddressResponse) { - option (google.api.http).get = "/sge-network/sge/reward/rewards/{address}"; + option (google.api.http).get = "/sge-network/sge/reward/rewards/{promoter_uid}/{address}"; } // Queries list of all Reward items by user address and reward type @@ -50,7 +50,7 @@ service Query { rpc RewardsByAddressAndCategory(QueryRewardsByAddressAndCategoryRequest) returns (QueryRewardsByAddressAndCategoryResponse) { option (google.api.http).get = - "/sge-network/sge/reward/rewards/{address}/{category}"; + "/sge-network/sge/reward/rewards/{promoter_uid}/{address}/{category}"; } // Queries list of all Reward items by campaign endpoint. @@ -114,6 +114,7 @@ message QueryRewardsResponse { message QueryRewardsByAddressRequest { cosmos.base.query.v1beta1.PageRequest pagination = 1; string address = 2; + string promoter_uid = 3; } // QueryRewardsByAddressResponse is response body of the query all rewards by @@ -129,6 +130,7 @@ message QueryRewardsByAddressAndCategoryRequest { cosmos.base.query.v1beta1.PageRequest pagination = 1; string address = 2; RewardCategory category = 3; + string promoter_uid = 4; } // QueryRewardsByAddressAndCategoryResponse is response body of the query all diff --git a/proto/sge/reward/ticket.proto b/proto/sge/reward/ticket.proto index b9a58795..9f92b0f7 100644 --- a/proto/sge/reward/ticket.proto +++ b/proto/sge/reward/ticket.proto @@ -4,6 +4,7 @@ package sgenetwork.sge.reward; import "gogoproto/gogo.proto"; import "sge/type/kyc.proto"; import "sge/reward/reward.proto"; +import "sge/reward/promoter.proto"; option go_package = "github.com/sge-network/sge/x/reward/types"; @@ -34,13 +35,12 @@ message CreateCampaignPayload { // is_active is the flag to check if the campaign is active or not. bool is_active = 8; - // claims_per_category is the number of times a user can claim a reward for - // category of this campaign. - uint64 claims_per_category = 9; - // meta is the metadata of the campaign. // It is a stringified base64 encoded json. string meta = 10; + + // cap_count is the maximum allowed grant for a certain account. + uint64 cap_count = 11; } // UpdateCampaignPayload is the type for campaign update payload. @@ -109,4 +109,23 @@ message GrantSignupAffiliatorRewardPayload { // affiliatee is the address of the account that used this affiliator's // address as source_uid string affiliatee = 2; +} + +// GrantBetBonusRewardPayload is the type for bet bonus reward +// grant payload. +message GrantBetBonusRewardPayload { + // common is the common properties of a reward + RewardPayloadCommon common = 1 [ (gogoproto.nullable) = false ]; + + // bet_uid is the list of uids + string bet_uid = 2 [ + (gogoproto.customname) = "BetUID", + (gogoproto.jsontag) = "bet_uid", + json_name = "bet_uid" + ]; +} + +// SetPromoterConfPayload is the payload for the promoter configuration change. +message SetPromoterConfPayload { + PromoterConf conf = 1 [ (gogoproto.nullable) = false ]; } \ No newline at end of file diff --git a/proto/sge/reward/tx.proto b/proto/sge/reward/tx.proto index 5570ce8d..a7760dab 100644 --- a/proto/sge/reward/tx.proto +++ b/proto/sge/reward/tx.proto @@ -8,6 +8,8 @@ option go_package = "github.com/sge-network/sge/x/reward/types"; // Msg defines the Msg service. service Msg { + // SetPromoterConf is a method to set the configurations of a promoter. + rpc SetPromoterConf(MsgSetPromoterConf) returns (MsgSetPromoterConfResponse); // CreateCampaign is a method to create a campaign rpc CreateCampaign(MsgCreateCampaign) returns (MsgCreateCampaignResponse); // UpdateCampaign is a method to update campaign @@ -18,6 +20,19 @@ service Msg { rpc GrantReward(MsgGrantReward) returns (MsgGrantRewardResponse); } +// MsgSetPromoterConf is msg to set promoter configuration. +message MsgSetPromoterConf { + // creator is the address of message signer account. + string creator = 1; + // uid is the unique identifier of the promoter. + string uid = 2; + // ticket is the payload data. + string ticket = 3; +} + +// MsgCreateCampaignResponse campaign create message response type. +message MsgSetPromoterConfResponse {} + // MsgCreateCampaign is msg to create a reward campaign message MsgCreateCampaign { // creator is the address of campaign creator account. diff --git a/x/reward/client/cli/tx.go b/x/reward/client/cli/tx.go index bf7131ab..f4aec33a 100644 --- a/x/reward/client/cli/tx.go +++ b/x/reward/client/cli/tx.go @@ -24,6 +24,7 @@ func GetTxCmd() *cobra.Command { RunE: client.ValidateCmd, } + cmd.AddCommand(CmdSetPromoterConf()) cmd.AddCommand(CmdCreateCampaign()) cmd.AddCommand(CmdUpdateCampaign()) cmd.AddCommand(CmdWithdrawFunds()) diff --git a/x/reward/client/cli/tx_promoter.go b/x/reward/client/cli/tx_promoter.go new file mode 100644 index 00000000..be0286fe --- /dev/null +++ b/x/reward/client/cli/tx_promoter.go @@ -0,0 +1,46 @@ +package cli + +import ( + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + + "github.com/sge-network/sge/x/reward/types" +) + +func CmdSetPromoterConf() *cobra.Command { + cmd := &cobra.Command{ + Use: "set-promoter-conf [uid] [ticket]", + Short: "Set promoter config", + Long: "Set promoter config of a promoter by uid and the ticket", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) (err error) { + // Get indexes + argUID := args[0] + + // Get value arguments + argTicket := args[1] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgSetPromoterConfig( + clientCtx.GetFromAddress().String(), + argUID, + argTicket, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/reward/genesis.go b/x/reward/genesis.go index b841832b..8a1d7b49 100644 --- a/x/reward/genesis.go +++ b/x/reward/genesis.go @@ -1,6 +1,8 @@ package reward import ( + "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/sge-network/sge/x/reward/keeper" @@ -9,6 +11,12 @@ import ( // InitGenesis initializes the module's state from a provided genesis state. func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + for _, elem := range genState.PromoterList { + k.SetPromoter(ctx, elem) + } + for _, elem := range genState.PromoterByAddressList { + k.SetPromoterByAddress(ctx, elem) + } // Set all the campaign for _, elem := range genState.CampaignList { k.SetCampaign(ctx, elem) @@ -17,7 +25,19 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) k.SetReward(ctx, elem) } for _, elem := range genState.RewardByCategoryList { - k.SetRewardByReceiver(ctx, elem) + reward, found := k.GetReward(ctx, elem.UID) + if !found { + panic(fmt.Errorf("reward is not valid %s", elem.UID)) + } + camp, found := k.GetCampaign(ctx, reward.CampaignUID) + if !found { + panic(fmt.Errorf("campaign is not valid %s", reward.CampaignUID)) + } + promoter, found := k.GetPromoterByAddress(ctx, camp.Promoter) + if !found { + panic(fmt.Errorf("promoter is not valid %s", camp.Promoter)) + } + k.SetRewardOfReceiverByPromoterAndCategory(ctx, promoter.PromoterUID, elem) } for _, elem := range genState.RewardByCampaignList { k.SetRewardByCampaign(ctx, elem) diff --git a/x/reward/genesis_test.go b/x/reward/genesis_test.go index 497fbc5b..590bf851 100644 --- a/x/reward/genesis_test.go +++ b/x/reward/genesis_test.go @@ -13,39 +13,75 @@ import ( ) func TestGenesis(t *testing.T) { + promoterAddr := "promoter" + promoterUID := uuid.NewString() + + campaignUID1 := uuid.NewString() + campaignUID2 := uuid.NewString() + + rewardID1 := uuid.NewString() + rewardID2 := uuid.NewString() + genesisState := types.GenesisState{ Params: types.DefaultParams(), + PromoterList: []types.Promoter{ + { + Creator: promoterAddr, + UID: promoterUID, + Addresses: []string{promoterAddr}, + Conf: types.PromoterConf{ + CategoryCap: []types.CategoryCap{ + { + Category: types.RewardCategory_REWARD_CATEGORY_SIGNUP, + CapPerAcc: 1, + }, + }, + }, + }, + }, + PromoterByAddressList: []types.PromoterByAddress{ + { + PromoterUID: promoterUID, + Address: promoterAddr, + }, + }, CampaignList: []types.Campaign{ { - UID: uuid.NewString(), + UID: campaignUID1, + Promoter: promoterAddr, }, { - UID: uuid.NewString(), + UID: campaignUID2, + Promoter: promoterAddr, }, }, RewardList: []types.Reward{ { - UID: uuid.NewString(), + UID: rewardID1, + CampaignUID: campaignUID1, }, { - UID: uuid.NewString(), + UID: rewardID2, + CampaignUID: campaignUID2, }, }, RewardByCategoryList: []types.RewardByCategory{ { - UID: uuid.NewString(), + UID: rewardID1, }, { - UID: uuid.NewString(), + UID: rewardID2, }, }, RewardByCampaignList: []types.RewardByCampaign{ { - UID: uuid.NewString(), + UID: rewardID1, + CampaignUID: campaignUID1, }, { - UID: uuid.NewString(), + UID: rewardID1, + CampaignUID: campaignUID2, }, }, } diff --git a/x/reward/keeper/campaign.go b/x/reward/keeper/campaign.go index 7fe23843..c894a927 100644 --- a/x/reward/keeper/campaign.go +++ b/x/reward/keeper/campaign.go @@ -10,9 +10,7 @@ import ( func (k Keeper) SetCampaign(ctx sdk.Context, campaign types.Campaign) { store := k.getCampaignStore(ctx) b := k.cdc.MustMarshal(&campaign) - store.Set(types.GetCampaignKey( - campaign.UID, - ), b) + store.Set(types.GetCampaignKey(campaign.UID), b) } // GetCampaign returns a campaign from its index diff --git a/x/reward/keeper/msg_server_campaign.go b/x/reward/keeper/msg_server_campaign.go index a88c82e5..feefadbe 100644 --- a/x/reward/keeper/msg_server_campaign.go +++ b/x/reward/keeper/msg_server_campaign.go @@ -53,7 +53,7 @@ func (k msgServer) CreateCampaign(goCtx context.Context, msg *types.MsgCreateCam campaign := types.NewCampaign( msg.Creator, payload.Promoter, msg.Uid, - payload.StartTs, payload.EndTs, payload.ClaimsPerCategory, + payload.StartTs, payload.EndTs, payload.RewardType, payload.Category, payload.RewardAmountType, @@ -61,6 +61,7 @@ func (k msgServer) CreateCampaign(goCtx context.Context, msg *types.MsgCreateCam payload.IsActive, payload.Meta, types.NewPool(msg.TotalFunds), + payload.CapCount, ) rewardFactory, err := campaign.GetRewardsFactory() diff --git a/x/reward/keeper/msg_server_promoter.go b/x/reward/keeper/msg_server_promoter.go new file mode 100644 index 00000000..9fcaa4bb --- /dev/null +++ b/x/reward/keeper/msg_server_promoter.go @@ -0,0 +1,48 @@ +package keeper + +import ( + "context" + + sdkerrors "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrtypes "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/sge-network/sge/x/reward/types" +) + +func (k msgServer) SetPromoterConf(goCtx context.Context, msg *types.MsgSetPromoterConf) (*types.MsgSetPromoterConfResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // Check if the value already exists + promoter, isFound := k.GetPromoter(ctx, msg.Uid) + if !isFound { + return nil, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "promoter does not exist %s", msg.Uid) + } + + creatorIsPromoter := false + for _, p := range promoter.Addresses { + if p == msg.Creator { + creatorIsPromoter = true + } + } + + if !creatorIsPromoter { + return nil, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "creator should be one of stored addresses in promoter") + } + + var payload types.SetPromoterConfPayload + if err := k.ovmKeeper.VerifyTicketUnmarshal(goCtx, msg.Ticket, &payload); err != nil { + return nil, sdkerrors.Wrapf(types.ErrInTicketVerification, "%s", err) + } + + if err := payload.Validate(); err != nil { + return nil, err + } + + promoter.Conf = payload.Conf + + k.SetPromoter(ctx, promoter) + + msg.EmitEvent(&ctx, promoter.Conf) + + return &types.MsgSetPromoterConfResponse{}, nil +} diff --git a/x/reward/keeper/msg_server_promoter_test.go b/x/reward/keeper/msg_server_promoter_test.go new file mode 100644 index 00000000..5ce13fe2 --- /dev/null +++ b/x/reward/keeper/msg_server_promoter_test.go @@ -0,0 +1,116 @@ +package keeper_test + +import ( + "testing" + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/golang-jwt/jwt" + "github.com/google/uuid" + "github.com/sge-network/sge/testutil/simapp" + "github.com/stretchr/testify/require" + + "github.com/sge-network/sge/x/reward/keeper" + "github.com/sge-network/sge/x/reward/types" +) + +func TestSetPromoterConfig(t *testing.T) { + k, ctx := setupKeeper(t) + srv := keeper.NewMsgServerImpl(*k) + ctx = ctx.WithBlockTime(time.Now()) + wctx := sdk.WrapSDKContext(ctx) + promoter := simapp.TestParamUsers["user1"].Address.String() + promoterUID := uuid.NewString() + k.SetPromoter(ctx, types.Promoter{ + Creator: promoter, + UID: promoterUID, + Addresses: []string{ + promoter, + }, + Conf: types.PromoterConf{ + CategoryCap: []types.CategoryCap{ + { + Category: types.RewardCategory_REWARD_CATEGORY_SIGNUP, + CapPerAcc: 1, + }, + }, + }, + }) + + for _, tc := range []struct { + desc string + claims jwt.MapClaims + uid string + err error + }{ + { + desc: "invalid ticket", + claims: jwt.MapClaims{ + "exp": time.Now().Add(time.Minute * 5).Unix(), + "iat": time.Now().Unix(), + "conf": "invalid", + }, + uid: promoterUID, + err: types.ErrInTicketVerification, + }, + { + desc: "duplicate cap category", + claims: jwt.MapClaims{ + "exp": time.Now().Add(time.Minute * 5).Unix(), + "iat": time.Now().Unix(), + "conf": types.PromoterConf{ + CategoryCap: []types.CategoryCap{ + {Category: types.RewardCategory_REWARD_CATEGORY_SIGNUP, CapPerAcc: 1}, + {Category: types.RewardCategory_REWARD_CATEGORY_SIGNUP, CapPerAcc: 1}, + }, + }, + }, + uid: promoterUID, + err: types.ErrDuplicateCategoryInConf, + }, + { + desc: "low cap category", + claims: jwt.MapClaims{ + "exp": time.Now().Add(time.Minute * 5).Unix(), + "iat": time.Now().Unix(), + "conf": types.PromoterConf{ + CategoryCap: []types.CategoryCap{ + {Category: types.RewardCategory_REWARD_CATEGORY_SIGNUP, CapPerAcc: 0}, + {Category: types.RewardCategory_REWARD_CATEGORY_AFFILIATE, CapPerAcc: 1}, + }, + }, + }, + uid: promoterUID, + err: types.ErrCategoryCapShouldBePos, + }, + { + desc: "valid", + claims: jwt.MapClaims{ + "exp": time.Now().Add(time.Minute * 5).Unix(), + "iat": time.Now().Unix(), + "conf": types.PromoterConf{ + CategoryCap: []types.CategoryCap{ + {Category: types.RewardCategory_REWARD_CATEGORY_SIGNUP, CapPerAcc: 1}, + }, + }, + }, + uid: promoterUID, + }, + } { + t.Run(tc.desc, func(t *testing.T) { + ticket, err := simapp.CreateJwtTicket(tc.claims) + require.Nil(t, err) + conf := &types.MsgSetPromoterConf{ + Uid: tc.uid, + Creator: promoter, + Ticket: ticket, + } + _, err = srv.SetPromoterConf(wctx, conf) + if tc.err != nil { + require.ErrorContains(t, err, tc.err.Error()) + } else { + require.NoError(t, err) + } + }) + } +} diff --git a/x/reward/keeper/msg_server_reward.go b/x/reward/keeper/msg_server_reward.go index 6a7b9e5c..a649b9a4 100644 --- a/x/reward/keeper/msg_server_reward.go +++ b/x/reward/keeper/msg_server_reward.go @@ -48,12 +48,40 @@ func (k msgServer) GrantReward(goCtx context.Context, msg *types.MsgGrantReward) return nil, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "distribution calculation failed %s", err) } - rewards, err := k.GetRewardsByAddressAndCategory(ctx, factData.Receiver.MainAccountAddr, campaign.RewardCategory) + var grantStats uint64 + if campaign.CapCount > 0 { + grantStats, isFound = k.GetRewardGrantsStats(ctx, msg.CampaignUid, factData.Receiver.MainAccountAddr) + if !isFound { + grantStats = 0 + } + if grantStats >= campaign.CapCount { + return nil, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "maximum count cap of the campaign is reached %d", grantStats) + } + + grantStats++ + k.SetRewardGrantsStats(ctx, msg.CampaignUid, factData.Receiver.MainAccountAddr, grantStats) + } + + promoterByAddress, isFound := k.GetPromoterByAddress(ctx, campaign.Promoter) + if !isFound { + return nil, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "promoter with the address: %s not found", campaign.Promoter) + } + promoter, isFound := k.GetPromoter(ctx, promoterByAddress.PromoterUID) + if !isFound { + return nil, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "promoter with the uid: %s not found", promoterByAddress.PromoterUID) + } + + rewards, err := k.GetRewardsOfReceiverByPromoterAndCategory(ctx, promoter.UID, factData.Receiver.MainAccountAddr, campaign.RewardCategory) if err != nil { return nil, sdkerrors.Wrap(sdkerrtypes.ErrInvalidRequest, "failed to retrieve rewards for user.") } - if len(rewards) >= cast.ToInt(campaign.ClaimsPerCategory) { - return nil, sdkerrors.Wrap(sdkerrtypes.ErrInvalidRequest, "maximum rewards claimed for the given category.") + + for _, c := range promoter.Conf.CategoryCap { + if c.Category == campaign.RewardCategory { + if len(rewards) >= cast.ToInt(c.CapPerAcc) { + return nil, sdkerrors.Wrap(sdkerrtypes.ErrInvalidRequest, "maximum rewards claimed for the given category.") + } + } } if err := campaign.CheckPoolBalance(factData.Receiver.SubAccountAmount.Add(factData.Receiver.MainAccountAmount)); err != nil { @@ -72,7 +100,8 @@ func (k msgServer) GrantReward(goCtx context.Context, msg *types.MsgGrantReward) factData.Common.SourceUID, factData.Common.Meta, )) - k.SetRewardByReceiver(ctx, types.NewRewardByCategory(msg.Uid, factData.Receiver.MainAccountAddr, campaign.RewardCategory)) + + k.SetRewardOfReceiverByPromoterAndCategory(ctx, promoter.UID, types.NewRewardByCategory(msg.Uid, factData.Receiver.MainAccountAddr, campaign.RewardCategory)) k.SetRewardByCampaign(ctx, types.NewRewardByCampaign(msg.Uid, campaign.UID)) msg.EmitEvent(&ctx, msg.CampaignUid, msg.Uid, campaign.Promoter, *campaign.RewardAmount, factData.Receiver, unlockTS) diff --git a/x/reward/keeper/msg_server_reward_test.go b/x/reward/keeper/msg_server_reward_test.go index ad75745c..bc3134b4 100644 --- a/x/reward/keeper/msg_server_reward_test.go +++ b/x/reward/keeper/msg_server_reward_test.go @@ -20,6 +20,12 @@ import ( subaccounttypes "github.com/sge-network/sge/x/subaccount/types" ) +var promoterUID = uuid.NewString() + +var defaultCategoryCap = []types.CategoryCap{ + {Category: types.RewardCategory_REWARD_CATEGORY_SIGNUP, CapPerAcc: 1}, +} + func getDefaultClaim(creator string) jwt.MapClaims { return jwt.MapClaims{ "exp": time.Now().Add(time.Minute * 5).Unix(), @@ -35,8 +41,23 @@ func getDefaultClaim(creator string) jwt.MapClaims { } func createCampaign(t *testing.T, k *keeper.Keeper, srv types.MsgServer, ctx sdk.Context, - promoter string, claims jwt.MapClaims, + promoter string, claims jwt.MapClaims, categoryCap []types.CategoryCap, ) string { + k.SetPromoter(ctx, types.Promoter{ + Creator: promoter, + UID: promoterUID, + Addresses: []string{promoter}, + Conf: types.PromoterConf{ + CategoryCap: categoryCap, + }, + }) + + k.SetPromoterByAddress(ctx, + types.PromoterByAddress{ + Address: promoter, + PromoterUID: promoterUID, + }) + ticket, err := simapp.CreateJwtTicket(claims) require.Nil(t, err) @@ -81,7 +102,7 @@ func TestMsgApplySignupReward(t *testing.T) { UnlockPeriod: uint64(ctx.BlockTime().Add(10 * time.Minute).Unix()), } - campUID := createCampaign(t, k, srv, ctx, promoter, campClaims) + campUID := createCampaign(t, k, srv, ctx, promoter, campClaims, defaultCategoryCap) for _, tc := range []struct { desc string @@ -133,6 +154,62 @@ func TestMsgApplySignupReward(t *testing.T) { } } +func TestMsgApplySignupRewardWithCap(t *testing.T) { + tApp, k, ctx := setupKeeperAndApp(t) + srv := keeper.NewMsgServerImpl(*k) + ctx = ctx.WithBlockTime(time.Now()) + wctx := sdk.WrapSDKContext(ctx) + + promoter := simapp.TestParamUsers["user1"].Address.String() + receiverAddr := simapp.TestParamUsers["user2"].Address.String() + + _, err := tApp.SubaccountKeeper.CreateSubAccount(ctx, receiverAddr, receiverAddr, []subaccounttypes.LockedBalance{ + { + Amount: sdk.ZeroInt(), + UnlockTS: uint64(ctx.BlockTime().Add(60 * time.Minute).Unix()), + }, + }) + require.NoError(t, err) + + campClaims := getDefaultClaim(promoter) + campClaims["reward_type"] = types.RewardType_REWARD_TYPE_SIGNUP + campClaims["reward_amount_type"] = types.RewardAmountType_REWARD_AMOUNT_TYPE_FIXED + campClaims["reward_amount"] = types.RewardAmount{ + SubaccountAmount: sdkmath.NewInt(100), + UnlockPeriod: uint64(ctx.BlockTime().Add(10 * time.Minute).Unix()), + } + campClaims["cap_count"] = 1 + + campUID := createCampaign(t, k, srv, ctx, promoter, campClaims, []types.CategoryCap{}) + + ticket, err := simapp.CreateJwtTicket(jwt.MapClaims{ + "exp": time.Now().Add(time.Minute * 5).Unix(), + "iat": time.Now().Unix(), + "common": types.RewardPayloadCommon{ + Receiver: receiverAddr, + SourceUID: "", + Meta: "signup reward for example user", + KycData: &sgetypes.KycDataPayload{ + Approved: true, + ID: receiverAddr, + }, + }, + }) + require.Nil(t, err) + reward := &types.MsgGrantReward{ + Uid: uuid.NewString(), + Creator: promoter, + CampaignUid: campUID, + Ticket: ticket, + } + _, err = srv.GrantReward(wctx, reward) + require.NoError(t, err) + + reward.Uid = uuid.NewString() + _, err = srv.GrantReward(wctx, reward) + require.ErrorContains(t, err, "maximum count cap of the campaign is reached") +} + func TestMsgApplySignupRefereeReward(t *testing.T) { tApp, k, ctx := setupKeeperAndApp(t) srv := keeper.NewMsgServerImpl(*k) @@ -160,7 +237,7 @@ func TestMsgApplySignupRefereeReward(t *testing.T) { UnlockPeriod: uint64(ctx.BlockTime().Add(10 * time.Minute).Unix()), } - campUID := createCampaign(t, k, srv, ctx, promoter, campClaims) + campUID := createCampaign(t, k, srv, ctx, promoter, campClaims, defaultCategoryCap) for _, tc := range []struct { desc string @@ -253,7 +330,7 @@ func TestMsgApplySignupReferrerReward(t *testing.T) { SubaccountAmount: sdkmath.NewInt(100), UnlockPeriod: uint64(ctx.BlockTime().Add(10 * time.Minute).Unix()), } - referralSignupCampUID := createCampaign(t, k, srv, ctx, promoter, referralSignupCampClaims) + referralSignupCampUID := createCampaign(t, k, srv, ctx, promoter, referralSignupCampClaims, defaultCategoryCap) // referral campaign referralCampClaims := getDefaultClaim(promoter) @@ -264,7 +341,7 @@ func TestMsgApplySignupReferrerReward(t *testing.T) { SubaccountAmount: sdkmath.NewInt(100), UnlockPeriod: uint64(ctx.BlockTime().Add(10 * time.Minute).Unix()), } - referralCampUID := createCampaign(t, k, srv, ctx, promoter, referralCampClaims) + referralCampUID := createCampaign(t, k, srv, ctx, promoter, referralCampClaims, defaultCategoryCap) refereeClaims := jwt.MapClaims{ "exp": time.Now().Add(time.Minute * 5).Unix(), @@ -290,7 +367,7 @@ func TestMsgApplySignupReferrerReward(t *testing.T) { _, err = srv.GrantReward(wctx, reward) require.NoError(t, err) - rewardGrant, err := k.GetRewardsByAddressAndCategory(ctx, referee, types.RewardCategory_REWARD_CATEGORY_SIGNUP) + rewardGrant, err := k.GetRewardsOfReceiverByPromoterAndCategory(ctx, promoterUID, referee, types.RewardCategory_REWARD_CATEGORY_SIGNUP) require.NoError(t, err) require.Equal(t, types.RewardByCategory{ UID: reward.Uid, @@ -298,7 +375,7 @@ func TestMsgApplySignupReferrerReward(t *testing.T) { RewardCategory: types.RewardCategory_REWARD_CATEGORY_SIGNUP, }, rewardGrant[0]) - require.True(t, k.HasRewardByReceiver(ctx, referee, types.RewardCategory_REWARD_CATEGORY_SIGNUP)) + require.True(t, k.HasRewardOfReceiverByPromoter(ctx, promoterUID, referee, types.RewardCategory_REWARD_CATEGORY_SIGNUP)) for _, tc := range []struct { desc string @@ -392,7 +469,7 @@ func TestMsgApplySignupAffiliateReward(t *testing.T) { UnlockPeriod: uint64(ctx.BlockTime().Add(10 * time.Minute).Unix()), } - campUID := createCampaign(t, k, srv, ctx, promoter, campClaims) + campUID := createCampaign(t, k, srv, ctx, promoter, campClaims, defaultCategoryCap) for _, tc := range []struct { desc string @@ -485,7 +562,7 @@ func TestMsgApplySignupAffiliateeReward(t *testing.T) { SubaccountAmount: sdkmath.NewInt(100), UnlockPeriod: uint64(ctx.BlockTime().Add(10 * time.Minute).Unix()), } - affiliateSignupCampUID := createCampaign(t, k, srv, ctx, promoter, affiliateSignupCampClaims) + affiliateSignupCampUID := createCampaign(t, k, srv, ctx, promoter, affiliateSignupCampClaims, defaultCategoryCap) // affiliate campaign affiliateCampClaims := getDefaultClaim(promoter) @@ -496,7 +573,7 @@ func TestMsgApplySignupAffiliateeReward(t *testing.T) { MainAccountAmount: sdkmath.NewInt(100), UnlockPeriod: 0, } - affiliateCampUID := createCampaign(t, k, srv, ctx, promoter, affiliateCampClaims) + affiliateCampUID := createCampaign(t, k, srv, ctx, promoter, affiliateCampClaims, defaultCategoryCap) affiliateClaims := jwt.MapClaims{ "exp": time.Now().Add(time.Minute * 5).Unix(), @@ -522,7 +599,7 @@ func TestMsgApplySignupAffiliateeReward(t *testing.T) { _, err = srv.GrantReward(wctx, reward) require.NoError(t, err) - rewardGrant, err := k.GetRewardsByAddressAndCategory(ctx, affiliatee, types.RewardCategory_REWARD_CATEGORY_SIGNUP) + rewardGrant, err := k.GetRewardsOfReceiverByPromoterAndCategory(ctx, promoterUID, affiliatee, types.RewardCategory_REWARD_CATEGORY_SIGNUP) require.NoError(t, err) require.Equal(t, types.RewardByCategory{ UID: reward.Uid, @@ -530,7 +607,7 @@ func TestMsgApplySignupAffiliateeReward(t *testing.T) { RewardCategory: types.RewardCategory_REWARD_CATEGORY_SIGNUP, }, rewardGrant[0]) - require.True(t, k.HasRewardByReceiver(ctx, affiliatee, types.RewardCategory_REWARD_CATEGORY_SIGNUP)) + require.True(t, k.HasRewardOfReceiverByPromoter(ctx, promoterUID, affiliatee, types.RewardCategory_REWARD_CATEGORY_SIGNUP)) for _, tc := range []struct { desc string @@ -614,7 +691,7 @@ func TestMsgApplySignupRewardSubAcc(t *testing.T) { UnlockPeriod: uint64(ctx.BlockTime().Add(10 * time.Minute).Unix()), } - campUID := createCampaign(t, k, srv, ctx, promoter, campClaims) + campUID := createCampaign(t, k, srv, ctx, promoter, campClaims, defaultCategoryCap) _, err := tApp.SubaccountKeeper.CreateSubAccount(ctx, receiverAddr, receiverAddr, []subaccounttypes.LockedBalance{ { @@ -729,7 +806,7 @@ func TestMsgApplySubAccFunds(t *testing.T) { UnlockPeriod: uint64(ctx.BlockTime().Add(10 * time.Minute).Unix()), } - campUID := createCampaign(t, k, srv, ctx, promoter, campClaims) + campUID := createCampaign(t, k, srv, ctx, promoter, campClaims, defaultCategoryCap) claims := jwt.MapClaims{ "exp": time.Now().Add(time.Minute * 5).Unix(), diff --git a/x/reward/keeper/promoter.go b/x/reward/keeper/promoter.go new file mode 100644 index 00000000..c43b8350 --- /dev/null +++ b/x/reward/keeper/promoter.go @@ -0,0 +1,65 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/sge-network/sge/x/reward/types" +) + +// SetPromoter set a specific promoter in the store from its index +func (k Keeper) SetPromoter(ctx sdk.Context, promoter types.Promoter) { + store := k.getPromoterStore(ctx) + b := k.cdc.MustMarshal(&promoter) + store.Set(types.GetPromoterKey(promoter.UID), b) +} + +// GetPromoter returns a promoter, +func (k Keeper) GetPromoter( + ctx sdk.Context, + uid string, +) (val types.Promoter, found bool) { + store := k.getPromoterStore(ctx) + + b := store.Get(types.GetPromoterKey(uid)) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +// GetAllPromoter returns all promoters +func (k Keeper) GetAllPromoter(ctx sdk.Context) (list []types.Promoter) { + store := k.getPromoterStore(ctx) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.Promoter + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} + +// SetPromoterByAddress set a specific promoter in the store from its address +func (k Keeper) SetPromoterByAddress(ctx sdk.Context, promoterByAddress types.PromoterByAddress) { + store := k.getPromoterByAddressStore(ctx) + b := k.cdc.MustMarshal(&promoterByAddress) + store.Set(types.GetPromoterByAddressKey(promoterByAddress.Address), b) +} + +// GetPromoter returns a promoter, +func (k Keeper) GetPromoterByAddress(ctx sdk.Context, address string) (val types.PromoterByAddress, found bool) { + store := k.getPromoterByAddressStore(ctx) + + b := store.Get(types.GetPromoterByAddressKey(address)) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} diff --git a/x/reward/keeper/query_reward.go b/x/reward/keeper/query_reward.go index c1d2545e..8ea7acba 100644 --- a/x/reward/keeper/query_reward.go +++ b/x/reward/keeper/query_reward.go @@ -64,7 +64,7 @@ func (k Keeper) RewardsByAddress(goCtx context.Context, req *types.QueryRewardsB ctx := sdk.UnwrapSDKContext(goCtx) store := k.getRewardByReceiverAndCategoryStore(ctx) - rewardStore := prefix.NewStore(store, types.GetRewardsByAccPrefix(req.Address)) + rewardStore := prefix.NewStore(store, types.GetRewardsOfReceiverByPromoterPrefix(req.PromoterUid, req.Address)) pageRes, err := query.Paginate(rewardStore, req.Pagination, func(key []byte, value []byte) error { var reward types.RewardByCategory @@ -91,7 +91,7 @@ func (k Keeper) RewardsByAddressAndCategory(goCtx context.Context, req *types.Qu ctx := sdk.UnwrapSDKContext(goCtx) store := k.getRewardByReceiverAndCategoryStore(ctx) - rewardStore := prefix.NewStore(store, types.GetRewardsByCategoryPrefix(req.Address, req.Category)) + rewardStore := prefix.NewStore(store, types.GetRewardsOfReceiverByPromoterAndCategoryPrefix(req.PromoterUid, req.Address, req.Category)) pageRes, err := query.Paginate(rewardStore, req.Pagination, func(key []byte, value []byte) error { var reward types.RewardByCategory diff --git a/x/reward/keeper/reward.go b/x/reward/keeper/reward.go index 48a4151e..28473a72 100644 --- a/x/reward/keeper/reward.go +++ b/x/reward/keeper/reward.go @@ -2,6 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/sge-network/sge/utils" "github.com/sge-network/sge/x/reward/types" ) @@ -53,20 +54,20 @@ func (k Keeper) GetAllRewards(ctx sdk.Context) (list []types.Reward) { return } -func (k Keeper) SetRewardByReceiver(ctx sdk.Context, rByCategory types.RewardByCategory) { +func (k Keeper) SetRewardOfReceiverByPromoterAndCategory(ctx sdk.Context, promoterUID string, rByCategory types.RewardByCategory) { store := k.getRewardByReceiverAndCategoryStore(ctx) b := k.cdc.MustMarshal(&rByCategory) - store.Set(types.GetRewardsByCategoryKey(rByCategory.Addr, rByCategory.RewardCategory, rByCategory.UID), b) + store.Set(types.GetRewardsOfReceiverByPromoterAndCategoryKey(promoterUID, rByCategory.Addr, rByCategory.RewardCategory, rByCategory.UID), b) } -// GetRewardsByAddressAndCategory returns all rewards by address and category. -func (k Keeper) GetRewardsByAddressAndCategory( +// GetRewardsOfReceiverByPromoterAndCategory returns all rewards by address and category. +func (k Keeper) GetRewardsOfReceiverByPromoterAndCategory( ctx sdk.Context, - addr string, + promoterUID, addr string, category types.RewardCategory, ) (list []types.RewardByCategory, err error) { store := k.getRewardByReceiverAndCategoryStore(ctx) - iterator := sdk.KVStorePrefixIterator(store, types.GetRewardsByCategoryPrefix(addr, category)) + iterator := sdk.KVStorePrefixIterator(store, types.GetRewardsOfReceiverByPromoterAndCategoryPrefix(promoterUID, addr, category)) defer func() { err = iterator.Close() @@ -82,8 +83,8 @@ func (k Keeper) GetRewardsByAddressAndCategory( } // HasRewardByReceiver returns true if there is a record for the category and reward receiver -func (k Keeper) HasRewardByReceiver(ctx sdk.Context, addr string, category types.RewardCategory) bool { - rewardsByCat, err := k.GetRewardsByAddressAndCategory(ctx, addr, category) +func (k Keeper) HasRewardOfReceiverByPromoter(ctx sdk.Context, promoterUID, addr string, category types.RewardCategory) bool { + rewardsByCat, err := k.GetRewardsOfReceiverByPromoterAndCategory(ctx, promoterUID, addr, category) if err != nil || len(rewardsByCat) > 0 { return true } @@ -127,3 +128,20 @@ func (k Keeper) GetAllRewardsByCampaign(ctx sdk.Context) (list []types.RewardByC return } + +func (k Keeper) SetRewardGrantsStats(ctx sdk.Context, campaignUID, accAddr string, count uint64) { + store := k.getRewardGrantsStatStore(ctx) + b := utils.Uint64ToBytes(count) + store.Set(types.GetRewardGrantStatKey(campaignUID, accAddr), b) +} + +func (k Keeper) GetRewardGrantsStats(ctx sdk.Context, campaignUID, accAddr string) (val uint64, found bool) { + store := k.getRewardGrantsStatStore(ctx) + b := store.Get(types.GetRewardGrantStatKey(campaignUID, accAddr)) + if b == nil { + return val, false + } + + val = utils.Uint64FromBytes(b) + return val, true +} diff --git a/x/reward/keeper/view.go b/x/reward/keeper/view.go index be5119bc..273f7d92 100644 --- a/x/reward/keeper/view.go +++ b/x/reward/keeper/view.go @@ -30,3 +30,21 @@ func (k Keeper) getRewardsByCampaignStore(ctx sdk.Context) prefix.Store { store := ctx.KVStore(k.storeKey) return prefix.NewStore(store, types.RewardByCampaignKeyPrefix) } + +// getPromoterByAddressStore gets the store containing all promoter by address. +func (k Keeper) getPromoterByAddressStore(ctx sdk.Context) prefix.Store { + store := ctx.KVStore(k.storeKey) + return prefix.NewStore(store, types.PromoterAddressKeyPrefix) +} + +// getPromoterStore gets the store containing all promoters. +func (k Keeper) getPromoterStore(ctx sdk.Context) prefix.Store { + store := ctx.KVStore(k.storeKey) + return prefix.NewStore(store, types.PromoterKeyPrefix) +} + +// getRewardGrantsStatStore gets the store containing all reward grant stats. +func (k Keeper) getRewardGrantsStatStore(ctx sdk.Context) prefix.Store { + store := ctx.KVStore(k.storeKey) + return prefix.NewStore(store, types.RewardGrantStatKeyPrefix) +} diff --git a/x/reward/types/campaign.go b/x/reward/types/campaign.go index f61a9aa7..4d595fa8 100644 --- a/x/reward/types/campaign.go +++ b/x/reward/types/campaign.go @@ -7,7 +7,7 @@ import ( func NewCampaign( creator, promoter, uID string, - startTS, endTS, claimsPerCategory uint64, + startTS, endTS uint64, rewardType RewardType, rewardCategory RewardCategory, rewardAmountType RewardAmountType, @@ -15,21 +15,22 @@ func NewCampaign( isActive bool, meta string, pool Pool, + capCount uint64, ) Campaign { return Campaign{ - Creator: creator, - Promoter: promoter, - UID: uID, - StartTS: startTS, - EndTS: endTS, - RewardCategory: rewardCategory, - RewardType: rewardType, - RewardAmountType: rewardAmountType, - RewardAmount: rewardAmount, - IsActive: isActive, - Meta: meta, - Pool: pool, - ClaimsPerCategory: claimsPerCategory, + Creator: creator, + Promoter: promoter, + UID: uID, + StartTS: startTS, + EndTS: endTS, + RewardCategory: rewardCategory, + RewardType: rewardType, + RewardAmountType: rewardAmountType, + RewardAmount: rewardAmount, + IsActive: isActive, + Meta: meta, + Pool: pool, + CapCount: capCount, } } diff --git a/x/reward/types/campaign.pb.go b/x/reward/types/campaign.pb.go index b1249d6a..654c5fb0 100644 --- a/x/reward/types/campaign.pb.go +++ b/x/reward/types/campaign.pb.go @@ -49,12 +49,11 @@ type Campaign struct { Pool Pool `protobuf:"bytes,10,opt,name=pool,proto3" json:"pool"` // is_active is the flag to check if the campaign is active or not. IsActive bool `protobuf:"varint,11,opt,name=is_active,json=isActive,proto3" json:"is_active,omitempty"` - // claims_per_category is the number of times a user can claim a - // reward for category of this campaign. - ClaimsPerCategory uint64 `protobuf:"varint,12,opt,name=claims_per_category,json=claimsPerCategory,proto3" json:"claims_per_category,omitempty"` // meta is the metadata of the campaign. // It is a stringified base64 encoded json. Meta string `protobuf:"bytes,13,opt,name=meta,proto3" json:"meta,omitempty"` + // cap_count is the maximum allowed grant for a certain account. + CapCount uint64 `protobuf:"varint,14,opt,name=cap_count,json=capCount,proto3" json:"cap_count,omitempty"` } func (m *Campaign) Reset() { *m = Campaign{} } @@ -167,18 +166,18 @@ func (m *Campaign) GetIsActive() bool { return false } -func (m *Campaign) GetClaimsPerCategory() uint64 { +func (m *Campaign) GetMeta() string { if m != nil { - return m.ClaimsPerCategory + return m.Meta } - return 0 + return "" } -func (m *Campaign) GetMeta() string { +func (m *Campaign) GetCapCount() uint64 { if m != nil { - return m.Meta + return m.CapCount } - return "" + return 0 } // Pool tracks funds assigned and spent to/for a campaign. @@ -228,42 +227,41 @@ func init() { func init() { proto.RegisterFile("sge/reward/campaign.proto", fileDescriptor_6d1d1b3139567e36) } var fileDescriptor_6d1d1b3139567e36 = []byte{ - // 545 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0x4f, 0x6f, 0xd3, 0x3c, - 0x1c, 0xc7, 0x9b, 0xa7, 0x69, 0x9b, 0xba, 0x5d, 0x1f, 0xf0, 0x98, 0x66, 0x3a, 0x29, 0x09, 0x45, - 0x88, 0x22, 0xb4, 0x44, 0xda, 0xc4, 0x85, 0xdb, 0x52, 0x90, 0xd8, 0x05, 0x4d, 0xde, 0x76, 0xe1, - 0x52, 0x79, 0xa9, 0x95, 0x45, 0x6b, 0xe2, 0xc8, 0x76, 0x19, 0x7d, 0x17, 0xe3, 0x5d, 0xed, 0xb8, - 0x23, 0xe2, 0x10, 0xa1, 0xf4, 0xb6, 0x23, 0xaf, 0x00, 0xd9, 0xc9, 0xc2, 0x86, 0x60, 0xda, 0x25, - 0xfe, 0xfd, 0xf9, 0x7e, 0x3f, 0x49, 0xec, 0x9f, 0xc1, 0x53, 0x11, 0x51, 0x9f, 0xd3, 0x73, 0xc2, - 0x67, 0x7e, 0x48, 0x92, 0x8c, 0xc4, 0x51, 0xea, 0x65, 0x9c, 0x49, 0x06, 0x37, 0x44, 0x44, 0x53, - 0x2a, 0xcf, 0x19, 0x3f, 0xf3, 0x44, 0x44, 0xbd, 0x52, 0x35, 0x7c, 0x12, 0xb1, 0x88, 0x69, 0x85, - 0xaf, 0xa2, 0x52, 0x3c, 0xdc, 0xbc, 0xc5, 0x29, 0x97, 0xb2, 0x31, 0xfa, 0xda, 0x02, 0xd6, 0xa4, - 0x02, 0x43, 0x04, 0x3a, 0x21, 0xa7, 0x44, 0x32, 0x8e, 0x0c,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 0x7f, 0xb9, 0xb9, 0x72, 0xea, 0xe4, 0xc5, 0x49, 0x5b, - 0x5f, 0xb9, 0xdd, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xb3, 0x08, 0x2a, 0x3e, 0xd5, 0x03, 0x00, - 0x00, + // 536 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0x4f, 0x6f, 0xd3, 0x30, + 0x18, 0xc6, 0x6b, 0x9a, 0xb6, 0xa9, 0xbb, 0x15, 0x64, 0x98, 0x66, 0x3a, 0x29, 0x09, 0x45, 0x88, + 0x22, 0xb4, 0x44, 0xda, 0xc4, 0x85, 0xdb, 0x52, 0x90, 0xd8, 0x05, 0x21, 0x6f, 0xbb, 0x70, 0xa9, + 0xbc, 0xd4, 0xca, 0xa2, 0x35, 0x71, 0x64, 0xbb, 0x8c, 0x7e, 0x8b, 0x7d, 0xac, 0x1d, 0x77, 0x44, + 0x1c, 0x22, 0x94, 0xde, 0x76, 0xe4, 0x03, 0x20, 0x64, 0x27, 0xab, 0x36, 0xc4, 0xa6, 0x5d, 0xea, + 0xf7, 0xcf, 0xf3, 0xfc, 0xdc, 0xd8, 0xaf, 0xe1, 0x73, 0x19, 0xb3, 0x40, 0xb0, 0x33, 0x2a, 0xa6, + 0x41, 0x44, 0xd3, 0x9c, 0x26, 0x71, 0xe6, 0xe7, 0x82, 0x2b, 0x8e, 0x36, 0x64, 0xcc, 0x32, 0xa6, + 0xce, 0xb8, 0x38, 0xf5, 0x65, 0xcc, 0xfc, 0x4a, 0x35, 0x78, 0x16, 0xf3, 0x98, 0x1b, 0x45, 0xa0, + 0xa3, 0x4a, 0x3c, 0xd8, 0xbc, 0xc1, 0xa9, 0x96, 0xaa, 0x31, 0xfc, 0x63, 0x41, 0x7b, 0x5c, 0x83, + 0x11, 0x86, 0x9d, 0x48, 0x30, 0xaa, 0xb8, 0xc0, 0xc0, 0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e3, 0xb6, 0x79, 0x5f, 0xbb, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, + 0xad, 0x1c, 0x52, 0x91, 0xc2, 0x03, 0x00, 0x00, } func (m *Campaign) Marshal() (dAtA []byte, err error) { @@ -286,6 +284,11 @@ func (m *Campaign) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.CapCount != 0 { + i = encodeVarintCampaign(dAtA, i, uint64(m.CapCount)) + i-- + dAtA[i] = 0x70 + } if len(m.Meta) > 0 { i -= len(m.Meta) copy(dAtA[i:], m.Meta) @@ -293,11 +296,6 @@ func (m *Campaign) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x6a } - if m.ClaimsPerCategory != 0 { - i = encodeVarintCampaign(dAtA, i, uint64(m.ClaimsPerCategory)) - i-- - dAtA[i] = 0x60 - } if m.IsActive { i-- if m.IsActive { @@ -475,13 +473,13 @@ func (m *Campaign) Size() (n int) { if m.IsActive { n += 2 } - if m.ClaimsPerCategory != 0 { - n += 1 + sovCampaign(uint64(m.ClaimsPerCategory)) - } l = len(m.Meta) if l > 0 { n += 1 + l + sovCampaign(uint64(l)) } + if m.CapCount != 0 { + n += 1 + sovCampaign(uint64(m.CapCount)) + } return n } @@ -813,25 +811,6 @@ func (m *Campaign) Unmarshal(dAtA []byte) error { } } m.IsActive = bool(v != 0) - case 12: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ClaimsPerCategory", wireType) - } - m.ClaimsPerCategory = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCampaign - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ClaimsPerCategory |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } case 13: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Meta", wireType) @@ -864,6 +843,25 @@ func (m *Campaign) Unmarshal(dAtA []byte) error { } m.Meta = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 14: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CapCount", wireType) + } + m.CapCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCampaign + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CapCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipCampaign(dAtA[iNdEx:]) diff --git a/x/reward/types/errors.go b/x/reward/types/errors.go index ca2fdbde..093a078d 100644 --- a/x/reward/types/errors.go +++ b/x/reward/types/errors.go @@ -37,4 +37,6 @@ var ( ErrCampaignHasNotStarted = sdkerrors.Register(ModuleName, 7127, "campaign validity period is not started yet") ErrUserKycFailed = sdkerrors.Register(ModuleName, 7128, "KYC Validation failed for receiver account address") ErrUserKycNotProvided = sdkerrors.Register(ModuleName, 7129, "KYC data not provided") + ErrDuplicateCategoryInConf = sdkerrors.Register(ModuleName, 7130, "duplicate category in promoter configurations") + ErrCategoryCapShouldBePos = sdkerrors.Register(ModuleName, 7131, "category cap should be a positive number") ) diff --git a/x/reward/types/events.go b/x/reward/types/events.go index 27953918..b5ef8904 100644 --- a/x/reward/types/events.go +++ b/x/reward/types/events.go @@ -10,4 +10,5 @@ const ( attributeKeyMainAmount = "main_acc_amount" attributeKeySubAmount = "sub_acc_amount" attributeKeyUnlockTS = "sub_acc_unlock_ts" + attributeKeyPromoterConf = "promoter_conf" ) diff --git a/x/reward/types/expected_keepers.go b/x/reward/types/expected_keepers.go index 7445762e..eac09a54 100644 --- a/x/reward/types/expected_keepers.go +++ b/x/reward/types/expected_keepers.go @@ -71,5 +71,6 @@ type SubAccountKeeper interface { // RewardKeeper defines the expected interface needed to get and filter the rewards. type RewardKeeper interface { - HasRewardByReceiver(ctx sdk.Context, addr string, category RewardCategory) bool + HasRewardOfReceiverByPromoter(ctx sdk.Context, promoterUID, addr string, category RewardCategory) bool + GetPromoterByAddress(ctx sdk.Context, address string) (val PromoterByAddress, found bool) } diff --git a/x/reward/types/genesis.pb.go b/x/reward/types/genesis.pb.go index c3bdca04..7eaff929 100644 --- a/x/reward/types/genesis.pb.go +++ b/x/reward/types/genesis.pb.go @@ -25,11 +25,13 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the reward module's genesis state. type GenesisState struct { - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` - CampaignList []Campaign `protobuf:"bytes,2,rep,name=campaign_list,json=campaignList,proto3" json:"campaign_list"` - RewardList []Reward `protobuf:"bytes,3,rep,name=reward_list,json=rewardList,proto3" json:"reward_list"` - RewardByCategoryList []RewardByCategory `protobuf:"bytes,4,rep,name=reward_by_category_list,json=rewardByCategoryList,proto3" json:"reward_by_category_list"` - RewardByCampaignList []RewardByCampaign `protobuf:"bytes,5,rep,name=reward_by_campaign_list,json=rewardByCampaignList,proto3" json:"reward_by_campaign_list"` + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + CampaignList []Campaign `protobuf:"bytes,2,rep,name=campaign_list,json=campaignList,proto3" json:"campaign_list"` + RewardList []Reward `protobuf:"bytes,3,rep,name=reward_list,json=rewardList,proto3" json:"reward_list"` + RewardByCategoryList []RewardByCategory `protobuf:"bytes,4,rep,name=reward_by_category_list,json=rewardByCategoryList,proto3" json:"reward_by_category_list"` + RewardByCampaignList []RewardByCampaign `protobuf:"bytes,5,rep,name=reward_by_campaign_list,json=rewardByCampaignList,proto3" json:"reward_by_campaign_list"` + PromoterList []Promoter `protobuf:"bytes,6,rep,name=promoter_list,json=promoterList,proto3" json:"promoter_list"` + PromoterByAddressList []PromoterByAddress `protobuf:"bytes,7,rep,name=promoter_by_address_list,json=promoterByAddressList,proto3" json:"promoter_by_address_list"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -100,6 +102,20 @@ func (m *GenesisState) GetRewardByCampaignList() []RewardByCampaign { return nil } +func (m *GenesisState) GetPromoterList() []Promoter { + if m != nil { + return m.PromoterList + } + return nil +} + +func (m *GenesisState) GetPromoterByAddressList() []PromoterByAddress { + if m != nil { + return m.PromoterByAddressList + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "sgenetwork.sge.reward.GenesisState") } @@ -107,28 +123,31 @@ func init() { func init() { proto.RegisterFile("sge/reward/genesis.proto", fileDescriptor_cf3f52dafc32b537) } var fileDescriptor_cf3f52dafc32b537 = []byte{ - // 324 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x28, 0x4e, 0x4f, 0xd5, - 0x2f, 0x4a, 0x2d, 0x4f, 0x2c, 0x4a, 0xd1, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, - 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x2d, 0x06, 0xf1, 0x4b, 0xca, 0xf3, 0x8b, 0xb2, 0xf5, 0x8a, - 0xd3, 0x53, 0xf5, 0x20, 0x8a, 0xa4, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x2a, 0xf4, 0x41, 0x2c, - 0x88, 0x62, 0x29, 0x71, 0x24, 0x63, 0x0a, 0x12, 0x8b, 0x12, 0x73, 0xa1, 0xa6, 0x48, 0x49, 0x22, - 0x49, 0x24, 0x27, 0xe6, 0x16, 0x24, 0x66, 0xa6, 0xe7, 0x61, 0xd1, 0x03, 0xa1, 0x20, 0x12, 0x4a, - 0x2b, 0x99, 0xb9, 0x78, 0xdc, 0x21, 0x6e, 0x09, 0x2e, 0x49, 0x2c, 0x49, 0x15, 0xb2, 0xe6, 0x62, - 0x83, 0x18, 0x2a, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xab, 0x87, 0xd5, 0x6d, 0x7a, 0x01, - 0x60, 0x45, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0x41, 0xb5, 0x08, 0x79, 0x71, 0xf1, 0xc2, - 0x2c, 0x8e, 0xcf, 0xc9, 0x2c, 0x2e, 0x91, 0x60, 0x52, 0x60, 0xd6, 0xe0, 0x36, 0x92, 0xc7, 0x61, - 0x86, 0x33, 0x54, 0x2d, 0xd4, 0x14, 0x1e, 0x98, 0x5e, 0x9f, 0xcc, 0xe2, 0x12, 0x21, 0x17, 0x2e, - 0x6e, 0x88, 0x32, 0x88, 0x49, 0xcc, 0x60, 0x93, 0x70, 0xb9, 0x26, 0x08, 0x4c, 0x41, 0xcd, 0xe1, - 0x82, 0x08, 0x82, 0x4d, 0x49, 0xe1, 0x12, 0x87, 0x9a, 0x92, 0x54, 0x19, 0x9f, 0x9c, 0x58, 0x92, - 0x9a, 0x9e, 0x5f, 0x54, 0x09, 0x31, 0x91, 0x05, 0x6c, 0xa2, 0x3a, 0x7e, 0x13, 0x2b, 0x9d, 0xa1, - 0x7a, 0xa0, 0x66, 0x8b, 0x14, 0xa1, 0x89, 0x63, 0xb3, 0x05, 0x39, 0x04, 0x58, 0x89, 0xb4, 0x05, - 0x25, 0x24, 0x90, 0x6c, 0x41, 0x84, 0x88, 0x93, 0xf3, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, - 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, - 0xcb, 0x31, 0x44, 0x69, 0xa6, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x17, - 0xa7, 0xa7, 0xea, 0x42, 0x6d, 0x02, 0xb1, 0xf5, 0x2b, 0x60, 0xf1, 0x5e, 0x52, 0x59, 0x90, 0x5a, - 0x9c, 0xc4, 0x06, 0x8e, 0x77, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x4a, 0x9d, 0xa4, 0xe3, - 0x8d, 0x02, 0x00, 0x00, + // 376 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x41, 0x4f, 0xc2, 0x30, + 0x1c, 0xc5, 0x37, 0x41, 0x4c, 0x0a, 0x5c, 0x16, 0x08, 0x93, 0xc4, 0x41, 0xbc, 0x88, 0x07, 0xb7, + 0x04, 0x8f, 0x9e, 0x04, 0x13, 0x13, 0xe2, 0x81, 0xe0, 0xcd, 0x0b, 0xe9, 0x58, 0x53, 0x17, 0x1d, + 0x5d, 0xda, 0x1a, 0xdc, 0xb7, 0xf0, 0x63, 0x71, 0xe4, 0xe8, 0x89, 0x18, 0xf8, 0x22, 0x66, 0xfd, + 0x77, 0x66, 0x92, 0x81, 0x9e, 0xda, 0xb5, 0xef, 0xfd, 0xde, 0x3f, 0x6f, 0x45, 0xb6, 0xa0, 0xc4, + 0xe3, 0x64, 0x81, 0x79, 0xe0, 0x51, 0x32, 0x27, 0x22, 0x14, 0x6e, 0xcc, 0x99, 0x64, 0x56, 0x53, + 0xa4, 0xdf, 0x72, 0xc1, 0xf8, 0x8b, 0x2b, 0x28, 0x71, 0x41, 0xd4, 0x6e, 0x50, 0x46, 0x99, 0x52, + 0x78, 0xe9, 0x0e, 0xc4, 0xed, 0x56, 0x0e, 0x13, 0x63, 0x8e, 0x23, 0x4d, 0x69, 0x9f, 0xe6, 0x2e, + 0x66, 0x38, 0x8a, 0x71, 0x48, 0xe7, 0x05, 0x1e, 0x58, 0x0a, 0x3c, 0x31, 0x67, 0x11, 0x93, 0x84, + 0xc3, 0xd5, 0xf9, 0xba, 0x8c, 0x6a, 0xf7, 0x30, 0xe6, 0xa3, 0xc4, 0x92, 0x58, 0x37, 0xa8, 0x02, + 0x79, 0xb6, 0xd9, 0x35, 0x7b, 0xd5, 0xfe, 0x99, 0x5b, 0x38, 0xb6, 0x3b, 0x56, 0xa2, 0x41, 0x79, + 0xb9, 0xee,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x63, 0xbd, 0xfe, 0x0e, 0x00, 0x00, 0xff, 0xff, + 0xd3, 0x6c, 0xe5, 0xbd, 0x5d, 0x03, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -151,6 +170,34 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.PromoterByAddressList) > 0 { + for iNdEx := len(m.PromoterByAddressList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PromoterByAddressList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } + } + if len(m.PromoterList) > 0 { + for iNdEx := len(m.PromoterList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PromoterList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } if len(m.RewardByCampaignList) > 0 { for iNdEx := len(m.RewardByCampaignList) - 1; iNdEx >= 0; iNdEx-- { { @@ -263,6 +310,18 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if len(m.PromoterList) > 0 { + for _, e := range m.PromoterList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.PromoterByAddressList) > 0 { + for _, e := range m.PromoterByAddressList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -470,6 +529,74 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PromoterList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PromoterList = append(m.PromoterList, Promoter{}) + if err := m.PromoterList[len(m.PromoterList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PromoterByAddressList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PromoterByAddressList = append(m.PromoterByAddressList, PromoterByAddress{}) + if err := m.PromoterByAddressList[len(m.PromoterByAddressList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/reward/types/key_promoter.go b/x/reward/types/key_promoter.go new file mode 100644 index 00000000..509e6bcd --- /dev/null +++ b/x/reward/types/key_promoter.go @@ -0,0 +1,27 @@ +package types + +import ( + "encoding/binary" + + "github.com/sge-network/sge/utils" +) + +var _ binary.ByteOrder + +var ( + // PromoterKeyPrefix is the prefix to retrieve all promoter + PromoterKeyPrefix = []byte{0x04} + + // PromoterAddressKeyPrefix is the prefix to retrieve all addresses promoter + PromoterAddressKeyPrefix = []byte{0x05} +) + +// GetPromoterKey returns the store key to retrieve a promoter +func GetPromoterKey(uid string) []byte { + return utils.StrBytes(uid) +} + +// GetPromoterByAddressKey returns the promoter of a certain promoter address. +func GetPromoterByAddressKey(accAddr string) []byte { + return utils.StrBytes(accAddr) +} diff --git a/x/reward/types/key_reward.go b/x/reward/types/key_reward.go index 66043780..8d56a279 100644 --- a/x/reward/types/key_reward.go +++ b/x/reward/types/key_reward.go @@ -17,22 +17,25 @@ var ( // RewardByCampaignKeyPrefix is the prefix to retrieve all applied rewards for a certain campaign. RewardByCampaignKeyPrefix = []byte{0x03} + + // RewardGrantStatKeyPrefix is the prefix to retrieve count of reward grants for a certain account. + RewardGrantStatKeyPrefix = []byte{0x06} ) -// GetRewardsByAccPrefix returns the store key to retrieve list of all applied rewards of a certain campaign +// GetRewardsOfReceiverByPromoterPrefix returns the store key to retrieve list of all applied rewards of a certain campaign // this should be used with RewardByReceiverKeyPrefix -func GetRewardsByAccPrefix(receiverAcc string) []byte { - return utils.StrBytes(receiverAcc) +func GetRewardsOfReceiverByPromoterPrefix(promoterUID, receiverAcc string) []byte { + return append(utils.StrBytes(promoterUID), utils.StrBytes(receiverAcc)...) } -// GetRewardsByCategoryPrefix returns the store key to retrieve list of all applied rewards of certain address and category -func GetRewardsByCategoryPrefix(receiverAcc string, rewardCategory RewardCategory) []byte { - return append(GetRewardsByAccPrefix(receiverAcc), utils.Int32ToBytes(int32(rewardCategory))...) +// GetRewardsOfReceiverByPromoterAndCategoryPrefix returns the store key to retrieve list of all applied rewards of certain address and category +func GetRewardsOfReceiverByPromoterAndCategoryPrefix(promoterUID, receiverAcc string, rewardCategory RewardCategory) []byte { + return append(GetRewardsOfReceiverByPromoterPrefix(promoterUID, receiverAcc), utils.Int32ToBytes(int32(rewardCategory))...) } -// GetRewardsByCategoryKey returns the store key to retrieve list of applied reward of certain address and category -func GetRewardsByCategoryKey(receiverAcc string, rewardCategory RewardCategory, uid string) []byte { - return append(GetRewardsByCategoryPrefix(receiverAcc, rewardCategory), utils.StrBytes(uid)...) +// GetRewardsOfReceiverByPromoterAndCategoryKey returns the store key to retrieve list of applied reward of certain address and category +func GetRewardsOfReceiverByPromoterAndCategoryKey(promoterUID, receiverAcc string, rewardCategory RewardCategory, uid string) []byte { + return append(GetRewardsOfReceiverByPromoterAndCategoryPrefix(promoterUID, receiverAcc, rewardCategory), utils.StrBytes(uid)...) } // GetRewardKey returns the store key to retrieve a certain reward. @@ -51,3 +54,8 @@ func GetRewardsByCampaignPrefix(campaignUID string) []byte { func GetRewardsByCampaignKey(campaignUID, uid string) []byte { return append(utils.StrBytes(campaignUID), utils.StrBytes(uid)...) } + +// GetRewardGrantStatKey returns the store key to retrieve a certain account. +func GetRewardGrantStatKey(campaignUID, addr string) []byte { + return append(utils.StrBytes(campaignUID), utils.StrBytes(addr)...) +} diff --git a/x/reward/types/messages_promoter.go b/x/reward/types/messages_promoter.go new file mode 100644 index 00000000..3de553e5 --- /dev/null +++ b/x/reward/types/messages_promoter.go @@ -0,0 +1,75 @@ +package types + +import ( + sdkerrors "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrtypes "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/sge-network/sge/utils" +) + +const ( + TypeMsgSetPromoterConf = "set_promoter_conf" +) + +var _ sdk.Msg = &MsgSetPromoterConf{} + +func NewMsgSetPromoterConfig( + creator string, + uid string, + ticket string, +) *MsgSetPromoterConf { + return &MsgSetPromoterConf{ + Creator: creator, + Uid: uid, + Ticket: ticket, + } +} + +func (msg *MsgSetPromoterConf) Route() string { + return RouterKey +} + +func (msg *MsgSetPromoterConf) Type() string { + return TypeMsgSetPromoterConf +} + +func (msg *MsgSetPromoterConf) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgSetPromoterConf) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgSetPromoterConf) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrtypes.ErrInvalidAddress, "invalid creator address (%s)", err) + } + + if !utils.IsValidUID(msg.Uid) { + return sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "invalid uid") + } + + if msg.Ticket == "" { + return sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "invalid ticket") + } + + return nil +} + +// EmitEvent emits the event for the message success. +func (msg *MsgSetPromoterConf) EmitEvent(ctx *sdk.Context, conf PromoterConf) { + emitter := utils.NewEventEmitter(ctx, attributeValueCategory) + emitter.AddMsg(TypeMsgSetPromoterConf, msg.Creator, + sdk.NewAttribute(attributeKeyUID, msg.Uid), + sdk.NewAttribute(attributeKeyPromoterConf, conf.String()), + ) + emitter.Emit() +} diff --git a/x/reward/types/messages_promoter_test.go b/x/reward/types/messages_promoter_test.go new file mode 100644 index 00000000..bc0b5afb --- /dev/null +++ b/x/reward/types/messages_promoter_test.go @@ -0,0 +1,62 @@ +package types_test + +import ( + "testing" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/google/uuid" + "github.com/sge-network/sge/testutil/sample" + "github.com/sge-network/sge/x/reward/types" + "github.com/stretchr/testify/require" +) + +func TestMsgSetPromoterConf_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg types.MsgSetPromoterConf + err error + }{ + { + name: "invalid address", + msg: types.MsgSetPromoterConf{ + Creator: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, + { + name: "invalid campaign uid", + msg: types.MsgSetPromoterConf{ + Creator: sample.AccAddress(), + Uid: "bad uid", + Ticket: "ticket", + }, + err: sdkerrors.ErrInvalidRequest, + }, + { + name: "invalid ticket", + msg: types.MsgSetPromoterConf{ + Creator: sample.AccAddress(), + Uid: uuid.NewString(), + }, + err: sdkerrors.ErrInvalidRequest, + }, + { + name: "valid address", + msg: types.MsgSetPromoterConf{ + Creator: sample.AccAddress(), + Uid: uuid.NewString(), + Ticket: "ticket", + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/reward/types/promoter.pb.go b/x/reward/types/promoter.pb.go new file mode 100644 index 00000000..7fd7945a --- /dev/null +++ b/x/reward/types/promoter.pb.go @@ -0,0 +1,1092 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: sge/reward/promoter.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/gogo/protobuf/proto" + 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 + +// Promoter is type for defining the reward promoter properties and configuration. +type Promoter struct { + // creator is the address of promoter. + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + // uid is the unique identifier of a promoter. + UID string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid"` + // addresses is the list of account addresses of promoter. + Addresses []string `protobuf:"bytes,3,rep,name=addresses,proto3" json:"addresses,omitempty"` + // conf is the configurations of the current promoter for the reward grant. + Conf PromoterConf `protobuf:"bytes,4,opt,name=conf,proto3" json:"conf"` +} + +func (m *Promoter) Reset() { *m = Promoter{} } +func (m *Promoter) String() string { return proto.CompactTextString(m) } +func (*Promoter) ProtoMessage() {} +func (*Promoter) Descriptor() ([]byte, []int) { + return fileDescriptor_35eedf87bdac6383, []int{0} +} +func (m *Promoter) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Promoter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Promoter.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 *Promoter) XXX_Merge(src proto.Message) { + xxx_messageInfo_Promoter.Merge(m, src) +} +func (m *Promoter) XXX_Size() int { + return m.Size() +} +func (m *Promoter) XXX_DiscardUnknown() { + xxx_messageInfo_Promoter.DiscardUnknown(m) +} + +var xxx_messageInfo_Promoter proto.InternalMessageInfo + +func (m *Promoter) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *Promoter) GetUID() string { + if m != nil { + return m.UID + } + return "" +} + +func (m *Promoter) GetAddresses() []string { + if m != nil { + return m.Addresses + } + return nil +} + +func (m *Promoter) GetConf() PromoterConf { + if m != nil { + return m.Conf + } + return PromoterConf{} +} + +// PromoterConf is type for defining the promoter specific configurations. +type PromoterConf struct { + // category_cap is the maximium allowed cap for each category. + CategoryCap []CategoryCap `protobuf:"bytes,1,rep,name=category_cap,json=categoryCap,proto3" json:"category_cap"` +} + +func (m *PromoterConf) Reset() { *m = PromoterConf{} } +func (m *PromoterConf) String() string { return proto.CompactTextString(m) } +func (*PromoterConf) ProtoMessage() {} +func (*PromoterConf) Descriptor() ([]byte, []int) { + return fileDescriptor_35eedf87bdac6383, []int{1} +} +func (m *PromoterConf) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PromoterConf) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PromoterConf.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 *PromoterConf) XXX_Merge(src proto.Message) { + xxx_messageInfo_PromoterConf.Merge(m, src) +} +func (m *PromoterConf) XXX_Size() int { + return m.Size() +} +func (m *PromoterConf) XXX_DiscardUnknown() { + xxx_messageInfo_PromoterConf.DiscardUnknown(m) +} + +var xxx_messageInfo_PromoterConf proto.InternalMessageInfo + +func (m *PromoterConf) GetCategoryCap() []CategoryCap { + if m != nil { + return m.CategoryCap + } + return nil +} + +// CategoryCap is type to define category and its maximum cap. +type CategoryCap struct { + Category RewardCategory `protobuf:"varint,1,opt,name=category,proto3,enum=sgenetwork.sge.reward.RewardCategory" json:"category,omitempty"` + CapPerAcc int32 `protobuf:"varint,2,opt,name=cap_per_acc,json=capPerAcc,proto3" json:"cap_per_acc,omitempty"` +} + +func (m *CategoryCap) Reset() { *m = CategoryCap{} } +func (m *CategoryCap) String() string { return proto.CompactTextString(m) } +func (*CategoryCap) ProtoMessage() {} +func (*CategoryCap) Descriptor() ([]byte, []int) { + return fileDescriptor_35eedf87bdac6383, []int{2} +} +func (m *CategoryCap) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CategoryCap) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CategoryCap.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 *CategoryCap) XXX_Merge(src proto.Message) { + xxx_messageInfo_CategoryCap.Merge(m, src) +} +func (m *CategoryCap) XXX_Size() int { + return m.Size() +} +func (m *CategoryCap) XXX_DiscardUnknown() { + xxx_messageInfo_CategoryCap.DiscardUnknown(m) +} + +var xxx_messageInfo_CategoryCap proto.InternalMessageInfo + +func (m *CategoryCap) GetCategory() RewardCategory { + if m != nil { + return m.Category + } + return RewardCategory_REWARD_CATEGORY_UNSPECIFIED +} + +func (m *CategoryCap) GetCapPerAcc() int32 { + if m != nil { + return m.CapPerAcc + } + return 0 +} + +// PromoterByAddress is type for defining the promoter by address. +type PromoterByAddress struct { + // promoter_uid is the unique identifier of a certain promoter. + PromoterUID string `protobuf:"bytes,1,opt,name=promoter_uid,proto3" json:"promoter_uid"` + // address is the address of the promoter account. + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *PromoterByAddress) Reset() { *m = PromoterByAddress{} } +func (m *PromoterByAddress) String() string { return proto.CompactTextString(m) } +func (*PromoterByAddress) ProtoMessage() {} +func (*PromoterByAddress) Descriptor() ([]byte, []int) { + return fileDescriptor_35eedf87bdac6383, []int{3} +} +func (m *PromoterByAddress) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PromoterByAddress) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PromoterByAddress.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 *PromoterByAddress) XXX_Merge(src proto.Message) { + xxx_messageInfo_PromoterByAddress.Merge(m, src) +} +func (m *PromoterByAddress) XXX_Size() int { + return m.Size() +} +func (m *PromoterByAddress) XXX_DiscardUnknown() { + xxx_messageInfo_PromoterByAddress.DiscardUnknown(m) +} + +var xxx_messageInfo_PromoterByAddress proto.InternalMessageInfo + +func (m *PromoterByAddress) GetPromoterUID() string { + if m != nil { + return m.PromoterUID + } + return "" +} + +func (m *PromoterByAddress) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func init() { + proto.RegisterType((*Promoter)(nil), "sgenetwork.sge.reward.Promoter") + proto.RegisterType((*PromoterConf)(nil), "sgenetwork.sge.reward.PromoterConf") + proto.RegisterType((*CategoryCap)(nil), "sgenetwork.sge.reward.CategoryCap") + proto.RegisterType((*PromoterByAddress)(nil), "sgenetwork.sge.reward.PromoterByAddress") +} + +func init() { proto.RegisterFile("sge/reward/promoter.proto", fileDescriptor_35eedf87bdac6383) } + +var fileDescriptor_35eedf87bdac6383 = []byte{ + // 403 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x52, 0xbd, 0xae, 0xd3, 0x30, + 0x18, 0x8d, 0x49, 0x81, 0x1b, 0xa7, 0xba, 0x12, 0x16, 0x88, 0x70, 0x85, 0x92, 0x28, 0x08, 0x29, + 0x0c, 0x24, 0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 0x97, + 0x02, 0x00, 0x00, +} + +func (m *Promoter) 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 *Promoter) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Promoter) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Conf.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPromoter(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.Addresses) > 0 { + for iNdEx := len(m.Addresses) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Addresses[iNdEx]) + copy(dAtA[i:], m.Addresses[iNdEx]) + i = encodeVarintPromoter(dAtA, i, uint64(len(m.Addresses[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } + if len(m.UID) > 0 { + i -= len(m.UID) + copy(dAtA[i:], m.UID) + i = encodeVarintPromoter(dAtA, i, uint64(len(m.UID))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintPromoter(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *PromoterConf) 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 *PromoterConf) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PromoterConf) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.CategoryCap) > 0 { + for iNdEx := len(m.CategoryCap) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.CategoryCap[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPromoter(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *CategoryCap) 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 *CategoryCap) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CategoryCap) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.CapPerAcc != 0 { + i = encodeVarintPromoter(dAtA, i, uint64(m.CapPerAcc)) + i-- + dAtA[i] = 0x10 + } + if m.Category != 0 { + i = encodeVarintPromoter(dAtA, i, uint64(m.Category)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *PromoterByAddress) 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 *PromoterByAddress) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PromoterByAddress) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintPromoter(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0x12 + } + if len(m.PromoterUID) > 0 { + i -= len(m.PromoterUID) + copy(dAtA[i:], m.PromoterUID) + i = encodeVarintPromoter(dAtA, i, uint64(len(m.PromoterUID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintPromoter(dAtA []byte, offset int, v uint64) int { + offset -= sovPromoter(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Promoter) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovPromoter(uint64(l)) + } + l = len(m.UID) + if l > 0 { + n += 1 + l + sovPromoter(uint64(l)) + } + if len(m.Addresses) > 0 { + for _, s := range m.Addresses { + l = len(s) + n += 1 + l + sovPromoter(uint64(l)) + } + } + l = m.Conf.Size() + n += 1 + l + sovPromoter(uint64(l)) + return n +} + +func (m *PromoterConf) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.CategoryCap) > 0 { + for _, e := range m.CategoryCap { + l = e.Size() + n += 1 + l + sovPromoter(uint64(l)) + } + } + return n +} + +func (m *CategoryCap) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Category != 0 { + n += 1 + sovPromoter(uint64(m.Category)) + } + if m.CapPerAcc != 0 { + n += 1 + sovPromoter(uint64(m.CapPerAcc)) + } + return n +} + +func (m *PromoterByAddress) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PromoterUID) + if l > 0 { + n += 1 + l + sovPromoter(uint64(l)) + } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovPromoter(uint64(l)) + } + return n +} + +func sovPromoter(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozPromoter(x uint64) (n int) { + return sovPromoter(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Promoter) 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 ErrIntOverflowPromoter + } + 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: Promoter: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Promoter: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPromoter + } + 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 ErrInvalidLengthPromoter + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPromoter + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPromoter + } + 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 ErrInvalidLengthPromoter + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPromoter + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.UID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Addresses", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPromoter + } + 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 ErrInvalidLengthPromoter + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPromoter + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Addresses = append(m.Addresses, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Conf", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPromoter + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPromoter + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPromoter + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Conf.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPromoter(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPromoter + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PromoterConf) 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 ErrIntOverflowPromoter + } + 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: PromoterConf: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PromoterConf: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CategoryCap", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPromoter + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPromoter + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPromoter + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CategoryCap = append(m.CategoryCap, CategoryCap{}) + if err := m.CategoryCap[len(m.CategoryCap)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPromoter(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPromoter + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CategoryCap) 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 ErrIntOverflowPromoter + } + 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: CategoryCap: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CategoryCap: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Category", wireType) + } + m.Category = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPromoter + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Category |= RewardCategory(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CapPerAcc", wireType) + } + m.CapPerAcc = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPromoter + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CapPerAcc |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipPromoter(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPromoter + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PromoterByAddress) 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 ErrIntOverflowPromoter + } + 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: PromoterByAddress: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PromoterByAddress: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PromoterUID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPromoter + } + 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 ErrInvalidLengthPromoter + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPromoter + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PromoterUID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPromoter + } + 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 ErrInvalidLengthPromoter + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPromoter + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPromoter(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPromoter + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipPromoter(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, ErrIntOverflowPromoter + } + 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, ErrIntOverflowPromoter + } + 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, ErrIntOverflowPromoter + } + 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, ErrInvalidLengthPromoter + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupPromoter + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthPromoter + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthPromoter = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowPromoter = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupPromoter = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/reward/types/query.pb.go b/x/reward/types/query.pb.go index 8405e5e4..b7a3cc6b 100644 --- a/x/reward/types/query.pb.go +++ b/x/reward/types/query.pb.go @@ -493,8 +493,9 @@ func (m *QueryRewardsResponse) GetPagination() *query.PageResponse { // QueryRewardsByAddressRequest is request body for the query all rewards by // address endpoint. type QueryRewardsByAddressRequest struct { - Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` - Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + PromoterUid string `protobuf:"bytes,3,opt,name=promoter_uid,json=promoterUid,proto3" json:"promoter_uid,omitempty"` } func (m *QueryRewardsByAddressRequest) Reset() { *m = QueryRewardsByAddressRequest{} } @@ -544,6 +545,13 @@ func (m *QueryRewardsByAddressRequest) GetAddress() string { return "" } +func (m *QueryRewardsByAddressRequest) GetPromoterUid() string { + if m != nil { + return m.PromoterUid + } + return "" +} + // QueryRewardsByAddressResponse is response body of the query all rewards by // address endpoint. type QueryRewardsByAddressResponse struct { @@ -601,9 +609,10 @@ func (m *QueryRewardsByAddressResponse) GetPagination() *query.PageResponse { // QueryRewardsByAddressAndCategoryRequest is request body for the query all // rewards by address and category endpoint. type QueryRewardsByAddressAndCategoryRequest struct { - Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` - Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` - Category RewardCategory `protobuf:"varint,3,opt,name=category,proto3,enum=sgenetwork.sge.reward.RewardCategory" json:"category,omitempty"` + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + Category RewardCategory `protobuf:"varint,3,opt,name=category,proto3,enum=sgenetwork.sge.reward.RewardCategory" json:"category,omitempty"` + PromoterUid string `protobuf:"bytes,4,opt,name=promoter_uid,json=promoterUid,proto3" json:"promoter_uid,omitempty"` } func (m *QueryRewardsByAddressAndCategoryRequest) Reset() { @@ -662,6 +671,13 @@ func (m *QueryRewardsByAddressAndCategoryRequest) GetCategory() RewardCategory { return RewardCategory_REWARD_CATEGORY_UNSPECIFIED } +func (m *QueryRewardsByAddressAndCategoryRequest) GetPromoterUid() string { + if m != nil { + return m.PromoterUid + } + return "" +} + // QueryRewardsByAddressAndCategoryResponse is response body of the query all // rewards by address and category endpoint. type QueryRewardsByAddressAndCategoryResponse struct { @@ -848,60 +864,62 @@ func init() { func init() { proto.RegisterFile("sge/reward/query.proto", fileDescriptor_324afa5f2186a8c0) } var fileDescriptor_324afa5f2186a8c0 = []byte{ - // 848 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x97, 0x4b, 0x4f, 0x13, 0x51, - 0x14, 0xc7, 0x7b, 0x41, 0x0b, 0x5c, 0x8c, 0xc1, 0x23, 0x20, 0x56, 0x18, 0x60, 0xd4, 0x3e, 0x78, - 0xcc, 0x84, 0x87, 0x1a, 0xe3, 0x83, 0x00, 0x89, 0x6c, 0xb1, 0x89, 0x1b, 0x12, 0x43, 0xa6, 0xf4, - 0x66, 0x9c, 0x68, 0x7b, 0xcb, 0xdc, 0xa9, 0xd8, 0x90, 0x26, 0xc6, 0x8d, 0x89, 0xc6, 0xc4, 0x84, - 0xb8, 0x75, 0xe5, 0x07, 0xf0, 0xb1, 0x75, 0xe3, 0x8e, 0x95, 0x21, 0x71, 0xe3, 0xc2, 0x18, 0x03, - 0x7e, 0x10, 0xd3, 0xfb, 0x28, 0xed, 0xf4, 0x35, 0x90, 0x6a, 0x5c, 0xcd, 0x30, 0x73, 0x1e, 0xbf, - 0xf3, 0x3f, 0x77, 0xce, 0xa1, 0x78, 0x90, 0xd9, 0xc4, 0x74, 0xc9, 0x96, 0xe5, 0xa6, 0xcd, 0xcd, - 0x3c, 0x71, 0x0b, 0x46, 0xce, 0xa5, 0x1e, 0x85, 0x01, 0x66, 0x93, 0x2c, 0xf1, 0xb6, 0xa8, 0xfb, - 0xd0, 0x60, 0x36, 0x31, 0x84, 0x49, 0xa4, 0xdf, 0xa6, 0x36, 0xe5, 0x16, 0x66, 0xe9, 0x4e, 0x18, - 0x47, 0x86, 0x6d, 0x4a, 0xed, 0x47, 0xc4, 0xb4, 0x72, 0x8e, 0x69, 0x65, 0xb3, 0xd4, 0xb3, 0x3c, - 0x87, 0x66, 0x99, 0x7c, 0x3b, 0xb1, 0x41, 0x59, 0x86, 0x32, 0x33, 0x65, 0x31, 0x22, 0x72, 0x98, - 0x8f, 0x67, 0x52, 0xc4, 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0x0a, 0xce, - 0x7e, 0xc2, 0xf8, 0x24, 0x87, 0x86, 0xe7, 0x08, 0x87, 0xc5, 0xd6, 0x84, 0x44, 0x03, 0xaa, 0xda, - 0x35, 0x1d, 0x99, 0x08, 0x62, 0x2a, 0xf2, 0xea, 0xd1, 0x67, 0xdf, 0x7e, 0xef, 0x74, 0x8c, 0x81, - 0x66, 0x32, 0x9b, 0x4c, 0x4b, 0x27, 0xb3, 0xe6, 0x5f, 0x09, 0x78, 0x83, 0x70, 0xb7, 0x2a, 0x1c, - 0x26, 0x9b, 0x25, 0xf0, 0x75, 0x3b, 0x32, 0x15, 0xcc, 0x58, 0xf2, 0x18, 0x9c, 0x27, 0x0e, 0xd1, - 0x46, 0x3c, 0xaa, 0xbb, 0xe6, 0x76, 0xde, 0x49, 0x17, 0x61, 0x07, 0xe1, 0x9e, 0xf2, 0x4a, 0x85, - 0x40, 0xb9, 0xca, 0x3a, 0x4d, 0x07, 0xb4, 0x96, 0x68, 0x09, 0x8e, 0x76, 0x11, 0xc6, 0x5b, 0xa1, - 0x31, 0x78, 0x85, 0x70, 0x58, 0x1c, 0x97, 0xe6, 0x7d, 0xab, 0x5a, 0xb3, 0xcd, 0xfb, 0x56, 0xbd, - 0x69, 0xf5, 0x29, 0x0e, 0x13, 0x85, 0x4b, 0x8d, 0x60, 0xe4, 0x45, 0xa8, 0xf4, 0x12, 0xe1, 0x2e, - 0xf9, 0x05, 0x40, 0x80, 0x2c, 0x65, 0x85, 0x26, 0x03, 0xd9, 0x4a, 0xa4, 0x18, 0x47, 0x1a, 0x87, - 0xd1, 0xe6, 0x48, 0x0c, 0xde, 0x23, 0xdc, 0xe7, 0x9f, 0x6d, 0x30, 0x17, 0x20, 0x95, 0x7f, 0x23, - 0x46, 0xe6, 0x8f, 0xe6, 0x24, 0x41, 0x67, 0x38, 0xe8, 0x24, 0x24, 0x5a, 0x80, 0x9a, 0xdb, 0x72, - 0xaa, 0x17, 0xe1, 0x07, 0xc2, 0x17, 0x9a, 0x8c, 0x63, 0xb8, 0x7d, 0x14, 0x90, 0xda, 0xc5, 0x14, - 0x59, 0x38, 0xb6, 0xbf, 0xac, 0xe9, 0x26, 0xaf, 0xe9, 0x2a, 0xcc, 0x07, 0xae, 0xc9, 0xdc, 0x56, - 0x1b, 0xa7, 0x08, 0x5f, 0x10, 0x3e, 0x53, 0x33, 0x21, 0x21, 0x98, 0xba, 0xfe, 0xef, 0xfd, 0xca, - 0x11, 0xbd, 0x64, 0x01, 0x0b, 0xbc, 0x80, 0xeb, 0x70, 0xad, 0x55, 0x01, 0x87, 0x03, 0xa0, 0x72, - 0xf8, 0x17, 0x97, 0x96, 0x77, 0xf7, 0x35, 0xb4, 0xb7, 0xaf, 0xa1, 0x5f, 0xfb, 0x1a, 0x7a, 0x7d, - 0xa0, 0x85, 0xf6, 0x0e, 0xb4, 0xd0, 0xf7, 0x03, 0x2d, 0xb4, 0x96, 0xb0, 0x1d, 0xef, 0x41, 0x3e, - 0x65, 0x6c, 0xd0, 0x4c, 0x4d, 0xf0, 0x27, 0x2a, 0xbc, 0x57, 0xc8, 0x11, 0x96, 0x0a, 0xf3, 0x9f, - 0x3f, 0x73, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x25, 0x82, 0xdd, 0x83, 0xdc, 0x0d, 0x00, 0x00, + // 878 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x97, 0x4b, 0x4f, 0x13, 0x5d, + 0x18, 0xc7, 0x7b, 0x80, 0xb7, 0xc0, 0x81, 0xbc, 0xe1, 0x3d, 0x2f, 0x20, 0x56, 0x18, 0xe8, 0xa8, + 0x6d, 0xb9, 0xcd, 0x04, 0xd0, 0x78, 0x8b, 0x22, 0x34, 0xca, 0xc2, 0x0d, 0x36, 0x71, 0x43, 0x62, + 0xc8, 0x94, 0x9e, 0x8c, 0x13, 0x6d, 0xcf, 0x30, 0x67, 0x2a, 0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f, 0x77, 0x7f, 0xa2, 0x60, 0xda, 0x7b, 0x6f, 0x83, 0xf3, 0xc7, 0xcc, + 0x12, 0xf3, 0x2c, 0xb3, 0x79, 0x2e, 0xa1, 0x0b, 0xad, 0xe6, 0x39, 0xba, 0x1e, 0xaa, 0x57, 0x43, + 0x69, 0x35, 0xb9, 0x77, 0xa0, 0x80, 0xfd, 0x03, 0x05, 0x7c, 0x3b, 0x50, 0xc0, 0x8b, 0x43, 0x25, + 0xb4, 0x7f, 0xa8, 0x84, 0xbe, 0x1c, 0x2a, 0xa1, 0x8d, 0x69, 0xd3, 0x72, 0xef, 0xe5, 0xd3, 0xda, + 0x16, 0xc9, 0xfa, 0x8a, 0x3f, 0x92, 0xe5, 0xdd, 0x82, 0x8d, 0x69, 0x3a, 0xcc, 0xfe, 0xc4, 0x5a, + 0xfa, 0x15, 0x00, 0x00, 0xff, 0xff, 0x0a, 0x7f, 0x1b, 0x06, 0x40, 0x0e, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1624,6 +1642,13 @@ func (m *QueryRewardsByAddressRequest) MarshalToSizedBuffer(dAtA []byte) (int, e _ = i var l int _ = l + if len(m.PromoterUid) > 0 { + i -= len(m.PromoterUid) + copy(dAtA[i:], m.PromoterUid) + i = encodeVarintQuery(dAtA, i, uint64(len(m.PromoterUid))) + i-- + dAtA[i] = 0x1a + } if len(m.Address) > 0 { i -= len(m.Address) copy(dAtA[i:], m.Address) @@ -1715,6 +1740,13 @@ func (m *QueryRewardsByAddressAndCategoryRequest) MarshalToSizedBuffer(dAtA []by _ = i var l int _ = l + if len(m.PromoterUid) > 0 { + i -= len(m.PromoterUid) + copy(dAtA[i:], m.PromoterUid) + i = encodeVarintQuery(dAtA, i, uint64(len(m.PromoterUid))) + i-- + dAtA[i] = 0x22 + } if m.Category != 0 { i = encodeVarintQuery(dAtA, i, uint64(m.Category)) i-- @@ -2039,6 +2071,10 @@ func (m *QueryRewardsByAddressRequest) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } + l = len(m.PromoterUid) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } return n } @@ -2078,6 +2114,10 @@ func (m *QueryRewardsByAddressAndCategoryRequest) Size() (n int) { if m.Category != 0 { n += 1 + sovQuery(uint64(m.Category)) } + l = len(m.PromoterUid) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } return n } @@ -3114,6 +3154,38 @@ func (m *QueryRewardsByAddressRequest) Unmarshal(dAtA []byte) error { } m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PromoterUid", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PromoterUid = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -3371,6 +3443,38 @@ func (m *QueryRewardsByAddressAndCategoryRequest) Unmarshal(dAtA []byte) error { break } } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PromoterUid", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PromoterUid = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) diff --git a/x/reward/types/query.pb.gw.go b/x/reward/types/query.pb.gw.go index 6a9886e6..70134ca9 100644 --- a/x/reward/types/query.pb.gw.go +++ b/x/reward/types/query.pb.gw.go @@ -232,7 +232,7 @@ func local_request_Query_Rewards_0(ctx context.Context, marshaler runtime.Marsha } var ( - filter_Query_RewardsByAddress_0 = &utilities.DoubleArray{Encoding: map[string]int{"address": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} + filter_Query_RewardsByAddress_0 = &utilities.DoubleArray{Encoding: map[string]int{"promoter_uid": 0, "address": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} ) func request_Query_RewardsByAddress_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -246,6 +246,17 @@ func request_Query_RewardsByAddress_0(ctx context.Context, marshaler runtime.Mar _ = err ) + val, ok = pathParams["promoter_uid"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "promoter_uid") + } + + protoReq.PromoterUid, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "promoter_uid", err) + } + val, ok = pathParams["address"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") @@ -280,6 +291,17 @@ func local_request_Query_RewardsByAddress_0(ctx context.Context, marshaler runti _ = err ) + val, ok = pathParams["promoter_uid"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "promoter_uid") + } + + protoReq.PromoterUid, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "promoter_uid", err) + } + val, ok = pathParams["address"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") @@ -304,7 +326,7 @@ func local_request_Query_RewardsByAddress_0(ctx context.Context, marshaler runti } var ( - filter_Query_RewardsByAddressAndCategory_0 = &utilities.DoubleArray{Encoding: map[string]int{"address": 0, "category": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} + filter_Query_RewardsByAddressAndCategory_0 = &utilities.DoubleArray{Encoding: map[string]int{"promoter_uid": 0, "address": 1, "category": 2}, Base: []int{1, 1, 2, 3, 0, 0, 0}, Check: []int{0, 1, 1, 1, 2, 3, 4}} ) func request_Query_RewardsByAddressAndCategory_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -319,6 +341,17 @@ func request_Query_RewardsByAddressAndCategory_0(ctx context.Context, marshaler _ = err ) + val, ok = pathParams["promoter_uid"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "promoter_uid") + } + + protoReq.PromoterUid, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "promoter_uid", err) + } + val, ok = pathParams["address"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") @@ -367,6 +400,17 @@ func local_request_Query_RewardsByAddressAndCategory_0(ctx context.Context, mars _ = err ) + val, ok = pathParams["promoter_uid"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "promoter_uid") + } + + protoReq.PromoterUid, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "promoter_uid", err) + } + val, ok = pathParams["address"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") @@ -880,9 +924,9 @@ var ( pattern_Query_Rewards_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"sge-network", "sge", "reward", "rewards"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_RewardsByAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"sge-network", "sge", "reward", "rewards", "address"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_RewardsByAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"sge-network", "sge", "reward", "rewards", "promoter_uid", "address"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_RewardsByAddressAndCategory_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"sge-network", "sge", "reward", "rewards", "address", "category"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_RewardsByAddressAndCategory_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5, 1, 0, 4, 1, 5, 6}, []string{"sge-network", "sge", "reward", "rewards", "promoter_uid", "address", "category"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_RewardsByCampaign_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"sge-network", "sge", "reward", "rewards", "campaign", "campaign_uid"}, "", runtime.AssumeColonVerbOpt(false))) ) diff --git a/x/reward/types/reward_bet_bonus.go b/x/reward/types/reward_bet_bonus.go new file mode 100644 index 00000000..9156a9d1 --- /dev/null +++ b/x/reward/types/reward_bet_bonus.go @@ -0,0 +1,90 @@ +package types + +import ( + context "context" + + sdkerrors "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrtypes "github.com/cosmos/cosmos-sdk/types/errors" +) + +var percent = sdk.NewInt(100) + +// BetBonusReward is the type for bet bonus rewards calculations +type BetBonusReward struct{} + +// NewBetBonusReward create new object of bet bonus reward calculator type. +func NewBetBonusReward() BetBonusReward { return BetBonusReward{} } + +// ValidateCampaign validates campaign definitions. +func (sur BetBonusReward) ValidateCampaign(campaign Campaign) error { + if campaign.RewardCategory != RewardCategory_REWARD_CATEGORY_BET_DISCOUNT { + return sdkerrors.Wrapf(ErrWrongRewardCategory, "bet bonus rewards can only have single definition") + } + if campaign.RewardAmount.MainAccountAmount.GT(percent) { + return sdkerrors.Wrapf(ErrWrongAmountForType, "bet bonus rewards percent for main account should be between 0 and 100") + } + if campaign.RewardAmount.SubaccountAmount.GT(percent) { + return sdkerrors.Wrapf(ErrWrongAmountForType, "bet bonus rewards percent for sub account should be between 0 and 100") + } + if campaign.RewardAmount.MainAccountAmount.IsZero() && campaign.RewardAmount.SubaccountAmount.IsZero() { + return sdkerrors.Wrapf(ErrWrongAmountForType, "one of main account and sub account percentage should be higher than zero") + } + if campaign.RewardAmountType != RewardAmountType_REWARD_AMOUNT_TYPE_PERCENTAGE { + return sdkerrors.Wrapf(ErrWrongRewardAmountType, "reward amount type not supported for given reward type.") + } + + return nil +} + +// Calculate parses ticket payload and returns the distribution list of bet bonus reward. +func (sur BetBonusReward) Calculate(goCtx context.Context, ctx sdk.Context, keepers RewardFactoryKeepers, + campaign Campaign, ticket, creator string, +) (RewardFactoryData, error) { + var payload GrantBetBonusRewardPayload + if err := keepers.OVMKeeper.VerifyTicketUnmarshal(goCtx, ticket, &payload); err != nil { + return RewardFactoryData{}, sdkerrors.Wrapf(ErrInTicketVerification, "%s", err) + } + + if err := payload.Common.Validate(); err != nil { + return RewardFactoryData{}, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "%s", err) + } + + addr, err := sdk.AccAddressFromBech32(payload.Common.Receiver) + if err != nil { + return RewardFactoryData{}, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidAddress, "%s", err) + } + + if keepers.SubAccountKeeper.IsSubAccount(ctx, addr) { + return RewardFactoryData{}, ErrReceiverAddrCanNotBeSubAcc + } + + subAccountAddressString, err := keepers.getSubAccAddr(ctx, creator, payload.Common.Receiver) + if err != nil { + return RewardFactoryData{}, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidAddress, "%s", err) + } + + uid2ID, found := keepers.BetKeeper.GetBetID(ctx, payload.BetUID) + if !found { + return RewardFactoryData{}, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "bet id not found for uid %s", payload.BetUID) + } + + bet, found := keepers.BetKeeper.GetBet(ctx, payload.Common.Receiver, uid2ID.ID) + if !found { + return RewardFactoryData{}, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "bet not found with uid %s", payload.BetUID) + } + + mainAmount := bet.Amount.Mul(campaign.RewardAmount.MainAccountAmount).Quo(percent) + subAmount := bet.Amount.Mul(campaign.RewardAmount.SubaccountAmount).Quo(percent) + + return NewRewardFactoryData( + NewReceiver( + subAccountAddressString, + payload.Common.Receiver, + mainAmount, + subAmount, + campaign.RewardAmount.UnlockPeriod, + ), + payload.Common, + ), nil +} diff --git a/x/reward/types/reward_signup_affiliator.go b/x/reward/types/reward_signup_affiliator.go index 6dd0e5f9..7f969f0b 100644 --- a/x/reward/types/reward_signup_affiliator.go +++ b/x/reward/types/reward_signup_affiliator.go @@ -51,7 +51,12 @@ func (sur SignUpAffiliatorReward) Calculate(goCtx context.Context, ctx sdk.Conte return RewardFactoryData{}, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidAddress, "%s", err) } - if !keepers.RewardKeeper.HasRewardByReceiver(ctx, payload.Affiliatee, RewardCategory_REWARD_CATEGORY_SIGNUP) { + promoter, isFound := keepers.GetPromoterByAddress(ctx, campaign.Promoter) + if !isFound { + return RewardFactoryData{}, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "promoter with the address: %s not found", campaign.Promoter) + } + + if !keepers.RewardKeeper.HasRewardOfReceiverByPromoter(ctx, promoter.PromoterUID, payload.Affiliatee, RewardCategory_REWARD_CATEGORY_SIGNUP) { return RewardFactoryData{}, sdkerrors.Wrap(sdkerrtypes.ErrInvalidRequest, "affiliatee account has signed up yet, there is no affiliatee claim record") } diff --git a/x/reward/types/reward_signup_referrer.go b/x/reward/types/reward_signup_referrer.go index 5f95a2f4..7a8c344a 100644 --- a/x/reward/types/reward_signup_referrer.go +++ b/x/reward/types/reward_signup_referrer.go @@ -48,7 +48,12 @@ func (sur SignUpReferrerReward) Calculate(goCtx context.Context, ctx sdk.Context return RewardFactoryData{}, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidAddress, "%s", err) } - if !keepers.RewardKeeper.HasRewardByReceiver(ctx, payload.Referee, RewardCategory_REWARD_CATEGORY_SIGNUP) { + promoter, isFound := keepers.GetPromoterByAddress(ctx, campaign.Promoter) + if !isFound { + return RewardFactoryData{}, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "promoter with the address: %s not found", campaign.Promoter) + } + + if !keepers.RewardKeeper.HasRewardOfReceiverByPromoter(ctx, promoter.PromoterUID, payload.Referee, RewardCategory_REWARD_CATEGORY_SIGNUP) { return RewardFactoryData{}, sdkerrors.Wrap(sdkerrtypes.ErrInvalidRequest, "referee account has signed up yet, there is no referee claim record") } diff --git a/x/reward/types/ticket.go b/x/reward/types/ticket.go index 744035d4..b8f9d2dd 100644 --- a/x/reward/types/ticket.go +++ b/x/reward/types/ticket.go @@ -40,10 +40,6 @@ func (payload *CreateCampaignPayload) Validate(blockTime uint64) error { return sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "sub account should have unlock period") } - if payload.ClaimsPerCategory == 0 { - return sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "claim per category should be a positive number") - } - return nil } @@ -106,3 +102,21 @@ func (payload *RewardPayloadCommon) Validate() error { } return nil } + +// Validate validates promoter config set ticket payload. +func (payload *SetPromoterConfPayload) Validate() error { + catMap := make(map[RewardCategory]struct{}) + for _, v := range payload.Conf.CategoryCap { + _, ok := catMap[v.Category] + if ok { + return sdkerrors.Wrapf(ErrDuplicateCategoryInConf, "%s", v.Category) + } + if v.CapPerAcc <= 0 { + return sdkerrors.Wrapf(ErrCategoryCapShouldBePos, "%s", v.Category) + } + + catMap[v.Category] = struct{}{} + } + + return nil +} diff --git a/x/reward/types/ticket.pb.go b/x/reward/types/ticket.pb.go index 1fafafe4..178c3d0a 100644 --- a/x/reward/types/ticket.pb.go +++ b/x/reward/types/ticket.pb.go @@ -43,12 +43,11 @@ type CreateCampaignPayload struct { RewardAmount *RewardAmount `protobuf:"bytes,7,opt,name=reward_amount,json=rewardAmount,proto3" json:"reward_amount,omitempty"` // is_active is the flag to check if the campaign is active or not. IsActive bool `protobuf:"varint,8,opt,name=is_active,json=isActive,proto3" json:"is_active,omitempty"` - // claims_per_category is the number of times a user can claim a reward for - // category of this campaign. - ClaimsPerCategory uint64 `protobuf:"varint,9,opt,name=claims_per_category,json=claimsPerCategory,proto3" json:"claims_per_category,omitempty"` // meta is the metadata of the campaign. // It is a stringified base64 encoded json. Meta string `protobuf:"bytes,10,opt,name=meta,proto3" json:"meta,omitempty"` + // cap_count is the maximum allowed grant for a certain account. + CapCount uint64 `protobuf:"varint,11,opt,name=cap_count,json=capCount,proto3" json:"cap_count,omitempty"` } func (m *CreateCampaignPayload) Reset() { *m = CreateCampaignPayload{} } @@ -140,18 +139,18 @@ func (m *CreateCampaignPayload) GetIsActive() bool { return false } -func (m *CreateCampaignPayload) GetClaimsPerCategory() uint64 { +func (m *CreateCampaignPayload) GetMeta() string { if m != nil { - return m.ClaimsPerCategory + return m.Meta } - return 0 + return "" } -func (m *CreateCampaignPayload) GetMeta() string { +func (m *CreateCampaignPayload) GetCapCount() uint64 { if m != nil { - return m.Meta + return m.CapCount } - return "" + return 0 } // UpdateCampaignPayload is the type for campaign update payload. @@ -493,6 +492,107 @@ func (m *GrantSignupAffiliatorRewardPayload) GetAffiliatee() string { return "" } +// GrantBetBonusRewardPayload is the type for bet bonus reward +// grant payload. +type GrantBetBonusRewardPayload struct { + // common is the common properties of a reward + Common RewardPayloadCommon `protobuf:"bytes,1,opt,name=common,proto3" json:"common"` + // bet_uid is the list of uids + BetUID string `protobuf:"bytes,2,opt,name=bet_uid,proto3" json:"bet_uid"` +} + +func (m *GrantBetBonusRewardPayload) Reset() { *m = GrantBetBonusRewardPayload{} } +func (m *GrantBetBonusRewardPayload) String() string { return proto.CompactTextString(m) } +func (*GrantBetBonusRewardPayload) ProtoMessage() {} +func (*GrantBetBonusRewardPayload) Descriptor() ([]byte, []int) { + return fileDescriptor_5d710bc1249ca8ae, []int{7} +} +func (m *GrantBetBonusRewardPayload) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GrantBetBonusRewardPayload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GrantBetBonusRewardPayload.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 *GrantBetBonusRewardPayload) XXX_Merge(src proto.Message) { + xxx_messageInfo_GrantBetBonusRewardPayload.Merge(m, src) +} +func (m *GrantBetBonusRewardPayload) XXX_Size() int { + return m.Size() +} +func (m *GrantBetBonusRewardPayload) XXX_DiscardUnknown() { + xxx_messageInfo_GrantBetBonusRewardPayload.DiscardUnknown(m) +} + +var xxx_messageInfo_GrantBetBonusRewardPayload proto.InternalMessageInfo + +func (m *GrantBetBonusRewardPayload) GetCommon() RewardPayloadCommon { + if m != nil { + return m.Common + } + return RewardPayloadCommon{} +} + +func (m *GrantBetBonusRewardPayload) GetBetUID() string { + if m != nil { + return m.BetUID + } + return "" +} + +// SetPromoterConfPayload is the payload for the promoter configuration change. +type SetPromoterConfPayload struct { + Conf PromoterConf `protobuf:"bytes,1,opt,name=conf,proto3" json:"conf"` +} + +func (m *SetPromoterConfPayload) Reset() { *m = SetPromoterConfPayload{} } +func (m *SetPromoterConfPayload) String() string { return proto.CompactTextString(m) } +func (*SetPromoterConfPayload) ProtoMessage() {} +func (*SetPromoterConfPayload) Descriptor() ([]byte, []int) { + return fileDescriptor_5d710bc1249ca8ae, []int{8} +} +func (m *SetPromoterConfPayload) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SetPromoterConfPayload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SetPromoterConfPayload.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 *SetPromoterConfPayload) XXX_Merge(src proto.Message) { + xxx_messageInfo_SetPromoterConfPayload.Merge(m, src) +} +func (m *SetPromoterConfPayload) XXX_Size() int { + return m.Size() +} +func (m *SetPromoterConfPayload) XXX_DiscardUnknown() { + xxx_messageInfo_SetPromoterConfPayload.DiscardUnknown(m) +} + +var xxx_messageInfo_SetPromoterConfPayload proto.InternalMessageInfo + +func (m *SetPromoterConfPayload) GetConf() PromoterConf { + if m != nil { + return m.Conf + } + return PromoterConf{} +} + func init() { proto.RegisterType((*CreateCampaignPayload)(nil), "sgenetwork.sge.reward.CreateCampaignPayload") proto.RegisterType((*UpdateCampaignPayload)(nil), "sgenetwork.sge.reward.UpdateCampaignPayload") @@ -501,52 +601,58 @@ func init() { proto.RegisterType((*GrantSignupRewardPayload)(nil), "sgenetwork.sge.reward.GrantSignupRewardPayload") proto.RegisterType((*GrantSignupReferrerRewardPayload)(nil), "sgenetwork.sge.reward.GrantSignupReferrerRewardPayload") proto.RegisterType((*GrantSignupAffiliatorRewardPayload)(nil), "sgenetwork.sge.reward.GrantSignupAffiliatorRewardPayload") + proto.RegisterType((*GrantBetBonusRewardPayload)(nil), "sgenetwork.sge.reward.GrantBetBonusRewardPayload") + proto.RegisterType((*SetPromoterConfPayload)(nil), "sgenetwork.sge.reward.SetPromoterConfPayload") } func init() { proto.RegisterFile("sge/reward/ticket.proto", fileDescriptor_5d710bc1249ca8ae) } var fileDescriptor_5d710bc1249ca8ae = []byte{ - // 633 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0x4f, 0x6b, 0xd4, 0x40, - 0x14, 0xdf, 0x69, 0xb7, 0xbb, 0xd9, 0x57, 0x15, 0x9d, 0x76, 0x31, 0xb6, 0x90, 0xae, 0x11, 0x71, - 0x15, 0xcc, 0xc2, 0x7a, 0x14, 0x84, 0xdd, 0x2d, 0x5a, 0xe9, 0xa5, 0xa4, 0x2d, 0x82, 0x97, 0x30, - 0x4d, 0xa6, 0xe9, 0xb0, 0x4d, 0x26, 0xcc, 0xcc, 0xb6, 0xe6, 0x0b, 0x78, 0x14, 0x3f, 0x93, 0xa7, - 0x1e, 0x7b, 0xf4, 0x54, 0x64, 0x7b, 0xf3, 0xe0, 0x67, 0x90, 0x4c, 0xd2, 0x34, 0x2b, 0x75, 0x29, - 0x88, 0xa7, 0xbc, 0x37, 0xef, 0xf7, 0x7e, 0xef, 0xf7, 0xfe, 0x10, 0x78, 0x28, 0x43, 0xda, 0x13, - 0xf4, 0x94, 0x88, 0xa0, 0xa7, 0x98, 0x3f, 0xa6, 0xca, 0x49, 0x04, 0x57, 0x1c, 0xb7, 0x65, 0x48, - 0x63, 0xaa, 0x4e, 0xb9, 0x18, 0x3b, 0x32, 0xa4, 0x4e, 0x8e, 0x59, 0x5b, 0x0d, 0x79, 0xc8, 0x35, - 0xa2, 0x97, 0x59, 0x39, 0x78, 0x0d, 0x67, 0x2c, 0x2a, 0x4d, 0x68, 0x6f, 0x9c, 0xfa, 0xc5, 0x5b, - 0x95, 0x39, 0xff, 0xe4, 0x01, 0xfb, 0xd7, 0x22, 0xb4, 0x47, 0x82, 0x12, 0x45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 0x2a, 0x04, 0x15, 0x7f, 0x2b, 0x87, - 0xfe, 0xad, 0x1c, 0x36, 0xa1, 0x29, 0xb2, 0x12, 0x34, 0x5f, 0x74, 0xcb, 0xbd, 0x72, 0xed, 0x2f, - 0x08, 0xec, 0x8a, 0x90, 0xc1, 0xe1, 0x21, 0x3b, 0x66, 0x44, 0xf1, 0xff, 0x26, 0xc5, 0x02, 0x20, - 0x45, 0x91, 0x52, 0x4d, 0xe5, 0x65, 0x38, 0x3a, 0x9b, 0x5a, 0xe8, 0x7c, 0x6a, 0xa1, 0x1f, 0x53, - 0x0b, 0x7d, 0xbd, 0xb4, 0x6a, 0xe7, 0x97, 0x56, 0xed, 0xfb, 0xa5, 0x55, 0xfb, 0xf8, 0x3c, 0x64, - 0xea, 0x68, 0x72, 0xe0, 0xf8, 0x3c, 0xea, 0xc9, 0x90, 0xbe, 0x2c, 0xca, 0x67, 0x76, 0xef, 0x53, - 0xf9, 0x73, 0x4d, 0x13, 0x2a, 0x0f, 0x1a, 0xfa, 0x17, 0xf8, 0xea, 0x77, 0x00, 0x00, 0x00, 0xff, - 0xff, 0x28, 0xb9, 0x2a, 0x10, 0x77, 0x05, 0x00, 0x00, + // 698 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0x41, 0x6b, 0xdb, 0x4a, + 0x10, 0xf6, 0x26, 0x8e, 0x2d, 0x8f, 0xdf, 0x7b, 0x3c, 0xf6, 0xc5, 0xaf, 0x8a, 0x03, 0xb6, 0xab, + 0x52, 0xea, 0x16, 0x6a, 0x83, 0x7b, 0x2c, 0x2d, 0xd8, 0x0e, 0x6d, 0x4a, 0x2e, 0x41, 0x49, 0x08, + 0xf4, 0x62, 0x36, 0xd2, 0x58, 0x11, 0x8e, 0xb5, 0x62, 0x77, 0x9d, 0x54, 0x7f, 0xa0, 0xc7, 0xd2, + 0x5b, 0xff, 0x4f, 0x4f, 0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0xa8, 0x57, 0x90, 0x77, 0x78, 0x30, 0x4c, 0x25, 0xdd, 0xf4, + 0x10, 0x64, 0x33, 0x53, 0x2d, 0x3a, 0xad, 0xd7, 0x3f, 0x9f, 0xd5, 0xc8, 0xc5, 0xac, 0x46, 0x7e, + 0xcc, 0x6a, 0xe4, 0xf3, 0x65, 0x2d, 0x77, 0x71, 0x59, 0xcb, 0x7d, 0xbb, 0xac, 0xe5, 0xde, 0x3f, + 0xf5, 0x7c, 0x75, 0x3c, 0x39, 0x6a, 0x39, 0x7c, 0xdc, 0x96, 0x1e, 0x3e, 0x4f, 0x59, 0x63, 0xbb, + 0xfd, 0x61, 0xf1, 0x5f, 0x89, 0x42, 0x94, 0x47, 0x05, 0xfd, 0xc4, 0xbf, 0xf8, 0x15, 0x00, 0x00, + 0xff, 0xff, 0x36, 0x67, 0x85, 0x1c, 0x72, 0x06, 0x00, 0x00, } func (m *CreateCampaignPayload) Marshal() (dAtA []byte, err error) { @@ -569,6 +675,11 @@ func (m *CreateCampaignPayload) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.CapCount != 0 { + i = encodeVarintTicket(dAtA, i, uint64(m.CapCount)) + i-- + dAtA[i] = 0x58 + } if len(m.Meta) > 0 { i -= len(m.Meta) copy(dAtA[i:], m.Meta) @@ -576,11 +687,6 @@ func (m *CreateCampaignPayload) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x52 } - if m.ClaimsPerCategory != 0 { - i = encodeVarintTicket(dAtA, i, uint64(m.ClaimsPerCategory)) - i-- - dAtA[i] = 0x48 - } if m.IsActive { i-- if m.IsActive { @@ -875,6 +981,79 @@ func (m *GrantSignupAffiliatorRewardPayload) MarshalToSizedBuffer(dAtA []byte) ( return len(dAtA) - i, nil } +func (m *GrantBetBonusRewardPayload) 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 *GrantBetBonusRewardPayload) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GrantBetBonusRewardPayload) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.BetUID) > 0 { + i -= len(m.BetUID) + copy(dAtA[i:], m.BetUID) + i = encodeVarintTicket(dAtA, i, uint64(len(m.BetUID))) + i-- + dAtA[i] = 0x12 + } + { + size, err := m.Common.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 (m *SetPromoterConfPayload) 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 *SetPromoterConfPayload) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SetPromoterConfPayload) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Conf.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 @@ -918,13 +1097,13 @@ func (m *CreateCampaignPayload) Size() (n int) { if m.IsActive { n += 2 } - if m.ClaimsPerCategory != 0 { - n += 1 + sovTicket(uint64(m.ClaimsPerCategory)) - } l = len(m.Meta) if l > 0 { n += 1 + l + sovTicket(uint64(l)) } + if m.CapCount != 0 { + n += 1 + sovTicket(uint64(m.CapCount)) + } return n } @@ -1022,6 +1201,32 @@ func (m *GrantSignupAffiliatorRewardPayload) Size() (n int) { return n } +func (m *GrantBetBonusRewardPayload) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Common.Size() + n += 1 + l + sovTicket(uint64(l)) + l = len(m.BetUID) + if l > 0 { + n += 1 + l + sovTicket(uint64(l)) + } + return n +} + +func (m *SetPromoterConfPayload) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Conf.Size() + n += 1 + l + sovTicket(uint64(l)) + return n +} + func sovTicket(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1240,25 +1445,6 @@ func (m *CreateCampaignPayload) Unmarshal(dAtA []byte) error { } } m.IsActive = bool(v != 0) - case 9: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ClaimsPerCategory", wireType) - } - m.ClaimsPerCategory = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTicket - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ClaimsPerCategory |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } case 10: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Meta", wireType) @@ -1291,6 +1477,25 @@ func (m *CreateCampaignPayload) Unmarshal(dAtA []byte) error { } m.Meta = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 11: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CapCount", wireType) + } + m.CapCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTicket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CapCount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipTicket(dAtA[iNdEx:]) @@ -1978,6 +2183,204 @@ func (m *GrantSignupAffiliatorRewardPayload) Unmarshal(dAtA []byte) error { } return nil } +func (m *GrantBetBonusRewardPayload) 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: GrantBetBonusRewardPayload: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GrantBetBonusRewardPayload: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Common", 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 err := m.Common.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BetUID", 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 + } + m.BetUID = string(dAtA[iNdEx:postIndex]) + 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 (m *SetPromoterConfPayload) 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: SetPromoterConfPayload: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SetPromoterConfPayload: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Conf", 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 err := m.Conf.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 diff --git a/x/reward/types/ticket_test.go b/x/reward/types/ticket_test.go index 061a4ab3..069a9ff0 100644 --- a/x/reward/types/ticket_test.go +++ b/x/reward/types/ticket_test.go @@ -61,9 +61,8 @@ func TestCreateCampaignPayloadValidation(t *testing.T) { SubaccountAmount: sdkmath.NewInt(1000), UnlockPeriod: uint64(time.Now().Add(10 * time.Minute).Unix()), }, - ClaimsPerCategory: 1, - IsActive: true, - Meta: "sample campaign", + IsActive: true, + Meta: "sample campaign", }, }, } diff --git a/x/reward/types/tx.pb.go b/x/reward/types/tx.pb.go index 6c7fa231..70c55422 100644 --- a/x/reward/types/tx.pb.go +++ b/x/reward/types/tx.pb.go @@ -29,6 +29,107 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// MsgSetPromoterConf is msg to set promoter configuration. +type MsgSetPromoterConf struct { + // creator is the address of message signer account. + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + // uid is the unique identifier of the promoter. + Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid,omitempty"` + // ticket is the payload data. + Ticket string `protobuf:"bytes,3,opt,name=ticket,proto3" json:"ticket,omitempty"` +} + +func (m *MsgSetPromoterConf) Reset() { *m = MsgSetPromoterConf{} } +func (m *MsgSetPromoterConf) String() string { return proto.CompactTextString(m) } +func (*MsgSetPromoterConf) ProtoMessage() {} +func (*MsgSetPromoterConf) Descriptor() ([]byte, []int) { + return fileDescriptor_ad69e28332238e66, []int{0} +} +func (m *MsgSetPromoterConf) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetPromoterConf) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetPromoterConf.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 *MsgSetPromoterConf) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetPromoterConf.Merge(m, src) +} +func (m *MsgSetPromoterConf) XXX_Size() int { + return m.Size() +} +func (m *MsgSetPromoterConf) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetPromoterConf.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetPromoterConf proto.InternalMessageInfo + +func (m *MsgSetPromoterConf) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgSetPromoterConf) GetUid() string { + if m != nil { + return m.Uid + } + return "" +} + +func (m *MsgSetPromoterConf) GetTicket() string { + if m != nil { + return m.Ticket + } + return "" +} + +// MsgCreateCampaignResponse campaign create message response type. +type MsgSetPromoterConfResponse struct { +} + +func (m *MsgSetPromoterConfResponse) Reset() { *m = MsgSetPromoterConfResponse{} } +func (m *MsgSetPromoterConfResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSetPromoterConfResponse) ProtoMessage() {} +func (*MsgSetPromoterConfResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_ad69e28332238e66, []int{1} +} +func (m *MsgSetPromoterConfResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetPromoterConfResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetPromoterConfResponse.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 *MsgSetPromoterConfResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetPromoterConfResponse.Merge(m, src) +} +func (m *MsgSetPromoterConfResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSetPromoterConfResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetPromoterConfResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetPromoterConfResponse proto.InternalMessageInfo + // MsgCreateCampaign is msg to create a reward campaign type MsgCreateCampaign struct { // creator is the address of campaign creator account. @@ -45,7 +146,7 @@ func (m *MsgCreateCampaign) Reset() { *m = MsgCreateCampaign{} } func (m *MsgCreateCampaign) String() string { return proto.CompactTextString(m) } func (*MsgCreateCampaign) ProtoMessage() {} func (*MsgCreateCampaign) Descriptor() ([]byte, []int) { - return fileDescriptor_ad69e28332238e66, []int{0} + return fileDescriptor_ad69e28332238e66, []int{2} } func (m *MsgCreateCampaign) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -103,7 +204,7 @@ func (m *MsgCreateCampaignResponse) Reset() { *m = MsgCreateCampaignResp func (m *MsgCreateCampaignResponse) String() string { return proto.CompactTextString(m) } func (*MsgCreateCampaignResponse) ProtoMessage() {} func (*MsgCreateCampaignResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ad69e28332238e66, []int{1} + return fileDescriptor_ad69e28332238e66, []int{3} } func (m *MsgCreateCampaignResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -149,7 +250,7 @@ func (m *MsgUpdateCampaign) Reset() { *m = MsgUpdateCampaign{} } func (m *MsgUpdateCampaign) String() string { return proto.CompactTextString(m) } func (*MsgUpdateCampaign) ProtoMessage() {} func (*MsgUpdateCampaign) Descriptor() ([]byte, []int) { - return fileDescriptor_ad69e28332238e66, []int{2} + return fileDescriptor_ad69e28332238e66, []int{4} } func (m *MsgUpdateCampaign) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -207,7 +308,7 @@ func (m *MsgUpdateCampaignResponse) Reset() { *m = MsgUpdateCampaignResp func (m *MsgUpdateCampaignResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateCampaignResponse) ProtoMessage() {} func (*MsgUpdateCampaignResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ad69e28332238e66, []int{3} + return fileDescriptor_ad69e28332238e66, []int{5} } func (m *MsgUpdateCampaignResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -252,7 +353,7 @@ func (m *MsgGrantReward) Reset() { *m = MsgGrantReward{} } func (m *MsgGrantReward) String() string { return proto.CompactTextString(m) } func (*MsgGrantReward) ProtoMessage() {} func (*MsgGrantReward) Descriptor() ([]byte, []int) { - return fileDescriptor_ad69e28332238e66, []int{4} + return fileDescriptor_ad69e28332238e66, []int{6} } func (m *MsgGrantReward) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -317,7 +418,7 @@ func (m *MsgGrantRewardResponse) Reset() { *m = MsgGrantRewardResponse{} func (m *MsgGrantRewardResponse) String() string { return proto.CompactTextString(m) } func (*MsgGrantRewardResponse) ProtoMessage() {} func (*MsgGrantRewardResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ad69e28332238e66, []int{5} + return fileDescriptor_ad69e28332238e66, []int{7} } func (m *MsgGrantRewardResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -360,7 +461,7 @@ func (m *MsgWithdrawFunds) Reset() { *m = MsgWithdrawFunds{} } func (m *MsgWithdrawFunds) String() string { return proto.CompactTextString(m) } func (*MsgWithdrawFunds) ProtoMessage() {} func (*MsgWithdrawFunds) Descriptor() ([]byte, []int) { - return fileDescriptor_ad69e28332238e66, []int{6} + return fileDescriptor_ad69e28332238e66, []int{8} } func (m *MsgWithdrawFunds) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -418,7 +519,7 @@ func (m *MsgWithdrawFundsResponse) Reset() { *m = MsgWithdrawFundsRespon func (m *MsgWithdrawFundsResponse) String() string { return proto.CompactTextString(m) } func (*MsgWithdrawFundsResponse) ProtoMessage() {} func (*MsgWithdrawFundsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ad69e28332238e66, []int{7} + return fileDescriptor_ad69e28332238e66, []int{9} } func (m *MsgWithdrawFundsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -448,6 +549,8 @@ func (m *MsgWithdrawFundsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgWithdrawFundsResponse proto.InternalMessageInfo func init() { + proto.RegisterType((*MsgSetPromoterConf)(nil), "sgenetwork.sge.reward.MsgSetPromoterConf") + proto.RegisterType((*MsgSetPromoterConfResponse)(nil), "sgenetwork.sge.reward.MsgSetPromoterConfResponse") proto.RegisterType((*MsgCreateCampaign)(nil), "sgenetwork.sge.reward.MsgCreateCampaign") proto.RegisterType((*MsgCreateCampaignResponse)(nil), "sgenetwork.sge.reward.MsgCreateCampaignResponse") proto.RegisterType((*MsgUpdateCampaign)(nil), "sgenetwork.sge.reward.MsgUpdateCampaign") @@ -461,37 +564,39 @@ func init() { func init() { proto.RegisterFile("sge/reward/tx.proto", fileDescriptor_ad69e28332238e66) } var fileDescriptor_ad69e28332238e66 = []byte{ - // 468 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x94, 0x41, 0x6f, 0xd3, 0x30, - 0x14, 0xc7, 0x1b, 0x82, 0x86, 0x78, 0x85, 0x69, 0x04, 0x36, 0x85, 0x20, 0xa5, 0x50, 0x09, 0x31, - 0x0e, 0x73, 0x10, 0xbb, 0x71, 0x5c, 0x25, 0x10, 0x87, 0x5e, 0x22, 0x06, 0x12, 0x97, 0xc9, 0x4b, - 0x8c, 0x6b, 0xb5, 0x89, 0x2d, 0xdb, 0x51, 0xb7, 0x6f, 0xc1, 0x17, 0xe1, 0xc0, 0xb7, 0xd8, 0x71, - 0x47, 0xc4, 0xa1, 0x42, 0xed, 0x37, 0xe0, 0x13, 0x20, 0xbb, 0x4d, 0x68, 0xba, 0x75, 0x4a, 0xe1, - 0xe6, 0xe7, 0xf7, 0x7f, 0xef, 0xf7, 0xfe, 0xc9, 0x93, 0xe1, 0xa1, 0xa2, 0x24, 0x92, 0x64, 0x8c, - 0x65, 0x1a, 0xe9, 0x33, 0x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xe4, 0x04, 0x00, 0x00, + // 505 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x41, 0x6e, 0xd3, 0x40, + 0x14, 0x8d, 0x49, 0x55, 0xc4, 0x0f, 0x94, 0x62, 0x68, 0x65, 0x0c, 0x72, 0xc0, 0x12, 0xa2, 0x5d, + 0xd4, 0x06, 0xba, 0x63, 0xd9, 0x48, 0x20, 0x16, 0x96, 0x50, 0xa0, 0x80, 0xd8, 0x54, 0x53, 0x7b, + 0x3a, 0xb1, 0x12, 0x7b, 0x46, 0x33, 0x63, 0xa5, 0xbd, 0x05, 0x67, 0x60, 0xcf, 0x3d, 0xba, 0xec, + 0x12, 0xb1, 0x88, 0x50, 0x72, 0x03, 0x4e, 0x80, 0x6c, 0xc7, 0x96, 0xc7, 0x69, 0x2a, 0x07, 0xba, + 0x9b, 0x3f, 0x7e, 0xff, 0xbd, 0xff, 0xe4, 0xf7, 0x07, 0xee, 0x0b, 0x82, 0x5d, 0x8e, 0xc7, 0x88, + 0x07, 0xae, 0x3c, 0x75, 0x18, 0xa7, 0x92, 0xea, 0x5b, 0x82, 0xe0, 0x18, 0xcb, 0x31, 0xe5, 0x43, + 0x47, 0x10, 0xec, 0xe4, 0xdf, 0xcd, 0x07, 0x84, 0x12, 0x9a, 0x21, 0xdc, 0xf4, 0x94, 0x83, 0xed, + 0x2f, 0xa0, 0x7b, 0x82, 0x7c, 0xc0, 0xf2, 0x3d, 0xa7, 0x11, 0x95, 0x98, 0xf7, 0x68, 0x7c, 0xa2, + 0x1b, 0x70, 0xd3, 0xe7, 0x18, 0x49, 0xca, 0x0d, 0xed, 0x89, 0xb6, 0x73, 0xab, 0x5f, 0x94, 0xfa, + 0x26, 0xb4, 0x93, 0x30, 0x30, 0x6e, 0x64, 0xb7, 0xe9, 0x51, 0xdf, 0x86, 0x75, 0x19, 0xfa, 0x43, + 0x2c, 0x8d, 0x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x4f, 0x10, 0x9d, 0xc2, 0xdd, 0xfa, 0x76, + 0xec, 0x3a, 0x97, 0x6e, 0x98, 0xb3, 0x18, 0x77, 0xf3, 0x65, 0x63, 0x68, 0x21, 0xac, 0x8f, 0x60, + 0xa3, 0xb6, 0x15, 0x3b, 0xcb, 0x49, 0x54, 0xa4, 0xf9, 0xa2, 0x29, 0xb2, 0xaa, 0x56, 0x8b, 0xed, + 0x15, 0x6a, 0x2a, 0xf2, 0x2a, 0xb5, 0xcb, 0xb3, 0xa5, 0x87, 0x70, 0x47, 0xfd, 0x8b, 0xcf, 0x97, + 0x53, 0x28, 0x40, 0xd3, 0x6d, 0x08, 0x2c, 0xa5, 0x7c, 0xe8, 0x54, 0x33, 0xfc, 0x6c, 0x79, 0x7f, + 0x05, 0x66, 0xee, 0x35, 0x82, 0x15, 0x22, 0x07, 0xbd, 0xf3, 0xa9, 0xa5, 0x5d, 0x4c, 0x2d, 0xed, + 0xf7, 0xd4, 0xd2, 0xbe, 0xcd, 0xac, 0xd6, 0xc5, 0xcc, 0x6a, 0xfd, 0x9c, 0x59, 0xad, 0xaf, 0xbb, + 0x24, 0x94, 0x83, 0xe4, 0xd8, 0xf1, 0x69, 0xe4, 0x0a, 0x82, 0xf7, 0xe6, 0x9c, 0xe9, 0xd9, 0x3d, + 0x2d, 0x9f, 0xec, 0x33, 0x86, 0xc5, 0xf1, 0x7a, 0xf6, 0x12, 0xef, 0xff, 0x0d, 0x00, 0x00, 0xff, + 0xff, 0x85, 0x43, 0xde, 0x62, 0xcd, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -506,6 +611,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 { + // SetPromoterConf is a method to set the configurations of a promoter. + SetPromoterConf(ctx context.Context, in *MsgSetPromoterConf, opts ...grpc.CallOption) (*MsgSetPromoterConfResponse, error) // CreateCampaign is a method to create a campaign CreateCampaign(ctx context.Context, in *MsgCreateCampaign, opts ...grpc.CallOption) (*MsgCreateCampaignResponse, error) // UpdateCampaign is a method to update campaign @@ -524,6 +631,15 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } +func (c *msgClient) SetPromoterConf(ctx context.Context, in *MsgSetPromoterConf, opts ...grpc.CallOption) (*MsgSetPromoterConfResponse, error) { + out := new(MsgSetPromoterConfResponse) + err := c.cc.Invoke(ctx, "/sgenetwork.sge.reward.Msg/SetPromoterConf", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *msgClient) CreateCampaign(ctx context.Context, in *MsgCreateCampaign, opts ...grpc.CallOption) (*MsgCreateCampaignResponse, error) { out := new(MsgCreateCampaignResponse) err := c.cc.Invoke(ctx, "/sgenetwork.sge.reward.Msg/CreateCampaign", in, out, opts...) @@ -562,6 +678,8 @@ func (c *msgClient) GrantReward(ctx context.Context, in *MsgGrantReward, opts .. // MsgServer is the server API for Msg service. type MsgServer interface { + // SetPromoterConf is a method to set the configurations of a promoter. + SetPromoterConf(context.Context, *MsgSetPromoterConf) (*MsgSetPromoterConfResponse, error) // CreateCampaign is a method to create a campaign CreateCampaign(context.Context, *MsgCreateCampaign) (*MsgCreateCampaignResponse, error) // UpdateCampaign is a method to update campaign @@ -576,6 +694,9 @@ type MsgServer interface { type UnimplementedMsgServer struct { } +func (*UnimplementedMsgServer) SetPromoterConf(ctx context.Context, req *MsgSetPromoterConf) (*MsgSetPromoterConfResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetPromoterConf not implemented") +} func (*UnimplementedMsgServer) CreateCampaign(ctx context.Context, req *MsgCreateCampaign) (*MsgCreateCampaignResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateCampaign not implemented") } @@ -593,6 +714,24 @@ func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } +func _Msg_SetPromoterConf_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSetPromoterConf) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SetPromoterConf(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/sgenetwork.sge.reward.Msg/SetPromoterConf", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SetPromoterConf(ctx, req.(*MsgSetPromoterConf)) + } + return interceptor(ctx, in, info, handler) +} + func _Msg_CreateCampaign_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgCreateCampaign) if err := dec(in); err != nil { @@ -669,6 +808,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "sgenetwork.sge.reward.Msg", HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ + { + MethodName: "SetPromoterConf", + Handler: _Msg_SetPromoterConf_Handler, + }, { MethodName: "CreateCampaign", Handler: _Msg_CreateCampaign_Handler, @@ -690,6 +833,73 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Metadata: "sge/reward/tx.proto", } +func (m *MsgSetPromoterConf) 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 *MsgSetPromoterConf) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetPromoterConf) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + 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] = 0x1a + } + if len(m.Uid) > 0 { + i -= len(m.Uid) + copy(dAtA[i:], m.Uid) + i = encodeVarintTx(dAtA, i, uint64(len(m.Uid))) + 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 + } + return len(dAtA) - i, nil +} + +func (m *MsgSetPromoterConfResponse) 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 *MsgSetPromoterConfResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetPromoterConfResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func (m *MsgCreateCampaign) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -996,6 +1206,36 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *MsgSetPromoterConf) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Uid) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Ticket) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgSetPromoterConfResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func (m *MsgCreateCampaign) Size() (n int) { if m == nil { return 0 @@ -1130,6 +1370,202 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (m *MsgSetPromoterConf) 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 ErrIntOverflowTx + } + 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: MsgSetPromoterConf: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetPromoterConf: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Uid", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Uid = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Ticket", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Ticket = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgSetPromoterConfResponse) 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 ErrIntOverflowTx + } + 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: MsgSetPromoterConfResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetPromoterConfResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *MsgCreateCampaign) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0