From 9156b40514aeb7b75ca0dea30822d2a59a3bb000 Mon Sep 17 00:00:00 2001 From: P-U-D-G-E Date: Tue, 7 Nov 2023 17:34:18 +0530 Subject: [PATCH 01/12] working state --- x/reward/keeper/msg_server_campaign.go | 4 ++ x/reward/keeper/msg_server_reward.go | 20 +++++----- x/reward/keeper/query_reward.go | 23 +----------- x/reward/keeper/reward.go | 30 --------------- x/reward/types/reward.go | 52 +++++++++++++------------- x/reward/types/reward_signup.go | 3 -- x/reward/types/ticket.go | 6 +-- 7 files changed, 45 insertions(+), 93 deletions(-) diff --git a/x/reward/keeper/msg_server_campaign.go b/x/reward/keeper/msg_server_campaign.go index b7ff33a4..7bd01bfc 100644 --- a/x/reward/keeper/msg_server_campaign.go +++ b/x/reward/keeper/msg_server_campaign.go @@ -108,3 +108,7 @@ func (k msgServer) UpdateCampaign(goCtx context.Context, msg *types.MsgUpdateCam return &types.MsgUpdateCampaignResponse{}, nil } + +func (k msgServer) WithdrawFunds(goCtx context.Context, msg *types.MsgWithdrawFunds) (*types.MsgWithdrawFundsResponse, error) { + return nil, nil +} diff --git a/x/reward/keeper/msg_server_reward.go b/x/reward/keeper/msg_server_reward.go index 1483e334..f4438e99 100644 --- a/x/reward/keeper/msg_server_reward.go +++ b/x/reward/keeper/msg_server_reward.go @@ -27,7 +27,7 @@ func (k msgServer) GrantReward(goCtx context.Context, msg *types.MsgGrantReward) return nil, sdkerrors.Wrap(sdkerrtypes.ErrInvalidRequest, "failed to retrieve reward factory") } - recevier, rewardCommon, isSubAccount, oneTimeKey, err := rewardFactory.Calculate(goCtx, ctx, + recevier, _, isSubAccount, _, err := rewardFactory.Calculate(goCtx, ctx, types.RewardFactoryKeepers{ OVMKeeper: k.ovmKeeper, BetKeeper: k.betKeeper, @@ -46,15 +46,15 @@ func (k msgServer) GrantReward(goCtx context.Context, msg *types.MsgGrantReward) } k.UpdateCampaignPool(ctx, campaign, recevier) - k.SetReward(ctx, types.NewReward( - msg.Uid, msg.Creator, recevier.Addr, - msg.CampaignUid, campaign.RewardAmount, - rewardCommon.Source, rewardCommon.SourceCode, rewardCommon.SourceUID, - uint64(ctx.BlockTime().Unix()), - )) - k.SetOneTimeReward(ctx, types.NewOneTimeReward(oneTimeKey, campaign.RewardType)) - k.SetRewardByReceiver(ctx, types.NewRewardByType(msg.Uid, recevier.Addr, campaign.RewardType)) - k.SetRewardByCampaign(ctx, types.NewRewardByCampaign(msg.Uid, campaign.UID)) + // k.SetReward(ctx, types.NewReward( + // msg.Uid, msg.Creator, recevier.Addr, + // msg.CampaignUid, campaign.RewardAmount, + // rewardCommon.Source, rewardCommon.SourceCode, rewardCommon.SourceUID, + // uint64(ctx.BlockTime().Unix()), + // )) + // k.SetOneTimeReward(ctx, types.NewOneTimeReward(oneTimeKey, campaign.RewardType)) + // k.SetRewardByReceiver(ctx, types.NewRewardByType(msg.Uid, recevier.Addr, campaign.RewardType)) + // k.SetRewardByCampaign(ctx, types.NewRewardByCampaign(msg.Uid, campaign.UID)) msg.EmitEvent(&ctx, msg.CampaignUid, recevier) diff --git a/x/reward/keeper/query_reward.go b/x/reward/keeper/query_reward.go index 4af15da8..d6dc9b32 100644 --- a/x/reward/keeper/query_reward.go +++ b/x/reward/keeper/query_reward.go @@ -82,31 +82,12 @@ func (k Keeper) RewardsByAddress(goCtx context.Context, req *types.QueryRewardsB return &types.QueryRewardsByAddressResponse{Rewards: rewards, Pagination: pageRes}, nil } -func (k Keeper) RewardsByAddressAndType(goCtx context.Context, req *types.QueryRewardsByAddressAndTypeRequest) (*types.QueryRewardsByAddressAndTypeResponse, error) { +func (k Keeper) RewardsByAddressAndCategory(goCtx context.Context, req *types.QueryRewardsByAddressAndCategoryRequest) (*types.QueryRewardsByAddressAndCategoryResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } - var rewards []types.Reward - ctx := sdk.UnwrapSDKContext(goCtx) - - store := k.getRewardByReceiverAndTypeStore(ctx) - rewardStore := prefix.NewStore(store, types.GetRewardsByTypePrefix(req.Address, req.RewardType)) - - pageRes, err := query.Paginate(rewardStore, req.Pagination, func(key []byte, value []byte) error { - var reward types.Reward - if err := k.cdc.Unmarshal(value, &reward); err != nil { - return err - } - - rewards = append(rewards, reward) - return nil - }) - if err != nil { - return nil, status.Error(codes.Internal, err.Error()) - } - - return &types.QueryRewardsByAddressAndTypeResponse{Rewards: rewards, Pagination: pageRes}, nil + return nil, nil } func (k Keeper) RewardsByCampaign(goCtx context.Context, req *types.QueryRewardsByCampaignRequest) (*types.QueryRewardsByCampaignResponse, error) { diff --git a/x/reward/keeper/reward.go b/x/reward/keeper/reward.go index 40960468..9142d0c1 100644 --- a/x/reward/keeper/reward.go +++ b/x/reward/keeper/reward.go @@ -52,33 +52,3 @@ func (k Keeper) GetAllReward(ctx sdk.Context) (list []types.Reward) { return } - -// SetOneTimeReward set a specific record to track if a reward is already given or not. -func (k Keeper) SetOneTimeReward(ctx sdk.Context, oneTimeReward types.OneTimeReward) { - store := k.getRewardOneTimeStore(ctx) - b := k.cdc.MustMarshal(&oneTimeReward) - store.Set(types.GetOneTimeRewardsPrefix(oneTimeReward.RewardType, oneTimeReward.OneTimeKey), b) -} - -// HasOneTimeReward returns if the reward for the reward type is already given. -func (k Keeper) HasOneTimeReward( - ctx sdk.Context, - oneTimeReward types.OneTimeReward, -) bool { - store := k.getRewardOneTimeStore(ctx) - return store.Has(types.GetOneTimeRewardsPrefix(oneTimeReward.RewardType, oneTimeReward.OneTimeKey)) -} - -// SetOneTimeReward set a specific record to track if a reward is already given or not. -func (k Keeper) SetRewardByReceiver(ctx sdk.Context, rewByType types.RewardByType) { - store := k.getRewardByReceiverAndTypeStore(ctx) - b := k.cdc.MustMarshal(&rewByType) - store.Set(types.GetRewardsByTypeKey(rewByType.Addr, rewByType.RewardType, rewByType.UID), b) -} - -// SetOneTimeReward set a specific record to track if a reward is already given or not. -func (k Keeper) SetRewardByCampaign(ctx sdk.Context, rewByCampaign types.RewardByCampaign) { - store := k.getRewardsByCampaignStore(ctx) - b := k.cdc.MustMarshal(&rewByCampaign) - store.Set(types.GetRewardsByCampaignKey(rewByCampaign.CampaignUID, rewByCampaign.UID), b) -} diff --git a/x/reward/types/reward.go b/x/reward/types/reward.go index d7a04ced..a4a971c5 100644 --- a/x/reward/types/reward.go +++ b/x/reward/types/reward.go @@ -35,37 +35,37 @@ func NewReward( Receiver: receiver, CampaignUID: campaignUID, RewardAmount: rewardAmount, - Source: source, - SourceCode: sourceCode, - SourceUID: sourceID, - CreatedAt: blockTime, + // Source: source, + // SourceCode: sourceCode, + SourceUID: sourceID, + // CreatedAt: blockTime, } } -func NewOneTimeReward( - oneTimeKey string, - rewType RewardType, -) OneTimeReward { - return OneTimeReward{ - OneTimeKey: oneTimeKey, - RewardType: rewType, - } -} +// func NewOneTimeReward( +// oneTimeKey string, +// rewType RewardType, +// ) OneTimeReward { +// return OneTimeReward{ +// OneTimeKey: oneTimeKey, +// RewardType: rewType, +// } +// } -func NewRewardByType(uid, addr string, rewType RewardType) RewardByType { - return RewardByType{ - UID: uid, - RewardType: rewType, - Addr: addr, - } -} +// func NewRewardByType(uid, addr string, rewType RewardType) RewardByType { +// return RewardByType{ +// UID: uid, +// RewardType: rewType, +// Addr: addr, +// } +// } -func NewRewardByCampaign(uid, campaignUID string) RewardByCampaign { - return RewardByCampaign{ - UID: uid, - CampaignUID: campaignUID, - } -} +// func NewRewardByCampaign(uid, campaignUID string) RewardByCampaign { +// return RewardByCampaign{ +// UID: uid, +// CampaignUID: campaignUID, +// } +// } // IRewardFactory defines the methods that should be implemented for all reward types. type IRewardFactory interface { diff --git a/x/reward/types/reward_signup.go b/x/reward/types/reward_signup.go index c68b3775..b861de3c 100644 --- a/x/reward/types/reward_signup.go +++ b/x/reward/types/reward_signup.go @@ -19,9 +19,6 @@ func (sur SignUpReward) VaidateCampaign(campaign Campaign) error { if campaign.RewardCategory != RewardCategory_REWARD_CATEGORY_SIGNUP { return sdkerrors.Wrapf(ErrWrongRewardCategory, "signup rewards can only have single definition") } - if campaign.RewardAmount.MainAccountAmount.GT(sdkmath.ZeroInt()) { - return sdkerrors.Wrapf(ErrInvalidGranteeType, "signup rewards can be defined for subaccount only") - } if campaign.RewardAmount.SubaccountAmount.LTE(sdkmath.ZeroInt()) { return sdkerrors.Wrapf(ErrWrongAmountForType, "signup rewards for subaccount should be positive") } diff --git a/x/reward/types/ticket.go b/x/reward/types/ticket.go index 566245d5..d6c39ba5 100644 --- a/x/reward/types/ticket.go +++ b/x/reward/types/ticket.go @@ -32,9 +32,9 @@ func (payload *CreateCampaignPayload) Validate(blockTime uint64) error { return sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "pool amount should be positive") } - if payload.RewardAmount.MainAccountAmount.GT(sdkmath.ZeroInt()) && - payload.RewardAmount.SubaccountAmount.GT(sdkmath.ZeroInt()) { - return sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "reward amount should be set for main account or subaccount not both") + if payload.RewardAmount.MainAccountAmount.Equal(sdkmath.ZeroInt()) && + payload.RewardAmount.SubaccountAmount.Equal(sdkmath.ZeroInt()) { + return sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "reward amount should be set for atleast one of main account or subaccount") } if payload.RewardAmount.SubaccountAmount.GT(sdkmath.ZeroInt()) && From 249861642a558b72a7de9f5ace8ead3d08b02aa1 Mon Sep 17 00:00:00 2001 From: P-U-D-G-E Date: Tue, 7 Nov 2023 19:00:33 +0530 Subject: [PATCH 02/12] msg reward --- x/reward/keeper/msg_server_reward.go | 28 ++++++++++++++-------- x/reward/keeper/query_reward.go | 24 +++++++++++++++++-- x/reward/keeper/reward.go | 34 +++++++++++++++++++++++++++ x/reward/keeper/view.go | 10 ++------ x/reward/types/key_reward.go | 35 +++++++--------------------- x/reward/types/reward.go | 34 +++------------------------ 6 files changed, 88 insertions(+), 77 deletions(-) diff --git a/x/reward/keeper/msg_server_reward.go b/x/reward/keeper/msg_server_reward.go index f4438e99..46f4bb06 100644 --- a/x/reward/keeper/msg_server_reward.go +++ b/x/reward/keeper/msg_server_reward.go @@ -27,7 +27,15 @@ func (k msgServer) GrantReward(goCtx context.Context, msg *types.MsgGrantReward) return nil, sdkerrors.Wrap(sdkerrtypes.ErrInvalidRequest, "failed to retrieve reward factory") } - recevier, _, isSubAccount, _, err := rewardFactory.Calculate(goCtx, ctx, + rewards, err := k.GetRewardsByAddressAndCategory(ctx, msg.Creator, campaign.RewardCategory) + if err != nil { + return nil, sdkerrors.Wrap(sdkerrtypes.ErrInvalidRequest, "failed to retrieve rewards for user.") + } + if len(rewards) > 0 { + return nil, sdkerrors.Wrap(sdkerrtypes.ErrInvalidRequest, "maximum rewards claimed for the given category.") + } + + recevier, rewardCommon, isSubAccount, _, err := rewardFactory.Calculate(goCtx, ctx, types.RewardFactoryKeepers{ OVMKeeper: k.ovmKeeper, BetKeeper: k.betKeeper, @@ -46,15 +54,15 @@ func (k msgServer) GrantReward(goCtx context.Context, msg *types.MsgGrantReward) } k.UpdateCampaignPool(ctx, campaign, recevier) - // k.SetReward(ctx, types.NewReward( - // msg.Uid, msg.Creator, recevier.Addr, - // msg.CampaignUid, campaign.RewardAmount, - // rewardCommon.Source, rewardCommon.SourceCode, rewardCommon.SourceUID, - // uint64(ctx.BlockTime().Unix()), - // )) - // k.SetOneTimeReward(ctx, types.NewOneTimeReward(oneTimeKey, campaign.RewardType)) - // k.SetRewardByReceiver(ctx, types.NewRewardByType(msg.Uid, recevier.Addr, campaign.RewardType)) - // k.SetRewardByCampaign(ctx, types.NewRewardByCampaign(msg.Uid, campaign.UID)) + reward := types.NewReward( + msg.Uid, msg.Creator, recevier.Addr, + msg.CampaignUid, campaign.RewardAmount, + rewardCommon.SourceUID, + "", + ) + k.SetReward(ctx, reward) + k.SetRewardByReceiver(ctx, campaign.RewardCategory, reward) + k.SetRewardByCampaign(ctx, reward) msg.EmitEvent(&ctx, msg.CampaignUid, recevier) diff --git a/x/reward/keeper/query_reward.go b/x/reward/keeper/query_reward.go index d6dc9b32..1274c5cb 100644 --- a/x/reward/keeper/query_reward.go +++ b/x/reward/keeper/query_reward.go @@ -63,7 +63,7 @@ func (k Keeper) RewardsByAddress(goCtx context.Context, req *types.QueryRewardsB var rewards []types.Reward ctx := sdk.UnwrapSDKContext(goCtx) - store := k.getRewardByReceiverAndTypeStore(ctx) + store := k.getRewardByReceiverAndCategoryStore(ctx) rewardStore := prefix.NewStore(store, types.GetRewardsByAccPrefix(req.Address)) pageRes, err := query.Paginate(rewardStore, req.Pagination, func(key []byte, value []byte) error { @@ -87,7 +87,27 @@ func (k Keeper) RewardsByAddressAndCategory(goCtx context.Context, req *types.Qu return nil, status.Error(codes.InvalidArgument, "invalid request") } - return nil, nil + var rewards []types.Reward + ctx := sdk.UnwrapSDKContext(goCtx) + + store := k.getRewardByReceiverAndCategoryStore(ctx) + rewardStore := prefix.NewStore(store, types.GetRewardsByCategoryPrefix(req.Address, req.Category)) + + pageRes, err := query.Paginate(rewardStore, req.Pagination, func(key []byte, value []byte) error { + var reward types.Reward + if err := k.cdc.Unmarshal(value, &reward); err != nil { + return err + } + + rewards = append(rewards, reward) + return nil + }) + + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryRewardsByAddressAndCategoryResponse{Rewards: rewards, Pagination: pageRes}, nil } func (k Keeper) RewardsByCampaign(goCtx context.Context, req *types.QueryRewardsByCampaignRequest) (*types.QueryRewardsByCampaignResponse, error) { diff --git a/x/reward/keeper/reward.go b/x/reward/keeper/reward.go index 9142d0c1..caed101a 100644 --- a/x/reward/keeper/reward.go +++ b/x/reward/keeper/reward.go @@ -52,3 +52,37 @@ func (k Keeper) GetAllReward(ctx sdk.Context) (list []types.Reward) { return } + +func (k Keeper) SetRewardByReceiver(ctx sdk.Context, rewardType types.RewardCategory, r types.Reward) { + store := k.getRewardByReceiverAndCategoryStore(ctx) + b := k.cdc.MustMarshal(&r) + store.Set(types.GetRewardsByCategoryKey(r.Creator, rewardType, r.UID), b) +} + +// GetRewardsByAddressAndCategory returns all rewards by address and category. +func (k Keeper) GetRewardsByAddressAndCategory( + ctx sdk.Context, + address string, + category types.RewardCategory, +) (list []types.Reward, err error) { + store := k.getRewardByReceiverAndCategoryStore(ctx) + iterator := sdk.KVStorePrefixIterator(store, types.GetRewardsByCategoryPrefix(address, category)) + + defer func() { + err = iterator.Close() + }() + + for ; iterator.Valid(); iterator.Next() { + var val types.Reward + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} + +func (k Keeper) SetRewardByCampaign(ctx sdk.Context, reward types.Reward) { + store := k.getRewardsByCampaignStore(ctx) + b := k.cdc.MustMarshal(&reward) + store.Set(types.GetRewardsByCampaignKey(reward.CampaignUID, reward.UID), b) +} diff --git a/x/reward/keeper/view.go b/x/reward/keeper/view.go index 11f4bd1b..be5119bc 100644 --- a/x/reward/keeper/view.go +++ b/x/reward/keeper/view.go @@ -19,16 +19,10 @@ func (k Keeper) getRewardStore(ctx sdk.Context) prefix.Store { return prefix.NewStore(store, types.RewardKeyPrefix) } -// getRewardOneTimeStore gets the store containing all onetime rewards. -func (k Keeper) getRewardOneTimeStore(ctx sdk.Context) prefix.Store { - store := ctx.KVStore(k.storeKey) - return prefix.NewStore(store, types.RewardOneTimeKeyPrefix) -} - // getRewardByReceiverAndTypeStore gets the store containing all rewards by receiver. -func (k Keeper) getRewardByReceiverAndTypeStore(ctx sdk.Context) prefix.Store { +func (k Keeper) getRewardByReceiverAndCategoryStore(ctx sdk.Context) prefix.Store { store := ctx.KVStore(k.storeKey) - return prefix.NewStore(store, types.RewardByReceiverAndTypeKeyPrefix) + return prefix.NewStore(store, types.RewardByReceiverAndCategoryKeyPrefix) } // getRewardsByCampaignStore gets the store containing all rewards by campaign uid. diff --git a/x/reward/types/key_reward.go b/x/reward/types/key_reward.go index c2bb58ef..270c26e8 100644 --- a/x/reward/types/key_reward.go +++ b/x/reward/types/key_reward.go @@ -12,14 +12,11 @@ var ( // RewardKeyPrefix is the prefix to retrieve all applied rewards RewardKeyPrefix = []byte{0x01} - // RewardOneTimeKeyPrefix is the prefix to retrieve all applied rewards that not allowed to be granted twice. - RewardOneTimeKeyPrefix = []byte{0x02} - - // RewardByReceiverAndTypeKeyPrefix is the prefix to retrieve all applied rewards for a certain receiver account. - RewardByReceiverAndTypeKeyPrefix = []byte{0x03} + // RewardByReceiverAndCategoryKeyPrefix is the prefix to retrieve all applied rewards for a certain receiver account. + RewardByReceiverAndCategoryKeyPrefix = []byte{0x02} // RewardByCampaignKeyPrefix is the prefix to retrieve all applied rewards for a certain campaign. - RewardByCampaignKeyPrefix = []byte{0x04} + RewardByCampaignKeyPrefix = []byte{0x03} ) // GetRewardsByAccPrefix returns the store key to retrieve list of all applied rewards of a certain campaign @@ -28,16 +25,14 @@ func GetRewardsByAccPrefix(receiverAcc string) []byte { return utils.StrBytes(receiverAcc) } -// GetRewardsByTypePrefix returns the store key to retrieve list of all applied rewards of certain address and type -// this should be used with RewardOneTimeKeyPrefix -func GetRewardsByTypePrefix(receiverAcc string, rewardType RewardType) []byte { - return append(GetRewardsByAccPrefix(receiverAcc), utils.Int32ToBytes(int32(rewardType))...) +// 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))...) } -// GetRewardsByTypeKey returns the store key to retrieve list of applied reward of certain address and type and uid -// this should be used with RewardOneTimeKeyPrefix -func GetRewardsByTypeKey(receiverAcc string, rewardType RewardType, uid string) []byte { - return append(GetRewardsByTypePrefix(receiverAcc, rewardType), utils.StrBytes(uid)...) +// 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)...) } // GetRewardKey returns the store key to retrieve a certain reward. @@ -68,15 +63,3 @@ func GetRewardsByCampaignKey(campaignUID, uid string) []byte { func GetOneTimeRewardsPrefix(rewardType RewardType, oneTimeKey string) []byte { return append(utils.Int32ToBytes(int32(rewardType)), utils.StrBytes(oneTimeKey)...) } - -func getSignupRewardOneTimeKey(receiver string) string { - return receiver -} - -func getSignupReferralRewardOneTimeKey(referrer, receiver string) string { - return referrer + receiver -} - -func getSignupAffiliateRewardOneTimeKey(affiliator, receiver string) string { - return affiliator + receiver -} diff --git a/x/reward/types/reward.go b/x/reward/types/reward.go index a4a971c5..afd2f05d 100644 --- a/x/reward/types/reward.go +++ b/x/reward/types/reward.go @@ -26,8 +26,7 @@ func NewReward( uid, creator, receiver string, campaignUID string, rewardAmount *RewardAmount, - source, sourceCode, sourceID string, - blockTime uint64, + sourceID, meta string, ) Reward { return Reward{ UID: uid, @@ -35,38 +34,11 @@ func NewReward( Receiver: receiver, CampaignUID: campaignUID, RewardAmount: rewardAmount, - // Source: source, - // SourceCode: sourceCode, - SourceUID: sourceID, - // CreatedAt: blockTime, + SourceUID: sourceID, + Meta: meta, } } -// func NewOneTimeReward( -// oneTimeKey string, -// rewType RewardType, -// ) OneTimeReward { -// return OneTimeReward{ -// OneTimeKey: oneTimeKey, -// RewardType: rewType, -// } -// } - -// func NewRewardByType(uid, addr string, rewType RewardType) RewardByType { -// return RewardByType{ -// UID: uid, -// RewardType: rewType, -// Addr: addr, -// } -// } - -// func NewRewardByCampaign(uid, campaignUID string) RewardByCampaign { -// return RewardByCampaign{ -// UID: uid, -// CampaignUID: campaignUID, -// } -// } - // IRewardFactory defines the methods that should be implemented for all reward types. type IRewardFactory interface { VaidateCampaign(campaign Campaign) error From 07602e7ff2f6936e795e208e67a212ebd41f91b0 Mon Sep 17 00:00:00 2001 From: 3EyedRaGa <90416391+3eyedraga@users.noreply.github.com> Date: Wed, 8 Nov 2023 15:30:19 +0530 Subject: [PATCH 03/12] feat: Withdraw funds from campaign (#288) * feat: Withdraw funds from campaign msg server * fix: missing return statement --- proto/sge/reward/ticket.proto | 10 -- x/reward/keeper/msg_server_campaign.go | 53 +++++++- x/reward/types/errors.go | 1 + x/reward/types/ticket.go | 9 ++ x/reward/types/ticket.pb.go | 167 ++++++------------------- 5 files changed, 99 insertions(+), 141 deletions(-) diff --git a/proto/sge/reward/ticket.proto b/proto/sge/reward/ticket.proto index 3c44232c..f5dd0355 100644 --- a/proto/sge/reward/ticket.proto +++ b/proto/sge/reward/ticket.proto @@ -64,16 +64,6 @@ message WithdrawFundsPayload { // promoter is the address of campaign promoter. // Funds would be transferred to this account. string promoter = 1; - - // amount is the funds that needs to be withdrawn. - string amount = 8 [ - (gogoproto.customtype) = "cosmossdk.io/math.Int", - (gogoproto.nullable) = false, - (gogoproto.moretags) = "yaml:\"amount\"" - ]; - - // is_active is the flag to check if the campaign is active or not. - bool is_active = 9; } message RewardPayloadCommon { diff --git a/x/reward/keeper/msg_server_campaign.go b/x/reward/keeper/msg_server_campaign.go index 7bd01bfc..78e700b1 100644 --- a/x/reward/keeper/msg_server_campaign.go +++ b/x/reward/keeper/msg_server_campaign.go @@ -2,6 +2,7 @@ package keeper import ( "context" + sdkmath "cosmossdk.io/math" sdkerrors "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" @@ -92,7 +93,7 @@ func (k msgServer) UpdateCampaign(goCtx context.Context, msg *types.MsgUpdateCam return nil, sdkerrors.Wrap(sdkerrtypes.ErrKeyNotFound, "index not set") } - // Checks if the the msg creator is the same as the current owner + // Checks if the msg creator is the same as the current owner if msg.Creator != valFound.Promoter { if err := utils.ValidateMsgAuthorization(k.authzKeeper, ctx, msg.Creator, valFound.Promoter, msg, types.ErrAuthorizationNotFound, types.ErrAuthorizationNotAccepted); err != nil { @@ -110,5 +111,53 @@ func (k msgServer) UpdateCampaign(goCtx context.Context, msg *types.MsgUpdateCam } func (k msgServer) WithdrawFunds(goCtx context.Context, msg *types.MsgWithdrawFunds) (*types.MsgWithdrawFundsResponse, error) { - return nil, nil + ctx := sdk.UnwrapSDKContext(goCtx) + + var payload types.WithdrawFundsPayload + if err := k.ovmKeeper.VerifyTicketUnmarshal(goCtx, msg.Ticket, &payload); err != nil { + return nil, sdkerrors.Wrapf(types.ErrInTicketVerification, "%s", err) + } + + // Validate ticket payload + if err := payload.Validate(); err != nil { + return nil, err + } + + // Check if the campaign exists + valFound, isFound := k.GetCampaign(ctx, msg.Uid) + if !isFound { + return nil, sdkerrors.Wrap(sdkerrtypes.ErrKeyNotFound, "campaign not found") + } + + // Checks if the msg creator is the same as the current owner + if msg.Creator != valFound.Promoter { + if err := utils.ValidateMsgAuthorization(k.authzKeeper, ctx, msg.Creator, valFound.Promoter, msg, + types.ErrAuthorizationNotFound, types.ErrAuthorizationNotAccepted); err != nil { + return nil, err + } + } + // check if the pool amount is positive + if valFound.Pool.Total.IsNil() || !valFound.Pool.Total.GT(sdkmath.ZeroInt()) { + return nil, sdkerrors.Wrapf(types.ErrWithdrawFromCampaignPool, "pool amount should be positive") + } + + // transfer the funds present in campaign to the promoter + if err := k.modFunder.Refund( + types.RewardPoolFunder{}, ctx, + sdk.MustAccAddressFromBech32(payload.Promoter), + valFound.Pool.Total, + ); err != nil { + return nil, sdkerrors.Wrapf(types.ErrWithdrawFromCampaignPool, "%s", err) + } + // set the pool amount to zero + valFound.Pool.Total = sdkmath.ZeroInt() + // deactivate the campaign + valFound.IsActive = false + + // store the campaign + k.SetCampaign(ctx, valFound) + // emit withdraw event + msg.EmitEvent(&ctx, msg.Uid) + + return &types.MsgWithdrawFundsResponse{}, nil } diff --git a/x/reward/types/errors.go b/x/reward/types/errors.go index 88fe0b73..8db9cb3f 100644 --- a/x/reward/types/errors.go +++ b/x/reward/types/errors.go @@ -17,6 +17,7 @@ var ( ErrCampaignPoolBalance = sdkerrors.Register(ModuleName, 7106, "not enough campaign pool balance") ErrUnknownRewardType = sdkerrors.Register(ModuleName, 7107, "unknown reward type") ErrInFundingCampaignPool = sdkerrors.Register(ModuleName, 7108, "error in funding the campaign pool") + ErrWithdrawFromCampaignPool = sdkerrors.Register(ModuleName, 7109, "error in withdrawing from the campaign pool") ErrUnknownAccType = sdkerrors.Register(ModuleName, 7109, "unknown account type") ErrCampaignEnded = sdkerrors.Register(ModuleName, 7110, "campaign validity period is ended") ErrInsufficientPoolBalance = sdkerrors.Register(ModuleName, 7111, "insufficient campaign pool balance") diff --git a/x/reward/types/ticket.go b/x/reward/types/ticket.go index d6c39ba5..fae2e019 100644 --- a/x/reward/types/ticket.go +++ b/x/reward/types/ticket.go @@ -84,3 +84,12 @@ func (payload *UpdateCampaignPayload) Validate(blockTime uint64) error { return nil } + +// Validate validates campaign withdraw funds ticket payload. +func (payload *WithdrawFundsPayload) Validate() error { + _, err := sdk.AccAddressFromBech32(payload.Promoter) + if err != nil { + return sdkerrors.Wrapf(sdkerrtypes.ErrInvalidAddress, "invalid promoter address (%s)", err) + } + return nil +} diff --git a/x/reward/types/ticket.pb.go b/x/reward/types/ticket.pb.go index df420bf2..dce70a2a 100644 --- a/x/reward/types/ticket.pb.go +++ b/x/reward/types/ticket.pb.go @@ -215,10 +215,6 @@ type WithdrawFundsPayload struct { // promoter is the address of campaign promoter. // Funds would be transferred to this account. Promoter string `protobuf:"bytes,1,opt,name=promoter,proto3" json:"promoter,omitempty"` - // amount is the funds that needs to be withdrawn. - Amount cosmossdk_io_math.Int `protobuf:"bytes,8,opt,name=amount,proto3,customtype=cosmossdk.io/math.Int" json:"amount" yaml:"amount"` - // is_active is the flag to check if the campaign is active or not. - IsActive bool `protobuf:"varint,9,opt,name=is_active,json=isActive,proto3" json:"is_active,omitempty"` } func (m *WithdrawFundsPayload) Reset() { *m = WithdrawFundsPayload{} } @@ -261,13 +257,6 @@ func (m *WithdrawFundsPayload) GetPromoter() string { return "" } -func (m *WithdrawFundsPayload) GetIsActive() bool { - if m != nil { - return m.IsActive - } - return false -} - type RewardPayloadCommon struct { // receiver is the address of the account that receives the reward. Receiver string `protobuf:"bytes,1,opt,name=receiver,proto3" json:"receiver,omitempty"` @@ -392,45 +381,44 @@ func init() { func init() { proto.RegisterFile("sge/reward/ticket.proto", fileDescriptor_5d710bc1249ca8ae) } var fileDescriptor_5d710bc1249ca8ae = []byte{ - // 605 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0x41, 0x6f, 0xd3, 0x30, - 0x14, 0xae, 0xb7, 0xae, 0x4b, 0x5f, 0x19, 0x42, 0x66, 0x15, 0xd9, 0x26, 0xa5, 0x25, 0x08, 0x51, - 0x90, 0x48, 0xa4, 0xed, 0x06, 0xa7, 0xb5, 0x68, 0x6c, 0x37, 0x94, 0x75, 0x42, 0xe2, 0x52, 0x79, - 0x89, 0xc9, 0xa2, 0x2d, 0x71, 0x64, 0x3b, 0x2b, 0xb9, 0xf2, 0x0b, 0x38, 0x20, 0xf1, 0x97, 0x76, - 0xdc, 0x11, 0x71, 0xa8, 0x50, 0x7b, 0xe3, 0xc8, 0x2f, 0x40, 0xb1, 0x43, 0x97, 0xa2, 0xa9, 0xec, - 0xe4, 0xf7, 0xfc, 0xbe, 0xf7, 0xf9, 0xf3, 0xf7, 0x2c, 0xc3, 0x23, 0x11, 0x52, 0x97, 0xd3, 0x31, - 0xe1, 0x81, 0x2b, 0x23, 0xff, 0x9c, 0x4a, 0x27, 0xe5, 0x4c, 0x32, 0xdc, 0x16, 0x21, 0x4d, 0xa8, - 0x1c, 0x33, 0x7e, 0xee, 0x88, 0x90, 0x3a, 0x1a, 0xb3, 0xbd, 0x19, 0xb2, 0x90, 0x29, 0x84, 0x5b, - 0x44, 0x1a, 0xbc, 0x5d, 0x65, 0xd1, 0x4b, 0x59, 0xd8, 0xaa, 0x14, 0x7c, 0x12, 0xa7, 0x24, 0x0a, - 0x13, 0x5d, 0xb2, 0xbf, 0xd6, 0xa1, 0x3d, 0xe0, 0x94, 0x48, 0x3a, 0x28, 0x0b, 0xef, 0x48, 0x7e, - 0xc1, 0x48, 0x80, 0xb7, 0xc1,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 0xb6, 0x70, 0x89, 0x7e, 0xbd, 0x70, 0xcc, 0x2b, 0xfb, 0xfb, 0x83, 0xab, 0xa9, 0x85, - 0xae, 0xa7, 0x16, 0xfa, 0x39, 0xb5, 0xd0, 0x97, 0x99, 0x55, 0xbb, 0x9e, 0x59, 0xb5, 0xef, 0x33, - 0xab, 0xf6, 0xe1, 0x79, 0x18, 0xc9, 0xb3, 0xec, 0xd4, 0xf1, 0x59, 0xec, 0x8a, 0x90, 0xbe, 0x2c, - 0xe9, 0x8b, 0xd8, 0xfd, 0x34, 0xff, 0xab, 0xf2, 0x94, 0x8a, 0xd3, 0x86, 0xfa, 0x4a, 0xf6, 0xfe, - 0x04, 0x00, 0x00, 0xff, 0xff, 0xb9, 0xbb, 0x00, 0xf6, 0xc6, 0x04, 0x00, 0x00, + // 582 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0xcd, 0x6e, 0xd3, 0x40, + 0x10, 0xc7, 0xe3, 0xe6, 0xa3, 0xce, 0x04, 0x10, 0x5a, 0x12, 0xe1, 0xa6, 0x92, 0x13, 0x8c, 0x10, + 0x01, 0x09, 0x5b, 0x4a, 0x6f, 0x70, 0x4a, 0x82, 0xa0, 0xbd, 0x21, 0x37, 0x11, 0x12, 0x97, 0x68, + 0x6b, 0x2f, 0x8e, 0x95, 0xd8, 0x6b, 0xed, 0xae, 0x1b, 0x7c, 0xe5, 0x09, 0x38, 0xf0, 0x50, 0x3d, + 0xf6, 0x88, 0x38, 0x44, 0x28, 0xb9, 0x71, 0xe4, 0x09, 0x90, 0xd7, 0x26, 0x75, 0x50, 0x15, 0xf5, + 0xb4, 0x33, 0x3b, 0xff, 0xf9, 0xed, 0xec, 0xcc, 0xda, 0xf0, 0x98, 0x7b, 0xc4, 0x62, 0x64, 0x89, + 0x99, 0x6b, 0x09, 0xdf, 0x99, 0x13, 0x61, 0x46, 0x8c, 0x0a,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0xab, 0x4e, 0x41, 0x62, 0x17, 0xec, 0x6d, 0x6f, 0xca, 0x85, + 0xde, 0xb8, 0xa0, 0xbd, 0x67, 0x38, 0x14, 0xe7, 0xbe, 0x17, 0xc6, 0xd1, 0x4e, 0x39, 0xe8, 0x14, + 0x6a, 0x8e, 0x2c, 0x49, 0x1e, 0xd4, 0xe8, 0xbf, 0xdc, 0xfb, 0x02, 0x76, 0x2e, 0x31, 0xac, 0xa4, + 0x53, 0xb6, 0xf3, 0xfc, 0xe1, 0xe8, 0x6a, 0xad, 0x2b, 0xd7, 0x6b, 0x5d, 0xf9, 0xb5, 0xd6, 0x95, + 0x6f, 0x1b, 0xbd, 0x74, 0xbd, 0xd1, 0x4b, 0x3f, 0x36, 0x7a, 0xe9, 0xd3, 0x0b, 0xcf, 0x17, 0xb3, + 0xf8, 0xc2, 0x74, 0x68, 0x60, 0x71, 0x8f, 0xbc, 0xca, 0xf1, 0xa9, 0x6d, 0x7d, 0xd9, 0xfe, 0x45, + 0x92, 0x88, 0xf0, 0x8b, 0x9a, 0xfc, 0xc8, 0x4f, 0xfe, 0x06, 0x00, 0x00, 0xff, 0xff, 0x8e, 0x61, + 0x7a, 0x2b, 0x60, 0x04, 0x00, 0x00, } func (m *CreateCampaignPayload) Marshal() (dAtA []byte, err error) { @@ -592,26 +580,6 @@ func (m *WithdrawFundsPayload) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.IsActive { - i-- - if m.IsActive { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x48 - } - { - size := m.Amount.Size() - i -= size - if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTicket(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x42 if len(m.Promoter) > 0 { i -= len(m.Promoter) copy(dAtA[i:], m.Promoter) @@ -780,11 +748,6 @@ func (m *WithdrawFundsPayload) Size() (n int) { if l > 0 { n += 1 + l + sovTicket(uint64(l)) } - l = m.Amount.Size() - n += 1 + l + sovTicket(uint64(l)) - if m.IsActive { - n += 2 - } return n } @@ -1307,60 +1270,6 @@ func (m *WithdrawFundsPayload) Unmarshal(dAtA []byte) error { } m.Promoter = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTicket - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTicket - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTicket - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 9: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IsActive", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTicket - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.IsActive = bool(v != 0) default: iNdEx = preIndex skippy, err := skipTicket(dAtA[iNdEx:]) From 3f1296935675d3a88d445e7a065979bd1be2ac6b Mon Sep 17 00:00:00 2001 From: P-U-D-G-E Date: Wed, 8 Nov 2023 15:31:17 +0530 Subject: [PATCH 04/12] msg reward --- proto/sge/reward/campaign.proto | 5 +- proto/sge/reward/reward.proto | 33 +- proto/sge/reward/ticket.proto | 5 +- x/reward/keeper/campaign.go | 2 +- x/reward/keeper/distribution.go | 28 +- x/reward/keeper/msg_server_campaign_test.go | 4 +- x/reward/keeper/msg_server_reward.go | 21 +- x/reward/keeper/reward.go | 12 +- x/reward/types/campaign.go | 4 - x/reward/types/campaign.pb.go | 110 ++-- x/reward/types/errors.go | 3 +- x/reward/types/expected_keepers.go | 3 +- x/reward/types/reward.go | 42 +- x/reward/types/reward.pb.go | 599 ++++++++++++++++++-- x/reward/types/reward_affiliate.go | 54 -- x/reward/types/reward_referral.go | 54 -- x/reward/types/reward_signup.go | 33 +- x/reward/types/ticket.go | 2 +- x/reward/types/ticket.pb.go | 120 ++-- x/reward/types/ticket_test.go | 6 +- 20 files changed, 823 insertions(+), 317 deletions(-) delete mode 100644 x/reward/types/reward_affiliate.go delete mode 100644 x/reward/types/reward_referral.go diff --git a/proto/sge/reward/campaign.proto b/proto/sge/reward/campaign.proto index e8193696..f6f61353 100644 --- a/proto/sge/reward/campaign.proto +++ b/proto/sge/reward/campaign.proto @@ -54,9 +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 = 12; + string meta = 13; } // Pool is the type for the campaign funding pool. diff --git a/proto/sge/reward/reward.proto b/proto/sge/reward/reward.proto index d63cc08d..6b4d0140 100644 --- a/proto/sge/reward/reward.proto +++ b/proto/sge/reward/reward.proto @@ -66,11 +66,34 @@ message RewardAmount { (gogoproto.moretags) = "yaml:\"subaccount_amount\"" ]; - // unlock timestamp - uint64 unlock_ts = 3 [ - (gogoproto.customname) = "UnlockTS", - (gogoproto.jsontag) = "unlock_ts", - json_name = "unlock_ts" + // unlock period + uint64 unlock_period = 3 [ + (gogoproto.customname) = "UnlockPeriod", + (gogoproto.jsontag) = "unlock_period", + json_name = "unlock_period" + ]; +} + +message RewardByCategory { + string uid = 1 [ + (gogoproto.customname) = "UID", + (gogoproto.jsontag) = "uid", + json_name = "uid" + ]; + string addr = 2; + RewardCategory reward_category = 3; +} + +message RewardByCampaign { + string uid = 1 [ + (gogoproto.customname) = "UID", + (gogoproto.jsontag) = "uid", + json_name = "uid" + ]; + string campaign_uid = 2 [ + (gogoproto.customname) = "CampaignUID", + (gogoproto.jsontag) = "campaign_uid", + json_name = "campaign_uid" ]; } diff --git a/proto/sge/reward/ticket.proto b/proto/sge/reward/ticket.proto index 3c44232c..317da6ed 100644 --- a/proto/sge/reward/ticket.proto +++ b/proto/sge/reward/ticket.proto @@ -41,9 +41,12 @@ message CreateCampaignPayload { // is_active is the flag to check if the campaign is active or not. bool is_active = 9; + // claims_per_category is the number of times a user can claim a reward for category of this campaign. + uint64 claims_per_category = 10; + // meta is the metadata of the campaign. // It is a stringified base64 encoded json. - string meta = 10; + string meta = 11; } // UpdateCampaignPayload is the type for campaign update payload. diff --git a/x/reward/keeper/campaign.go b/x/reward/keeper/campaign.go index bffc8b29..51ef44d6 100644 --- a/x/reward/keeper/campaign.go +++ b/x/reward/keeper/campaign.go @@ -57,7 +57,7 @@ func (k Keeper) GetAllCampaign(ctx sdk.Context) (list []types.Campaign) { } func (k Keeper) UpdateCampaignPool(ctx sdk.Context, campaign types.Campaign, receiver types.Receiver) { - totalAmount := receiver.Amount.Add(receiver.Amount) + totalAmount := receiver.SubAccountAmount.Add(receiver.MainAccountAmount) campaign.Pool.Spent = campaign.Pool.Spent.Add(totalAmount) k.SetCampaign(ctx, campaign) diff --git a/x/reward/keeper/distribution.go b/x/reward/keeper/distribution.go index 2732c417..dd26e059 100644 --- a/x/reward/keeper/distribution.go +++ b/x/reward/keeper/distribution.go @@ -2,7 +2,6 @@ package keeper import ( sdkerrors "cosmossdk.io/errors" - sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/sge-network/sge/x/reward/types" @@ -10,26 +9,25 @@ import ( ) // DistributeRewards distributes the rewards according to the input distribution list. -func (k Keeper) DistributeRewards(ctx sdk.Context, funderAddr string, isSubAccount bool, receiver types.Receiver) error { - if isSubAccount { - if _, err := k.subaccountKeeper.TopUp(ctx, funderAddr, receiver.Addr, +func (k Keeper) DistributeRewards(ctx sdk.Context, receiver types.Receiver) error { + if receiver.SubAccountAmount.GT(sdk.ZeroInt()) { + if _, err := k.subaccountKeeper.TopUp(ctx, types.RewardPoolFunder{}.GetModuleAcc(), receiver.SubAccountAddr, []subaccounttypes.LockedBalance{ { UnlockTS: receiver.UnlockTS, - Amount: receiver.Amount, + Amount: receiver.SubAccountAmount, }, }); err != nil { - return sdkerrors.Wrapf(types.ErrSubAccRewardTopUp, "subaccount address %s, %s", receiver.Addr, err) + return sdkerrors.Wrapf(types.ErrSubAccRewardTopUp, "subaccount address %s, %s", receiver.SubAccountAddr, err) } - } else { - if receiver.Amount.GT(sdkmath.ZeroInt()) { - if err := k.modFunder.Refund( - types.RewardPoolFunder{}, ctx, - sdk.MustAccAddressFromBech32(receiver.Addr), - receiver.Amount, - ); err != nil { - return err - } + } + if receiver.MainAccountAmount.GT(sdk.ZeroInt()) { + if err := k.modFunder.Refund( + types.RewardPoolFunder{}, ctx, + sdk.MustAccAddressFromBech32(receiver.MainAccountAddr), + receiver.MainAccountAmount, + ); err != nil { + return err } } diff --git a/x/reward/keeper/msg_server_campaign_test.go b/x/reward/keeper/msg_server_campaign_test.go index 08575e39..9c35b534 100644 --- a/x/reward/keeper/msg_server_campaign_test.go +++ b/x/reward/keeper/msg_server_campaign_test.go @@ -40,7 +40,7 @@ func TestCampaignMsgServerCreate(t *testing.T) { "reward_amount_type": types.RewardAmountType_REWARD_AMOUNT_TYPE_FIXED, "reward_amount": types.RewardAmount{ SubaccountAmount: sdkmath.NewInt(100), - UnlockTS: uint64(ctx.BlockTime().Add(10 * time.Minute).Unix()), + UnlockPeriod: uint64(ctx.BlockTime().Add(10 * time.Minute).Unix()), }, "total_funds": sdkmath.NewInt(1000000), "is_active": true, @@ -113,7 +113,7 @@ func TestCampaignMsgServerUpdate(t *testing.T) { "reward_amount_type": types.RewardAmountType_REWARD_AMOUNT_TYPE_FIXED, "reward_amount": types.RewardAmount{ SubaccountAmount: sdkmath.NewInt(100), - UnlockTS: uint64(ctx.BlockTime().Add(10 * time.Minute).Unix()), + UnlockPeriod: uint64(ctx.BlockTime().Add(10 * time.Minute).Unix()), }, "total_funds": sdkmath.NewInt(1000000), "is_active": true, diff --git a/x/reward/keeper/msg_server_reward.go b/x/reward/keeper/msg_server_reward.go index 46f4bb06..a5cfacb6 100644 --- a/x/reward/keeper/msg_server_reward.go +++ b/x/reward/keeper/msg_server_reward.go @@ -31,38 +31,37 @@ func (k msgServer) GrantReward(goCtx context.Context, msg *types.MsgGrantReward) if err != nil { return nil, sdkerrors.Wrap(sdkerrtypes.ErrInvalidRequest, "failed to retrieve rewards for user.") } - if len(rewards) > 0 { + if len(rewards) >= int(campaign.ClaimsPerCategory) { return nil, sdkerrors.Wrap(sdkerrtypes.ErrInvalidRequest, "maximum rewards claimed for the given category.") } - recevier, rewardCommon, isSubAccount, _, err := rewardFactory.Calculate(goCtx, ctx, + recevier, rewardCommon, err := rewardFactory.Calculate(goCtx, ctx, types.RewardFactoryKeepers{ OVMKeeper: k.ovmKeeper, BetKeeper: k.betKeeper, SubAccountKeeper: k.subaccountKeeper, - }, campaign, msg.Ticket) + }, campaign, msg.Ticket, msg.Creator) if err != nil { return nil, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "distribution calculation failed %s", err) } - if err := campaign.CheckPoolBalance(recevier.Amount); err != nil { + if err := campaign.CheckPoolBalance(recevier.SubAccountAmount.Add(recevier.MainAccountAmount)); err != nil { return nil, types.ErrInsufficientPoolBalance } - if err := k.DistributeRewards(ctx, campaign.Promoter, isSubAccount, recevier); err != nil { + if err := k.DistributeRewards(ctx, recevier); err != nil { return nil, sdkerrors.Wrapf(types.ErrInDistributionOfRewards, "%s", err) } k.UpdateCampaignPool(ctx, campaign, recevier) - reward := types.NewReward( - msg.Uid, msg.Creator, recevier.Addr, + k.SetReward(ctx, types.NewReward( + msg.Uid, msg.Creator, recevier.MainAccountAddr, msg.CampaignUid, campaign.RewardAmount, rewardCommon.SourceUID, "", - ) - k.SetReward(ctx, reward) - k.SetRewardByReceiver(ctx, campaign.RewardCategory, reward) - k.SetRewardByCampaign(ctx, reward) + )) + k.SetRewardByReceiver(ctx, types.NewRewardByType(msg.Uid, recevier.MainAccountAddr, campaign.RewardCategory)) + k.SetRewardByCampaign(ctx, types.NewRewardByCampaign(msg.Uid, campaign.UID)) msg.EmitEvent(&ctx, msg.CampaignUid, recevier) diff --git a/x/reward/keeper/reward.go b/x/reward/keeper/reward.go index caed101a..5c115765 100644 --- a/x/reward/keeper/reward.go +++ b/x/reward/keeper/reward.go @@ -53,10 +53,10 @@ func (k Keeper) GetAllReward(ctx sdk.Context) (list []types.Reward) { return } -func (k Keeper) SetRewardByReceiver(ctx sdk.Context, rewardType types.RewardCategory, r types.Reward) { +func (k Keeper) SetRewardByReceiver(ctx sdk.Context, rByCategory types.RewardByCategory) { store := k.getRewardByReceiverAndCategoryStore(ctx) - b := k.cdc.MustMarshal(&r) - store.Set(types.GetRewardsByCategoryKey(r.Creator, rewardType, r.UID), b) + b := k.cdc.MustMarshal(&rByCategory) + store.Set(types.GetRewardsByCategoryKey(rByCategory.Addr, rByCategory.RewardCategory, rByCategory.UID), b) } // GetRewardsByAddressAndCategory returns all rewards by address and category. @@ -81,8 +81,8 @@ func (k Keeper) GetRewardsByAddressAndCategory( return } -func (k Keeper) SetRewardByCampaign(ctx sdk.Context, reward types.Reward) { +func (k Keeper) SetRewardByCampaign(ctx sdk.Context, rewByCampaign types.RewardByCampaign) { store := k.getRewardsByCampaignStore(ctx) - b := k.cdc.MustMarshal(&reward) - store.Set(types.GetRewardsByCampaignKey(reward.CampaignUID, reward.UID), b) + b := k.cdc.MustMarshal(&rewByCampaign) + store.Set(types.GetRewardsByCampaignKey(rewByCampaign.CampaignUID, rewByCampaign.UID), b) } diff --git a/x/reward/types/campaign.go b/x/reward/types/campaign.go index 9996dec1..39cfd286 100644 --- a/x/reward/types/campaign.go +++ b/x/reward/types/campaign.go @@ -37,10 +37,6 @@ func (c *Campaign) GetRewardsFactory() (IRewardFactory, error) { switch c.RewardType { case RewardType_REWARD_TYPE_SIGNUP: return NewSignUpReward(), nil - case RewardType_REWARD_TYPE_REFERRAL: - return NewReferralReward(), nil - case RewardType_REWARD_TYPE_AFFILIATE: - return NewAffiliateReward(), nil default: return nil, sdkerrors.Wrapf(ErrUnknownRewardType, "%d", c.RewardType) } diff --git a/x/reward/types/campaign.pb.go b/x/reward/types/campaign.pb.go index 55aaa59c..27e1df08 100644 --- a/x/reward/types/campaign.pb.go +++ b/x/reward/types/campaign.pb.go @@ -49,9 +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,12,opt,name=meta,proto3" json:"meta,omitempty"` + Meta string `protobuf:"bytes,13,opt,name=meta,proto3" json:"meta,omitempty"` } func (m *Campaign) Reset() { *m = Campaign{} } @@ -164,6 +166,13 @@ func (m *Campaign) GetIsActive() bool { return false } +func (m *Campaign) GetClaimsPerCategory() uint64 { + if m != nil { + return m.ClaimsPerCategory + } + return 0 +} + func (m *Campaign) GetMeta() string { if m != nil { return m.Meta @@ -218,40 +227,42 @@ func init() { func init() { proto.RegisterFile("sge/reward/campaign.proto", fileDescriptor_6d1d1b3139567e36) } var fileDescriptor_6d1d1b3139567e36 = []byte{ - // 517 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, 0x5b, 0x0a, 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0x40, 0x4b, 0x53, 0xd0, 0x04, 0xb6, 0x14, 0x57, 0x74, 0x5e, - 0x6d, 0x57, 0xb8, 0xad, 0xa1, 0x3f, 0x0a, 0x77, 0x23, 0xe2, 0x32, 0xe5, 0x52, 0xce, 0x4e, 0xfd, - 0x84, 0x07, 0x29, 0x55, 0x27, 0xfe, 0x7e, 0xa6, 0x7e, 0x17, 0x6e, 0x7f, 0x49, 0xd3, 0xf9, 0xbb, - 0x91, 0xf1, 0x8c, 0x48, 0xe5, 0xd5, 0x10, 0x99, 0xb3, 0x4c, 0xd5, 0xcb, 0x78, 0x5f, 0x88, 0xf1, - 0x8c, 0x48, 0xe5, 0x0d, 0x27, 0x17, 0xa5, 0x03, 0x2e, 0x4b, 0x07, 0xfc, 0x2c, 0x1d, 0x70, 0xbe, - 0x72, 0x1a, 0x97, 0x2b, 0xa7, 0xf1, 0x7d, 0xe5, 0x34, 0xbe, 0xbc, 0x8e, 0x13, 0x75, 0xb2, 0x38, - 0xf6, 0x23, 0x9e, 0x06, 0x32, 0x66, 0xdb, 0xf5, 0x89, 0xe8, 0x3c, 0xf8, 0x76, 0xfd, 0x84, 0xf4, - 0x4d, 0xca, 0xe3, 0xb6, 0x79, 0x42, 0xbb, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xc4, 0x4c, 0x75, - 0xd4, 0xa5, 0x03, 0x00, 0x00, + // 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, 0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03, 0x98, 0xea, 0xad, 0x70, 0x02, 0x5a, 0x92, 0x49, 0x32, 0x2f, 0xa7, 0x31, 0xd8, 0x56, 0x1f, + 0xf1, 0x3d, 0x77, 0x36, 0x42, 0x26, 0x12, 0x26, 0xc4, 0xec, 0xcc, 0x8b, 0x99, 0x9f, 0x10, 0x79, + 0xea, 0xed, 0xa7, 0xf2, 0x67, 0xee, 0xf4, 0x97, 0x24, 0x99, 0xbf, 0x1d, 0x69, 0xcf, 0x08, 0x97, + 0x5e, 0x05, 0x11, 0x19, 0x4d, 0x65, 0x35, 0xbc, 0x0f, 0x85, 0x68, 0xcf, 0x08, 0x97, 0xde, 0x60, + 0x72, 0x59, 0xd8, 0xc6, 0x55, 0x61, 0x1b, 0x3f, 0x0a, 0xdb, 0xb8, 0x58, 0xd9, 0x8d, 0xab, 0x95, + 0xdd, 0xf8, 0xb6, 0xb2, 0x1b, 0x9f, 0x5e, 0x45, 0xb1, 0x3c, 0x5d, 0x9c, 0x78, 0x21, 0x4b, 0x7c, + 0x11, 0xd1, 0xed, 0x6a, 0x07, 0x55, 0xec, 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, } func (m *Campaign) Marshal() (dAtA []byte, err error) { @@ -279,7 +290,12 @@ func (m *Campaign) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Meta) i = encodeVarintCampaign(dAtA, i, uint64(len(m.Meta))) i-- - dAtA[i] = 0x62 + dAtA[i] = 0x6a + } + if m.ClaimsPerCategory != 0 { + i = encodeVarintCampaign(dAtA, i, uint64(m.ClaimsPerCategory)) + i-- + dAtA[i] = 0x60 } if m.IsActive { i-- @@ -458,6 +474,9 @@ 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)) @@ -794,6 +813,25 @@ 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) } diff --git a/x/reward/types/errors.go b/x/reward/types/errors.go index 88fe0b73..d6f7dcff 100644 --- a/x/reward/types/errors.go +++ b/x/reward/types/errors.go @@ -30,5 +30,6 @@ var ( ErrAccReceiverTypeNotFound = sdkerrors.Register(ModuleName, 7119, "receiver type not found in the receivers") ErrInvalidNoLossBetUID = sdkerrors.Register(ModuleName, 7120, "invalid no loss bet uid") ErrWrongAmountForType = sdkerrors.Register(ModuleName, 7121, "wrong amount for account type") - ErrReceiverAddrNotSubAcc = sdkerrors.Register(ModuleName, 7122, "receiver address is not a subaccount address") + ErrSubAccountCreationFailed = sdkerrors.Register(ModuleName, 7122, "suba ccount creation failed") + ErrWrongRewardAmountType = sdkerrors.Register(ModuleName, 7114, "wrong reward amount type") ) diff --git a/x/reward/types/expected_keepers.go b/x/reward/types/expected_keepers.go index 9b7fba6a..11bdf9ee 100644 --- a/x/reward/types/expected_keepers.go +++ b/x/reward/types/expected_keepers.go @@ -64,5 +64,6 @@ type AuthzKeeper interface { // SubAccountKeeper defines the expected interface needed to ge/create/topup a subaccount. type SubAccountKeeper interface { TopUp(ctx sdk.Context, creator, subAccOwnerAddr string, lockedBalance []subaccounttypes.LockedBalance) (string, error) - GetSubAccountOwner(ctx sdk.Context, subaccountAddr sdk.AccAddress) (sdk.AccAddress, bool) + GetSubAccountByOwner(ctx sdk.Context, mainAccountAddress sdk.AccAddress) (sdk.AccAddress, bool) + CreateSubAccount(ctx sdk.Context, creator, owner string, lockedBalances []subaccounttypes.LockedBalance) (string, error) } diff --git a/x/reward/types/reward.go b/x/reward/types/reward.go index afd2f05d..591d4554 100644 --- a/x/reward/types/reward.go +++ b/x/reward/types/reward.go @@ -10,9 +10,11 @@ import ( ) type Receiver struct { - Addr string - Amount sdkmath.Int - UnlockTS uint64 + SubAccountAddr string + SubAccountAmount sdkmath.Int + UnlockTS uint64 + MainAccountAddr string + MainAccountAmount sdkmath.Int } // RewardFactoryKeepers holds the keeper objectes usable by reward types methods. @@ -26,7 +28,7 @@ func NewReward( uid, creator, receiver string, campaignUID string, rewardAmount *RewardAmount, - sourceID, meta string, + sourceUID, meta string, ) Reward { return Reward{ UID: uid, @@ -34,24 +36,42 @@ func NewReward( Receiver: receiver, CampaignUID: campaignUID, RewardAmount: rewardAmount, - SourceUID: sourceID, + SourceUID: sourceUID, Meta: meta, } } +func NewRewardByType(uid, addr string, rewardCategory RewardCategory) RewardByCategory { + return RewardByCategory{ + UID: uid, + RewardCategory: rewardCategory, + Addr: addr, + } +} + +func NewRewardByCampaign(uid, campaignUID string) RewardByCampaign { + return RewardByCampaign{ + UID: uid, + CampaignUID: campaignUID, + } +} + // IRewardFactory defines the methods that should be implemented for all reward types. type IRewardFactory interface { VaidateCampaign(campaign Campaign) error - Calculate(goCtx context.Context, ctx sdk.Context, keepers RewardFactoryKeepers, campaign Campaign, ticket string, - ) (Receiver, RewardPayloadCommon, bool, string, error) + Calculate( + goCtx context.Context, ctx sdk.Context, keepers RewardFactoryKeepers, campaign Campaign, ticket, creator string, + ) (Receiver, RewardPayloadCommon, error) } // NewReceiver creates reveiver object. -func NewReceiver(addr string, amount sdkmath.Int, unlockTS uint64) Receiver { +func NewReceiver(saAddr, maAddr string, saAmount, maAmount sdkmath.Int, unlockTS uint64) Receiver { return Receiver{ - Amount: amount, - Addr: addr, - UnlockTS: unlockTS, + SubAccountAddr: saAddr, + SubAccountAmount: saAmount, + UnlockTS: unlockTS, + MainAccountAddr: maAddr, + MainAccountAmount: maAmount, } } diff --git a/x/reward/types/reward.pb.go b/x/reward/types/reward.pb.go index 2354e8b8..7869bf36 100644 --- a/x/reward/types/reward.pb.go +++ b/x/reward/types/reward.pb.go @@ -282,8 +282,8 @@ type RewardAmount struct { MainAccountAmount cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=main_account_amount,json=mainAccountAmount,proto3,customtype=cosmossdk.io/math.Int" json:"main_account_amount" yaml:"main_account_amount"` // sub account reward amount SubaccountAmount cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=subaccount_amount,json=subaccountAmount,proto3,customtype=cosmossdk.io/math.Int" json:"subaccount_amount" yaml:"subaccount_amount"` - // unlock timestamp - UnlockTS uint64 `protobuf:"varint,3,opt,name=unlock_ts,proto3" json:"unlock_ts"` + // unlock period + UnlockPeriod uint64 `protobuf:"varint,3,opt,name=unlock_period,proto3" json:"unlock_period"` } func (m *RewardAmount) Reset() { *m = RewardAmount{} } @@ -319,72 +319,190 @@ func (m *RewardAmount) XXX_DiscardUnknown() { var xxx_messageInfo_RewardAmount proto.InternalMessageInfo -func (m *RewardAmount) GetUnlockTS() uint64 { +func (m *RewardAmount) GetUnlockPeriod() uint64 { if m != nil { - return m.UnlockTS + return m.UnlockPeriod } return 0 } +type RewardByCategory struct { + UID string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid"` + Addr string `protobuf:"bytes,2,opt,name=addr,proto3" json:"addr,omitempty"` + RewardCategory RewardCategory `protobuf:"varint,3,opt,name=reward_category,json=rewardCategory,proto3,enum=sgenetwork.sge.reward.RewardCategory" json:"reward_category,omitempty"` +} + +func (m *RewardByCategory) Reset() { *m = RewardByCategory{} } +func (m *RewardByCategory) String() string { return proto.CompactTextString(m) } +func (*RewardByCategory) ProtoMessage() {} +func (*RewardByCategory) Descriptor() ([]byte, []int) { + return fileDescriptor_3412add70a4f177f, []int{2} +} +func (m *RewardByCategory) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RewardByCategory) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RewardByCategory.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 *RewardByCategory) XXX_Merge(src proto.Message) { + xxx_messageInfo_RewardByCategory.Merge(m, src) +} +func (m *RewardByCategory) XXX_Size() int { + return m.Size() +} +func (m *RewardByCategory) XXX_DiscardUnknown() { + xxx_messageInfo_RewardByCategory.DiscardUnknown(m) +} + +var xxx_messageInfo_RewardByCategory proto.InternalMessageInfo + +func (m *RewardByCategory) GetUID() string { + if m != nil { + return m.UID + } + return "" +} + +func (m *RewardByCategory) GetAddr() string { + if m != nil { + return m.Addr + } + return "" +} + +func (m *RewardByCategory) GetRewardCategory() RewardCategory { + if m != nil { + return m.RewardCategory + } + return RewardCategory_REWARD_CATEGORY_UNSPECIFIED +} + +type RewardByCampaign struct { + UID string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid"` + CampaignUID string `protobuf:"bytes,2,opt,name=campaign_uid,proto3" json:"campaign_uid"` +} + +func (m *RewardByCampaign) Reset() { *m = RewardByCampaign{} } +func (m *RewardByCampaign) String() string { return proto.CompactTextString(m) } +func (*RewardByCampaign) ProtoMessage() {} +func (*RewardByCampaign) Descriptor() ([]byte, []int) { + return fileDescriptor_3412add70a4f177f, []int{3} +} +func (m *RewardByCampaign) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RewardByCampaign) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RewardByCampaign.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 *RewardByCampaign) XXX_Merge(src proto.Message) { + xxx_messageInfo_RewardByCampaign.Merge(m, src) +} +func (m *RewardByCampaign) XXX_Size() int { + return m.Size() +} +func (m *RewardByCampaign) XXX_DiscardUnknown() { + xxx_messageInfo_RewardByCampaign.DiscardUnknown(m) +} + +var xxx_messageInfo_RewardByCampaign proto.InternalMessageInfo + +func (m *RewardByCampaign) GetUID() string { + if m != nil { + return m.UID + } + return "" +} + +func (m *RewardByCampaign) GetCampaignUID() string { + if m != nil { + return m.CampaignUID + } + return "" +} + func init() { proto.RegisterEnum("sgenetwork.sge.reward.RewardCategory", RewardCategory_name, RewardCategory_value) proto.RegisterEnum("sgenetwork.sge.reward.RewardType", RewardType_name, RewardType_value) proto.RegisterEnum("sgenetwork.sge.reward.RewardAmountType", RewardAmountType_name, RewardAmountType_value) proto.RegisterType((*Reward)(nil), "sgenetwork.sge.reward.Reward") proto.RegisterType((*RewardAmount)(nil), "sgenetwork.sge.reward.RewardAmount") + proto.RegisterType((*RewardByCategory)(nil), "sgenetwork.sge.reward.RewardByCategory") + proto.RegisterType((*RewardByCampaign)(nil), "sgenetwork.sge.reward.RewardByCampaign") } func init() { proto.RegisterFile("sge/reward/reward.proto", fileDescriptor_3412add70a4f177f) } var fileDescriptor_3412add70a4f177f = []byte{ - // 740 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x54, 0x3d, 0x6f, 0xd3, 0x50, - 0x14, 0x8d, 0x9d, 0x34, 0x1f, 0xaf, 0xa5, 0x72, 0x1f, 0x4d, 0xeb, 0xa6, 0xad, 0x9d, 0x86, 0xa5, - 0x54, 0xc2, 0x91, 0x60, 0x40, 0xd0, 0xc9, 0x71, 0x5e, 0x82, 0xa5, 0x34, 0x89, 0x5e, 0x1c, 0x41, - 0x59, 0x22, 0xd7, 0x35, 0x6e, 0x94, 0x3a, 0x8e, 0x6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f, 0x32, 0x91, 0xbb, 0x9a, - 0xb7, 0xcd, 0xbd, 0xca, 0xc2, 0x3c, 0xd8, 0x8a, 0xa2, 0xa1, 0x4f, 0xb9, 0x93, 0xaf, 0x14, 0x60, - 0xa2, 0xbf, 0x27, 0xe2, 0x56, 0x09, 0x70, 0x53, 0xae, 0x78, 0x16, 0xb4, 0xaf, 0x32, 0x6d, 0xa1, - 0x16, 0xe5, 0xd4, 0xe4, 0x77, 0xa8, 0xba, 0xf4, 0xdd, 0x44, 0xd1, 0x46, 0xab, 0x2e, 0x4b, 0x0c, - 0x0d, 0x8f, 0xc0, 0xe1, 0x0a, 0xb4, 0x8d, 0xb0, 0x84, 0x9a, 0x8a, 0x58, 0x47, 0x4c, 0xb2, 0x22, - 0xdd, 0xfa, 0x1c, 0x75, 0xe7, 0x73, 0xd4, 0x2f, 0x9f, 0xa3, 0xbe, 0xdc, 0x73, 0x89, 0xbb, 0x7b, - 0x2e, 0xf1, 0xe3, 0x9e, 0x4b, 0xbc, 0x7f, 0x6a, 0xf4, 0xdd, 0xab, 0xf1, 0x85, 0xa0, 0x59, 0x66, - 0xd9, 0x31, 0xf4, 0x67, 0xd3, 0x47, 0x2b, 0x88, 0xcb, 0x9f, 0x66, 0xef, 0xb8, 0x3b, 0x19, 0xe9, - 0xce, 0x45, 0x9a, 0x3c, 0xcd, 0x2f, 0xfe, 0x06, 0x00, 0x00, 0xff, 0xff, 0xb9, 0x77, 0xd4, 0xbe, - 0xe2, 0x05, 0x00, 0x00, + // 806 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0x4f, 0x8f, 0xdb, 0x54, + 0x10, 0x8f, 0x9d, 0x74, 0xff, 0x4c, 0xb7, 0x8b, 0xf7, 0xd1, 0x6d, 0xdd, 0x6c, 0x6b, 0xa7, 0x46, + 0x48, 0x65, 0x25, 0x1c, 0xa9, 0x9c, 0xa0, 0x27,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a, 0xed, + 0xb9, 0xcd, 0xc0, 0xa1, 0x9f, 0xa6, 0xfb, 0x19, 0x9f, 0x9b, 0xdf, 0x67, 0x5f, 0xbb, 0x70, 0xbd, + 0xa4, 0xc1, 0xd5, 0x01, 0xfb, 0x80, 0x7d, 0xf6, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x3c, 0xb4, + 0x71, 0xab, 0x08, 0x07, 0x00, 0x00, } func (m *Reward) Marshal() (dAtA []byte, err error) { @@ -484,8 +602,8 @@ func (m *RewardAmount) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.UnlockTS != 0 { - i = encodeVarintReward(dAtA, i, uint64(m.UnlockTS)) + if m.UnlockPeriod != 0 { + i = encodeVarintReward(dAtA, i, uint64(m.UnlockPeriod)) i-- dAtA[i] = 0x18 } @@ -512,6 +630,85 @@ func (m *RewardAmount) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *RewardByCategory) 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 *RewardByCategory) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RewardByCategory) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.RewardCategory != 0 { + i = encodeVarintReward(dAtA, i, uint64(m.RewardCategory)) + i-- + dAtA[i] = 0x18 + } + if len(m.Addr) > 0 { + i -= len(m.Addr) + copy(dAtA[i:], m.Addr) + i = encodeVarintReward(dAtA, i, uint64(len(m.Addr))) + i-- + dAtA[i] = 0x12 + } + if len(m.UID) > 0 { + i -= len(m.UID) + copy(dAtA[i:], m.UID) + i = encodeVarintReward(dAtA, i, uint64(len(m.UID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RewardByCampaign) 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 *RewardByCampaign) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RewardByCampaign) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.CampaignUID) > 0 { + i -= len(m.CampaignUID) + copy(dAtA[i:], m.CampaignUID) + i = encodeVarintReward(dAtA, i, uint64(len(m.CampaignUID))) + i-- + dAtA[i] = 0x12 + } + if len(m.UID) > 0 { + i -= len(m.UID) + copy(dAtA[i:], m.UID) + i = encodeVarintReward(dAtA, i, uint64(len(m.UID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintReward(dAtA []byte, offset int, v uint64) int { offset -= sovReward(v) base := offset @@ -570,8 +767,45 @@ func (m *RewardAmount) Size() (n int) { n += 1 + l + sovReward(uint64(l)) l = m.SubaccountAmount.Size() n += 1 + l + sovReward(uint64(l)) - if m.UnlockTS != 0 { - n += 1 + sovReward(uint64(m.UnlockTS)) + if m.UnlockPeriod != 0 { + n += 1 + sovReward(uint64(m.UnlockPeriod)) + } + return n +} + +func (m *RewardByCategory) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.UID) + if l > 0 { + n += 1 + l + sovReward(uint64(l)) + } + l = len(m.Addr) + if l > 0 { + n += 1 + l + sovReward(uint64(l)) + } + if m.RewardCategory != 0 { + n += 1 + sovReward(uint64(m.RewardCategory)) + } + return n +} + +func (m *RewardByCampaign) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.UID) + if l > 0 { + n += 1 + l + sovReward(uint64(l)) + } + l = len(m.CampaignUID) + if l > 0 { + n += 1 + l + sovReward(uint64(l)) } return n } @@ -959,9 +1193,9 @@ func (m *RewardAmount) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field UnlockTS", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field UnlockPeriod", wireType) } - m.UnlockTS = 0 + m.UnlockPeriod = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowReward @@ -971,7 +1205,7 @@ func (m *RewardAmount) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.UnlockTS |= uint64(b&0x7F) << shift + m.UnlockPeriod |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -997,6 +1231,253 @@ func (m *RewardAmount) Unmarshal(dAtA []byte) error { } return nil } +func (m *RewardByCategory) 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 ErrIntOverflowReward + } + 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: RewardByCategory: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RewardByCategory: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowReward + } + 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 ErrInvalidLengthReward + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthReward + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.UID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Addr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowReward + } + 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 ErrInvalidLengthReward + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthReward + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Addr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardCategory", wireType) + } + m.RewardCategory = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowReward + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RewardCategory |= RewardCategory(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipReward(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthReward + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RewardByCampaign) 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 ErrIntOverflowReward + } + 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: RewardByCampaign: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RewardByCampaign: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowReward + } + 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 ErrInvalidLengthReward + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthReward + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.UID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CampaignUID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowReward + } + 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 ErrInvalidLengthReward + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthReward + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CampaignUID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipReward(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthReward + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipReward(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/reward/types/reward_affiliate.go b/x/reward/types/reward_affiliate.go deleted file mode 100644 index d7bb1490..00000000 --- a/x/reward/types/reward_affiliate.go +++ /dev/null @@ -1,54 +0,0 @@ -package types - -import ( - context "context" - - sdkerrors "cosmossdk.io/errors" - sdkmath "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// AffiliateReward is the type for affiliation rewards calculations -type AffiliateReward struct{} - -// NewAffiliateReward create new object of affiliation reward calculator type. -func NewAffiliateReward() AffiliateReward { return AffiliateReward{} } - -// VaidateCampaign validates campaign definitions. -func (rfr AffiliateReward) VaidateCampaign(campaign Campaign) error { - if campaign.RewardCategory != RewardCategory_REWARD_CATEGORY_SIGNUP { - return sdkerrors.Wrapf(ErrWrongRewardCategory, "affiliate rewards can only have single definition") - } - if campaign.RewardAmount.MainAccountAmount.GT(sdkmath.ZeroInt()) { - return sdkerrors.Wrapf(ErrInvalidGranteeType, "affiliate rewards can be defined for subaccount only") - } - if campaign.RewardAmount.SubaccountAmount.LTE(sdkmath.ZeroInt()) { - return sdkerrors.Wrapf(ErrWrongAmountForType, "affiliate rewards for subaccount should be positive") - } - - // TODO: validate duplicate signup affiliate reward - return nil -} - -// Calculate parses ticket payload and returns the distribution list of referral reward. -func (rfr AffiliateReward) Calculate(goCtx context.Context, ctx sdk.Context, keepers RewardFactoryKeepers, - campaign Campaign, ticket string, -) (Receiver, RewardPayloadCommon, bool, string, error) { - var payload GrantSignupRewardPayload - if err := keepers.OVMKeeper.VerifyTicketUnmarshal(goCtx, ticket, &payload); err != nil { - return Receiver{}, payload.Common, false, "", sdkerrors.Wrapf(ErrInTicketVerification, "%s", err) - } - - _, found := keepers.SubAccountKeeper.GetSubAccountOwner(ctx, sdk.MustAccAddressFromBech32(payload.Common.Receiver)) - if !found { - return Receiver{}, payload.Common, false, "", sdkerrors.Wrapf(ErrReceiverAddrNotSubAcc, "%s", &payload.Common.Receiver) - } - - // TODO: validate reward grant for referral - - return NewReceiver( - payload.Common.Receiver, - campaign.RewardAmount.SubaccountAmount, - 0, - ), payload.Common, true, "", nil -} diff --git a/x/reward/types/reward_referral.go b/x/reward/types/reward_referral.go deleted file mode 100644 index 53152cd8..00000000 --- a/x/reward/types/reward_referral.go +++ /dev/null @@ -1,54 +0,0 @@ -package types - -import ( - context "context" - - sdkerrors "cosmossdk.io/errors" - sdkmath "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// ReferralReward is the type for referral rewards calculations -type ReferralReward struct{} - -// NewReferralReward create new object of referral reward calculator type. -func NewReferralReward() ReferralReward { return ReferralReward{} } - -// VaidateCampaign validates campaign definitions. -func (rfr ReferralReward) VaidateCampaign(campaign Campaign) error { - if campaign.RewardCategory != RewardCategory_REWARD_CATEGORY_SIGNUP { - return sdkerrors.Wrapf(ErrWrongRewardCategory, "referral rewards can only have single definition") - } - if campaign.RewardAmount.MainAccountAmount.GT(sdkmath.ZeroInt()) { - return sdkerrors.Wrapf(ErrInvalidGranteeType, "referral rewards can be defined for subaccount only") - } - if campaign.RewardAmount.SubaccountAmount.LTE(sdkmath.ZeroInt()) { - return sdkerrors.Wrapf(ErrWrongAmountForType, "referral rewards for subaccount should be positive") - } - - // TODO: validate duplicate signup referral reward - return nil -} - -// Calculate parses ticket payload and returns the distribution list of referral reward. -func (rfr ReferralReward) Calculate(goCtx context.Context, ctx sdk.Context, keepers RewardFactoryKeepers, - campaign Campaign, ticket string, -) (Receiver, RewardPayloadCommon, bool, string, error) { - var payload GrantSignupRewardPayload - if err := keepers.OVMKeeper.VerifyTicketUnmarshal(goCtx, ticket, &payload); err != nil { - return Receiver{}, payload.Common, false, "", sdkerrors.Wrapf(ErrInTicketVerification, "%s", err) - } - - _, found := keepers.SubAccountKeeper.GetSubAccountOwner(ctx, sdk.MustAccAddressFromBech32(payload.Common.Receiver)) - if !found { - return Receiver{}, payload.Common, false, "", sdkerrors.Wrapf(ErrReceiverAddrNotSubAcc, "%s", &payload.Common.Receiver) - } - - // TODO: validate reward grant for referral - - return NewReceiver( - payload.Common.Receiver, - campaign.RewardAmount.SubaccountAmount, - 0, - ), payload.Common, true, "", nil -} diff --git a/x/reward/types/reward_signup.go b/x/reward/types/reward_signup.go index b861de3c..154fe030 100644 --- a/x/reward/types/reward_signup.go +++ b/x/reward/types/reward_signup.go @@ -6,6 +6,7 @@ import ( sdkerrors "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" + subaccounttypes "github.com/sge-network/sge/x/subaccount/types" ) // SignUpReward is the type for signup rewards calculations @@ -22,30 +23,42 @@ func (sur SignUpReward) VaidateCampaign(campaign Campaign) error { if campaign.RewardAmount.SubaccountAmount.LTE(sdkmath.ZeroInt()) { return sdkerrors.Wrapf(ErrWrongAmountForType, "signup rewards for subaccount should be positive") } - - // TODO: validate duplicate signup reward + if campaign.RewardAmountType != RewardAmountType_REWARD_AMOUNT_TYPE_FIXED { + 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 signup reward. func (sur SignUpReward) Calculate(goCtx context.Context, ctx sdk.Context, keepers RewardFactoryKeepers, - campaign Campaign, ticket string, -) (Receiver, RewardPayloadCommon, bool, string, error) { + campaign Campaign, ticket, creator string, +) (Receiver, RewardPayloadCommon, error) { var payload GrantSignupRewardPayload if err := keepers.OVMKeeper.VerifyTicketUnmarshal(goCtx, ticket, &payload); err != nil { - return Receiver{}, payload.Common, false, "", sdkerrors.Wrapf(ErrInTicketVerification, "%s", err) + return Receiver{}, payload.Common, sdkerrors.Wrapf(ErrInTicketVerification, "%s", err) } - - _, found := keepers.SubAccountKeeper.GetSubAccountOwner(ctx, sdk.MustAccAddressFromBech32(payload.Common.Receiver)) + // TODO check if receiver is not a sub account itself + var ( + subAccountAddressString string + err error + ) + subAccountAddress, found := keepers.SubAccountKeeper.GetSubAccountByOwner(ctx, sdk.MustAccAddressFromBech32(payload.Common.Receiver)) if !found { - return Receiver{}, payload.Common, false, "", sdkerrors.Wrapf(ErrReceiverAddrNotSubAcc, "%s", &payload.Common.Receiver) + subAccountAddressString, err = keepers.SubAccountKeeper.CreateSubAccount(ctx, creator, payload.Common.Receiver, []subaccounttypes.LockedBalance{}) + if err != nil { + return Receiver{}, payload.Common, sdkerrors.Wrapf(ErrSubAccountCreationFailed, "%s", payload.Common.Receiver) + } + } else { + subAccountAddressString = subAccountAddress.String() } // TODO: validate reward grant for sighnup return NewReceiver( + subAccountAddressString, payload.Common.Receiver, campaign.RewardAmount.SubaccountAmount, - 0, - ), payload.Common, true, payload.Common.Receiver, nil + campaign.RewardAmount.MainAccountAmount, + campaign.RewardAmount.UnlockPeriod, + ), payload.Common, nil } diff --git a/x/reward/types/ticket.go b/x/reward/types/ticket.go index d6c39ba5..83294b7c 100644 --- a/x/reward/types/ticket.go +++ b/x/reward/types/ticket.go @@ -38,7 +38,7 @@ func (payload *CreateCampaignPayload) Validate(blockTime uint64) error { } if payload.RewardAmount.SubaccountAmount.GT(sdkmath.ZeroInt()) && - payload.RewardAmount.UnlockTS == 0 { + payload.RewardAmount.UnlockPeriod == 0 { return sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "sub account should have unlock timestamp") } diff --git a/x/reward/types/ticket.pb.go b/x/reward/types/ticket.pb.go index df420bf2..ad49ab75 100644 --- a/x/reward/types/ticket.pb.go +++ b/x/reward/types/ticket.pb.go @@ -45,9 +45,11 @@ type CreateCampaignPayload struct { TotalFunds cosmossdk_io_math.Int `protobuf:"bytes,8,opt,name=total_funds,json=totalFunds,proto3,customtype=cosmossdk.io/math.Int" json:"total_funds" yaml:"total_funds"` // is_active is the flag to check if the campaign is active or not. IsActive bool `protobuf:"varint,9,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,10,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"` + Meta string `protobuf:"bytes,11,opt,name=meta,proto3" json:"meta,omitempty"` } func (m *CreateCampaignPayload) Reset() { *m = CreateCampaignPayload{} } @@ -139,6 +141,13 @@ func (m *CreateCampaignPayload) GetIsActive() bool { return false } +func (m *CreateCampaignPayload) GetClaimsPerCategory() uint64 { + if m != nil { + return m.ClaimsPerCategory + } + return 0 +} + func (m *CreateCampaignPayload) GetMeta() string { if m != nil { return m.Meta @@ -392,45 +401,47 @@ func init() { func init() { proto.RegisterFile("sge/reward/ticket.proto", fileDescriptor_5d710bc1249ca8ae) } var fileDescriptor_5d710bc1249ca8ae = []byte{ - // 605 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0x41, 0x6f, 0xd3, 0x30, - 0x14, 0xae, 0xb7, 0xae, 0x4b, 0x5f, 0x19, 0x42, 0x66, 0x15, 0xd9, 0x26, 0xa5, 0x25, 0x08, 0x51, - 0x90, 0x48, 0xa4, 0xed, 0x06, 0xa7, 0xb5, 0x68, 0x6c, 0x37, 0x94, 0x75, 0x42, 0xe2, 0x52, 0x79, - 0x89, 0xc9, 0xa2, 0x2d, 0x71, 0x64, 0x3b, 0x2b, 0xb9, 0xf2, 0x0b, 0x38, 0x20, 0xf1, 0x97, 0x76, - 0xdc, 0x11, 0x71, 0xa8, 0x50, 0x7b, 0xe3, 0xc8, 0x2f, 0x40, 0xb1, 0x43, 0x97, 0xa2, 0xa9, 0xec, - 0xe4, 0xf7, 0xfc, 0xbe, 0xf7, 0xf9, 0xf3, 0xf7, 0x2c, 0xc3, 0x23, 0x11, 0x52, 0x97, 0xd3, 0x31, - 0xe1, 0x81, 0x2b, 0x23, 0xff, 0x9c, 0x4a, 0x27, 0xe5, 0x4c, 0x32, 0xdc, 0x16, 0x21, 0x4d, 0xa8, - 0x1c, 0x33, 0x7e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x68, - 0x17, 0xfa, 0x3b, 0xd3, 0x49, 0xa7, 0x79, 0xac, 0x76, 0x4f, 0x8e, 0xde, 0xfc, 0x9a, 0x74, 0x2a, - 0x10, 0xaf, 0x12, 0xcf, 0x27, 0xb0, 0x5a, 0x99, 0x40, 0x00, 0xe6, 0x5b, 0x4e, 0x12, 0x79, 0x1c, - 0x85, 0x49, 0x96, 0x2e, 0xc8, 0xc1, 0x87, 0xd0, 0xf0, 0x95, 0x24, 0x75, 0x50, 0x6b, 0xf7, 0xc5, - 0xd2, 0x77, 0xb6, 0x70, 0x89, 0x7e, 0xbd, 0x70, 0xcc, 0x2b, 0xfb, 0xfb, 0x83, 0xab, 0xa9, 0x85, - 0xae, 0xa7, 0x16, 0xfa, 0x39, 0xb5, 0xd0, 0x97, 0x99, 0x55, 0xbb, 0x9e, 0x59, 0xb5, 0xef, 0x33, - 0xab, 0xf6, 0xe1, 0x79, 0x18, 0xc9, 0xb3, 0xec, 0xd4, 0xf1, 0x59, 0xec, 0x8a, 0x90, 0xbe, 0x2c, - 0xe9, 0x8b, 0xd8, 0xfd, 0x34, 0xff, 0xab, 0xf2, 0x94, 0x8a, 0xd3, 0x86, 0xfa, 0x4a, 0xf6, 0xfe, - 0x04, 0x00, 0x00, 0xff, 0xff, 0xb9, 0xbb, 0x00, 0xf6, 0xc6, 0x04, 0x00, 0x00, + // 630 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xc1, 0x6e, 0xd3, 0x40, + 0x10, 0xcd, 0xb6, 0x69, 0x9a, 0x4c, 0x28, 0x82, 0x6d, 0x23, 0xdc, 0x56, 0x4a, 0x82, 0x11, 0x22, + 0x20, 0xe1, 0x48, 0xed, 0x0d, 0x4e, 0x4d, 0x50, 0x69, 0x6f, 0x95, 0x9b, 0x0a, 0x89, 0x8b, 0xb5, + 0xb5, 0x17, 0x77, 0xd5, 0xd8, 0x6b,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xc3, 0x3d, 0xa8, + 0x9b, 0x16, 0x4f, 0x8d, 0x13, 0x6a, 0xad, 0x68, 0x94, 0xa7, 0x0b, 0x51, 0x06, 0xe3, 0x84, 0xba, + 0x20, 0xf2, 0x18, 0x9f, 0x00, 0xce, 0x30, 0x48, 0xc4, 0x47, 0xb1, 0x32, 0x50, 0x15, 0x0d, 0xf5, + 0x62, 0x21, 0xd4, 0x9e, 0xee, 0xd7, 0x80, 0x8f, 0xc4, 0x3f, 0x6f, 0xf0, 0x01, 0xac, 0xcd, 0xc1, + 0x5a, 0xab, 0x6d, 0xd4, 0xa9, 0xef, 0x3c, 0xbb, 0x07, 0xa2, 0xfb, 0xa0, 0x88, 0x86, 0x07, 0x50, + 0x57, 0x5c, 0x91, 0xa1, 0xf7, 0x69, 0x14, 0x07, 0xd2, 0xaa, 0xa6, 0xc2, 0xf7, 0x76, 0xaf, 0x26, + 0xad, 0xd2, 0xcf, 0x49, 0xab, 0xe1, 0x73, 0x19, 0x71, 0x29, 0x83, 0x73, 0x87, 0xf1, 0x6e, 0x44, + 0xd4, 0x99, 0x73, 0x18, 0xab, 0x3f, 0x93, 0x16, 0x1e, 0x93, 0x68, 0xf8, 0xc6, 0x2e, 0x4c, 0xda, + 0x2e, 0xe8, 0x6c, 0x3f, 0x4d, 0xf0, 0x36, 0xd4, 0x98, 0xf4, 0x88, 0xaf, 0xd8, 0x05, 0xb5, 0x6a, + 0x6d, 0xd4, 0xa9, 0xba, 0x55, 0x26, 0xf7, 0x74, 0x8e, 0x1d, 0x58, 0xf7, 0x87, 0x84, 0x45, 0xd2, + 0x4b, 0xa8, 0xf0, 0x72, 0x97, 0x40, 0xdb, 0xf7, 0xd8, 0x94, 0x8e, 0xa8, 0xb8, 0x71, 0x04, 0x63, + 0x28, 0x47, 0x54, 0x11, 0xab, 0xae, 0x8f, 0x42, 0xc7, 0x36, 0x81, 0xc6, 0x49, 0x12, 0xdc, 0x71, + 0x45, 0xb7, 0xe7, 0x80, 0x8a, 0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dd, 0xcf, 0xf9, 0xbf, 0x6d, + 0x9c, 0x50, 0x79, 0x5a, 0xd1, 0xbf, 0x9e, 0xdd, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x73, 0x8f, + 0xe2, 0xac, 0xf6, 0x04, 0x00, 0x00, } func (m *CreateCampaignPayload) Marshal() (dAtA []byte, err error) { @@ -458,7 +469,12 @@ func (m *CreateCampaignPayload) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Meta) i = encodeVarintTicket(dAtA, i, uint64(len(m.Meta))) i-- - dAtA[i] = 0x52 + dAtA[i] = 0x5a + } + if m.ClaimsPerCategory != 0 { + i = encodeVarintTicket(dAtA, i, uint64(m.ClaimsPerCategory)) + i-- + dAtA[i] = 0x50 } if m.IsActive { i-- @@ -744,6 +760,9 @@ 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)) @@ -1073,6 +1092,25 @@ func (m *CreateCampaignPayload) Unmarshal(dAtA []byte) error { } m.IsActive = bool(v != 0) case 10: + 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 11: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Meta", wireType) } diff --git a/x/reward/types/ticket_test.go b/x/reward/types/ticket_test.go index 9338c32e..69ba3f6a 100644 --- a/x/reward/types/ticket_test.go +++ b/x/reward/types/ticket_test.go @@ -60,7 +60,7 @@ func TestCreateCampaignPayloadValidation(t *testing.T) { RewardAmountType: types.RewardAmountType_REWARD_AMOUNT_TYPE_FIXED, RewardAmount: &types.RewardAmount{ SubaccountAmount: sdkmath.NewInt(1000), - UnlockTS: 0, + UnlockPeriod: 0, }, IsActive: true, Meta: "sample campaign", @@ -78,7 +78,7 @@ func TestCreateCampaignPayloadValidation(t *testing.T) { RewardAmountType: types.RewardAmountType_REWARD_AMOUNT_TYPE_FIXED, RewardAmount: &types.RewardAmount{ SubaccountAmount: sdkmath.NewInt(1000), - UnlockTS: 0, + UnlockPeriod: 0, }, TotalFunds: sdkmath.NewInt(0), IsActive: true, @@ -97,7 +97,7 @@ func TestCreateCampaignPayloadValidation(t *testing.T) { RewardAmountType: types.RewardAmountType_REWARD_AMOUNT_TYPE_FIXED, RewardAmount: &types.RewardAmount{ SubaccountAmount: sdkmath.NewInt(1000), - UnlockTS: 0, + UnlockPeriod: 0, }, TotalFunds: poolBalance, IsActive: true, From bd2e4dfc2a717407e53aa72e64dd518f602df763 Mon Sep 17 00:00:00 2001 From: P-U-D-G-E Date: Wed, 8 Nov 2023 17:10:24 +0530 Subject: [PATCH 05/12] minor changes --- x/reward/client/cli/tx_reward.go | 10 ++++++---- x/reward/keeper/distribution.go | 6 +++--- x/reward/keeper/msg_server_campaign.go | 2 +- x/reward/keeper/msg_server_reward.go | 20 +++++++++---------- x/reward/keeper/reward.go | 4 ++-- x/reward/types/campaign.go | 27 +++++++++++++------------- x/reward/types/errors.go | 4 ++-- x/reward/types/messages_reward.go | 2 ++ x/reward/types/reward.go | 8 ++++---- 9 files changed, 44 insertions(+), 39 deletions(-) diff --git a/x/reward/client/cli/tx_reward.go b/x/reward/client/cli/tx_reward.go index 25812c79..5839b72d 100644 --- a/x/reward/client/cli/tx_reward.go +++ b/x/reward/client/cli/tx_reward.go @@ -12,15 +12,16 @@ import ( func CmdGrantReward() *cobra.Command { cmd := &cobra.Command{ - Use: "apply [campaign uid] [ticket]", + Use: "apply [uid] [campaign uid] [ticket]", Short: "Apply a new reward", - Args: cobra.ExactArgs(2), + Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) (err error) { // Get indexes - argCampaignUID := args[0] + argUID := args[0] + argCampaignUID := args[1] // Get value arguments - argTicket := args[1] + argTicket := args[2] clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -29,6 +30,7 @@ func CmdGrantReward() *cobra.Command { msg := types.NewMsgGrantReward( clientCtx.GetFromAddress().String(), + argUID, argCampaignUID, argTicket, ) diff --git a/x/reward/keeper/distribution.go b/x/reward/keeper/distribution.go index dd26e059..6c3bbee2 100644 --- a/x/reward/keeper/distribution.go +++ b/x/reward/keeper/distribution.go @@ -9,12 +9,12 @@ import ( ) // DistributeRewards distributes the rewards according to the input distribution list. -func (k Keeper) DistributeRewards(ctx sdk.Context, receiver types.Receiver) error { +func (k Keeper) DistributeRewards(ctx sdk.Context, funderAddr string, receiver types.Receiver) error { if receiver.SubAccountAmount.GT(sdk.ZeroInt()) { - if _, err := k.subaccountKeeper.TopUp(ctx, types.RewardPoolFunder{}.GetModuleAcc(), receiver.SubAccountAddr, + if _, err := k.subaccountKeeper.TopUp(ctx, funderAddr, receiver.MainAccountAddr, []subaccounttypes.LockedBalance{ { - UnlockTS: receiver.UnlockTS, + UnlockTS: uint64(ctx.BlockTime().Unix()) + receiver.UnlockPeriod, Amount: receiver.SubAccountAmount, }, }); err != nil { diff --git a/x/reward/keeper/msg_server_campaign.go b/x/reward/keeper/msg_server_campaign.go index 5aca8c58..2e2a504d 100644 --- a/x/reward/keeper/msg_server_campaign.go +++ b/x/reward/keeper/msg_server_campaign.go @@ -40,7 +40,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.StartTs, payload.EndTs, payload.ClaimsPerCategory, payload.RewardType, payload.Category, payload.RewardAmountType, diff --git a/x/reward/keeper/msg_server_reward.go b/x/reward/keeper/msg_server_reward.go index 68ea71d6..0db79cc0 100644 --- a/x/reward/keeper/msg_server_reward.go +++ b/x/reward/keeper/msg_server_reward.go @@ -31,14 +31,6 @@ func (k msgServer) GrantReward(goCtx context.Context, msg *types.MsgGrantReward) return nil, sdkerrors.Wrap(sdkerrtypes.ErrInvalidRequest, "failed to retrieve reward factory") } - rewards, err := k.GetRewardsByAddressAndCategory(ctx, msg.Creator, campaign.RewardCategory) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrtypes.ErrInvalidRequest, "failed to retrieve rewards for user.") - } - if len(rewards) >= int(campaign.ClaimsPerCategory) { - return nil, sdkerrors.Wrap(sdkerrtypes.ErrInvalidRequest, "maximum rewards claimed for the given category.") - } - recevier, rewardCommon, err := rewardFactory.Calculate(goCtx, ctx, types.RewardFactoryKeepers{ OVMKeeper: k.ovmKeeper, @@ -49,11 +41,19 @@ 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, recevier.MainAccountAddr, campaign.RewardCategory) + if err != nil { + return nil, sdkerrors.Wrap(sdkerrtypes.ErrInvalidRequest, "failed to retrieve rewards for user.") + } + if len(rewards) >= int(campaign.ClaimsPerCategory) { + return nil, sdkerrors.Wrap(sdkerrtypes.ErrInvalidRequest, "maximum rewards claimed for the given category.") + } + if err := campaign.CheckPoolBalance(recevier.SubAccountAmount.Add(recevier.MainAccountAmount)); err != nil { return nil, types.ErrInsufficientPoolBalance } - if err := k.DistributeRewards(ctx, recevier); err != nil { + if err := k.DistributeRewards(ctx, campaign.Promoter, recevier); err != nil { return nil, sdkerrors.Wrapf(types.ErrInDistributionOfRewards, "%s", err) } @@ -64,7 +64,7 @@ func (k msgServer) GrantReward(goCtx context.Context, msg *types.MsgGrantReward) rewardCommon.SourceUID, "", )) - k.SetRewardByReceiver(ctx, types.NewRewardByType(msg.Uid, recevier.MainAccountAddr, campaign.RewardCategory)) + k.SetRewardByReceiver(ctx, types.NewRewardByCategory(msg.Uid, recevier.MainAccountAddr, campaign.RewardCategory)) k.SetRewardByCampaign(ctx, types.NewRewardByCampaign(msg.Uid, campaign.UID)) msg.EmitEvent(&ctx, msg.CampaignUid, recevier) diff --git a/x/reward/keeper/reward.go b/x/reward/keeper/reward.go index 5c115765..86b9e3f6 100644 --- a/x/reward/keeper/reward.go +++ b/x/reward/keeper/reward.go @@ -64,7 +64,7 @@ func (k Keeper) GetRewardsByAddressAndCategory( ctx sdk.Context, address string, category types.RewardCategory, -) (list []types.Reward, err error) { +) (list []types.RewardByCategory, err error) { store := k.getRewardByReceiverAndCategoryStore(ctx) iterator := sdk.KVStorePrefixIterator(store, types.GetRewardsByCategoryPrefix(address, category)) @@ -73,7 +73,7 @@ func (k Keeper) GetRewardsByAddressAndCategory( }() for ; iterator.Valid(); iterator.Next() { - var val types.Reward + var val types.RewardByCategory k.cdc.MustUnmarshal(iterator.Value(), &val) list = append(list, val) } diff --git a/x/reward/types/campaign.go b/x/reward/types/campaign.go index 39cfd286..83ca69d4 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 uint64, + startTS, endTS, claimsPerCategory uint64, rewardType RewardType, rewardCategory RewardCategory, rewardAmountType RewardAmountType, @@ -17,18 +17,19 @@ func NewCampaign( pool Pool, ) 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, + 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, } } diff --git a/x/reward/types/errors.go b/x/reward/types/errors.go index 65c71413..07fccbc3 100644 --- a/x/reward/types/errors.go +++ b/x/reward/types/errors.go @@ -18,7 +18,6 @@ var ( ErrUnknownRewardType = sdkerrors.Register(ModuleName, 7107, "unknown reward type") ErrInFundingCampaignPool = sdkerrors.Register(ModuleName, 7108, "error in funding the campaign pool") ErrWithdrawFromCampaignPool = sdkerrors.Register(ModuleName, 7109, "error in withdrawing from the campaign pool") - ErrUnknownAccType = sdkerrors.Register(ModuleName, 7109, "unknown account type") ErrCampaignEnded = sdkerrors.Register(ModuleName, 7110, "campaign validity period is ended") ErrInsufficientPoolBalance = sdkerrors.Register(ModuleName, 7111, "insufficient campaign pool balance") ErrInDistributionOfRewards = sdkerrors.Register(ModuleName, 7112, "reward distribution failed") @@ -32,5 +31,6 @@ var ( ErrInvalidNoLossBetUID = sdkerrors.Register(ModuleName, 7120, "invalid no loss bet uid") ErrWrongAmountForType = sdkerrors.Register(ModuleName, 7121, "wrong amount for account type") ErrSubAccountCreationFailed = sdkerrors.Register(ModuleName, 7122, "suba ccount creation failed") - ErrWrongRewardAmountType = sdkerrors.Register(ModuleName, 7114, "wrong reward amount type") + ErrWrongRewardAmountType = sdkerrors.Register(ModuleName, 7123, "wrong reward amount type") + ErrUnknownAccType = sdkerrors.Register(ModuleName, 7124, "unknown account type") ) diff --git a/x/reward/types/messages_reward.go b/x/reward/types/messages_reward.go index 17bc9224..9cdf4519 100644 --- a/x/reward/types/messages_reward.go +++ b/x/reward/types/messages_reward.go @@ -16,11 +16,13 @@ var _ sdk.Msg = &MsgGrantReward{} func NewMsgGrantReward( creator string, + uid string, campaignUID string, ticket string, ) *MsgGrantReward { return &MsgGrantReward{ Creator: creator, + Uid: uid, CampaignUid: campaignUID, Ticket: ticket, } diff --git a/x/reward/types/reward.go b/x/reward/types/reward.go index 591d4554..bbc81524 100644 --- a/x/reward/types/reward.go +++ b/x/reward/types/reward.go @@ -12,7 +12,7 @@ import ( type Receiver struct { SubAccountAddr string SubAccountAmount sdkmath.Int - UnlockTS uint64 + UnlockPeriod uint64 MainAccountAddr string MainAccountAmount sdkmath.Int } @@ -41,7 +41,7 @@ func NewReward( } } -func NewRewardByType(uid, addr string, rewardCategory RewardCategory) RewardByCategory { +func NewRewardByCategory(uid, addr string, rewardCategory RewardCategory) RewardByCategory { return RewardByCategory{ UID: uid, RewardCategory: rewardCategory, @@ -65,11 +65,11 @@ type IRewardFactory interface { } // NewReceiver creates reveiver object. -func NewReceiver(saAddr, maAddr string, saAmount, maAmount sdkmath.Int, unlockTS uint64) Receiver { +func NewReceiver(saAddr, maAddr string, saAmount, maAmount sdkmath.Int, unlockPeriod uint64) Receiver { return Receiver{ SubAccountAddr: saAddr, SubAccountAmount: saAmount, - UnlockTS: unlockTS, + UnlockPeriod: unlockPeriod, MainAccountAddr: maAddr, MainAccountAmount: maAmount, } From 261d595529b1f1d7b5a8f6937353650a67aebdaf Mon Sep 17 00:00:00 2001 From: 3eyedraga Date: Wed, 8 Nov 2023 17:28:01 +0530 Subject: [PATCH 06/12] go fumped --- x/reward/keeper/query_reward.go | 1 - x/reward/types/ticket.go | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/x/reward/keeper/query_reward.go b/x/reward/keeper/query_reward.go index 1274c5cb..74da9ff3 100644 --- a/x/reward/keeper/query_reward.go +++ b/x/reward/keeper/query_reward.go @@ -102,7 +102,6 @@ func (k Keeper) RewardsByAddressAndCategory(goCtx context.Context, req *types.Qu rewards = append(rewards, reward) return nil }) - if err != nil { return nil, status.Error(codes.Internal, err.Error()) } diff --git a/x/reward/types/ticket.go b/x/reward/types/ticket.go index 6543b5a2..ed51107c 100644 --- a/x/reward/types/ticket.go +++ b/x/reward/types/ticket.go @@ -46,7 +46,7 @@ func (payload *CreateCampaignPayload) Validate(blockTime uint64) error { } func (payload *CreateCampaignPayload) validateRewardCategory() error { - var err = errors.New("reward category is not compatible with reward type") + err := errors.New("reward category is not compatible with reward type") switch payload.Category { case RewardCategory_REWARD_CATEGORY_SIGNUP: if payload.RewardType != RewardType_REWARD_TYPE_SIGNUP && From cc7e978b9bf85978fb3138f1c02ff890f62aad1e Mon Sep 17 00:00:00 2001 From: P-U-D-G-E Date: Wed, 8 Nov 2023 19:06:27 +0530 Subject: [PATCH 07/12] lint --- x/reward/client/cli/query_reward.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/reward/client/cli/query_reward.go b/x/reward/client/cli/query_reward.go index 9ff55094..f698814e 100644 --- a/x/reward/client/cli/query_reward.go +++ b/x/reward/client/cli/query_reward.go @@ -122,7 +122,7 @@ func CmdGetRewardsByCampaign() *cobra.Command { queryClient := types.NewQueryClient(clientCtx) - argCampaignId := args[0] + argCampaignID := args[0] pageReq, err := client.ReadPageRequest(cmd.Flags()) if err != nil { @@ -130,7 +130,7 @@ func CmdGetRewardsByCampaign() *cobra.Command { } params := &types.QueryRewardsByCampaignRequest{ - CampaignUid: argCampaignId, + CampaignUid: argCampaignID, Pagination: pageReq, } From 2bb294520261b8a392af311acd289d7ebf141910 Mon Sep 17 00:00:00 2001 From: P-U-D-G-E Date: Wed, 8 Nov 2023 19:13:03 +0530 Subject: [PATCH 08/12] proto lint --- proto/sge/subaccount/tx.proto | 1 - 1 file changed, 1 deletion(-) diff --git a/proto/sge/subaccount/tx.proto b/proto/sge/subaccount/tx.proto index 2b38bcd8..e5d1cd1f 100644 --- a/proto/sge/subaccount/tx.proto +++ b/proto/sge/subaccount/tx.proto @@ -67,7 +67,6 @@ message MsgTopUpResponse {} // MsgWithdrawUnlockedBalances defines the Msg/WithdrawUnlockedBalances request // type. - message MsgWithdrawUnlockedBalances { // creator is the subaccount owner. string creator = 1; From 0a363863065b03d7ef8ce5cb9d9f697fbc245835 Mon Sep 17 00:00:00 2001 From: P-U-D-G-E Date: Wed, 8 Nov 2023 19:15:06 +0530 Subject: [PATCH 09/12] proto lint --- proto/sge/reward/tx.proto | 2 -- x/reward/types/tx.pb.go | 51 ++++++++++++++++++------------------- x/subaccount/types/tx.pb.go | 2 ++ 3 files changed, 27 insertions(+), 28 deletions(-) diff --git a/proto/sge/reward/tx.proto b/proto/sge/reward/tx.proto index 455483b1..8b862854 100644 --- a/proto/sge/reward/tx.proto +++ b/proto/sge/reward/tx.proto @@ -2,8 +2,6 @@ syntax = "proto3"; package sgenetwork.sge.reward; -import "gogoproto/gogo.proto"; - option go_package = "github.com/sge-network/sge/x/reward/types"; // Msg defines the Msg service. diff --git a/x/reward/types/tx.pb.go b/x/reward/types/tx.pb.go index abdf040a..c10ea609 100644 --- a/x/reward/types/tx.pb.go +++ b/x/reward/types/tx.pb.go @@ -6,7 +6,6 @@ package types import ( context "context" fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" grpc "google.golang.org/grpc" @@ -455,31 +454,31 @@ func init() { func init() { proto.RegisterFile("sge/reward/tx.proto", fileDescriptor_ad69e28332238e66) } var fileDescriptor_ad69e28332238e66 = []byte{ - // 383 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x94, 0xcf, 0x4a, 0xfb, 0x40, - 0x10, 0xc7, 0x9b, 0x5f, 0x7e, 0x54, 0x9c, 0x6a, 0xa9, 0x51, 0x4b, 0x8c, 0x10, 0xb4, 0x20, 0xd6, - 0x43, 0x13, 0xd1, 0x37, 0xb0, 0xa0, 0xa7, 0x5c, 0x0a, 0xb5, 0xe0, 0x45, 0xd2, 0x64, 0xd9, 0x86, - 0xda, 0x6c, 0xd8, 0xdd, 0x92, 0xfa, 0x16, 0xbe, 0x8a, 0x6f, 0xe1, 0xb1, 0x47, 0x8f, 0xd2, 0xbe, - 0x88, 0x6c, 0x9a, 0x84, 0x6e, 0xff, 0x51, 0x41, 0x6f, 0xb3, 0xb3, 0xdf, 0x7c, 0x3f, 0xc3, 0xcc, - 0x64, 0xe1, 0x90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 0x1d, 0x6b, 0x69, 0x90, 0xc6, 0xf5, - 0xb6, 0xca, 0x8c, 0x2a, 0x68, 0x0b, 0xf3, 0xde, 0x40, 0x93, 0x95, 0x9b, 0x68, 0xab, 0x47, 0xad, - 0x05, 0xb0, 0x2f, 0x37, 0xf5, 0x72, 0xbd, 0x85, 0x24, 0x34, 0xec, 0x2d, 0x85, 0x39, 0xca, 0x83, - 0xd2, 0xfc, 0x4a, 0x5d, 0xac, 0xff, 0x7e, 0x4e, 0x66, 0x34, 0xb6, 0x92, 0x65, 0x90, 0xbb, 0xe6, - 0xc7, 0xc4, 0x54, 0xc6, 0x13, 0x53, 0xf9, 0x9a, 0x98, 0xca, 0xdb, 0xd4, 0x2c, 0x8c, 0xa7, 0x66, - 0xe1, 0x73, 0x6a, 0x16, 0x9e, 0xae, 0x70, 0xc0, 0x7b, 0xc3, 0xae, 0xe5, 0x91, 0x81, 0xcd, 0x30, - 0x6a, 0xa4, 0x9e, 0x22, 0xb6, 0x47, 0xf9, 0xdb, 0xf0, 0x1a, 0x21, 0xd6, 0x2d, 0x26, 0xbf, 0xfc, - 0xed, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x2f, 0x26, 0xd9, 0xc2, 0x36, 0x04, 0x00, 0x00, + // 371 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x94, 0x4f, 0x4a, 0xc3, 0x40, + 0x14, 0xc6, 0x1b, 0x23, 0x15, 0x5f, 0xb5, 0xd4, 0x88, 0x25, 0x46, 0x08, 0x5a, 0x10, 0xeb, 0xa2, + 0x89, 0xe8, 0x0d, 0x2c, 0xe8, 0x2a, 0x9b, 0x42, 0x2d, 0xb8, 0x91, 0x34, 0x19, 0xa6, 0xa1, 0x36, + 0x09, 0xf3, 0xa6, 0xa4, 0xde, 0xc2, 0xab, 0x78, 0x0b, 0x97, 0x5d, 0xba, 0x94, 0xf6, 0x22, 0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a9, 0xf2, 0x0a, 0xe5, 0x85, 0xdc, 0xeb, 0xc6, 0xca, 0x47, 0x62, + 0x2c, 0x05, 0xa9, 0xdd, 0x6c, 0xab, 0xcc, 0xa8, 0x31, 0x6d, 0x21, 0xef, 0x0d, 0x34, 0x51, 0xb9, + 0x89, 0xb6, 0x3a, 0x6a, 0xc5, 0x83, 0x43, 0xf1, 0x52, 0xaf, 0xd6, 0x5b, 0x08, 0x42, 0xcd, 0xdc, + 0x52, 0x98, 0xa3, 0x1c, 0x28, 0xcd, 0x3f, 0xa9, 0xcb, 0xf5, 0xdf, 0xcf, 0xc9, 0xb4, 0xc6, 0x56, + 0xb2, 0x0c, 0x72, 0xdf, 0xfc, 0x9c, 0xe8, 0xd2, 0x78, 0xa2, 0x4b, 0xdf, 0x13, 0x5d, 0x7a, 0x9f, + 0xea, 0x85, 0xf1, 0x54, 0x2f, 0x7c, 0x4d, 0xf5, 0xc2, 0xf3, 0x35, 0xf5, 0x78, 0x6f, 0xd8, 0x35, + 0x9c, 0x60, 0x60, 0x22, 0x25, 0x8d, 0xd4, 0x33, 0x5e, 0x9b, 0xa3, 0x7c, 0x0a, 0xbc, 0x85, 0x04, + 0xbb, 0xc5, 0x64, 0x12, 0xdc, 0xfd, 0x04, 0x00, 0x00, 0xff, 0xff, 0xaf, 0xa3, 0xf4, 0xb3, 0x20, + 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/subaccount/types/tx.pb.go b/x/subaccount/types/tx.pb.go index 075ba666..6973418d 100644 --- a/x/subaccount/types/tx.pb.go +++ b/x/subaccount/types/tx.pb.go @@ -235,6 +235,8 @@ func (m *MsgTopUpResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgTopUpResponse proto.InternalMessageInfo +// MsgWithdrawUnlockedBalances defines the Msg/WithdrawUnlockedBalances request +// type. type MsgWithdrawUnlockedBalances struct { // creator is the subaccount owner. Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` From 2f09ca8ff1abfb7d318df08c7fe5de8dd6061e03 Mon Sep 17 00:00:00 2001 From: P-U-D-G-E Date: Wed, 8 Nov 2023 19:18:26 +0530 Subject: [PATCH 10/12] proto lint --- proto/sge/reward/ticket.proto | 1 + x/reward/types/ticket.pb.go | 1 + 2 files changed, 2 insertions(+) diff --git a/proto/sge/reward/ticket.proto b/proto/sge/reward/ticket.proto index 9a34d3b3..267b0be4 100644 --- a/proto/sge/reward/ticket.proto +++ b/proto/sge/reward/ticket.proto @@ -69,6 +69,7 @@ message WithdrawFundsPayload { string promoter = 1; } +// RewardPayloadCommon message RewardPayloadCommon { // receiver is the address of the account that receives the reward. string receiver = 1; diff --git a/x/reward/types/ticket.pb.go b/x/reward/types/ticket.pb.go index 891012fa..780d1f01 100644 --- a/x/reward/types/ticket.pb.go +++ b/x/reward/types/ticket.pb.go @@ -266,6 +266,7 @@ func (m *WithdrawFundsPayload) GetPromoter() string { return "" } +// RewardPayloadCommon type RewardPayloadCommon struct { // receiver is the address of the account that receives the reward. Receiver string `protobuf:"bytes,1,opt,name=receiver,proto3" json:"receiver,omitempty"` From 9148d694c72976b4988411fd55f6268fbc848bef Mon Sep 17 00:00:00 2001 From: P-U-D-G-E Date: Wed, 8 Nov 2023 19:21:09 +0530 Subject: [PATCH 11/12] proto lint --- proto/sge/reward/reward.proto | 3 +++ proto/sge/reward/ticket.proto | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/proto/sge/reward/reward.proto b/proto/sge/reward/reward.proto index 6b4d0140..8d1bf53f 100644 --- a/proto/sge/reward/reward.proto +++ b/proto/sge/reward/reward.proto @@ -51,6 +51,7 @@ message Reward { string meta = 12; } +// RewardAmount message RewardAmount { // main account reward amount string main_account_amount = 1 [ @@ -74,6 +75,7 @@ message RewardAmount { ]; } +// RewardByCategory message RewardByCategory { string uid = 1 [ (gogoproto.customname) = "UID", @@ -84,6 +86,7 @@ message RewardByCategory { RewardCategory reward_category = 3; } +// RewardByCampaign message RewardByCampaign { string uid = 1 [ (gogoproto.customname) = "UID", diff --git a/proto/sge/reward/ticket.proto b/proto/sge/reward/ticket.proto index 267b0be4..7ff49717 100644 --- a/proto/sge/reward/ticket.proto +++ b/proto/sge/reward/ticket.proto @@ -3,7 +3,6 @@ package sgenetwork.sge.reward; import "gogoproto/gogo.proto"; import "sge/reward/reward.proto"; -import "sge/reward/campaign.proto"; option go_package = "github.com/sge-network/sge/x/reward/types"; From f4af8f4c2b816fa2400ef7743fbfa84e69459d60 Mon Sep 17 00:00:00 2001 From: P-U-D-G-E Date: Thu, 9 Nov 2023 12:38:38 +0530 Subject: [PATCH 12/12] fixes queries --- proto/sge/reward/query.proto | 6 +- x/reward/client/cli/query_reward.go | 2 +- x/reward/keeper/query_reward.go | 12 +-- x/reward/types/query.pb.go | 126 ++++++++++++++-------------- x/reward/types/reward.pb.go | 3 + x/reward/types/ticket.pb.go | 78 ++++++++--------- 6 files changed, 115 insertions(+), 112 deletions(-) diff --git a/proto/sge/reward/query.proto b/proto/sge/reward/query.proto index 2cf85b95..0759b557 100644 --- a/proto/sge/reward/query.proto +++ b/proto/sge/reward/query.proto @@ -119,7 +119,7 @@ message QueryRewardsByAddressRequest { // QueryRewardsByAddressResponse is response body of the query all rewards by // address endpoint. message QueryRewardsByAddressResponse { - repeated Reward rewards = 1 [ (gogoproto.nullable) = false ]; + repeated RewardByCategory rewards = 1 [ (gogoproto.nullable) = false ]; cosmos.base.query.v1beta1.PageResponse pagination = 2; } @@ -134,7 +134,7 @@ message QueryRewardsByAddressAndCategoryRequest { // QueryRewardsByAddressAndTypeResponse is response body of the query all // rewards by address and type endpoint. message QueryRewardsByAddressAndCategoryResponse { - repeated Reward rewards = 1 [ (gogoproto.nullable) = false ]; + repeated RewardByCategory rewards = 1 [ (gogoproto.nullable) = false ]; cosmos.base.query.v1beta1.PageResponse pagination = 2; } @@ -148,6 +148,6 @@ message QueryRewardsByCampaignRequest { // QueryRewardsByCampaignResponse is response body of the query all rewards by // campaign endpoint. message QueryRewardsByCampaignResponse { - repeated Reward rewards = 1 [ (gogoproto.nullable) = false ]; + repeated RewardByCampaign rewards = 1 [ (gogoproto.nullable) = false ]; cosmos.base.query.v1beta1.PageResponse pagination = 2; } diff --git a/x/reward/client/cli/query_reward.go b/x/reward/client/cli/query_reward.go index f698814e..b2a7cc27 100644 --- a/x/reward/client/cli/query_reward.go +++ b/x/reward/client/cli/query_reward.go @@ -152,7 +152,7 @@ func CmdGetRewardByUserAndCategory() *cobra.Command { cmd := &cobra.Command{ Use: "rewards-by-user-category [address] [category]", Short: "shows a list of rewards by user and category", - Args: cobra.ExactArgs(1), + Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) (err error) { clientCtx := client.GetClientContextFromCmd(cmd) diff --git a/x/reward/keeper/query_reward.go b/x/reward/keeper/query_reward.go index 74da9ff3..c1d2545e 100644 --- a/x/reward/keeper/query_reward.go +++ b/x/reward/keeper/query_reward.go @@ -60,14 +60,14 @@ func (k Keeper) RewardsByAddress(goCtx context.Context, req *types.QueryRewardsB return nil, status.Error(codes.InvalidArgument, "invalid request") } - var rewards []types.Reward + var rewards []types.RewardByCategory ctx := sdk.UnwrapSDKContext(goCtx) store := k.getRewardByReceiverAndCategoryStore(ctx) rewardStore := prefix.NewStore(store, types.GetRewardsByAccPrefix(req.Address)) pageRes, err := query.Paginate(rewardStore, req.Pagination, func(key []byte, value []byte) error { - var reward types.Reward + var reward types.RewardByCategory if err := k.cdc.Unmarshal(value, &reward); err != nil { return err } @@ -87,14 +87,14 @@ func (k Keeper) RewardsByAddressAndCategory(goCtx context.Context, req *types.Qu return nil, status.Error(codes.InvalidArgument, "invalid request") } - var rewards []types.Reward + var rewards []types.RewardByCategory ctx := sdk.UnwrapSDKContext(goCtx) store := k.getRewardByReceiverAndCategoryStore(ctx) rewardStore := prefix.NewStore(store, types.GetRewardsByCategoryPrefix(req.Address, req.Category)) pageRes, err := query.Paginate(rewardStore, req.Pagination, func(key []byte, value []byte) error { - var reward types.Reward + var reward types.RewardByCategory if err := k.cdc.Unmarshal(value, &reward); err != nil { return err } @@ -114,14 +114,14 @@ func (k Keeper) RewardsByCampaign(goCtx context.Context, req *types.QueryRewards return nil, status.Error(codes.InvalidArgument, "invalid request") } - var rewards []types.Reward + var rewards []types.RewardByCampaign ctx := sdk.UnwrapSDKContext(goCtx) store := k.getRewardsByCampaignStore(ctx) rewardStore := prefix.NewStore(store, types.GetRewardsByCampaignPrefix(req.CampaignUid)) pageRes, err := query.Paginate(rewardStore, req.Pagination, func(key []byte, value []byte) error { - var reward types.Reward + var reward types.RewardByCampaign if err := k.cdc.Unmarshal(value, &reward); err != nil { return err } diff --git a/x/reward/types/query.pb.go b/x/reward/types/query.pb.go index 021daf3c..2f3fbd6a 100644 --- a/x/reward/types/query.pb.go +++ b/x/reward/types/query.pb.go @@ -547,7 +547,7 @@ func (m *QueryRewardsByAddressRequest) GetAddress() string { // QueryRewardsByAddressResponse is response body of the query all rewards by // address endpoint. type QueryRewardsByAddressResponse struct { - Rewards []Reward `protobuf:"bytes,1,rep,name=rewards,proto3" json:"rewards"` + Rewards []RewardByCategory `protobuf:"bytes,1,rep,name=rewards,proto3" json:"rewards"` Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } @@ -584,7 +584,7 @@ func (m *QueryRewardsByAddressResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryRewardsByAddressResponse proto.InternalMessageInfo -func (m *QueryRewardsByAddressResponse) GetRewards() []Reward { +func (m *QueryRewardsByAddressResponse) GetRewards() []RewardByCategory { if m != nil { return m.Rewards } @@ -665,7 +665,7 @@ func (m *QueryRewardsByAddressAndCategoryRequest) GetCategory() RewardCategory { // QueryRewardsByAddressAndTypeResponse is response body of the query all // rewards by address and type endpoint. type QueryRewardsByAddressAndCategoryResponse struct { - Rewards []Reward `protobuf:"bytes,1,rep,name=rewards,proto3" json:"rewards"` + Rewards []RewardByCategory `protobuf:"bytes,1,rep,name=rewards,proto3" json:"rewards"` Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } @@ -704,7 +704,7 @@ func (m *QueryRewardsByAddressAndCategoryResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryRewardsByAddressAndCategoryResponse proto.InternalMessageInfo -func (m *QueryRewardsByAddressAndCategoryResponse) GetRewards() []Reward { +func (m *QueryRewardsByAddressAndCategoryResponse) GetRewards() []RewardByCategory { if m != nil { return m.Rewards } @@ -775,7 +775,7 @@ func (m *QueryRewardsByCampaignRequest) GetCampaignUid() string { // QueryRewardsByCampaignResponse is response body of the query all rewards by // campaign endpoint. type QueryRewardsByCampaignResponse struct { - Rewards []Reward `protobuf:"bytes,1,rep,name=rewards,proto3" json:"rewards"` + Rewards []RewardByCampaign `protobuf:"bytes,1,rep,name=rewards,proto3" json:"rewards"` Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } @@ -812,7 +812,7 @@ func (m *QueryRewardsByCampaignResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryRewardsByCampaignResponse proto.InternalMessageInfo -func (m *QueryRewardsByCampaignResponse) GetRewards() []Reward { +func (m *QueryRewardsByCampaignResponse) GetRewards() []RewardByCampaign { if m != nil { return m.Rewards } @@ -848,60 +848,60 @@ func init() { func init() { proto.RegisterFile("sge/reward/query.proto", fileDescriptor_324afa5f2186a8c0) } var fileDescriptor_324afa5f2186a8c0 = []byte{ - // 836 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x97, 0x4d, 0x4f, 0x13, 0x6b, - 0x14, 0xc7, 0xfb, 0xc0, 0xbd, 0x05, 0x0e, 0x37, 0x37, 0xdc, 0x73, 0x01, 0xb1, 0xc2, 0x00, 0xa3, - 0x96, 0x96, 0x97, 0x99, 0xf0, 0xa2, 0xc6, 0xf8, 0x42, 0x80, 0x44,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, 0x4b, 0xcb, 0x2b, 0x7b, 0x07, 0x1a, 0xd9, 0x3f, 0xd0, 0xc8, 0xcf, - 0x03, 0x8d, 0xbc, 0x3a, 0xd4, 0x22, 0xfb, 0x87, 0x5a, 0xe4, 0xdb, 0xa1, 0x16, 0x59, 0x4b, 0xda, - 0x8e, 0x77, 0xbf, 0x98, 0x36, 0x36, 0xdc, 0x6c, 0x5d, 0xf0, 0xc7, 0x2a, 0xbc, 0xb7, 0x9d, 0xa7, - 0x2c, 0x1d, 0xe5, 0x3f, 0x70, 0xe6, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, 0xe5, 0x11, 0x1e, 0xd2, - 0xbe, 0x0d, 0x00, 0x00, + // 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, 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0xf1, 0x31, 0x8b, + 0xa4, 0x43, 0x9d, 0x63, 0x28, 0x7e, 0x7a, 0xf6, 0x72, 0x53, 0x81, 0xca, 0x84, 0x65, 0x37, 0xfd, + 0x33, 0xc2, 0xf1, 0xd6, 0x05, 0xfd, 0xb7, 0xfd, 0x78, 0x51, 0x73, 0x86, 0xfc, 0xa3, 0xbd, 0x5d, + 0x5d, 0x18, 0xc7, 0xa7, 0xd4, 0x04, 0x5c, 0x2f, 0xcd, 0x27, 0xd1, 0x8a, 0x5e, 0xf5, 0xec, 0x9e, + 0x93, 0xd6, 0x3f, 0x22, 0xac, 0x35, 0x82, 0x39, 0xbe, 0x82, 0x55, 0x53, 0xb8, 0xed, 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, 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0x0d, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -3193,7 +3193,7 @@ func (m *QueryRewardsByAddressResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Rewards = append(m.Rewards, Reward{}) + m.Rewards = append(m.Rewards, RewardByCategory{}) if err := m.Rewards[len(m.Rewards)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -3450,7 +3450,7 @@ func (m *QueryRewardsByAddressAndCategoryResponse) Unmarshal(dAtA []byte) error if postIndex > l { return io.ErrUnexpectedEOF } - m.Rewards = append(m.Rewards, Reward{}) + m.Rewards = append(m.Rewards, RewardByCategory{}) if err := m.Rewards[len(m.Rewards)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -3688,7 +3688,7 @@ func (m *QueryRewardsByCampaignResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Rewards = append(m.Rewards, Reward{}) + m.Rewards = append(m.Rewards, RewardByCampaign{}) if err := m.Rewards[len(m.Rewards)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/reward/types/reward.pb.go b/x/reward/types/reward.pb.go index 7869bf36..9b23e875 100644 --- a/x/reward/types/reward.pb.go +++ b/x/reward/types/reward.pb.go @@ -277,6 +277,7 @@ func (m *Reward) GetMeta() string { return "" } +// RewardAmount type RewardAmount struct { // main account reward amount MainAccountAmount cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=main_account_amount,json=mainAccountAmount,proto3,customtype=cosmossdk.io/math.Int" json:"main_account_amount" yaml:"main_account_amount"` @@ -326,6 +327,7 @@ func (m *RewardAmount) GetUnlockPeriod() uint64 { return 0 } +// RewardByCategory type RewardByCategory struct { UID string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid"` Addr string `protobuf:"bytes,2,opt,name=addr,proto3" json:"addr,omitempty"` @@ -386,6 +388,7 @@ func (m *RewardByCategory) GetRewardCategory() RewardCategory { return RewardCategory_REWARD_CATEGORY_UNSPECIFIED } +// RewardByCampaign type RewardByCampaign struct { UID string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid"` CampaignUID string `protobuf:"bytes,2,opt,name=campaign_uid,proto3" json:"campaign_uid"` diff --git a/x/reward/types/ticket.pb.go b/x/reward/types/ticket.pb.go index 780d1f01..c0353022 100644 --- a/x/reward/types/ticket.pb.go +++ b/x/reward/types/ticket.pb.go @@ -391,45 +391,45 @@ func init() { func init() { proto.RegisterFile("sge/reward/ticket.proto", fileDescriptor_5d710bc1249ca8ae) } var fileDescriptor_5d710bc1249ca8ae = []byte{ - // 606 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xc1, 0x6e, 0xd3, 0x40, - 0x10, 0x8d, 0xdb, 0x34, 0x75, 0x26, 0x80, 0x60, 0xdb, 0x08, 0xb7, 0x95, 0x9c, 0x60, 0x84, 0x08, - 0x48, 0xd8, 0x52, 0x7a, 0x83, 0x53, 0x13, 0x04, 0xed, 0xad, 0x72, 0x53, 0x21, 0x71, 0xb1, 0xb6, - 0xf6, 0xe2, 0xae, 0x1a, 0x7b, 0xad, 0xdd, 0x75, 0x8b, 0xaf, 0x7c, 0x01, 0x1f, 0xc5, 0xa1, 0xc7, - 0x1e, 0x11, 0x87, 0x08, 0xa5, 0x37, 0x8e, 0x7c, 0x01, 0xf2, 0xda, 0x75, 0x1d, 0x54, 0x45, 0x3d, - 0x79, 0x66, 0xdf, 0x9b, 0xe7, 0x99, 0xd9, 0xa7, 0x85, 0xa7, 0x22, 0x24, 0x0e, 0x27, 0x17, 0x98, - 0x07, 0x8e, 0xa4, 0xfe, 0x19, 0x91, 0x76, 0xc2, 0x99, 0x64, 0xa8, 0x2b, 0x42, 0x12, 0x13, 0x79, - 0xc1, 0xf8, 0x99, 0x2d, 0x42, 0x62, 0x17, 0x9c, 0xed, 0xcd, 0x90, 0x85, 0x4c, 0x31, 0x9c, 0x3c, - 0x2a, 0xc8, 0xdb, 0x75, 0x95, 0xe2, 0x53, 0x02, 0x5b, 0x35, 0xc0, 0xc7, 0x51, 0x82, 0x69, 0x18, - 0x17, 0x90, 0xf5, 0xa3, 0x09, 0xdd, 0x31, 0x27, 0x58, 0x92, 0x71, 0x09, 0x1c, 0xe2, 0x6c, 0xca, - 0x70, 0x80, 0xb6, 0x41, 0x4f, 0x38, 0x8b, 0x98, 0x24, 0xdc, 0xd0, 0xfa, 0xda, 0xa0, 0xed, 0x56, - 0x39, 0xda, 0x02, 0x5d, 0x48, 0xcc, 0xa5, 0x27, 0x85, 0xb1, 0xd2, 0xd7, 0x06, 0x4d, 0x77, 0x5d, - 0xe5, 0x13, 0x81, 0xba, 0xd0, 0x22, 0x71, 0x90, 0x03, 0xab, 0x0a, 0x58, 0x23, 0x71, 0x30, 0x11, - 0x68, 0x0f, 0x74, 0x1f, 0x4b, 0x12, 0x32, 0x9e, 0x19, 0xcd, 0xbe, 0x36, 0x78, 0x34, 0x7c, 0x61, - 0xdf, 0x39, 0x9b, 0xed, 0xaa, 0xcf, 0xb8, 0x24, 0xbb, 0x55, 0x19, 0x1a, 0x41, 0xa7, 0xa0, 0x78, - 0x32, 0x4b, 0x88, 0xb1, 0xa6, 0x54, 0x9e, 0x2d, 0x55, 0x99, 0x64, 0x09, 0x71, 0x81, 0x57, 0x31, - 0x3a, 0x06, 0x54, 0x6a, 0xe0, 0x88, 0xa5, 0xb1, 0x2c, 0xa4, 0x5a, 0x4a, 0xea, 0xe5, 0x52, 0xa9, - 0x3d, 0xc5, 0x57, 0x82, 0x8f, 0xf9, 0x7f, 0x27, 0x68, 0x1f, 0x1e, 0x2e, 0xc8, 0x1a, 0xeb, 0x7d, - 0x6d, 0xd0, 0x19, 0x3e, 0xbf, 0x87, 0xa2, 0xfb, 0xa0, 0xae, 0x86, 0x26, 0xd0, 0x91, 0x4c, 0xe2, - 0xa9, 0xf7, 0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x3a, 0x3d, 0x3e, 0x78, 0xff, 0x67, 0xd6, 0xab, - 0x51, 0xdc, 0x5a, 0x5c, 0xed, 0x66, 0xb5, 0xb6, 0x9b, 0x00, 0x8c, 0x8f, 0x1c, 0xc7, 0xf2, 0x88, - 0x86, 0x71, 0x9a, 0x2c, 0xb4, 0x83, 0xf6, 0xa1, 0xe5, 0xab, 0x96, 0xd4, 0x8f, 0x3a, 0xc3, 0xd7, - 0x4b, 0x1d, 0xb3, 0x30, 0xc4, 0xa8, 0x99, 0xbb, 0xc2, 0x2d, 0xeb, 0x47, 0xe3, 0xcb, 0xb9, 0xa9, - 0x5d, 0xcd, 0x4d, 0xed, 0xf7, 0xdc, 0xd4, 0xbe, 0x5f, 0x9b, 0x8d, 0xab, 0x6b, 0xb3, 0xf1, 0xf3, - 0xda, 0x6c, 0x7c, 0x7e, 0x15, 0x52, 0x79, 0x9a, 0x9e, 0xd8, 0x3e, 0x8b, 0x1c, 0x11, 0x92, 0x37, - 0xa5, 0x7c, 0x1e, 0x3b, 0x5f, 0xab, 0x57, 0x27, 0x4b, 0x88, 0x38, 0x69, 0xa9, 0x47, 0x61, 0xf7, - 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa2, 0x8d, 0x3a, 0x27, 0x90, 0x04, 0x00, 0x00, + // 600 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0x41, 0x6f, 0xd3, 0x4c, + 0x10, 0x8d, 0xdb, 0x34, 0x75, 0x26, 0xdf, 0x87, 0x60, 0xdb, 0x08, 0xd3, 0x4a, 0x4e, 0x30, 0x42, + 0x04, 0x24, 0x6c, 0x29, 0xbd, 0xc1, 0xa9, 0x09, 0x82, 0xf6, 0x56, 0xb9, 0xa9, 0x90, 0xb8, 0x58, + 0x5b, 0x7b, 0x71, 0x57, 0x89, 0xbd, 0xd6, 0xee, 0xba, 0xc1, 0x57, 0x7e, 0x01, 0x3f, 0x8a, 0x43, + 0x8f, 0x3d, 0x22, 0x0e, 0x11, 0x4a, 0x6e, 0x1c, 0xf9, 0x05, 0xc8, 0xeb, 0xd4, 0x75, 0x50, 0x15, + 0xf5, 0xe4, 0x79, 0x3b, 0x6f, 0x9e, 0x67, 0x66, 0x9f, 0x16, 0x1e, 0x8b, 0x90, 0x38, 0x9c, 0x4c, + 0x31, 0x0f, 0x1c, 0x49, 0xfd, 0x31, 0x91, 0x76, 0xc2, 0x99, 0x64, 0xa8, 0x2d, 0x42, 0x12, 0x13, + 0x39, 0x65, 0x7c, 0x6c, 0x8b, 0x90, 0xd8, 0x05, 0x67, 0x6f, 0x37, 0x64, 0x21, 0x53, 0x0c, 0x27, + 0x8f, 0x0a, 0xf2, 0x5e, 0x55, 0xa5, 0xf8, 0x14, 0x09, 0xeb, 0x7b, 0x1d, 0xda, 0x43, 0x4e, 0xb0, + 0x24, 0x43, 0x1c, 0x25, 0x98, 0x86, 0xf1, 0x09, 0xce, 0x26, 0x0c, 0x07, 0x68, 0x0f, 0xf4, 0x84, + 0xb3, 0x88, 0x49, 0xc2, 0x0d, 0xad, 0xab, 0xf5, 0x9a, 0x6e, 0x89, 0xd1, 0x13, 0xd0, 0x85, 0xc4, + 0x5c, 0x7a, 0x52, 0x18, 0x1b, 0x5d, 0xad, 0x57, 0x77, 0xb7, 0x15, 0x1e, 0x09, 0xd4, 0x86, 0x06, + 0x89, 0x83, 0x3c, 0xb1, 0xa9, 0x12, 0x5b, 0x24, 0x0e, 0x46, 0x02, 0x1d, 0x82, 0xee, 0x63, 0x49, + 0x42, 0xc6, 0x33, 0xa3, 0xde, 0xd5, 0x7a, 0x0f, 0xfa, 0xcf, 0xed, 0x3b, 0x07, 0xb0, 0x5d, 0xf5, + 0x19, 0x2e, 0xc9, 0x6e, 0x59, 0x86, 0x06, 0xd0, 0x2a, 0x28, 0x9e, 0xcc, 0x12, 0x62, 0x6c, 0x29, + 0x95, 0xa7, 0x6b, 0x55, 0x46, 0x59, 0x42, 0x5c, 0xe0, 0x65, 0x8c, 0xce, 0x00, 0x2d, 0x35, 0x70, + 0xc4, 0xd2, 0x58, 0x16, 0x52, 0x0d, 0x25, 0xf5, 0x62, 0xad, 0xd4, 0xa1, 0xe2, 0x2b, 0xc1, 0x87, + 0xfc, 0x9f, 0x13, 0x74, 0x04, 0xff, 0xaf, 0xc8, 0x1a, 0xdb, 0x5d, 0xad, 0xd7, 0xea, 0x3f, 0xbb, + 0x87, 0xa2, 0xfb, 0x5f, 0x55, 0x0d, 0x8d, 0xa0, 0x25, 0x99, 0xc4, 0x13, 0xef, 0x73, 0x1a, 0x07, + 0xc2, 0xd0, 0xf3, 0xc5, 0x0f, 0x0e, 0xae, 0x66, 0x9d, 0xda, 0xcf, 0x59, 0xa7, 0xed, 0x33, 0x11, + 0x31, 0x21, 0x82, 0xb1, 0x4d, 0x99, 0x13, 0x61, 0x79, 0x61, 0x1f, 0xc7, 0xf2, 0xcf, 0xac, 0x83, + 0x32, 0x1c, 0x4d, 0xde, 0x58, 0x95, 0x4a, 0xcb, 0x05, 0x85, 0xde, 0xe7, 0x00, 0xed, 0x43, 0x93, + 0x0a, 0x0f, 0xfb, 0x92, 0x5e, 0x12, 0xa3, 0xd9, 0xd5, 0x7a, 0xba, 0xab, 0x53, 0x71, 0xa8, 0x30, + 0xb2, 0x61, 0xc7, 0x9f, 0x60, 0x1a, 0x09, 0x2f, 0x21, 0xdc, 0x2b, 0x6f, 0x09, 0xd4, 0xf5, 0x3d, + 0x2a, 0x52, 0x27, 0x84, 0xdf, 0xdc, 0x08, 0x42, 0x50, 0x8f, 0x88, 0xc4, 0x46, 0x4b, 0x99, 0x42, + 0xc5, 0x16, 0x86, 0xf6, 0x59, 0x12, 0xdc, 0xe1, 0xa2, 0x5b, 0x3b, 0x68, 0x55, 0x3b, 0xec, 0xc2, + 0x56, 0x31, 0xe0, 0x86, 0x12, 0x29, 0xc0, 0x6a, 0x9b, 0x9b, 0xab, 0x6d, 0x5a, 0x7d, 0xd8, 0xfd, + 0x48, 0xe5, 0x45, 0xc0, 0xf1, 0x54, 0x0d, 0x75, 0x0f, 0x9f, 0x5a, 0x5f, 0x35, 0xd8, 0x29, 0x96, + 0xbd, 0x64, 0x0f, 0x59, 0x14, 0xb1, 0x38, 0xaf, 0xe1, 0xc4, 0x27, 0xf4, 0xf2, 0xb6, 0xe6, 0x06, + 0xa3, 0xb7, 0x00, 0x82, 0xa5, 0xdc, 0x27, 0x5e, 0x4a, 0x83, 0xa2, 0xbf, 0xc1, 0xfe, 0x7c, 0xd6, + 0x69, 0x9e, 0xaa, 0xd3, 0xb3, 0xe3, 0x77, 0xbf, 0x67, 0x9d, 0x0a, 0xc5, 0xad, 0xc4, 0xe5, 0x6e, + 0x36, 0x2b, 0xbb, 0x09, 0xc0, 0xf8, 0xc0, 0x71, 0x2c, 0x4f, 0x69, 0x18, 0xa7, 0xc9, 0x4a, 0x3b, + 0xe8, 0x08, 0x1a, 0xbe, 0x6a, 0x49, 0xfd, 0xa8, 0xd5, 0x7f, 0xb5, 0xd6, 0x31, 0x2b, 0x43, 0x0c, + 0xea, 0xb9, 0x2b, 0xdc, 0x65, 0xfd, 0x60, 0x78, 0x35, 0x37, 0xb5, 0xeb, 0xb9, 0xa9, 0xfd, 0x9a, + 0x9b, 0xda, 0xb7, 0x85, 0x59, 0xbb, 0x5e, 0x98, 0xb5, 0x1f, 0x0b, 0xb3, 0xf6, 0xe9, 0x65, 0x48, + 0xe5, 0x45, 0x7a, 0x6e, 0xfb, 0x2c, 0x72, 0x44, 0x48, 0x5e, 0x2f, 0xe5, 0xf3, 0xd8, 0xf9, 0x52, + 0x3e, 0x2d, 0x59, 0x42, 0xc4, 0x79, 0x43, 0x3d, 0x0a, 0x07, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, + 0xf0, 0x5e, 0x08, 0x88, 0x75, 0x04, 0x00, 0x00, } func (m *CreateCampaignPayload) Marshal() (dAtA []byte, err error) {