diff --git a/app/app.go b/app/app.go index c6b50680..cadf7eb3 100644 --- a/app/app.go +++ b/app/app.go @@ -45,6 +45,7 @@ import ( v5 "github.com/sge-network/sge/app/upgrades/v5" v6 "github.com/sge-network/sge/app/upgrades/v6" v7 "github.com/sge-network/sge/app/upgrades/v7" + v8 "github.com/sge-network/sge/app/upgrades/v8" abci "github.com/tendermint/tendermint/abci/types" tmjson "github.com/tendermint/tendermint/libs/json" @@ -82,6 +83,7 @@ var ( v5.Upgrade, v6.Upgrade, v7.Upgrade, + v8.Upgrade, } ) diff --git a/app/upgrades/v8/consts.go b/app/upgrades/v8/consts.go new file mode 100644 index 00000000..585c935f --- /dev/null +++ b/app/upgrades/v8/consts.go @@ -0,0 +1,19 @@ +package v8 + +import ( + store "github.com/cosmos/cosmos-sdk/store/types" + + "github.com/sge-network/sge/app/upgrades" +) + +// UpgradeName defines the on-chain upgrade name for the v1.6.0 upgrade. +const UpgradeName = "v1.6.0" + +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: CreateUpgradeHandler, + StoreUpgrades: store.StoreUpgrades{ + Added: []string{}, + Deleted: []string{}, + }, +} diff --git a/app/upgrades/v8/upgrades.go b/app/upgrades/v8/upgrades.go new file mode 100644 index 00000000..943a9e40 --- /dev/null +++ b/app/upgrades/v8/upgrades.go @@ -0,0 +1,56 @@ +package v8 + +import ( + sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + "github.com/google/uuid" + "github.com/sge-network/sge/app/keepers" + "github.com/sge-network/sge/x/reward/types" +) + +func CreateUpgradeHandler( + mm *module.Manager, + configurator module.Configurator, + k *keepers.AppKeepers, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + allCampaigns := k.RewardKeeper.GetAllCampaign(ctx) + promoters := make(map[string]struct{}) + for _, c := range allCampaigns { + c.CapCount = 0 // infinite cap for all campaigns + c.Pool.Withdrawn = sdkmath.ZeroInt() + k.RewardKeeper.SetCampaign(ctx, c) + promoters[c.Promoter] = struct{}{} + } + + promoterAddresses := []string{} + for addr := range promoters { + promoterAddresses = append(promoterAddresses, addr) + } + + if len(promoterAddresses) > 0 { + promoterUID := uuid.NewString() + k.RewardKeeper.SetPromoter(ctx, types.Promoter{ + Creator: promoterAddresses[0], + UID: promoterUID, + Addresses: promoterAddresses, + Conf: types.PromoterConf{ + CategoryCap: []types.CategoryCap{ + {Category: types.RewardCategory_REWARD_CATEGORY_SIGNUP, CapPerAcc: 1}, + }, + }, + }) + + for _, addr := range promoterAddresses { + k.RewardKeeper.SetPromoterByAddress(ctx, types.PromoterByAddress{ + PromoterUID: promoterUID, + Address: addr, + }) + } + } + + return mm.RunMigrations(ctx, configurator, fromVM) + } +} diff --git a/proto/sge/bet/bet.proto b/proto/sge/bet/bet.proto index a1d41352..144ce543 100644 --- a/proto/sge/bet/bet.proto +++ b/proto/sge/bet/bet.proto @@ -180,4 +180,6 @@ message MetaData { sgenetwork.sge.bet.OddsType selected_odds_type = 1; // selected_odds_value is metadata for bet string selected_odds_value = 2; + // is_main_market will tell weather the bet placed on the main market or not + bool is_main_market = 3; } diff --git a/proto/sge/reward/authz.proto b/proto/sge/reward/authz.proto index 9e266ba7..e45dd744 100644 --- a/proto/sge/reward/authz.proto +++ b/proto/sge/reward/authz.proto @@ -25,4 +25,10 @@ message UpdateCampaignAuthorization { // WithdrawCampaignAuthorization allows the grantee to withdraw remaining // pool balance of the campaign from the granter's account. -message WithdrawCampaignAuthorization {} \ No newline at end of file +message WithdrawCampaignAuthorization { + // withdraw_limit is the maximum limit of the withdrawal by authorization. + string withdraw_limit = 1 [ + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false + ]; +} \ No newline at end of file diff --git a/proto/sge/reward/campaign.proto b/proto/sge/reward/campaign.proto index b9605ccd..4577d0af 100644 --- a/proto/sge/reward/campaign.proto +++ b/proto/sge/reward/campaign.proto @@ -54,13 +54,15 @@ message Campaign { // is_active is the flag to check if the campaign is active or not. bool is_active = 11; - // claims_per_category is the number of times a user can claim a - // reward for category of this campaign. - uint64 claims_per_category = 12; - // meta is the metadata of the campaign. // It is a stringified base64 encoded json. string meta = 13; + + // cap_count is the maximum allowed grant for a certain account. + uint64 cap_count = 14; + + // constraints is the constrains of a campaign. + CampaignConstraints constraints = 15; } // Pool tracks funds assigned and spent to/for a campaign. @@ -75,4 +77,18 @@ message Pool { (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"spent\"" ]; + string withdrawn = 3 [ + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"spent\"" + ]; +} + +// CampaignConstraints contains campaign constraints and criteria. +message CampaignConstraints { + string max_bet_amount = 1 [ + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"max_bet_amount\"" + ]; } \ No newline at end of file diff --git a/proto/sge/reward/genesis.proto b/proto/sge/reward/genesis.proto index 937a59bb..58b8568b 100644 --- a/proto/sge/reward/genesis.proto +++ b/proto/sge/reward/genesis.proto @@ -6,6 +6,7 @@ import "gogoproto/gogo.proto"; import "sge/reward/params.proto"; import "sge/reward/campaign.proto"; import "sge/reward/reward.proto"; +import "sge/reward/promoter.proto"; option go_package = "github.com/sge-network/sge/x/reward/types"; @@ -18,4 +19,8 @@ message GenesisState { [ (gogoproto.nullable) = false ]; repeated RewardByCampaign reward_by_campaign_list = 5 [ (gogoproto.nullable) = false ]; + repeated Promoter promoter_list = 6 + [ (gogoproto.nullable) = false ]; + repeated PromoterByAddress promoter_by_address_list = 7 + [ (gogoproto.nullable) = false ]; } diff --git a/proto/sge/reward/promoter.proto b/proto/sge/reward/promoter.proto new file mode 100644 index 00000000..3b717c91 --- /dev/null +++ b/proto/sge/reward/promoter.proto @@ -0,0 +1,51 @@ +syntax = "proto3"; +package sgenetwork.sge.reward; + +import "gogoproto/gogo.proto"; + +import "sge/reward/reward.proto"; + +option go_package = "github.com/sge-network/sge/x/reward/types"; + +// Promoter is type for defining the reward promoter properties and configuration. +message Promoter { + // creator is the address of promoter. + string creator = 1; + + // uid is the unique identifier of a promoter. + string uid = 2 [ + (gogoproto.customname) = "UID", + (gogoproto.jsontag) = "uid", + json_name = "uid" + ]; + + // addresses is the list of account addresses of promoter. + repeated string addresses = 3; + + // conf is the configurations of the current promoter for the reward grant. + PromoterConf conf = 4 [ (gogoproto.nullable) = false ]; +} + +// PromoterConf is type for defining the promoter specific configurations. +message PromoterConf { + // category_cap is the maximium allowed cap for each category. + repeated CategoryCap category_cap = 1 [ (gogoproto.nullable) = false ]; +} + +// CategoryCap is type to define category and its maximum cap. +message CategoryCap { + RewardCategory category = 1; + int32 cap_per_acc = 2; +} + +// PromoterByAddress is type for defining the promoter by address. +message PromoterByAddress { + // promoter_uid is the unique identifier of a certain promoter. + string promoter_uid = 1 [ + (gogoproto.customname) = "PromoterUID", + (gogoproto.jsontag) = "promoter_uid", + json_name = "promoter_uid" + ]; + // address is the address of the promoter account. + string address = 2; +} \ No newline at end of file diff --git a/proto/sge/reward/query.proto b/proto/sge/reward/query.proto index 106e86af..f1dcb6fe 100644 --- a/proto/sge/reward/query.proto +++ b/proto/sge/reward/query.proto @@ -8,6 +8,7 @@ import "cosmos/base/query/v1beta1/pagination.proto"; import "sge/reward/params.proto"; import "sge/reward/campaign.proto"; import "sge/reward/reward.proto"; +import "sge/reward/promoter.proto"; option go_package = "github.com/sge-network/sge/x/reward/types"; @@ -19,6 +20,16 @@ service Query { option (google.api.http).get = "/sge-network/sge/reward/params"; } + // PromoterByAddress queries a certain promoter. + rpc PromoterByAddress(QueryPromoterByAddressRequest) returns (QueryPromoterByAddressResponse) { + option (google.api.http).get = "/sge-network/sge/reward/promoter-by-address/{addr}"; + } + + // Queries list of all Promoter items. + rpc Promoters(QueryPromotersRequest) returns (QueryPromotersResponse) { + option (google.api.http).get = "/sge-network/sge/reward/promoters"; + } + // Queries a specific Campaign item. rpc Campaign(QueryCampaignRequest) returns (QueryCampaignResponse) { option (google.api.http).get = "/sge-network/sge/reward/campaign/{uid}"; @@ -42,7 +53,7 @@ service Query { // Queries list of all Reward items by user address. rpc RewardsByAddress(QueryRewardsByAddressRequest) returns (QueryRewardsByAddressResponse) { - option (google.api.http).get = "/sge-network/sge/reward/rewards/{address}"; + option (google.api.http).get = "/sge-network/sge/reward/rewards/{promoter_uid}/{address}"; } // Queries list of all Reward items by user address and reward type @@ -50,7 +61,7 @@ service Query { rpc RewardsByAddressAndCategory(QueryRewardsByAddressAndCategoryRequest) returns (QueryRewardsByAddressAndCategoryResponse) { option (google.api.http).get = - "/sge-network/sge/reward/rewards/{address}/{category}"; + "/sge-network/sge/reward/rewards/{promoter_uid}/{address}/{category}"; } // Queries list of all Reward items by campaign endpoint. @@ -70,6 +81,29 @@ message QueryParamsResponse { Params params = 1 [ (gogoproto.nullable) = false ]; } +// QueryPromoterByAddressRequest is request type for the Query/GetPromoterByAddress RPC method. +message QueryPromoterByAddressRequest { + string addr = 1; +} + +// QueryPromoterByAddressResponse is response type for the Query/GetPromoterByAddress RPC method. +message QueryPromoterByAddressResponse { + // promoter holds the queries promoter. + Promoter promoter = 1 [ (gogoproto.nullable) = false ]; +} + +// QueryPromotersRequest is request body for the query all promoters endpoint. +message QueryPromotersRequest { + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +// QueryPromotersResponse is response body of the query all promoters +// endpoint. +message QueryPromotersResponse { + repeated Promoter promoter = 1 [ (gogoproto.nullable) = false ]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + // QueryCampaignRequest is request body of the query campaign endpoint. message QueryCampaignRequest { string uid = 1; } @@ -114,6 +148,7 @@ message QueryRewardsResponse { message QueryRewardsByAddressRequest { cosmos.base.query.v1beta1.PageRequest pagination = 1; string address = 2; + string promoter_uid = 3; } // QueryRewardsByAddressResponse is response body of the query all rewards by @@ -129,6 +164,7 @@ message QueryRewardsByAddressAndCategoryRequest { cosmos.base.query.v1beta1.PageRequest pagination = 1; string address = 2; RewardCategory category = 3; + string promoter_uid = 4; } // QueryRewardsByAddressAndCategoryResponse is response body of the query all diff --git a/proto/sge/reward/ticket.proto b/proto/sge/reward/ticket.proto index b9a58795..b634da04 100644 --- a/proto/sge/reward/ticket.proto +++ b/proto/sge/reward/ticket.proto @@ -3,7 +3,9 @@ package sgenetwork.sge.reward; import "gogoproto/gogo.proto"; import "sge/type/kyc.proto"; +import "sge/reward/campaign.proto"; import "sge/reward/reward.proto"; +import "sge/reward/promoter.proto"; option go_package = "github.com/sge-network/sge/x/reward/types"; @@ -34,13 +36,15 @@ message CreateCampaignPayload { // is_active is the flag to check if the campaign is active or not. bool is_active = 8; - // claims_per_category is the number of times a user can claim a reward for - // category of this campaign. - uint64 claims_per_category = 9; - // meta is the metadata of the campaign. // It is a stringified base64 encoded json. string meta = 10; + + // cap_count is the maximum allowed grant for a certain account. + uint64 cap_count = 11; + + // constraints is the constrains of a campaign. + CampaignConstraints constraints = 12; } // UpdateCampaignPayload is the type for campaign update payload. @@ -109,4 +113,34 @@ message GrantSignupAffiliatorRewardPayload { // affiliatee is the address of the account that used this affiliator's // address as source_uid string affiliatee = 2; +} + +// GrantBetBonusRewardPayload is the type for bet bonus reward +// grant payload. +message GrantBetBonusRewardPayload { + // common is the common properties of a reward + RewardPayloadCommon common = 1 [ (gogoproto.nullable) = false ]; + + // bet_uid is the list of uids + string bet_uid = 2 [ + (gogoproto.customname) = "BetUID", + (gogoproto.jsontag) = "bet_uid", + json_name = "bet_uid" + ]; +} + +// CreatePromoterPayload is the payload for the promoter create. +message CreatePromoterPayload { + // uid is the uid of the promoter to be created + string uid = 1 [ + (gogoproto.customname) = "UID", + (gogoproto.jsontag) = "uid", + json_name = "uid" + ]; + PromoterConf conf = 2 [ (gogoproto.nullable) = false ]; +} + +// SetPromoterConfPayload is the payload for the promoter configuration change. +message SetPromoterConfPayload { + PromoterConf conf = 1 [ (gogoproto.nullable) = false ]; } \ No newline at end of file diff --git a/proto/sge/reward/tx.proto b/proto/sge/reward/tx.proto index 5570ce8d..391480bf 100644 --- a/proto/sge/reward/tx.proto +++ b/proto/sge/reward/tx.proto @@ -8,6 +8,10 @@ option go_package = "github.com/sge-network/sge/x/reward/types"; // Msg defines the Msg service. service Msg { + // SetPromoterConf is a method to set the configurations of a promoter. + rpc SetPromoterConf(MsgSetPromoterConf) returns (MsgSetPromoterConfResponse); + // CreatePromoter is a method to create a promoter + rpc CreatePromoter(MsgCreatePromoter) returns (MsgCreatePromoterResponse); // CreateCampaign is a method to create a campaign rpc CreateCampaign(MsgCreateCampaign) returns (MsgCreateCampaignResponse); // UpdateCampaign is a method to update campaign @@ -18,6 +22,30 @@ service Msg { rpc GrantReward(MsgGrantReward) returns (MsgGrantRewardResponse); } +// MsgCreatePromoter is msg to create a promoter. +message MsgCreatePromoter { + // creator is the address of message signer account. + string creator = 1; + // ticket is the payload data. + string ticket = 2; +} + +// MsgCreatePromoterResponse promoter create message response type. +message MsgCreatePromoterResponse {} + +// MsgSetPromoterConf is msg to set promoter configuration. +message MsgSetPromoterConf { + // creator is the address of message signer account. + string creator = 1; + // uid is the unique identifier of the promoter. + string uid = 2; + // ticket is the payload data. + string ticket = 3; +} + +// MsgCreateCampaignResponse campaign create message response type. +message MsgSetPromoterConfResponse {} + // MsgCreateCampaign is msg to create a reward campaign message MsgCreateCampaign { // creator is the address of campaign creator account. @@ -80,6 +108,11 @@ message MsgWithdrawFunds { string uid = 2; // ticket is the payload data. string ticket = 3; + // amount is the requested withdrawal amount + string amount = 4 [ + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false + ]; } // MsgWithdrawFundsResponse withdraw funds message response type. diff --git a/x/bet/types/bet.pb.go b/x/bet/types/bet.pb.go index fe0eee5b..cfde1ab2 100644 --- a/x/bet/types/bet.pb.go +++ b/x/bet/types/bet.pb.go @@ -492,6 +492,8 @@ type MetaData struct { SelectedOddsType OddsType `protobuf:"varint,1,opt,name=selected_odds_type,json=selectedOddsType,proto3,enum=sgenetwork.sge.bet.OddsType" json:"selected_odds_type,omitempty"` // selected_odds_value is metadata for bet SelectedOddsValue string `protobuf:"bytes,2,opt,name=selected_odds_value,json=selectedOddsValue,proto3" json:"selected_odds_value,omitempty"` + // is_main_market will tell weather the bet placed on the main market or not + IsMainMarket bool `protobuf:"varint,3,opt,name=is_main_market,json=isMainMarket,proto3" json:"is_main_market,omitempty"` } func (m *MetaData) Reset() { *m = MetaData{} } @@ -541,6 +543,13 @@ func (m *MetaData) GetSelectedOddsValue() string { return "" } +func (m *MetaData) GetIsMainMarket() bool { + if m != nil { + return m.IsMainMarket + } + return false +} + func init() { proto.RegisterEnum("sgenetwork.sge.bet.Bet_Status", Bet_Status_name, Bet_Status_value) proto.RegisterEnum("sgenetwork.sge.bet.Bet_Result", Bet_Result_name, Bet_Result_value) @@ -555,67 +564,68 @@ func init() { func init() { proto.RegisterFile("sge/bet/bet.proto", fileDescriptor_9bc076bb1a4d9f6e) } var fileDescriptor_9bc076bb1a4d9f6e = []byte{ - // 949 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x55, 0x41, 0x6f, 0xe2, 0x46, - 0x14, 0xc6, 0xc0, 0x92, 0xf0, 0x92, 0x10, 0x33, 0xd9, 0xee, 0x5a, 0xe9, 0x2e, 0x20, 0x4b, 0xad, - 0x90, 0xaa, 0x35, 0x12, 0xab, 0xdd, 0x43, 0x7b, 0x29, 0x60, 0xa7, 0xa1, 0x25, 0x40, 0x07, 0x68, - 0xa5, 0x3d, 0xd4, 0x32, 0x78, 0x42, 0xdc, 0xd8, 0x18, 0x79, 0x86, 0x36, 0xf9, 0x03, 0x3d, 0xf7, - 0x27, 0xf4, 0xe7, 0xec, 0x71, 0x8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, 0x8f, 0x09, 0x6b, 0xc4, 0xdd, 0xee, 0x0d, 0x1c, 0xcc, 0x9d, 0xeb, 0x70, 0xc1, 0xec, - 0x79, 0x14, 0x9e, 0x7b, 0x4c, 0xcb, 0x0a, 0xd7, 0x57, 0x1f, 0x73, 0x7d, 0xbc, 0xde, 0x7a, 0x42, - 0xab, 0xe3, 0xfd, 0x78, 0xde, 0x8f, 0xa7, 0xbf, 0x29, 0xb0, 0xbb, 0xbe, 0x76, 0xe8, 0x5b, 0x40, - 0x94, 0xf8, 0x64, 0xc2, 0x9b, 0xd3, 0xe6, 0x91, 0x11, 0xc9, 0x2d, 0xdc, 0x7d, 0x61, 0x79, 0xef, - 0x1f, 0x5e, 0xcf, 0x09, 0xef, 0x4d, 0xb1, 0x6e, 0x8d, 0x20, 0x03, 0x8e, 0xb6, 0xbd, 0xe2, 0x17, - 0x20, 0x3e, 0xe8, 0x62, 0x92, 0x2e, 0x5e, 0x82, 0xe6, 0xd7, 0x6f, 0x57, 0x25, 0xe5, 0xdd, 0xaa, - 0xa4, 0xfc, 0xbd, 0x2a, 0x29, 0xbf, 0xdf, 0x94, 0x52, 0xef, 0x6e, 0x4a, 0xa9, 0x3f, 0x6f, 0x4a, - 0xa9, 0x37, 0xc9, 0x06, 0x46, 0xa7, 0xe4, 0x85, 0xdc, 0x04, 0x1f, 0xd7, 0xae, 0xc4, 0x83, 0x28, - 0x9a, 0xd8, 0x38, 0x27, 0x5e, 0xc3, 0x97, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0xa8, 0x4e, 0x5a, - 0xf7, 0x65, 0x07, 0x00, 0x00, + // 973 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x55, 0xdd, 0x6e, 0x1b, 0x45, + 0x14, 0xce, 0xda, 0xae, 0x13, 0x9f, 0x24, 0x8e, 0x3d, 0x29, 0xed, 0x2a, 0xb4, 0xb6, 0xb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x42, 0x9f, + 0xe9, 0xa3, 0x8a, 0x71, 0xf3, 0x52, 0xb6, 0x4d, 0x59, 0xea, 0x46, 0x45, 0xd9, 0x33, 0x9f, 0xff, + 0x13, 0x00, 0x00, 0xff, 0xff, 0x99, 0x7a, 0x48, 0xed, 0x8b, 0x07, 0x00, 0x00, } func (m *Bet) Marshal() (dAtA []byte, err error) { @@ -934,6 +944,16 @@ func (m *MetaData) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.IsMainMarket { + i-- + if m.IsMainMarket { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x18 + } if len(m.SelectedOddsValue) > 0 { i -= len(m.SelectedOddsValue) copy(dAtA[i:], m.SelectedOddsValue) @@ -1098,6 +1118,9 @@ func (m *MetaData) Size() (n int) { if l > 0 { n += 1 + l + sovBet(uint64(l)) } + if m.IsMainMarket { + n += 2 + } return n } @@ -2140,6 +2163,26 @@ func (m *MetaData) Unmarshal(dAtA []byte) error { } m.SelectedOddsValue = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsMainMarket", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBet + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsMainMarket = bool(v != 0) default: iNdEx = preIndex skippy, err := skipBet(dAtA[iNdEx:]) diff --git a/x/reward/client/cli/query.go b/x/reward/client/cli/query.go index 60a26fad..d8dd719a 100644 --- a/x/reward/client/cli/query.go +++ b/x/reward/client/cli/query.go @@ -22,6 +22,8 @@ func GetQueryCmd(_ string) *cobra.Command { } cmd.AddCommand(CmdQueryParams()) + cmd.AddCommand(CmdListPromoters()) + cmd.AddCommand(CmdGetPromoterByAddress()) cmd.AddCommand(CmdListCampaign()) cmd.AddCommand(CmdGetCampaign()) cmd.AddCommand(CmdListReward()) diff --git a/x/reward/client/cli/query_promoter.go b/x/reward/client/cli/query_promoter.go new file mode 100644 index 00000000..426fb77b --- /dev/null +++ b/x/reward/client/cli/query_promoter.go @@ -0,0 +1,75 @@ +package cli + +import ( + "context" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + + "github.com/sge-network/sge/x/reward/types" +) + +func CmdListPromoters() *cobra.Command { + cmd := &cobra.Command{ + Use: "promoters", + Short: "list all promoters", + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryPromotersRequest{ + Pagination: pageReq, + } + + res, err := queryClient.Promoters(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddPaginationFlagsToCmd(cmd, cmd.Use) + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdGetPromoterByAddress() *cobra.Command { + cmd := &cobra.Command{ + Use: "promoter-by-address [addr]", + Short: "shows a promoter by its address", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + argAddress := args[0] + + params := &types.QueryPromoterByAddressRequest{ + Addr: argAddress, + } + + res, err := queryClient.PromoterByAddress(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/reward/client/cli/tx.go b/x/reward/client/cli/tx.go index bf7131ab..ed1a3ef8 100644 --- a/x/reward/client/cli/tx.go +++ b/x/reward/client/cli/tx.go @@ -24,6 +24,8 @@ func GetTxCmd() *cobra.Command { RunE: client.ValidateCmd, } + cmd.AddCommand(CmdCreatePromoter()) + cmd.AddCommand(CmdSetPromoterConf()) cmd.AddCommand(CmdCreateCampaign()) cmd.AddCommand(CmdUpdateCampaign()) cmd.AddCommand(CmdWithdrawFunds()) diff --git a/x/reward/client/cli/tx_campaign.go b/x/reward/client/cli/tx_campaign.go index 3145c737..e273b8be 100644 --- a/x/reward/client/cli/tx_campaign.go +++ b/x/reward/client/cli/tx_campaign.go @@ -95,16 +95,21 @@ func CmdUpdateCampaign() *cobra.Command { func CmdWithdrawFunds() *cobra.Command { cmd := &cobra.Command{ - Use: "withdraw-funds [uid] [ticket]", + Use: "withdraw-funds [uid] [amount] [ticket]", Short: "Withdraw funds from a campaign", Long: "Withdrawal of the funds from a certain campaign", - Args: cobra.ExactArgs(2), + Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) (err error) { // Get indexes argUID := args[0] + argWithdrawAmountCosmosInt, ok := sdkmath.NewIntFromString(args[1]) + if !ok { + return types.ErrInvalidFunds + } + // Get value arguments - argTicket := args[1] + argTicket := args[2] clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -114,6 +119,7 @@ func CmdWithdrawFunds() *cobra.Command { msg := types.NewMsgWithdrawFunds( clientCtx.GetFromAddress().String(), argUID, + argWithdrawAmountCosmosInt, argTicket, ) if err := msg.ValidateBasic(); err != nil { diff --git a/x/reward/client/cli/tx_promoter.go b/x/reward/client/cli/tx_promoter.go new file mode 100644 index 00000000..762f3ad6 --- /dev/null +++ b/x/reward/client/cli/tx_promoter.go @@ -0,0 +1,77 @@ +package cli + +import ( + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + + "github.com/sge-network/sge/x/reward/types" +) + +func CmdCreatePromoter() *cobra.Command { + cmd := &cobra.Command{ + Use: "create-promoter [ticket]", + Short: "Create a new promoter", + Long: "Creating a new promoter with certain configurations the ticket", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + // Get value arguments + argTicket := args[0] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgCreatePromoter( + clientCtx.GetFromAddress().String(), + argTicket, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func CmdSetPromoterConf() *cobra.Command { + cmd := &cobra.Command{ + Use: "set-promoter-conf [uid] [ticket]", + Short: "Set promoter config", + Long: "Set promoter config of a promoter by uid and the ticket", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) (err error) { + // Get indexes + argUID := args[0] + + // Get value arguments + argTicket := args[1] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgSetPromoterConfig( + clientCtx.GetFromAddress().String(), + argUID, + argTicket, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/reward/genesis.go b/x/reward/genesis.go index b841832b..8a1d7b49 100644 --- a/x/reward/genesis.go +++ b/x/reward/genesis.go @@ -1,6 +1,8 @@ package reward import ( + "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/sge-network/sge/x/reward/keeper" @@ -9,6 +11,12 @@ import ( // InitGenesis initializes the module's state from a provided genesis state. func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + for _, elem := range genState.PromoterList { + k.SetPromoter(ctx, elem) + } + for _, elem := range genState.PromoterByAddressList { + k.SetPromoterByAddress(ctx, elem) + } // Set all the campaign for _, elem := range genState.CampaignList { k.SetCampaign(ctx, elem) @@ -17,7 +25,19 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) k.SetReward(ctx, elem) } for _, elem := range genState.RewardByCategoryList { - k.SetRewardByReceiver(ctx, elem) + reward, found := k.GetReward(ctx, elem.UID) + if !found { + panic(fmt.Errorf("reward is not valid %s", elem.UID)) + } + camp, found := k.GetCampaign(ctx, reward.CampaignUID) + if !found { + panic(fmt.Errorf("campaign is not valid %s", reward.CampaignUID)) + } + promoter, found := k.GetPromoterByAddress(ctx, camp.Promoter) + if !found { + panic(fmt.Errorf("promoter is not valid %s", camp.Promoter)) + } + k.SetRewardOfReceiverByPromoterAndCategory(ctx, promoter.PromoterUID, elem) } for _, elem := range genState.RewardByCampaignList { k.SetRewardByCampaign(ctx, elem) diff --git a/x/reward/genesis_test.go b/x/reward/genesis_test.go index 497fbc5b..590bf851 100644 --- a/x/reward/genesis_test.go +++ b/x/reward/genesis_test.go @@ -13,39 +13,75 @@ import ( ) func TestGenesis(t *testing.T) { + promoterAddr := "promoter" + promoterUID := uuid.NewString() + + campaignUID1 := uuid.NewString() + campaignUID2 := uuid.NewString() + + rewardID1 := uuid.NewString() + rewardID2 := uuid.NewString() + genesisState := types.GenesisState{ Params: types.DefaultParams(), + PromoterList: []types.Promoter{ + { + Creator: promoterAddr, + UID: promoterUID, + Addresses: []string{promoterAddr}, + Conf: types.PromoterConf{ + CategoryCap: []types.CategoryCap{ + { + Category: types.RewardCategory_REWARD_CATEGORY_SIGNUP, + CapPerAcc: 1, + }, + }, + }, + }, + }, + PromoterByAddressList: []types.PromoterByAddress{ + { + PromoterUID: promoterUID, + Address: promoterAddr, + }, + }, CampaignList: []types.Campaign{ { - UID: uuid.NewString(), + UID: campaignUID1, + Promoter: promoterAddr, }, { - UID: uuid.NewString(), + UID: campaignUID2, + Promoter: promoterAddr, }, }, RewardList: []types.Reward{ { - UID: uuid.NewString(), + UID: rewardID1, + CampaignUID: campaignUID1, }, { - UID: uuid.NewString(), + UID: rewardID2, + CampaignUID: campaignUID2, }, }, RewardByCategoryList: []types.RewardByCategory{ { - UID: uuid.NewString(), + UID: rewardID1, }, { - UID: uuid.NewString(), + UID: rewardID2, }, }, RewardByCampaignList: []types.RewardByCampaign{ { - UID: uuid.NewString(), + UID: rewardID1, + CampaignUID: campaignUID1, }, { - UID: uuid.NewString(), + UID: rewardID1, + CampaignUID: campaignUID2, }, }, } diff --git a/x/reward/keeper/campaign.go b/x/reward/keeper/campaign.go index 7079908e..ab071f52 100644 --- a/x/reward/keeper/campaign.go +++ b/x/reward/keeper/campaign.go @@ -10,9 +10,7 @@ import ( func (k Keeper) SetCampaign(ctx sdk.Context, campaign types.Campaign) { store := k.getCampaignStore(ctx) b := k.cdc.MustMarshal(&campaign) - store.Set(types.GetCampaignKey( - campaign.UID, - ), b) + store.Set(types.GetCampaignKey(campaign.UID), b) } // GetCampaign returns a campaign from its index @@ -58,7 +56,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.SubaccountAmount.Add(receiver.MainAccountAmount) // Fixme: Check if the logic is correct - campaign.Pool.Spent = campaign.Pool.Spent.Add(totalAmount) + campaign.Pool.Spend(totalAmount) k.SetCampaign(ctx, campaign) } diff --git a/x/reward/keeper/campaign_test.go b/x/reward/keeper/campaign_test.go index aae62008..12b5926b 100644 --- a/x/reward/keeper/campaign_test.go +++ b/x/reward/keeper/campaign_test.go @@ -33,7 +33,7 @@ func createNCampaign(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.Camp items[i].RewardAmountType = types.RewardAmountType_REWARD_AMOUNT_TYPE_FIXED items[i].IsActive = true items[i].Meta = "campaign " + items[i].UID - items[i].Pool = types.Pool{Spent: sdk.ZeroInt(), Total: sdkmath.NewInt(100)} + items[i].Pool = types.Pool{Spent: sdk.ZeroInt(), Withdrawn: sdk.ZeroInt(), Total: sdkmath.NewInt(100)} keeper.SetCampaign(ctx, items[i]) } diff --git a/x/reward/keeper/msg_server_campaign.go b/x/reward/keeper/msg_server_campaign.go index a88c82e5..a8b6bcdd 100644 --- a/x/reward/keeper/msg_server_campaign.go +++ b/x/reward/keeper/msg_server_campaign.go @@ -28,6 +28,10 @@ func (k msgServer) CreateCampaign(goCtx context.Context, msg *types.MsgCreateCam return nil, sdkerrors.Wrapf(types.ErrInTicketVerification, "%s", err) } + if !k.IsPromoter(ctx, payload.Promoter) { + return nil, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "promoter with the address: %s not found", payload.Promoter) + } + if msg.Creator != payload.Promoter { if err := utils.ValidateMsgAuthorization(k.authzKeeper, ctx, msg.Creator, payload.Promoter, msg, types.ErrAuthorizationNotFound, types.ErrAuthorizationNotAccepted); err != nil { @@ -53,7 +57,7 @@ func (k msgServer) CreateCampaign(goCtx context.Context, msg *types.MsgCreateCam campaign := types.NewCampaign( msg.Creator, payload.Promoter, msg.Uid, - payload.StartTs, payload.EndTs, payload.ClaimsPerCategory, + payload.StartTs, payload.EndTs, payload.RewardType, payload.Category, payload.RewardAmountType, @@ -61,6 +65,8 @@ func (k msgServer) CreateCampaign(goCtx context.Context, msg *types.MsgCreateCam payload.IsActive, payload.Meta, types.NewPool(msg.TotalFunds), + payload.CapCount, + payload.Constraints, ) rewardFactory, err := campaign.GetRewardsFactory() @@ -129,7 +135,7 @@ func (k msgServer) UpdateCampaign(goCtx context.Context, msg *types.MsgUpdateCam return nil, sdkerrors.Wrapf(types.ErrInFundingCampaignPool, "%s", err) } - campaign.Pool.Total = campaign.Pool.Total.Add(msg.TopupFunds) + campaign.Pool.TopUp(msg.TopupFunds) } campaign.EndTS = payload.EndTs @@ -172,24 +178,31 @@ func (k msgServer) WithdrawFunds(goCtx context.Context, msg *types.MsgWithdrawFu return nil, err } } - availableAmount := valFound.Pool.Total.Sub(valFound.Pool.Spent) + availableAmount := valFound.Pool.AvailableAmount() // check if the pool amount is positive if availableAmount.IsNil() || !availableAmount.GT(sdkmath.ZeroInt()) { return nil, sdkerrors.Wrapf(types.ErrWithdrawFromCampaignPool, "pool amount should be positive") } + if availableAmount.LT(msg.Amount) { + return nil, sdkerrors.Wrapf(types.ErrWithdrawFromCampaignPool, "not enough withdrawable balance %s", availableAmount) + } + // transfer the funds present in campaign to the promoter if err := k.modFunder.Refund( types.RewardPoolFunder{}, ctx, sdk.MustAccAddressFromBech32(payload.Promoter), - availableAmount, + msg.Amount, ); 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 + valFound.Pool.Withdraw(msg.Amount) + + if valFound.Pool.AvailableAmount().LTE(sdkmath.ZeroInt()) { + // deactivate the campaign + valFound.IsActive = false + } // store the campaign k.SetCampaign(ctx, valFound) diff --git a/x/reward/keeper/msg_server_campaign_test.go b/x/reward/keeper/msg_server_campaign_test.go index 117fcc4a..f64de9b0 100644 --- a/x/reward/keeper/msg_server_campaign_test.go +++ b/x/reward/keeper/msg_server_campaign_test.go @@ -22,12 +22,29 @@ import ( // Prevent strconv unused error var _ = strconv.IntSize +func setTestPromoter(k *keeper.Keeper, ctx sdk.Context, promoterAddr string) { + k.SetPromoter(ctx, types.Promoter{ + Creator: promoterAddr, + UID: promoterUID, + Addresses: []string{ + promoterAddr, + }, + }) + k.SetPromoterByAddress(ctx, types.PromoterByAddress{ + PromoterUID: promoterUID, + Address: promoterAddr, + }) +} + func TestCampaignMsgServerCreate(t *testing.T) { k, ctx := setupKeeper(t) srv := keeper.NewMsgServerImpl(*k) ctx = ctx.WithBlockTime(time.Now()) wctx := sdk.WrapSDKContext(ctx) creator := simapp.TestParamUsers["user1"].Address.String() + + setTestPromoter(k, ctx, creator) + for i := 0; i < 5; i++ { ticketClaim := jwt.MapClaims{ "exp": time.Now().Add(time.Minute * 5).Unix(), @@ -42,9 +59,11 @@ func TestCampaignMsgServerCreate(t *testing.T) { SubaccountAmount: sdkmath.NewInt(100), UnlockPeriod: uint64(ctx.BlockTime().Add(10 * time.Minute).Unix()), }, - "is_active": true, - "meta": "sample campaign", - "claims_per_category": 1, + "is_active": true, + "meta": "sample campaign", + "constraints": &types.CampaignConstraints{ + MaxBetAmount: sdkmath.NewInt(300), + }, } ticket, err := simapp.CreateJwtTicket(ticketClaim) require.Nil(t, err) @@ -74,6 +93,8 @@ func TestCampaignMsgServerCreateWithAuthoriation(t *testing.T) { creator := simapp.TestParamUsers["user2"] promoter := simapp.TestParamUsers["user1"] + setTestPromoter(k, ctx, promoter.Address.String()) + grantAmount := sdkmath.NewInt(1000000) expTime := time.Now().Add(5 * time.Minute) @@ -108,9 +129,11 @@ func TestCampaignMsgServerCreateWithAuthoriation(t *testing.T) { SubaccountAmount: sdkmath.NewInt(100), UnlockPeriod: uint64(ctx.BlockTime().Add(10 * time.Minute).Unix()), }, - "is_active": true, - "meta": "sample campaign", - "claims_per_category": 1, + "is_active": true, + "meta": "sample campaign", + "constraints": &types.CampaignConstraints{ + MaxBetAmount: sdkmath.NewInt(300), + }, } ticket, err := simapp.CreateJwtTicket(ticketClaim) require.Nil(t, err) @@ -143,10 +166,14 @@ func TestCampaignMsgServerUnAuthorizedCreate(t *testing.T) { ctx = ctx.WithBlockTime(time.Now()) wctx := sdk.WrapSDKContext(ctx) creator := simapp.TestParamUsers["user1"].Address.String() + promoter := sample.AccAddress() + + setTestPromoter(k, ctx, promoter) + ticketClaim := jwt.MapClaims{ "exp": time.Now().Add(time.Minute * 5).Unix(), "iat": time.Now().Unix(), - "promoter": sample.AccAddress(), + "promoter": promoter, } ticket, err := simapp.CreateJwtTicket(ticketClaim) require.Nil(t, err) @@ -199,6 +226,8 @@ func TestCampaignMsgServerUpdate(t *testing.T) { creator := simapp.TestParamUsers["user1"].Address.String() + setTestPromoter(k, ctx, creator) + ticketClaim := jwt.MapClaims{ "exp": time.Now().Add(time.Minute * 5).Unix(), "iat": time.Now().Unix(), @@ -212,9 +241,11 @@ func TestCampaignMsgServerUpdate(t *testing.T) { SubaccountAmount: sdkmath.NewInt(100), UnlockPeriod: uint64(ctx.BlockTime().Add(10 * time.Minute).Unix()), }, - "is_active": true, - "meta": "sample campaign", - "claims_per_category": 1, + "is_active": true, + "meta": "sample campaign", + "constraints": &types.CampaignConstraints{ + MaxBetAmount: sdkmath.NewInt(300), + }, } ticket, err := simapp.CreateJwtTicket(ticketClaim) require.Nil(t, err) @@ -256,7 +287,7 @@ func TestCampaignMsgServerUpdate(t *testing.T) { } } -func TestCampaignMsgServerUpdateWithAuthoriation(t *testing.T) { +func TestCampaignMsgServerUpdateWithAuthorization(t *testing.T) { tApp, k, ctx := setupKeeperAndApp(t) srv := keeper.NewMsgServerImpl(*k) ctx = ctx.WithBlockTime(time.Now()) @@ -267,6 +298,8 @@ func TestCampaignMsgServerUpdateWithAuthoriation(t *testing.T) { creator := simapp.TestParamUsers["user2"] promoter := simapp.TestParamUsers["user1"] + setTestPromoter(k, ctx, promoter.Address.String()) + grantAmount := sdkmath.NewInt(1000000) expTime := time.Now().Add(5 * time.Minute) @@ -319,9 +352,11 @@ func TestCampaignMsgServerUpdateWithAuthoriation(t *testing.T) { SubaccountAmount: sdkmath.NewInt(100), UnlockPeriod: uint64(ctx.BlockTime().Add(10 * time.Minute).Unix()), }, - "is_active": true, - "meta": "sample campaign", - "claims_per_category": 1, + "is_active": true, + "meta": "sample campaign", + "constraints": &types.CampaignConstraints{ + MaxBetAmount: sdkmath.NewInt(300), + }, } ticket, err := simapp.CreateJwtTicket(ticketClaim) require.Nil(t, err) diff --git a/x/reward/keeper/msg_server_promoter.go b/x/reward/keeper/msg_server_promoter.go new file mode 100644 index 00000000..ec32a142 --- /dev/null +++ b/x/reward/keeper/msg_server_promoter.go @@ -0,0 +1,82 @@ +package keeper + +import ( + "context" + + sdkerrors "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrtypes "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/sge-network/sge/x/reward/types" +) + +func (k msgServer) CreatePromoter(goCtx context.Context, msg *types.MsgCreatePromoter) (*types.MsgCreatePromoterResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + var payload types.CreatePromoterPayload + if err := k.ovmKeeper.VerifyTicketUnmarshal(goCtx, msg.Ticket, &payload); err != nil { + return nil, sdkerrors.Wrapf(types.ErrInTicketVerification, "%s", err) + } + + // Check if the value already exists + _, isFound := k.GetPromoter(ctx, payload.UID) + if isFound { + return nil, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "promoter with the uid: %s already exists", payload.UID) + } + + if err := payload.Validate(); err != nil { + return nil, err + } + + k.SetPromoter(ctx, types.Promoter{ + Creator: msg.Creator, + Addresses: []string{msg.Creator}, + UID: payload.UID, + Conf: payload.Conf, + }) + k.SetPromoterByAddress(ctx, types.PromoterByAddress{ + PromoterUID: payload.UID, + Address: msg.Creator, + }) + + msg.EmitEvent(&ctx, payload.UID, payload.Conf) + + return &types.MsgCreatePromoterResponse{}, nil +} + +func (k msgServer) SetPromoterConf(goCtx context.Context, msg *types.MsgSetPromoterConf) (*types.MsgSetPromoterConfResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // Check if the value already exists + promoter, isFound := k.GetPromoter(ctx, msg.Uid) + if !isFound { + return nil, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "promoter does not exist %s", msg.Uid) + } + + creatorIsPromoter := false + for _, p := range promoter.Addresses { + if p == msg.Creator { + creatorIsPromoter = true + } + } + + if !creatorIsPromoter { + return nil, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "creator should be one of stored addresses in promoter") + } + + var payload types.SetPromoterConfPayload + if err := k.ovmKeeper.VerifyTicketUnmarshal(goCtx, msg.Ticket, &payload); err != nil { + return nil, sdkerrors.Wrapf(types.ErrInTicketVerification, "%s", err) + } + + if err := payload.Validate(); err != nil { + return nil, err + } + + promoter.Conf = payload.Conf + + k.SetPromoter(ctx, promoter) + + msg.EmitEvent(&ctx, promoter.Conf) + + return &types.MsgSetPromoterConfResponse{}, nil +} diff --git a/x/reward/keeper/msg_server_promoter_test.go b/x/reward/keeper/msg_server_promoter_test.go new file mode 100644 index 00000000..5ce13fe2 --- /dev/null +++ b/x/reward/keeper/msg_server_promoter_test.go @@ -0,0 +1,116 @@ +package keeper_test + +import ( + "testing" + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/golang-jwt/jwt" + "github.com/google/uuid" + "github.com/sge-network/sge/testutil/simapp" + "github.com/stretchr/testify/require" + + "github.com/sge-network/sge/x/reward/keeper" + "github.com/sge-network/sge/x/reward/types" +) + +func TestSetPromoterConfig(t *testing.T) { + k, ctx := setupKeeper(t) + srv := keeper.NewMsgServerImpl(*k) + ctx = ctx.WithBlockTime(time.Now()) + wctx := sdk.WrapSDKContext(ctx) + promoter := simapp.TestParamUsers["user1"].Address.String() + promoterUID := uuid.NewString() + k.SetPromoter(ctx, types.Promoter{ + Creator: promoter, + UID: promoterUID, + Addresses: []string{ + promoter, + }, + Conf: types.PromoterConf{ + CategoryCap: []types.CategoryCap{ + { + Category: types.RewardCategory_REWARD_CATEGORY_SIGNUP, + CapPerAcc: 1, + }, + }, + }, + }) + + for _, tc := range []struct { + desc string + claims jwt.MapClaims + uid string + err error + }{ + { + desc: "invalid ticket", + claims: jwt.MapClaims{ + "exp": time.Now().Add(time.Minute * 5).Unix(), + "iat": time.Now().Unix(), + "conf": "invalid", + }, + uid: promoterUID, + err: types.ErrInTicketVerification, + }, + { + desc: "duplicate cap category", + claims: jwt.MapClaims{ + "exp": time.Now().Add(time.Minute * 5).Unix(), + "iat": time.Now().Unix(), + "conf": types.PromoterConf{ + CategoryCap: []types.CategoryCap{ + {Category: types.RewardCategory_REWARD_CATEGORY_SIGNUP, CapPerAcc: 1}, + {Category: types.RewardCategory_REWARD_CATEGORY_SIGNUP, CapPerAcc: 1}, + }, + }, + }, + uid: promoterUID, + err: types.ErrDuplicateCategoryInConf, + }, + { + desc: "low cap category", + claims: jwt.MapClaims{ + "exp": time.Now().Add(time.Minute * 5).Unix(), + "iat": time.Now().Unix(), + "conf": types.PromoterConf{ + CategoryCap: []types.CategoryCap{ + {Category: types.RewardCategory_REWARD_CATEGORY_SIGNUP, CapPerAcc: 0}, + {Category: types.RewardCategory_REWARD_CATEGORY_AFFILIATE, CapPerAcc: 1}, + }, + }, + }, + uid: promoterUID, + err: types.ErrCategoryCapShouldBePos, + }, + { + desc: "valid", + claims: jwt.MapClaims{ + "exp": time.Now().Add(time.Minute * 5).Unix(), + "iat": time.Now().Unix(), + "conf": types.PromoterConf{ + CategoryCap: []types.CategoryCap{ + {Category: types.RewardCategory_REWARD_CATEGORY_SIGNUP, CapPerAcc: 1}, + }, + }, + }, + uid: promoterUID, + }, + } { + t.Run(tc.desc, func(t *testing.T) { + ticket, err := simapp.CreateJwtTicket(tc.claims) + require.Nil(t, err) + conf := &types.MsgSetPromoterConf{ + Uid: tc.uid, + Creator: promoter, + Ticket: ticket, + } + _, err = srv.SetPromoterConf(wctx, conf) + if tc.err != nil { + require.ErrorContains(t, err, tc.err.Error()) + } else { + require.NoError(t, err) + } + }) + } +} diff --git a/x/reward/keeper/msg_server_reward.go b/x/reward/keeper/msg_server_reward.go index 699e16d3..ab488963 100644 --- a/x/reward/keeper/msg_server_reward.go +++ b/x/reward/keeper/msg_server_reward.go @@ -48,12 +48,40 @@ func (k msgServer) GrantReward(goCtx context.Context, msg *types.MsgGrantReward) return nil, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "distribution calculation failed %s", err) } - rewards, err := k.GetRewardsByAddressAndCategory(ctx, factData.Receiver.MainAccountAddr, campaign.RewardCategory) + var grantStats uint64 + if campaign.CapCount > 0 { + grantStats, isFound = k.GetRewardGrantsStats(ctx, msg.CampaignUid, factData.Receiver.MainAccountAddr) + if !isFound { + grantStats = 0 + } + if grantStats >= campaign.CapCount { + return nil, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "maximum count cap of the campaign is reached %d", grantStats) + } + + grantStats++ + k.SetRewardGrantsStats(ctx, msg.CampaignUid, factData.Receiver.MainAccountAddr, grantStats) + } + + promoterByAddress, isFound := k.GetPromoterByAddress(ctx, campaign.Promoter) + if !isFound { + return nil, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "promoter with the address: %s not found", campaign.Promoter) + } + promoter, isFound := k.GetPromoter(ctx, promoterByAddress.PromoterUID) + if !isFound { + return nil, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "promoter with the uid: %s not found", promoterByAddress.PromoterUID) + } + + rewards, err := k.GetRewardsOfReceiverByPromoterAndCategory(ctx, promoter.UID, factData.Receiver.MainAccountAddr, campaign.RewardCategory) if err != nil { return nil, sdkerrors.Wrap(sdkerrtypes.ErrInvalidRequest, "failed to retrieve rewards for user.") } - if len(rewards) >= cast.ToInt(campaign.ClaimsPerCategory) { - return nil, sdkerrors.Wrap(sdkerrtypes.ErrInvalidRequest, "maximum rewards claimed for the given category.") + + for _, c := range promoter.Conf.CategoryCap { + if c.Category == campaign.RewardCategory { + if len(rewards) >= cast.ToInt(c.CapPerAcc) { + return nil, sdkerrors.Wrap(sdkerrtypes.ErrInvalidRequest, "maximum rewards claimed for the given category.") + } + } } if err := campaign.CheckPoolBalance(factData.Receiver.SubaccountAmount.Add(factData.Receiver.MainAccountAmount)); err != nil { @@ -72,7 +100,8 @@ func (k msgServer) GrantReward(goCtx context.Context, msg *types.MsgGrantReward) factData.Common.SourceUID, factData.Common.Meta, )) - k.SetRewardByReceiver(ctx, types.NewRewardByCategory(msg.Uid, factData.Receiver.MainAccountAddr, campaign.RewardCategory)) + + k.SetRewardOfReceiverByPromoterAndCategory(ctx, promoter.UID, types.NewRewardByCategory(msg.Uid, factData.Receiver.MainAccountAddr, campaign.RewardCategory)) k.SetRewardByCampaign(ctx, types.NewRewardByCampaign(msg.Uid, campaign.UID)) msg.EmitEvent(&ctx, msg.CampaignUid, msg.Uid, campaign.Promoter, *campaign.RewardAmount, factData.Receiver, unlockTS) diff --git a/x/reward/keeper/msg_server_reward_test.go b/x/reward/keeper/msg_server_reward_test.go index ed3912ad..7a723053 100644 --- a/x/reward/keeper/msg_server_reward_test.go +++ b/x/reward/keeper/msg_server_reward_test.go @@ -15,28 +15,49 @@ import ( "github.com/sge-network/sge/testutil/sample" "github.com/sge-network/sge/testutil/simapp" sgetypes "github.com/sge-network/sge/types" + bettypes "github.com/sge-network/sge/x/bet/types" "github.com/sge-network/sge/x/reward/keeper" "github.com/sge-network/sge/x/reward/types" subaccounttypes "github.com/sge-network/sge/x/subaccount/types" ) +var promoterUID = uuid.NewString() + +var defaultCategoryCap = []types.CategoryCap{ + {Category: types.RewardCategory_REWARD_CATEGORY_SIGNUP, CapPerAcc: 1}, +} + func getDefaultClaim(creator string) jwt.MapClaims { return jwt.MapClaims{ - "exp": time.Now().Add(time.Minute * 5).Unix(), - "iat": time.Now().Unix(), - "promoter": creator, - "start_ts": time.Now().Unix(), - "end_ts": time.Now().Add(5 * time.Minute).Unix(), - "category": types.RewardCategory_REWARD_CATEGORY_SIGNUP, - "claims_per_category": 1, - "is_active": true, - "meta": "sample campaign", + "exp": time.Now().Add(time.Minute * 5).Unix(), + "iat": time.Now().Unix(), + "promoter": creator, + "start_ts": time.Now().Unix(), + "end_ts": time.Now().Add(5 * time.Minute).Unix(), + "category": types.RewardCategory_REWARD_CATEGORY_SIGNUP, + "is_active": true, + "meta": "sample campaign", } } func createCampaign(t *testing.T, k *keeper.Keeper, srv types.MsgServer, ctx sdk.Context, - promoter string, claims jwt.MapClaims, + promoter string, claims jwt.MapClaims, categoryCap []types.CategoryCap, ) string { + k.SetPromoter(ctx, types.Promoter{ + Creator: promoter, + UID: promoterUID, + Addresses: []string{promoter}, + Conf: types.PromoterConf{ + CategoryCap: categoryCap, + }, + }) + + k.SetPromoterByAddress(ctx, + types.PromoterByAddress{ + Address: promoter, + PromoterUID: promoterUID, + }) + ticket, err := simapp.CreateJwtTicket(claims) require.Nil(t, err) @@ -81,7 +102,7 @@ func TestMsgApplySignupReward(t *testing.T) { UnlockPeriod: uint64(ctx.BlockTime().Add(10 * time.Minute).Unix()), } - campUID := createCampaign(t, k, srv, ctx, promoter, campClaims) + campUID := createCampaign(t, k, srv, ctx, promoter, campClaims, defaultCategoryCap) for _, tc := range []struct { desc string @@ -105,7 +126,7 @@ func TestMsgApplySignupReward(t *testing.T) { "common": types.RewardPayloadCommon{ Receiver: receiverAddr, SourceUID: "", - Meta: "signup reward for example user", + Meta: "signup reward for sample user", KycData: &sgetypes.KycDataPayload{ Approved: true, ID: receiverAddr, @@ -133,6 +154,62 @@ func TestMsgApplySignupReward(t *testing.T) { } } +func TestMsgApplySignupRewardWithCap(t *testing.T) { + tApp, k, ctx := setupKeeperAndApp(t) + srv := keeper.NewMsgServerImpl(*k) + ctx = ctx.WithBlockTime(time.Now()) + wctx := sdk.WrapSDKContext(ctx) + + promoter := simapp.TestParamUsers["user1"].Address.String() + receiverAddr := simapp.TestParamUsers["user2"].Address.String() + + _, err := tApp.SubaccountKeeper.CreateSubaccount(ctx, receiverAddr, receiverAddr, []subaccounttypes.LockedBalance{ + { + Amount: sdk.ZeroInt(), + UnlockTS: uint64(ctx.BlockTime().Add(60 * time.Minute).Unix()), + }, + }) + require.NoError(t, err) + + campClaims := getDefaultClaim(promoter) + campClaims["reward_type"] = types.RewardType_REWARD_TYPE_SIGNUP + campClaims["reward_amount_type"] = types.RewardAmountType_REWARD_AMOUNT_TYPE_FIXED + campClaims["reward_amount"] = types.RewardAmount{ + SubaccountAmount: sdkmath.NewInt(100), + UnlockPeriod: uint64(ctx.BlockTime().Add(10 * time.Minute).Unix()), + } + campClaims["cap_count"] = 1 + + campUID := createCampaign(t, k, srv, ctx, promoter, campClaims, []types.CategoryCap{}) + + ticket, err := simapp.CreateJwtTicket(jwt.MapClaims{ + "exp": time.Now().Add(time.Minute * 5).Unix(), + "iat": time.Now().Unix(), + "common": types.RewardPayloadCommon{ + Receiver: receiverAddr, + SourceUID: "", + Meta: "signup reward for sample user", + KycData: &sgetypes.KycDataPayload{ + Approved: true, + ID: receiverAddr, + }, + }, + }) + require.Nil(t, err) + reward := &types.MsgGrantReward{ + Uid: uuid.NewString(), + Creator: promoter, + CampaignUid: campUID, + Ticket: ticket, + } + _, err = srv.GrantReward(wctx, reward) + require.NoError(t, err) + + reward.Uid = uuid.NewString() + _, err = srv.GrantReward(wctx, reward) + require.ErrorContains(t, err, "maximum count cap of the campaign is reached") +} + func TestMsgApplySignupRefereeReward(t *testing.T) { tApp, k, ctx := setupKeeperAndApp(t) srv := keeper.NewMsgServerImpl(*k) @@ -160,7 +237,7 @@ func TestMsgApplySignupRefereeReward(t *testing.T) { UnlockPeriod: uint64(ctx.BlockTime().Add(10 * time.Minute).Unix()), } - campUID := createCampaign(t, k, srv, ctx, promoter, campClaims) + campUID := createCampaign(t, k, srv, ctx, promoter, campClaims, defaultCategoryCap) for _, tc := range []struct { desc string @@ -184,7 +261,7 @@ func TestMsgApplySignupRefereeReward(t *testing.T) { "common": types.RewardPayloadCommon{ Receiver: receiverAddr, SourceUID: "", - Meta: "signup reward for example user", + Meta: "signup reward for sample user", }, }, err: sdkerrtypes.ErrInvalidRequest, @@ -197,7 +274,7 @@ func TestMsgApplySignupRefereeReward(t *testing.T) { "common": types.RewardPayloadCommon{ Receiver: receiverAddr, SourceUID: referrer, - Meta: "signup reward for example user", + Meta: "signup reward for sample user", KycData: &sgetypes.KycDataPayload{ Approved: true, ID: receiverAddr, @@ -253,7 +330,7 @@ func TestMsgApplySignupReferrerReward(t *testing.T) { SubaccountAmount: sdkmath.NewInt(100), UnlockPeriod: uint64(ctx.BlockTime().Add(10 * time.Minute).Unix()), } - referralSignupCampUID := createCampaign(t, k, srv, ctx, promoter, referralSignupCampClaims) + referralSignupCampUID := createCampaign(t, k, srv, ctx, promoter, referralSignupCampClaims, defaultCategoryCap) // referral campaign referralCampClaims := getDefaultClaim(promoter) @@ -264,7 +341,7 @@ func TestMsgApplySignupReferrerReward(t *testing.T) { SubaccountAmount: sdkmath.NewInt(100), UnlockPeriod: uint64(ctx.BlockTime().Add(10 * time.Minute).Unix()), } - referralCampUID := createCampaign(t, k, srv, ctx, promoter, referralCampClaims) + referralCampUID := createCampaign(t, k, srv, ctx, promoter, referralCampClaims, defaultCategoryCap) refereeClaims := jwt.MapClaims{ "exp": time.Now().Add(time.Minute * 5).Unix(), @@ -272,7 +349,7 @@ func TestMsgApplySignupReferrerReward(t *testing.T) { "common": types.RewardPayloadCommon{ Receiver: referee, SourceUID: referrer, - Meta: "signup reward for example user", + Meta: "signup reward for sample user", KycData: &sgetypes.KycDataPayload{ Approved: true, ID: referee, @@ -290,7 +367,7 @@ func TestMsgApplySignupReferrerReward(t *testing.T) { _, err = srv.GrantReward(wctx, reward) require.NoError(t, err) - rewardGrant, err := k.GetRewardsByAddressAndCategory(ctx, referee, types.RewardCategory_REWARD_CATEGORY_SIGNUP) + rewardGrant, err := k.GetRewardsOfReceiverByPromoterAndCategory(ctx, promoterUID, referee, types.RewardCategory_REWARD_CATEGORY_SIGNUP) require.NoError(t, err) require.Equal(t, types.RewardByCategory{ UID: reward.Uid, @@ -298,7 +375,7 @@ func TestMsgApplySignupReferrerReward(t *testing.T) { RewardCategory: types.RewardCategory_REWARD_CATEGORY_SIGNUP, }, rewardGrant[0]) - require.True(t, k.HasRewardByReceiver(ctx, referee, types.RewardCategory_REWARD_CATEGORY_SIGNUP)) + require.True(t, k.HasRewardOfReceiverByPromoter(ctx, promoterUID, referee, types.RewardCategory_REWARD_CATEGORY_SIGNUP)) for _, tc := range []struct { desc string @@ -322,7 +399,7 @@ func TestMsgApplySignupReferrerReward(t *testing.T) { "common": types.RewardPayloadCommon{ Receiver: receiverAddr, SourceUID: "", - Meta: "signup reward for example user", + Meta: "signup reward for sample user", }, "referee": "invalid", }, @@ -336,7 +413,7 @@ func TestMsgApplySignupReferrerReward(t *testing.T) { "common": types.RewardPayloadCommon{ Receiver: receiverAddr, SourceUID: "", - Meta: "signup reward for example user", + Meta: "signup reward for sample user", KycData: &sgetypes.KycDataPayload{ Approved: true, ID: receiverAddr, @@ -392,7 +469,7 @@ func TestMsgApplySignupAffiliateReward(t *testing.T) { UnlockPeriod: uint64(ctx.BlockTime().Add(10 * time.Minute).Unix()), } - campUID := createCampaign(t, k, srv, ctx, promoter, campClaims) + campUID := createCampaign(t, k, srv, ctx, promoter, campClaims, defaultCategoryCap) for _, tc := range []struct { desc string @@ -416,7 +493,7 @@ func TestMsgApplySignupAffiliateReward(t *testing.T) { "common": types.RewardPayloadCommon{ Receiver: receiverAddr, SourceUID: "", - Meta: "signup reward for example user", + Meta: "signup reward for sample user", }, }, err: sdkerrtypes.ErrInvalidRequest, @@ -429,7 +506,7 @@ func TestMsgApplySignupAffiliateReward(t *testing.T) { "common": types.RewardPayloadCommon{ Receiver: receiverAddr, SourceUID: leadGen, - Meta: "signup reward for example user", + Meta: "signup reward for sample user", KycData: &sgetypes.KycDataPayload{ Approved: true, ID: receiverAddr, @@ -485,7 +562,7 @@ func TestMsgApplySignupAffiliateeReward(t *testing.T) { SubaccountAmount: sdkmath.NewInt(100), UnlockPeriod: uint64(ctx.BlockTime().Add(10 * time.Minute).Unix()), } - affiliateSignupCampUID := createCampaign(t, k, srv, ctx, promoter, affiliateSignupCampClaims) + affiliateSignupCampUID := createCampaign(t, k, srv, ctx, promoter, affiliateSignupCampClaims, defaultCategoryCap) // affiliate campaign affiliateCampClaims := getDefaultClaim(promoter) @@ -496,7 +573,7 @@ func TestMsgApplySignupAffiliateeReward(t *testing.T) { MainAccountAmount: sdkmath.NewInt(100), UnlockPeriod: 0, } - affiliateCampUID := createCampaign(t, k, srv, ctx, promoter, affiliateCampClaims) + affiliateCampUID := createCampaign(t, k, srv, ctx, promoter, affiliateCampClaims, defaultCategoryCap) affiliateClaims := jwt.MapClaims{ "exp": time.Now().Add(time.Minute * 5).Unix(), @@ -504,7 +581,7 @@ func TestMsgApplySignupAffiliateeReward(t *testing.T) { "common": types.RewardPayloadCommon{ Receiver: affiliatee, SourceUID: affiliator, - Meta: "signup reward for example user", + Meta: "signup reward for sample user", KycData: &sgetypes.KycDataPayload{ Approved: true, ID: affiliatee, @@ -522,7 +599,7 @@ func TestMsgApplySignupAffiliateeReward(t *testing.T) { _, err = srv.GrantReward(wctx, reward) require.NoError(t, err) - rewardGrant, err := k.GetRewardsByAddressAndCategory(ctx, affiliatee, types.RewardCategory_REWARD_CATEGORY_SIGNUP) + rewardGrant, err := k.GetRewardsOfReceiverByPromoterAndCategory(ctx, promoterUID, affiliatee, types.RewardCategory_REWARD_CATEGORY_SIGNUP) require.NoError(t, err) require.Equal(t, types.RewardByCategory{ UID: reward.Uid, @@ -530,7 +607,7 @@ func TestMsgApplySignupAffiliateeReward(t *testing.T) { RewardCategory: types.RewardCategory_REWARD_CATEGORY_SIGNUP, }, rewardGrant[0]) - require.True(t, k.HasRewardByReceiver(ctx, affiliatee, types.RewardCategory_REWARD_CATEGORY_SIGNUP)) + require.True(t, k.HasRewardOfReceiverByPromoter(ctx, promoterUID, affiliatee, types.RewardCategory_REWARD_CATEGORY_SIGNUP)) for _, tc := range []struct { desc string @@ -554,7 +631,7 @@ func TestMsgApplySignupAffiliateeReward(t *testing.T) { "common": types.RewardPayloadCommon{ Receiver: receiverAddr, SourceUID: "", - Meta: "signup reward for example user", + Meta: "signup reward for sample user", }, "affiliatee": "invalid", }, @@ -568,7 +645,7 @@ func TestMsgApplySignupAffiliateeReward(t *testing.T) { "common": types.RewardPayloadCommon{ Receiver: receiverAddr, SourceUID: "", - Meta: "signup reward for example user", + Meta: "signup reward for sample user", KycData: &sgetypes.KycDataPayload{ Approved: true, ID: receiverAddr, @@ -597,6 +674,150 @@ func TestMsgApplySignupAffiliateeReward(t *testing.T) { } } +func TestMsgApplyBetBonus(t *testing.T) { + tApp, k, ctx := setupKeeperAndApp(t) + srv := keeper.NewMsgServerImpl(*k) + ctx = ctx.WithBlockTime(time.Now()) + wctx := sdk.WrapSDKContext(ctx) + + promoter := simapp.TestParamUsers["user1"].Address.String() + bettor := simapp.TestParamUsers["user2"].Address.String() + + bet := bettypes.Bet{ + Creator: bettor, + UID: uuid.NewString(), + MarketUID: uuid.NewString(), + Amount: sdkmath.NewInt(301), + Result: bettypes.Bet_RESULT_LOST, + Status: bettypes.Bet_STATUS_SETTLED, + Meta: bettypes.MetaData{ + IsMainMarket: true, + }, + } + tApp.BetKeeper.SetBet(ctx, bet, 1) + + _, err := tApp.SubaccountKeeper.CreateSubaccount(ctx, bettor, bettor, []subaccounttypes.LockedBalance{ + { + Amount: sdk.ZeroInt(), + UnlockTS: uint64(ctx.BlockTime().Add(60 * time.Minute).Unix()), + }, + }) + require.NoError(t, err) + + // referral signup campaign + betBonusCampClaims := getDefaultClaim(promoter) + betBonusCampClaims["category"] = types.RewardCategory_REWARD_CATEGORY_BET_DISCOUNT + betBonusCampClaims["reward_type"] = types.RewardType_REWARD_TYPE_BET_DISCOUNT + betBonusCampClaims["reward_amount_type"] = types.RewardAmountType_REWARD_AMOUNT_TYPE_PERCENTAGE + betBonusCampClaims["reward_amount"] = types.RewardAmount{ + MainAccountAmount: sdkmath.NewInt(10), + UnlockPeriod: 0, + } + betBonusCampClaims["constraints"] = types.CampaignConstraints{ + MaxBetAmount: sdkmath.NewInt(300), + } + betBonusCampUID := createCampaign(t, k, srv, ctx, promoter, betBonusCampClaims, defaultCategoryCap) + + betBonusClaims := jwt.MapClaims{ + "exp": time.Now().Add(time.Minute * 5).Unix(), + "iat": time.Now().Unix(), + "common": types.RewardPayloadCommon{ + Receiver: bettor, + SourceUID: "", + Meta: "bet bonus reward for sample user", + KycData: &sgetypes.KycDataPayload{ + Approved: true, + ID: bettor, + }, + }, + "bet_uid": bet.UID, + } + betBonusTicket, err := simapp.CreateJwtTicket(betBonusClaims) + require.Nil(t, err) + reward := &types.MsgGrantReward{ + Uid: uuid.NewString(), + Creator: promoter, + CampaignUid: betBonusCampUID, + Ticket: betBonusTicket, + } + _, err = srv.GrantReward(wctx, reward) + require.NoError(t, err) + + rewardGrant, err := k.GetRewardsOfReceiverByPromoterAndCategory(ctx, promoterUID, bettor, types.RewardCategory_REWARD_CATEGORY_BET_DISCOUNT) + require.NoError(t, err) + require.Equal(t, types.RewardByCategory{ + UID: reward.Uid, + Addr: bettor, + RewardCategory: types.RewardCategory_REWARD_CATEGORY_BET_DISCOUNT, + }, rewardGrant[0]) + + require.True(t, k.HasRewardOfReceiverByPromoter(ctx, promoterUID, bettor, types.RewardCategory_REWARD_CATEGORY_BET_DISCOUNT)) + + for _, tc := range []struct { + desc string + claims jwt.MapClaims + err error + }{ + { + desc: "invalid ticket", + claims: jwt.MapClaims{ + "exp": time.Now().Add(time.Minute * 5).Unix(), + "iat": time.Now().Unix(), + "common": "invalid", + }, + err: types.ErrInTicketVerification, + }, + { + desc: "invalid bettor", + claims: jwt.MapClaims{ + "exp": time.Now().Add(time.Minute * 5).Unix(), + "iat": time.Now().Unix(), + "common": types.RewardPayloadCommon{ + Receiver: bettor, + SourceUID: "", + Meta: "bet bonus reward for sample user", + }, + "bet_uid": "invalid", + }, + err: sdkerrtypes.ErrInvalidRequest, + }, + { + desc: "valid", + claims: jwt.MapClaims{ + "exp": time.Now().Add(time.Minute * 5).Unix(), + "iat": time.Now().Unix(), + "common": types.RewardPayloadCommon{ + Receiver: bettor, + SourceUID: "", + Meta: "bet bonus reward for sample user", + KycData: &sgetypes.KycDataPayload{ + Approved: true, + ID: bettor, + }, + }, + "bet_uid": bet.UID, + }, + }, + } { + t.Run(tc.desc, func(t *testing.T) { + ticket, err := simapp.CreateJwtTicket(tc.claims) + require.Nil(t, err) + reward := &types.MsgGrantReward{ + Uid: uuid.NewString(), + Creator: promoter, + CampaignUid: betBonusCampUID, + Ticket: ticket, + } + _, err = srv.GrantReward(wctx, reward) + if tc.err != nil { + require.ErrorContains(t, err, tc.err.Error()) + } else { + require.NoError(t, err) + } + }) + } +} + func TestMsgApplySignupRewardSubaccount(t *testing.T) { tApp, k, ctx := setupKeeperAndApp(t) srv := keeper.NewMsgServerImpl(*k) @@ -614,7 +835,7 @@ func TestMsgApplySignupRewardSubaccount(t *testing.T) { UnlockPeriod: uint64(ctx.BlockTime().Add(10 * time.Minute).Unix()), } - campUID := createCampaign(t, k, srv, ctx, promoter, campClaims) + campUID := createCampaign(t, k, srv, ctx, promoter, campClaims, defaultCategoryCap) _, err := tApp.SubaccountKeeper.CreateSubaccount(ctx, receiverAddr, receiverAddr, []subaccounttypes.LockedBalance{ { @@ -646,7 +867,7 @@ func TestMsgApplySignupRewardSubaccount(t *testing.T) { "common": types.RewardPayloadCommon{ Receiver: "invalid", SourceUID: "source id", - Meta: "signup reward for example user", + Meta: "signup reward for sample user", KycData: &sgetypes.KycDataPayload{ Approved: false, ID: "", @@ -664,7 +885,7 @@ func TestMsgApplySignupRewardSubaccount(t *testing.T) { "common": types.RewardPayloadCommon{ Receiver: sample.AccAddress(), SourceUID: "source id", - Meta: "signup reward for example user", + Meta: "signup reward for sample user", KycData: &sgetypes.KycDataPayload{ Approved: false, ID: "", @@ -681,7 +902,7 @@ func TestMsgApplySignupRewardSubaccount(t *testing.T) { "common": types.RewardPayloadCommon{ Receiver: receiverAddr, SourceUID: "source id", - Meta: "signup reward for example user", + Meta: "signup reward for sample user", KycData: &sgetypes.KycDataPayload{ Approved: true, ID: receiverAddr, @@ -729,7 +950,7 @@ func TestMsgApplySubaccountFunds(t *testing.T) { UnlockPeriod: uint64(ctx.BlockTime().Add(10 * time.Minute).Unix()), } - campUID := createCampaign(t, k, srv, ctx, promoter, campClaims) + campUID := createCampaign(t, k, srv, ctx, promoter, campClaims, defaultCategoryCap) claims := jwt.MapClaims{ "exp": time.Now().Add(time.Minute * 5).Unix(), @@ -737,7 +958,7 @@ func TestMsgApplySubaccountFunds(t *testing.T) { "common": types.RewardPayloadCommon{ Receiver: receiverAddr, SourceUID: "source id", - Meta: "signup reward for example user", + Meta: "signup reward for sample user", KycData: &sgetypes.KycDataPayload{ Approved: true, ID: receiverAddr, diff --git a/x/reward/keeper/promoter.go b/x/reward/keeper/promoter.go new file mode 100644 index 00000000..c9f14cee --- /dev/null +++ b/x/reward/keeper/promoter.go @@ -0,0 +1,71 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/sge-network/sge/x/reward/types" +) + +// SetPromoter set a specific promoter in the store from its index +func (k Keeper) SetPromoter(ctx sdk.Context, promoter types.Promoter) { + store := k.getPromoterStore(ctx) + b := k.cdc.MustMarshal(&promoter) + store.Set(types.GetPromoterKey(promoter.UID), b) +} + +// GetPromoter returns a promoter, +func (k Keeper) GetPromoter( + ctx sdk.Context, + uid string, +) (val types.Promoter, found bool) { + store := k.getPromoterStore(ctx) + + b := store.Get(types.GetPromoterKey(uid)) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +// GetAllPromoter returns all promoters +func (k Keeper) GetAllPromoter(ctx sdk.Context) (list []types.Promoter) { + store := k.getPromoterStore(ctx) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.Promoter + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} + +// SetPromoterByAddress set a specific promoter in the store from its address +func (k Keeper) SetPromoterByAddress(ctx sdk.Context, promoterByAddress types.PromoterByAddress) { + store := k.getPromoterByAddressStore(ctx) + b := k.cdc.MustMarshal(&promoterByAddress) + store.Set(types.GetPromoterByAddressKey(promoterByAddress.Address), b) +} + +// GetPromoter returns a promoter, +func (k Keeper) GetPromoterByAddress(ctx sdk.Context, address string) (val types.PromoterByAddress, found bool) { + store := k.getPromoterByAddressStore(ctx) + + b := store.Get(types.GetPromoterByAddressKey(address)) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +// IsPromoter returns true if there is a promoter with address +func (k Keeper) IsPromoter(ctx sdk.Context, address string) bool { + store := k.getPromoterByAddressStore(ctx) + return store.Has(types.GetPromoterByAddressKey(address)) +} diff --git a/x/reward/keeper/query_promoter.go b/x/reward/keeper/query_promoter.go new file mode 100644 index 00000000..dfedf679 --- /dev/null +++ b/x/reward/keeper/query_promoter.go @@ -0,0 +1,64 @@ +package keeper + +import ( + "context" + + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/sge-network/sge/x/reward/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) Promoters(goCtx context.Context, req *types.QueryPromotersRequest) (*types.QueryPromotersResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + var promoters []types.Promoter + ctx := sdk.UnwrapSDKContext(goCtx) + + store := ctx.KVStore(k.storeKey) + promoterStore := prefix.NewStore(store, types.PromoterKeyPrefix) + + pageRes, err := query.Paginate(promoterStore, req.Pagination, func(key []byte, value []byte) error { + var promoter types.Promoter + if err := k.cdc.Unmarshal(value, &promoter); err != nil { + return err + } + + promoters = append(promoters, promoter) + return nil + }) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryPromotersResponse{Promoter: promoters, Pagination: pageRes}, nil +} + +func (k Keeper) PromoterByAddress(goCtx context.Context, req *types.QueryPromoterByAddressRequest) (*types.QueryPromoterByAddressResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + promoterByAddress, found := k.GetPromoterByAddress( + ctx, + req.Addr, + ) + if !found { + return nil, status.Error(codes.NotFound, "promoter with the provided address not found") + } + + promoter, found := k.GetPromoter( + ctx, + promoterByAddress.PromoterUID, + ) + if !found { + return nil, status.Error(codes.NotFound, "promoter with the provided uid found") + } + + return &types.QueryPromoterByAddressResponse{Promoter: promoter}, nil +} diff --git a/x/reward/keeper/query_reward.go b/x/reward/keeper/query_reward.go index c1d2545e..8ea7acba 100644 --- a/x/reward/keeper/query_reward.go +++ b/x/reward/keeper/query_reward.go @@ -64,7 +64,7 @@ func (k Keeper) RewardsByAddress(goCtx context.Context, req *types.QueryRewardsB ctx := sdk.UnwrapSDKContext(goCtx) store := k.getRewardByReceiverAndCategoryStore(ctx) - rewardStore := prefix.NewStore(store, types.GetRewardsByAccPrefix(req.Address)) + rewardStore := prefix.NewStore(store, types.GetRewardsOfReceiverByPromoterPrefix(req.PromoterUid, req.Address)) pageRes, err := query.Paginate(rewardStore, req.Pagination, func(key []byte, value []byte) error { var reward types.RewardByCategory @@ -91,7 +91,7 @@ func (k Keeper) RewardsByAddressAndCategory(goCtx context.Context, req *types.Qu ctx := sdk.UnwrapSDKContext(goCtx) store := k.getRewardByReceiverAndCategoryStore(ctx) - rewardStore := prefix.NewStore(store, types.GetRewardsByCategoryPrefix(req.Address, req.Category)) + rewardStore := prefix.NewStore(store, types.GetRewardsOfReceiverByPromoterAndCategoryPrefix(req.PromoterUid, req.Address, req.Category)) pageRes, err := query.Paginate(rewardStore, req.Pagination, func(key []byte, value []byte) error { var reward types.RewardByCategory diff --git a/x/reward/keeper/reward.go b/x/reward/keeper/reward.go index 48a4151e..28473a72 100644 --- a/x/reward/keeper/reward.go +++ b/x/reward/keeper/reward.go @@ -2,6 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/sge-network/sge/utils" "github.com/sge-network/sge/x/reward/types" ) @@ -53,20 +54,20 @@ func (k Keeper) GetAllRewards(ctx sdk.Context) (list []types.Reward) { return } -func (k Keeper) SetRewardByReceiver(ctx sdk.Context, rByCategory types.RewardByCategory) { +func (k Keeper) SetRewardOfReceiverByPromoterAndCategory(ctx sdk.Context, promoterUID string, rByCategory types.RewardByCategory) { store := k.getRewardByReceiverAndCategoryStore(ctx) b := k.cdc.MustMarshal(&rByCategory) - store.Set(types.GetRewardsByCategoryKey(rByCategory.Addr, rByCategory.RewardCategory, rByCategory.UID), b) + store.Set(types.GetRewardsOfReceiverByPromoterAndCategoryKey(promoterUID, rByCategory.Addr, rByCategory.RewardCategory, rByCategory.UID), b) } -// GetRewardsByAddressAndCategory returns all rewards by address and category. -func (k Keeper) GetRewardsByAddressAndCategory( +// GetRewardsOfReceiverByPromoterAndCategory returns all rewards by address and category. +func (k Keeper) GetRewardsOfReceiverByPromoterAndCategory( ctx sdk.Context, - addr string, + promoterUID, addr string, category types.RewardCategory, ) (list []types.RewardByCategory, err error) { store := k.getRewardByReceiverAndCategoryStore(ctx) - iterator := sdk.KVStorePrefixIterator(store, types.GetRewardsByCategoryPrefix(addr, category)) + iterator := sdk.KVStorePrefixIterator(store, types.GetRewardsOfReceiverByPromoterAndCategoryPrefix(promoterUID, addr, category)) defer func() { err = iterator.Close() @@ -82,8 +83,8 @@ func (k Keeper) GetRewardsByAddressAndCategory( } // HasRewardByReceiver returns true if there is a record for the category and reward receiver -func (k Keeper) HasRewardByReceiver(ctx sdk.Context, addr string, category types.RewardCategory) bool { - rewardsByCat, err := k.GetRewardsByAddressAndCategory(ctx, addr, category) +func (k Keeper) HasRewardOfReceiverByPromoter(ctx sdk.Context, promoterUID, addr string, category types.RewardCategory) bool { + rewardsByCat, err := k.GetRewardsOfReceiverByPromoterAndCategory(ctx, promoterUID, addr, category) if err != nil || len(rewardsByCat) > 0 { return true } @@ -127,3 +128,20 @@ func (k Keeper) GetAllRewardsByCampaign(ctx sdk.Context) (list []types.RewardByC return } + +func (k Keeper) SetRewardGrantsStats(ctx sdk.Context, campaignUID, accAddr string, count uint64) { + store := k.getRewardGrantsStatStore(ctx) + b := utils.Uint64ToBytes(count) + store.Set(types.GetRewardGrantStatKey(campaignUID, accAddr), b) +} + +func (k Keeper) GetRewardGrantsStats(ctx sdk.Context, campaignUID, accAddr string) (val uint64, found bool) { + store := k.getRewardGrantsStatStore(ctx) + b := store.Get(types.GetRewardGrantStatKey(campaignUID, accAddr)) + if b == nil { + return val, false + } + + val = utils.Uint64FromBytes(b) + return val, true +} diff --git a/x/reward/keeper/view.go b/x/reward/keeper/view.go index be5119bc..273f7d92 100644 --- a/x/reward/keeper/view.go +++ b/x/reward/keeper/view.go @@ -30,3 +30,21 @@ func (k Keeper) getRewardsByCampaignStore(ctx sdk.Context) prefix.Store { store := ctx.KVStore(k.storeKey) return prefix.NewStore(store, types.RewardByCampaignKeyPrefix) } + +// getPromoterByAddressStore gets the store containing all promoter by address. +func (k Keeper) getPromoterByAddressStore(ctx sdk.Context) prefix.Store { + store := ctx.KVStore(k.storeKey) + return prefix.NewStore(store, types.PromoterAddressKeyPrefix) +} + +// getPromoterStore gets the store containing all promoters. +func (k Keeper) getPromoterStore(ctx sdk.Context) prefix.Store { + store := ctx.KVStore(k.storeKey) + return prefix.NewStore(store, types.PromoterKeyPrefix) +} + +// getRewardGrantsStatStore gets the store containing all reward grant stats. +func (k Keeper) getRewardGrantsStatStore(ctx sdk.Context) prefix.Store { + store := ctx.KVStore(k.storeKey) + return prefix.NewStore(store, types.RewardGrantStatKeyPrefix) +} diff --git a/x/reward/types/authz.pb.go b/x/reward/types/authz.pb.go index 1a72f80f..d932f1c1 100644 --- a/x/reward/types/authz.pb.go +++ b/x/reward/types/authz.pb.go @@ -105,6 +105,8 @@ var xxx_messageInfo_UpdateCampaignAuthorization proto.InternalMessageInfo // WithdrawCampaignAuthorization allows the grantee to withdraw remaining // pool balance of the campaign from the granter's account. type WithdrawCampaignAuthorization struct { + // withdraw_limit is the maximum limit of the withdrawal by authorization. + WithdrawLimit cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=withdraw_limit,json=withdrawLimit,proto3,customtype=cosmossdk.io/math.Int" json:"withdraw_limit"` } func (m *WithdrawCampaignAuthorization) Reset() { *m = WithdrawCampaignAuthorization{} } @@ -149,23 +151,24 @@ func init() { func init() { proto.RegisterFile("sge/reward/authz.proto", fileDescriptor_4c01411aa0c16fcd) } var fileDescriptor_4c01411aa0c16fcd = []byte{ - // 252 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x90, 0x31, 0x4b, 0x03, 0x31, - 0x18, 0x86, 0xef, 0x16, 0xc1, 0x73, 0x2b, 0x56, 0x44, 0x69, 0x4e, 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, 0x1d, 0xcb, 0x1e, 0xcf, 0xb5, 0x25, 0x53, 0xcf, 0xf8, 0x1c, 0x9d, 0x48, 0x1a, 0x2e, 0x7e, - 0x8c, 0xf5, 0x59, 0xbc, 0xfe, 0x6a, 0xa5, 0xb7, 0x00, 0x69, 0xb6, 0x33, 0xa8, 0xba, 0xfc, 0x0e, - 0x00, 0x00, 0xff, 0xff, 0x16, 0xa5, 0x07, 0x9a, 0x71, 0x01, 0x00, 0x00, + // 268 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x91, 0xb1, 0x4a, 0x03, 0x41, + 0x10, 0x86, 0xef, 0x1a, 0xc1, 0x15, 0x2d, 0x82, 0x11, 0x51, 0xb2, 0x11, 0x2b, 0x2d, 0xdc, 0x2d, + 0xec, 0x05, 0x73, 0x36, 0x82, 0x95, 0x20, 0x82, 0x20, 0xb2, 0xc9, 0x0d, 0x7b, 0x4b, 0xdc, 0x9d, + 0x65, 0x77, 0x8e, 0xd3, 0x3c, 0x85, 0x8f, 0x95, 0x32, 0xa5, 0x58, 0x04, 0xb9, 0x7b, 0x11, 0xb9, + 0x4b, 0xd2, 0xd9, 0x58, 0xd8, 0x4d, 0xf1, 0xfd, 0xff, 0x07, 0xff, 0xb0, 0x83, 0xa8, 0x41, 0x06, + 0xa8, 0x54, 0xc8, 0xa5, 0x2a, 0xa9, 0x98, 0x09, 0x1f, 0x90, 0xb0, 0xd7, 0x8f, 0x1a, 0x1c, 0x50, + 0x85, 0x61, 0x2a, 0xa2, 0x06, 0xb1, 0x42, 0x8e, 0xf6, 0x35, 0x6a, 0xec, 0x08, 0xd9, 0x5e, 0x2b, + 0xf8, 0xf4, 0x99, 0x1d, 0x67, 0x01, 0x14, 0x41, 0xa6, 0xac, 0x57, 0x46, 0xbb, 0xeb, 0x92, 0x0a, + 0x0c, 0x66, 0xa6, 0xc8, 0xa0, 0xeb, 0x5d, 0xb1, 0x9d, 0xe8, 0xc1, 0xe5, 0x2f, 0xaf, 0xc6, 0x1a, + 0x3a, 0x4c, 0x4f, 0xd2, 0xb3, 0xed, 0xd1, 0x60, 0xbe, 0x1c, 0x26, 0x5f, 0xcb, 0x61, 0x7f, 0x82, + 0xd1, 0x62, 0x8c, 0xf9, 0x54, 0x18, 0x94, 0x56, 0x51, 0x21, 0x6e, 0x1d, 0xdd, 0xb3, 0x2e, 0x71, + 0xd7, 0x06, 0xda, 0xfa, 0x07, 0x9f, 0xff, 0x5b, 0x3d, 0xb0, 0xc1, 0xa3, 0xa1, 0x22, 0x0f, 0xaa, + 0xfa, 0x5d, 0x70, 0xc3, 0xf6, 0xaa, 0x35, 0xf0, 0x17, 0xc7, 0xee, 0x26, 0xd4, 0x69, 0x46, 0xd9, + 0xbc, 0xe6, 0xe9, 0xa2, 0xe6, 0xe9, 0x77, 0xcd, 0xd3, 0x8f, 0x86, 0x27, 0x8b, 0x86, 0x27, 0x9f, + 0x0d, 0x4f, 0x9e, 0xce, 0xb5, 0xa1, 0xa2, 0x1c, 0x8b, 0x09, 0x5a, 0x19, 0x35, 0x5c, 0xac, 0x77, + 0x6f, 0x6f, 0xf9, 0xb6, 0x79, 0x0e, 0xbd, 0x7b, 0x88, 0xe3, 0xad, 0x6e, 0xf0, 0xcb, 0x9f, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x7e, 0x60, 0xa2, 0x52, 0xb7, 0x01, 0x00, 0x00, } func (m *CreateCampaignAuthorization) Marshal() (dAtA []byte, err error) { @@ -254,6 +257,16 @@ func (m *WithdrawCampaignAuthorization) MarshalToSizedBuffer(dAtA []byte) (int, _ = i var l int _ = l + { + size := m.WithdrawLimit.Size() + i -= size + if _, err := m.WithdrawLimit.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintAuthz(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -296,6 +309,8 @@ func (m *WithdrawCampaignAuthorization) Size() (n int) { } var l int _ = l + l = m.WithdrawLimit.Size() + n += 1 + l + sovAuthz(uint64(l)) return n } @@ -502,6 +517,40 @@ func (m *WithdrawCampaignAuthorization) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: WithdrawCampaignAuthorization: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WithdrawLimit", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthz + } + 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 ErrInvalidLengthAuthz + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAuthz + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.WithdrawLimit.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipAuthz(dAtA[iNdEx:]) diff --git a/x/reward/types/campaign.go b/x/reward/types/campaign.go index f61a9aa7..e5bfd3cc 100644 --- a/x/reward/types/campaign.go +++ b/x/reward/types/campaign.go @@ -7,7 +7,7 @@ import ( func NewCampaign( creator, promoter, uID string, - startTS, endTS, claimsPerCategory uint64, + startTS, endTS uint64, rewardType RewardType, rewardCategory RewardCategory, rewardAmountType RewardAmountType, @@ -15,21 +15,24 @@ func NewCampaign( isActive bool, meta string, pool Pool, + capCount uint64, + constraint *CampaignConstraints, ) Campaign { return Campaign{ - Creator: creator, - Promoter: promoter, - UID: uID, - StartTS: startTS, - EndTS: endTS, - RewardCategory: rewardCategory, - RewardType: rewardType, - RewardAmountType: rewardAmountType, - RewardAmount: rewardAmount, - IsActive: isActive, - Meta: meta, - Pool: pool, - ClaimsPerCategory: claimsPerCategory, + Creator: creator, + Promoter: promoter, + UID: uID, + StartTS: startTS, + EndTS: endTS, + RewardCategory: rewardCategory, + RewardType: rewardType, + RewardAmountType: rewardAmountType, + RewardAmount: rewardAmount, + IsActive: isActive, + Meta: meta, + Pool: pool, + CapCount: capCount, + Constraints: constraint, } } @@ -46,6 +49,8 @@ func (c *Campaign) GetRewardsFactory() (IRewardFactory, error) { return NewSignUpAffiliateeReward(), nil case RewardType_REWARD_TYPE_AFFILIATE: return NewSignUpAffiliatorReward(), nil + case RewardType_REWARD_TYPE_BET_DISCOUNT: + return NewBetBonusReward(), 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 b1249d6a..d0b1e15e 100644 --- a/x/reward/types/campaign.pb.go +++ b/x/reward/types/campaign.pb.go @@ -49,12 +49,13 @@ type Campaign struct { Pool Pool `protobuf:"bytes,10,opt,name=pool,proto3" json:"pool"` // is_active is the flag to check if the campaign is active or not. IsActive bool `protobuf:"varint,11,opt,name=is_active,json=isActive,proto3" json:"is_active,omitempty"` - // claims_per_category is the number of times a user can claim a - // reward for category of this campaign. - ClaimsPerCategory uint64 `protobuf:"varint,12,opt,name=claims_per_category,json=claimsPerCategory,proto3" json:"claims_per_category,omitempty"` // meta is the metadata of the campaign. // It is a stringified base64 encoded json. Meta string `protobuf:"bytes,13,opt,name=meta,proto3" json:"meta,omitempty"` + // cap_count is the maximum allowed grant for a certain account. + CapCount uint64 `protobuf:"varint,14,opt,name=cap_count,json=capCount,proto3" json:"cap_count,omitempty"` + // constraints is the constrains of a campaign. + Constraints *CampaignConstraints `protobuf:"bytes,15,opt,name=constraints,proto3" json:"constraints,omitempty"` } func (m *Campaign) Reset() { *m = Campaign{} } @@ -167,24 +168,32 @@ func (m *Campaign) GetIsActive() bool { return false } -func (m *Campaign) GetClaimsPerCategory() uint64 { +func (m *Campaign) GetMeta() string { + if m != nil { + return m.Meta + } + return "" +} + +func (m *Campaign) GetCapCount() uint64 { if m != nil { - return m.ClaimsPerCategory + return m.CapCount } return 0 } -func (m *Campaign) GetMeta() string { +func (m *Campaign) GetConstraints() *CampaignConstraints { if m != nil { - return m.Meta + return m.Constraints } - return "" + return nil } // Pool tracks funds assigned and spent to/for a campaign. type Pool struct { - Total cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=total,proto3,customtype=cosmossdk.io/math.Int" json:"total" yaml:"total"` - Spent cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=spent,proto3,customtype=cosmossdk.io/math.Int" json:"spent" yaml:"spent"` + Total cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=total,proto3,customtype=cosmossdk.io/math.Int" json:"total" yaml:"total"` + Spent cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=spent,proto3,customtype=cosmossdk.io/math.Int" json:"spent" yaml:"spent"` + Withdrawn cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=withdrawn,proto3,customtype=cosmossdk.io/math.Int" json:"withdrawn" yaml:"spent"` } func (m *Pool) Reset() { *m = Pool{} } @@ -220,50 +229,93 @@ func (m *Pool) XXX_DiscardUnknown() { var xxx_messageInfo_Pool proto.InternalMessageInfo +// CampaignConstraints contains campaign constraints and criteria. +type CampaignConstraints struct { + MaxBetAmount cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=max_bet_amount,json=maxBetAmount,proto3,customtype=cosmossdk.io/math.Int" json:"max_bet_amount" yaml:"max_bet_amount"` +} + +func (m *CampaignConstraints) Reset() { *m = CampaignConstraints{} } +func (m *CampaignConstraints) String() string { return proto.CompactTextString(m) } +func (*CampaignConstraints) ProtoMessage() {} +func (*CampaignConstraints) Descriptor() ([]byte, []int) { + return fileDescriptor_6d1d1b3139567e36, []int{2} +} +func (m *CampaignConstraints) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CampaignConstraints) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CampaignConstraints.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 *CampaignConstraints) XXX_Merge(src proto.Message) { + xxx_messageInfo_CampaignConstraints.Merge(m, src) +} +func (m *CampaignConstraints) XXX_Size() int { + return m.Size() +} +func (m *CampaignConstraints) XXX_DiscardUnknown() { + xxx_messageInfo_CampaignConstraints.DiscardUnknown(m) +} + +var xxx_messageInfo_CampaignConstraints proto.InternalMessageInfo + func init() { proto.RegisterType((*Campaign)(nil), "sgenetwork.sge.reward.Campaign") proto.RegisterType((*Pool)(nil), "sgenetwork.sge.reward.Pool") + proto.RegisterType((*CampaignConstraints)(nil), "sgenetwork.sge.reward.CampaignConstraints") } func init() { proto.RegisterFile("sge/reward/campaign.proto", fileDescriptor_6d1d1b3139567e36) } var fileDescriptor_6d1d1b3139567e36 = []byte{ - // 545 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0x4f, 0x6f, 0xd3, 0x3c, - 0x1c, 0xc7, 0x9b, 0xa7, 0x69, 0x9b, 0xba, 0x5d, 0x1f, 0xf0, 0x98, 0x66, 0x3a, 0x29, 0x09, 0x45, - 0x88, 0x22, 0xb4, 0x44, 0xda, 0xc4, 0x85, 0xdb, 0x52, 0x90, 0xd8, 0x05, 0x4d, 0xde, 0x76, 0xe1, - 0x52, 0x79, 0xa9, 0x95, 0x45, 0x6b, 0xe2, 0xc8, 0x76, 0x19, 0x7d, 0x17, 0xe3, 0x5d, 0xed, 0xb8, - 0x23, 0xe2, 0x10, 0xa1, 0xf4, 0xb6, 0x23, 0xaf, 0x00, 0xd9, 0xc9, 0xc2, 0x86, 0x60, 0xda, 0x25, - 0xfe, 0xfd, 0xf9, 0x7e, 0x3f, 0x49, 0xec, 0x9f, 0xc1, 0x53, 0x11, 0x51, 0x9f, 0xd3, 0x73, 0xc2, - 0x67, 0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x97, - 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, + // 623 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0xc1, 0x4f, 0xdb, 0x3e, + 0x14, 0xc7, 0x9b, 0x1f, 0x2d, 0xa4, 0x2e, 0x94, 0x9f, 0xcc, 0x10, 0x1e, 0x48, 0x4d, 0x97, 0x69, + 0x5a, 0xb7, 0x89, 0x54, 0x02, 0x6d, 0x87, 0xdd, 0x48, 0x36, 0x69, 0x68, 0xd3, 0x34, 0x19, 0xb8, + 0x4c, 0x93, 0x2a, 0x93, 0x58, 0x21, 0xa2, 0x89, 0x23, 0xdb, 0xac, 0xf4, 0xbf, 0xd8, 0x9f, 0xc5, + 0x61, 0x07, 0x8e, 0xd3, 0xa4, 0x45, 0x53, 0xb8, 0x71, 0xdc, 0x5f, 0x30, 0xd9, 0x4e, 0x0b, 0x4c, + 0xc0, 0xd8, 0x25, 0x7e, 0xef, 0xf9, 0x7d, 0x3f, 0x7e, 0xb6, 0x5f, 0x0c, 0xee, 0x8b, 0x98, 0xf6, + 0x39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, + 0x44, 0x87, 0x5e, 0xc2, 0xfa, 0x29, 0x91, 0x07, 0xde, 0x76, 0x26, 0x7f, 0x15, 0xce, 0xfc, 0x98, + 0xa4, 0xc3, 0x97, 0xae, 0xd6, 0xb8, 0xd8, 0x68, 0x15, 0x44, 0xe4, 0x34, 0x93, 0x55, 0xdf, 0xdf, + 0x15, 0xa2, 0x35, 0x2e, 0x36, 0x5a, 0xf8, 0x16, 0x34, 0x47, 0x89, 0x3c, 0x88, 0x38, 0x19, 0x65, + 0xe6, 0xcf, 0xf8, 0x57, 0xd0, 0x85, 0xde, 0x15, 0x60, 0xe9, 0x9a, 0x33, 0x80, 0x9f, 0x40, 0x3b, + 0x25, 0xc7, 0x83, 0x7d, 0x2a, 0x27, 0x4d, 0x61, 0xb6, 0xfd, 0xe2, 0x6f, 0x0b, 0x2d, 0x9b, 0x85, + 0xae, 0x8a, 0x5d, 0x3c, 0x9f, 0x92, 0x63, 0x9f, 0x4a, 0xd3, 0x27, 0x7e, 0x70, 0x52, 0x76, 0xac, + 0xd3, 0xb2, 0x63, 0xfd, 0x2c, 0x3b, 0xd6, 0x97, 0xb3, 0x4e, 0xed, 0xf4, 0xac, 0x53, 0xfb, 0x76, + 0xd6, 0xa9, 0x7d, 0x7c, 0x12, 0x27, 0xf2, 0xe0, 0x68, 0xdf, 0x0b, 0x59, 0xda, 0x17, 0x31, 0x5d, + 0xaf, 0xae, 0x4c, 0xd9, 0xfd, 0xe3, 0xc9, 0x7b, 0xa3, 0xda, 0x5e, 0xec, 0xcf, 0xea, 0xf7, 0x66, + 0xf3, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x43, 0x73, 0x63, 0x30, 0xd2, 0x04, 0x00, 0x00, } func (m *Campaign) Marshal() (dAtA []byte, err error) { @@ -286,6 +338,23 @@ func (m *Campaign) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Constraints != nil { + { + size, err := m.Constraints.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCampaign(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x7a + } + if m.CapCount != 0 { + i = encodeVarintCampaign(dAtA, i, uint64(m.CapCount)) + i-- + dAtA[i] = 0x70 + } if len(m.Meta) > 0 { i -= len(m.Meta) copy(dAtA[i:], m.Meta) @@ -293,11 +362,6 @@ func (m *Campaign) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x6a } - if m.ClaimsPerCategory != 0 { - i = encodeVarintCampaign(dAtA, i, uint64(m.ClaimsPerCategory)) - i-- - dAtA[i] = 0x60 - } if m.IsActive { i-- if m.IsActive { @@ -399,6 +463,16 @@ func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size := m.Withdrawn.Size() + i -= size + if _, err := m.Withdrawn.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintCampaign(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a { size := m.Spent.Size() i -= size @@ -422,6 +496,39 @@ func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *CampaignConstraints) 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 *CampaignConstraints) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CampaignConstraints) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.MaxBetAmount.Size() + i -= size + if _, err := m.MaxBetAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintCampaign(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func encodeVarintCampaign(dAtA []byte, offset int, v uint64) int { offset -= sovCampaign(v) base := offset @@ -475,13 +582,17 @@ func (m *Campaign) Size() (n int) { if m.IsActive { n += 2 } - if m.ClaimsPerCategory != 0 { - n += 1 + sovCampaign(uint64(m.ClaimsPerCategory)) - } l = len(m.Meta) if l > 0 { n += 1 + l + sovCampaign(uint64(l)) } + if m.CapCount != 0 { + n += 1 + sovCampaign(uint64(m.CapCount)) + } + if m.Constraints != nil { + l = m.Constraints.Size() + n += 1 + l + sovCampaign(uint64(l)) + } return n } @@ -495,6 +606,19 @@ func (m *Pool) Size() (n int) { n += 1 + l + sovCampaign(uint64(l)) l = m.Spent.Size() n += 1 + l + sovCampaign(uint64(l)) + l = m.Withdrawn.Size() + n += 1 + l + sovCampaign(uint64(l)) + return n +} + +func (m *CampaignConstraints) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.MaxBetAmount.Size() + n += 1 + l + sovCampaign(uint64(l)) return n } @@ -813,11 +937,43 @@ func (m *Campaign) Unmarshal(dAtA []byte) error { } } m.IsActive = bool(v != 0) - case 12: + case 13: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Meta", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCampaign + } + 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 ErrInvalidLengthCampaign + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCampaign + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Meta = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 14: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ClaimsPerCategory", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field CapCount", wireType) } - m.ClaimsPerCategory = 0 + m.CapCount = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowCampaign @@ -827,16 +983,16 @@ func (m *Campaign) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ClaimsPerCategory |= uint64(b&0x7F) << shift + m.CapCount |= uint64(b&0x7F) << shift if b < 0x80 { break } } - case 13: + case 15: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Meta", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Constraints", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowCampaign @@ -846,23 +1002,27 @@ func (m *Campaign) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthCampaign } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthCampaign } if postIndex > l { return io.ErrUnexpectedEOF } - m.Meta = string(dAtA[iNdEx:postIndex]) + if m.Constraints == nil { + m.Constraints = &CampaignConstraints{} + } + if err := m.Constraints.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex @@ -982,6 +1142,124 @@ func (m *Pool) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Withdrawn", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCampaign + } + 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 ErrInvalidLengthCampaign + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCampaign + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Withdrawn.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCampaign(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCampaign + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CampaignConstraints) 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 ErrIntOverflowCampaign + } + 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: CampaignConstraints: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CampaignConstraints: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxBetAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCampaign + } + 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 ErrInvalidLengthCampaign + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCampaign + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MaxBetAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipCampaign(dAtA[iNdEx:]) diff --git a/x/reward/types/campaign_authorizaton.go b/x/reward/types/campaign_authorizaton.go index 519b3f70..e3c47a19 100644 --- a/x/reward/types/campaign_authorizaton.go +++ b/x/reward/types/campaign_authorizaton.go @@ -121,24 +121,58 @@ func (a UpdateCampaignAuthorization) ValidateBasic() error { return nil } +var _ authz.Authorization = &WithdrawCampaignAuthorization{} + +// NewWithdrawAuthorization creates a new WithdrawAuthorization object. +func NewWithdrawAuthorization(withdrawLimit sdkmath.Int) *WithdrawCampaignAuthorization { + return &WithdrawCampaignAuthorization{ + WithdrawLimit: withdrawLimit, + } +} + // MsgTypeURL implements Authorization.MsgTypeURL. func (WithdrawCampaignAuthorization) MsgTypeURL() string { - return sdk.MsgTypeURL(&MsgUpdateCampaign{}) + return sdk.MsgTypeURL(&MsgWithdrawFunds{}) } // Accept implements Authorization.Accept. func (a WithdrawCampaignAuthorization) Accept(_ sdk.Context, msg sdk.Msg) (authz.AcceptResponse, error) { - _, ok := msg.(*MsgWithdrawFunds) + mWithdraw, ok := msg.(*MsgWithdrawFunds) if !ok { return authz.AcceptResponse{}, sdkerrtypes.ErrInvalidType.Wrap("type mismatch") } + limitLeft := a.WithdrawLimit.Sub(mWithdraw.Amount) + if limitLeft.IsNegative() { + return authz.AcceptResponse{}, sdkerrtypes.ErrInsufficientFunds.Wrapf( + "requested amount is more than withdraw limit", + ) + } + if limitLeft.IsZero() { + return authz.AcceptResponse{Accept: true, Delete: true}, nil + } + return authz.AcceptResponse{ Accept: true, - Delete: true, - Updated: &WithdrawCampaignAuthorization{}, + Delete: false, + Updated: &WithdrawCampaignAuthorization{WithdrawLimit: limitLeft}, }, nil } // ValidateBasic implements Authorization.ValidateBasic. -func (a WithdrawCampaignAuthorization) ValidateBasic() error { return nil } +func (a WithdrawCampaignAuthorization) ValidateBasic() error { + if a.WithdrawLimit.IsNil() { + return sdkerrtypes.ErrInvalidCoins.Wrap("withdraw limit cannot be nil") + } + if a.WithdrawLimit.LTE(sdk.ZeroInt()) { + return sdkerrtypes.ErrInvalidCoins.Wrap("withdraw limit cannot be less than or equal to zero") + } + if a.WithdrawLimit.GT(maxWithdrawGrant) { + return sdkerrtypes.ErrInvalidCoins.Wrapf( + "withdraw limit cannot be grated than %s", + maxWithdrawGrant, + ) + } + + return nil +} diff --git a/x/reward/types/consts.go b/x/reward/types/consts.go index 18364abd..41821183 100644 --- a/x/reward/types/consts.go +++ b/x/reward/types/consts.go @@ -2,5 +2,10 @@ package types import sdkmath "cosmossdk.io/math" -// minCampaignFunds is the minimum campaign funds allowed grant. -var minCampaignFunds = sdkmath.NewInt(100) +var ( + // minCampaignFunds is the minimum campaign funds allowed grant. + minCampaignFunds = sdkmath.NewInt(100) + + // maxWithdrawGrant is the maximum withdraw allowed grant. + maxWithdrawGrant = sdkmath.NewInt(100) +) diff --git a/x/reward/types/errors.go b/x/reward/types/errors.go index 5a3e4f85..335a0fd5 100644 --- a/x/reward/types/errors.go +++ b/x/reward/types/errors.go @@ -25,7 +25,7 @@ var ( ErrWrongRewardCategory = sdkerrors.Register(ModuleName, 7114, "wrong reward category") ErrMissingDefinition = sdkerrors.Register(ModuleName, 7115, "missing reward definition") ErrSubaccountRewardTopUp = sdkerrors.Register(ModuleName, 7116, "subaccount reward topup failed") - ErrUnlockTSIsSubaccountOnly = sdkerrors.Register(ModuleName, 7117, "unlock timestamp is allowed for subaccount only") + ErrUnlockTSIsSubAccOnly = sdkerrors.Register(ModuleName, 7117, "unlock timestamp is allowed for subaccount only") ErrUnlockTSDefBeforeBlockTime = sdkerrors.Register(ModuleName, 7118, "unlock timestamp should not be before the current block time") ErrInvalidNoLossBetUID = sdkerrors.Register(ModuleName, 7120, "invalid no loss bet uid") ErrWrongAmountForType = sdkerrors.Register(ModuleName, 7121, "wrong amount for account type") @@ -37,4 +37,7 @@ var ( ErrCampaignHasNotStarted = sdkerrors.Register(ModuleName, 7127, "campaign validity period is not started yet") ErrUserKycFailed = sdkerrors.Register(ModuleName, 7128, "KYC Validation failed for receiver account address") ErrUserKycNotProvided = sdkerrors.Register(ModuleName, 7129, "KYC data not provided") + ErrDuplicateCategoryInConf = sdkerrors.Register(ModuleName, 7130, "duplicate category in promoter configurations") + ErrCategoryCapShouldBePos = sdkerrors.Register(ModuleName, 7131, "category cap should be a positive number") + ErrMissingConstraintForCampaign = sdkerrors.Register(ModuleName, 7132, "missing constraints in the campaign") ) diff --git a/x/reward/types/events.go b/x/reward/types/events.go index 27953918..b5ef8904 100644 --- a/x/reward/types/events.go +++ b/x/reward/types/events.go @@ -10,4 +10,5 @@ const ( attributeKeyMainAmount = "main_acc_amount" attributeKeySubAmount = "sub_acc_amount" attributeKeyUnlockTS = "sub_acc_unlock_ts" + attributeKeyPromoterConf = "promoter_conf" ) diff --git a/x/reward/types/expected_keepers.go b/x/reward/types/expected_keepers.go index 3e0b1a31..3e4c2248 100644 --- a/x/reward/types/expected_keepers.go +++ b/x/reward/types/expected_keepers.go @@ -10,6 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/authz" bettypes "github.com/sge-network/sge/x/bet/types" + markettypes "github.com/sge-network/sge/x/market/types" subaccounttypes "github.com/sge-network/sge/x/subaccount/types" ) @@ -35,6 +36,11 @@ type BetKeeper interface { GetBetID(ctx sdk.Context, uid string) (val bettypes.UID2ID, found bool) } +// BetKeeper defines the expected interface needed to access market state. +type MarketKeeper interface { + GetMarket(ctx sdk.Context, marketUID string) (markettypes.Market, bool) +} + // OVMKeeper defines the expected interface needed to verify ticket and unmarshal it type OVMKeeper interface { VerifyTicketUnmarshal(goCtx context.Context, ticket string, clm interface{}) error @@ -71,5 +77,6 @@ type SubaccountKeeper interface { // RewardKeeper defines the expected interface needed to get and filter the rewards. type RewardKeeper interface { - HasRewardByReceiver(ctx sdk.Context, addr string, category RewardCategory) bool + HasRewardOfReceiverByPromoter(ctx sdk.Context, promoterUID, addr string, category RewardCategory) bool + GetPromoterByAddress(ctx sdk.Context, address string) (val PromoterByAddress, found bool) } diff --git a/x/reward/types/genesis.pb.go b/x/reward/types/genesis.pb.go index c3bdca04..7eaff929 100644 --- a/x/reward/types/genesis.pb.go +++ b/x/reward/types/genesis.pb.go @@ -25,11 +25,13 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the reward module's genesis state. type GenesisState struct { - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` - CampaignList []Campaign `protobuf:"bytes,2,rep,name=campaign_list,json=campaignList,proto3" json:"campaign_list"` - RewardList []Reward `protobuf:"bytes,3,rep,name=reward_list,json=rewardList,proto3" json:"reward_list"` - RewardByCategoryList []RewardByCategory `protobuf:"bytes,4,rep,name=reward_by_category_list,json=rewardByCategoryList,proto3" json:"reward_by_category_list"` - RewardByCampaignList []RewardByCampaign `protobuf:"bytes,5,rep,name=reward_by_campaign_list,json=rewardByCampaignList,proto3" json:"reward_by_campaign_list"` + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + CampaignList []Campaign `protobuf:"bytes,2,rep,name=campaign_list,json=campaignList,proto3" json:"campaign_list"` + RewardList []Reward `protobuf:"bytes,3,rep,name=reward_list,json=rewardList,proto3" json:"reward_list"` + RewardByCategoryList []RewardByCategory `protobuf:"bytes,4,rep,name=reward_by_category_list,json=rewardByCategoryList,proto3" json:"reward_by_category_list"` + RewardByCampaignList []RewardByCampaign `protobuf:"bytes,5,rep,name=reward_by_campaign_list,json=rewardByCampaignList,proto3" json:"reward_by_campaign_list"` + PromoterList []Promoter `protobuf:"bytes,6,rep,name=promoter_list,json=promoterList,proto3" json:"promoter_list"` + PromoterByAddressList []PromoterByAddress `protobuf:"bytes,7,rep,name=promoter_by_address_list,json=promoterByAddressList,proto3" json:"promoter_by_address_list"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -100,6 +102,20 @@ func (m *GenesisState) GetRewardByCampaignList() []RewardByCampaign { return nil } +func (m *GenesisState) GetPromoterList() []Promoter { + if m != nil { + return m.PromoterList + } + return nil +} + +func (m *GenesisState) GetPromoterByAddressList() []PromoterByAddress { + if m != nil { + return m.PromoterByAddressList + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "sgenetwork.sge.reward.GenesisState") } @@ -107,28 +123,31 @@ func init() { func init() { proto.RegisterFile("sge/reward/genesis.proto", fileDescriptor_cf3f52dafc32b537) } var fileDescriptor_cf3f52dafc32b537 = []byte{ - // 324 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x28, 0x4e, 0x4f, 0xd5, - 0x2f, 0x4a, 0x2d, 0x4f, 0x2c, 0x4a, 0xd1, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, - 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x2d, 0x06, 0xf1, 0x4b, 0xca, 0xf3, 0x8b, 0xb2, 0xf5, 0x8a, - 0xd3, 0x53, 0xf5, 0x20, 0x8a, 0xa4, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x2a, 0xf4, 0x41, 0x2c, - 0x88, 0x62, 0x29, 0x71, 0x24, 0x63, 0x0a, 0x12, 0x8b, 0x12, 0x73, 0xa1, 0xa6, 0x48, 0x49, 0x22, - 0x49, 0x24, 0x27, 0xe6, 0x16, 0x24, 0x66, 0xa6, 0xe7, 0x61, 0xd1, 0x03, 0xa1, 0x20, 0x12, 0x4a, - 0x2b, 0x99, 0xb9, 0x78, 0xdc, 0x21, 0x6e, 0x09, 0x2e, 0x49, 0x2c, 0x49, 0x15, 0xb2, 0xe6, 0x62, - 0x83, 0x18, 0x2a, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xab, 0x87, 0xd5, 0x6d, 0x7a, 0x01, - 0x60, 0x45, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0x41, 0xb5, 0x08, 0x79, 0x71, 0xf1, 0xc2, - 0x2c, 0x8e, 0xcf, 0xc9, 0x2c, 0x2e, 0x91, 0x60, 0x52, 0x60, 0xd6, 0xe0, 0x36, 0x92, 0xc7, 0x61, - 0x86, 0x33, 0x54, 0x2d, 0xd4, 0x14, 0x1e, 0x98, 0x5e, 0x9f, 0xcc, 0xe2, 0x12, 0x21, 0x17, 0x2e, - 0x6e, 0x88, 0x32, 0x88, 0x49, 0xcc, 0x60, 0x93, 0x70, 0xb9, 0x26, 0x08, 0x4c, 0x41, 0xcd, 0xe1, - 0x82, 0x08, 0x82, 0x4d, 0x49, 0xe1, 0x12, 0x87, 0x9a, 0x92, 0x54, 0x19, 0x9f, 0x9c, 0x58, 0x92, - 0x9a, 0x9e, 0x5f, 0x54, 0x09, 0x31, 0x91, 0x05, 0x6c, 0xa2, 0x3a, 0x7e, 0x13, 0x2b, 0x9d, 0xa1, - 0x7a, 0xa0, 0x66, 0x8b, 0x14, 0xa1, 0x89, 0x63, 0xb3, 0x05, 0x39, 0x04, 0x58, 0x89, 0xb4, 0x05, - 0x25, 0x24, 0x90, 0x6c, 0x41, 0x84, 0x88, 0x93, 0xf3, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, - 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, - 0xcb, 0x31, 0x44, 0x69, 0xa6, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x17, - 0xa7, 0xa7, 0xea, 0x42, 0x6d, 0x02, 0xb1, 0xf5, 0x2b, 0x60, 0xf1, 0x5e, 0x52, 0x59, 0x90, 0x5a, - 0x9c, 0xc4, 0x06, 0x8e, 0x77, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x4a, 0x9d, 0xa4, 0xe3, - 0x8d, 0x02, 0x00, 0x00, + // 376 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x41, 0x4f, 0xc2, 0x30, + 0x1c, 0xc5, 0x37, 0x41, 0x4c, 0x0a, 0x5c, 0x16, 0x08, 0x93, 0xc4, 0x41, 0xbc, 0x88, 0x07, 0xb7, + 0x04, 0x8f, 0x9e, 0x04, 0x13, 0x13, 0xe2, 0x81, 0xe0, 0xcd, 0x0b, 0xe9, 0x58, 0x53, 0x17, 0x1d, + 0x5d, 0xda, 0x1a, 0xdc, 0xb7, 0xf0, 0x63, 0x71, 0xe4, 0xe8, 0x89, 0x18, 0xf8, 0x22, 0x66, 0xfd, + 0x77, 0x66, 0x92, 0x81, 0x9e, 0xda, 0xb5, 0xef, 0xfd, 0xde, 0x3f, 0x6f, 0x45, 0xb6, 0xa0, 0xc4, + 0xe3, 0x64, 0x81, 0x79, 0xe0, 0x51, 0x32, 0x27, 0x22, 0x14, 0x6e, 0xcc, 0x99, 0x64, 0x56, 0x53, + 0xa4, 0xdf, 0x72, 0xc1, 0xf8, 0x8b, 0x2b, 0x28, 0x71, 0x41, 0xd4, 0x6e, 0x50, 0x46, 0x99, 0x52, + 0x78, 0xe9, 0x0e, 0xc4, 0xed, 0x56, 0x0e, 0x13, 0x63, 0x8e, 0x23, 0x4d, 0x69, 0x9f, 0xe6, 0x2e, + 0x66, 0x38, 0x8a, 0x71, 0x48, 0xe7, 0x05, 0x1e, 0x58, 0x0a, 0x3c, 0x31, 0x67, 0x11, 0x93, 0x84, + 0xc3, 0xd5, 0xf9, 0xba, 0x8c, 0x6a, 0xf7, 0x30, 0xe6, 0xa3, 0xc4, 0x92, 0x58, 0x37, 0xa8, 0x02, + 0x79, 0xb6, 0xd9, 0x35, 0x7b, 0xd5, 0xfe, 0x99, 0x5b, 0x38, 0xb6, 0x3b, 0x56, 0xa2, 0x41, 0x79, + 0xb9, 0xee, 0x18, 0x13, 0x6d, 0xb1, 0x46, 0xa8, 0x9e, 0xcd, 0x34, 0x7d, 0x0d, 0x85, 0xb4, 0x8f, + 0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 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -151,6 +170,34 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.PromoterByAddressList) > 0 { + for iNdEx := len(m.PromoterByAddressList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PromoterByAddressList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } + } + if len(m.PromoterList) > 0 { + for iNdEx := len(m.PromoterList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PromoterList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } if len(m.RewardByCampaignList) > 0 { for iNdEx := len(m.RewardByCampaignList) - 1; iNdEx >= 0; iNdEx-- { { @@ -263,6 +310,18 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if len(m.PromoterList) > 0 { + for _, e := range m.PromoterList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.PromoterByAddressList) > 0 { + for _, e := range m.PromoterByAddressList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -470,6 +529,74 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PromoterList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PromoterList = append(m.PromoterList, Promoter{}) + if err := m.PromoterList[len(m.PromoterList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PromoterByAddressList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PromoterByAddressList = append(m.PromoterByAddressList, PromoterByAddress{}) + if err := m.PromoterByAddressList[len(m.PromoterByAddressList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/reward/types/key_promoter.go b/x/reward/types/key_promoter.go new file mode 100644 index 00000000..509e6bcd --- /dev/null +++ b/x/reward/types/key_promoter.go @@ -0,0 +1,27 @@ +package types + +import ( + "encoding/binary" + + "github.com/sge-network/sge/utils" +) + +var _ binary.ByteOrder + +var ( + // PromoterKeyPrefix is the prefix to retrieve all promoter + PromoterKeyPrefix = []byte{0x04} + + // PromoterAddressKeyPrefix is the prefix to retrieve all addresses promoter + PromoterAddressKeyPrefix = []byte{0x05} +) + +// GetPromoterKey returns the store key to retrieve a promoter +func GetPromoterKey(uid string) []byte { + return utils.StrBytes(uid) +} + +// GetPromoterByAddressKey returns the promoter of a certain promoter address. +func GetPromoterByAddressKey(accAddr string) []byte { + return utils.StrBytes(accAddr) +} diff --git a/x/reward/types/key_reward.go b/x/reward/types/key_reward.go index 66043780..8d56a279 100644 --- a/x/reward/types/key_reward.go +++ b/x/reward/types/key_reward.go @@ -17,22 +17,25 @@ var ( // RewardByCampaignKeyPrefix is the prefix to retrieve all applied rewards for a certain campaign. RewardByCampaignKeyPrefix = []byte{0x03} + + // RewardGrantStatKeyPrefix is the prefix to retrieve count of reward grants for a certain account. + RewardGrantStatKeyPrefix = []byte{0x06} ) -// GetRewardsByAccPrefix returns the store key to retrieve list of all applied rewards of a certain campaign +// GetRewardsOfReceiverByPromoterPrefix returns the store key to retrieve list of all applied rewards of a certain campaign // this should be used with RewardByReceiverKeyPrefix -func GetRewardsByAccPrefix(receiverAcc string) []byte { - return utils.StrBytes(receiverAcc) +func GetRewardsOfReceiverByPromoterPrefix(promoterUID, receiverAcc string) []byte { + return append(utils.StrBytes(promoterUID), utils.StrBytes(receiverAcc)...) } -// GetRewardsByCategoryPrefix returns the store key to retrieve list of all applied rewards of certain address and category -func GetRewardsByCategoryPrefix(receiverAcc string, rewardCategory RewardCategory) []byte { - return append(GetRewardsByAccPrefix(receiverAcc), utils.Int32ToBytes(int32(rewardCategory))...) +// GetRewardsOfReceiverByPromoterAndCategoryPrefix returns the store key to retrieve list of all applied rewards of certain address and category +func GetRewardsOfReceiverByPromoterAndCategoryPrefix(promoterUID, receiverAcc string, rewardCategory RewardCategory) []byte { + return append(GetRewardsOfReceiverByPromoterPrefix(promoterUID, receiverAcc), utils.Int32ToBytes(int32(rewardCategory))...) } -// GetRewardsByCategoryKey returns the store key to retrieve list of applied reward of certain address and category -func GetRewardsByCategoryKey(receiverAcc string, rewardCategory RewardCategory, uid string) []byte { - return append(GetRewardsByCategoryPrefix(receiverAcc, rewardCategory), utils.StrBytes(uid)...) +// GetRewardsOfReceiverByPromoterAndCategoryKey returns the store key to retrieve list of applied reward of certain address and category +func GetRewardsOfReceiverByPromoterAndCategoryKey(promoterUID, receiverAcc string, rewardCategory RewardCategory, uid string) []byte { + return append(GetRewardsOfReceiverByPromoterAndCategoryPrefix(promoterUID, receiverAcc, rewardCategory), utils.StrBytes(uid)...) } // GetRewardKey returns the store key to retrieve a certain reward. @@ -51,3 +54,8 @@ func GetRewardsByCampaignPrefix(campaignUID string) []byte { func GetRewardsByCampaignKey(campaignUID, uid string) []byte { return append(utils.StrBytes(campaignUID), utils.StrBytes(uid)...) } + +// GetRewardGrantStatKey returns the store key to retrieve a certain account. +func GetRewardGrantStatKey(campaignUID, addr string) []byte { + return append(utils.StrBytes(campaignUID), utils.StrBytes(addr)...) +} diff --git a/x/reward/types/messages_campaign.go b/x/reward/types/messages_campaign.go index 03495f50..58919c7d 100644 --- a/x/reward/types/messages_campaign.go +++ b/x/reward/types/messages_campaign.go @@ -149,11 +149,13 @@ var _ sdk.Msg = &MsgWithdrawFunds{} func NewMsgWithdrawFunds( creator string, uid string, + amount sdkmath.Int, ticket string, ) *MsgWithdrawFunds { return &MsgWithdrawFunds{ Creator: creator, Uid: uid, + Amount: amount, Ticket: ticket, } } diff --git a/x/reward/types/messages_promoter.go b/x/reward/types/messages_promoter.go new file mode 100644 index 00000000..c83924b1 --- /dev/null +++ b/x/reward/types/messages_promoter.go @@ -0,0 +1,133 @@ +package types + +import ( + sdkerrors "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrtypes "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/sge-network/sge/utils" +) + +const ( + TypeMsgSetPromoterConf = "set_promoter_conf" + TypeMsgCreatePromoter = "create_promoter" +) + +var ( + _ sdk.Msg = &MsgSetPromoterConf{} + _ sdk.Msg = &MsgCreatePromoter{} +) + +func NewMsgSetPromoterConfig( + creator string, + uid string, + ticket string, +) *MsgSetPromoterConf { + return &MsgSetPromoterConf{ + Creator: creator, + Uid: uid, + Ticket: ticket, + } +} + +func (msg *MsgSetPromoterConf) Route() string { + return RouterKey +} + +func (msg *MsgSetPromoterConf) Type() string { + return TypeMsgSetPromoterConf +} + +func (msg *MsgSetPromoterConf) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgSetPromoterConf) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgSetPromoterConf) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrtypes.ErrInvalidAddress, "invalid creator address (%s)", err) + } + + if !utils.IsValidUID(msg.Uid) { + return sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "invalid uid") + } + + if msg.Ticket == "" { + return sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "invalid ticket") + } + + return nil +} + +// EmitEvent emits the event for the message success. +func (msg *MsgSetPromoterConf) EmitEvent(ctx *sdk.Context, conf PromoterConf) { + emitter := utils.NewEventEmitter(ctx, attributeValueCategory) + emitter.AddMsg(TypeMsgSetPromoterConf, msg.Creator, + sdk.NewAttribute(attributeKeyUID, msg.Uid), + sdk.NewAttribute(attributeKeyPromoterConf, conf.String()), + ) + emitter.Emit() +} + +func NewMsgCreatePromoter( + creator string, + ticket string, +) *MsgCreatePromoter { + return &MsgCreatePromoter{ + Creator: creator, + Ticket: ticket, + } +} + +func (msg *MsgCreatePromoter) Route() string { + return RouterKey +} + +func (msg *MsgCreatePromoter) Type() string { + return TypeMsgCreatePromoter +} + +func (msg *MsgCreatePromoter) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgCreatePromoter) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgCreatePromoter) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrtypes.ErrInvalidAddress, "invalid creator address (%s)", err) + } + + if msg.Ticket == "" { + return sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "invalid ticket") + } + + return nil +} + +// EmitEvent emits the event for the message success. +func (msg *MsgCreatePromoter) EmitEvent(ctx *sdk.Context, uid string, conf PromoterConf) { + emitter := utils.NewEventEmitter(ctx, attributeValueCategory) + emitter.AddMsg(TypeMsgCreatePromoter, msg.Creator, + sdk.NewAttribute(attributeKeyUID, uid), + sdk.NewAttribute(attributeKeyPromoterConf, conf.String()), + ) + emitter.Emit() +} diff --git a/x/reward/types/messages_promoter_test.go b/x/reward/types/messages_promoter_test.go new file mode 100644 index 00000000..bc0b5afb --- /dev/null +++ b/x/reward/types/messages_promoter_test.go @@ -0,0 +1,62 @@ +package types_test + +import ( + "testing" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/google/uuid" + "github.com/sge-network/sge/testutil/sample" + "github.com/sge-network/sge/x/reward/types" + "github.com/stretchr/testify/require" +) + +func TestMsgSetPromoterConf_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg types.MsgSetPromoterConf + err error + }{ + { + name: "invalid address", + msg: types.MsgSetPromoterConf{ + Creator: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, + { + name: "invalid campaign uid", + msg: types.MsgSetPromoterConf{ + Creator: sample.AccAddress(), + Uid: "bad uid", + Ticket: "ticket", + }, + err: sdkerrors.ErrInvalidRequest, + }, + { + name: "invalid ticket", + msg: types.MsgSetPromoterConf{ + Creator: sample.AccAddress(), + Uid: uuid.NewString(), + }, + err: sdkerrors.ErrInvalidRequest, + }, + { + name: "valid address", + msg: types.MsgSetPromoterConf{ + Creator: sample.AccAddress(), + Uid: uuid.NewString(), + Ticket: "ticket", + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/reward/types/pool.go b/x/reward/types/pool.go index 1aa2d09b..b29981ce 100644 --- a/x/reward/types/pool.go +++ b/x/reward/types/pool.go @@ -7,15 +7,32 @@ import ( func NewPool(total sdkmath.Int) Pool { return Pool{ - Total: total, - Spent: sdkmath.ZeroInt(), + Total: total, + Spent: sdkmath.ZeroInt(), + Withdrawn: sdkmath.ZeroInt(), } } func (p *Pool) CheckBalance(toSpend sdkmath.Int) error { - availablePool := p.Total.Sub(p.Spent) + availablePool := p.AvailableAmount() if availablePool.LT(toSpend) { return sdkerrors.Wrapf(ErrCampaignPoolBalance, "amount %s, available pool %s", toSpend, availablePool) } return nil } + +func (p *Pool) Spend(amount sdkmath.Int) { + p.Spent = p.Spent.Add(amount) +} + +func (p *Pool) TopUp(amount sdkmath.Int) { + p.Total = p.Total.Add(amount) +} + +func (p *Pool) Withdraw(amount sdkmath.Int) { + p.Withdrawn = p.Withdrawn.Add(amount) +} + +func (p *Pool) AvailableAmount() sdkmath.Int { + return p.Total.Sub(p.Withdrawn).Sub(p.Spent) +} diff --git a/x/reward/types/promoter.go b/x/reward/types/promoter.go new file mode 100644 index 00000000..91876b1e --- /dev/null +++ b/x/reward/types/promoter.go @@ -0,0 +1,20 @@ +package types + +import sdkerrors "cosmossdk.io/errors" + +func (cf *PromoterConf) Validate() error { + catMap := make(map[RewardCategory]struct{}) + for _, v := range cf.CategoryCap { + _, ok := catMap[v.Category] + if ok { + return sdkerrors.Wrapf(ErrDuplicateCategoryInConf, "%s", v.Category) + } + if v.CapPerAcc <= 0 { + return sdkerrors.Wrapf(ErrCategoryCapShouldBePos, "%s", v.Category) + } + + catMap[v.Category] = struct{}{} + } + + return nil +} diff --git a/x/reward/types/promoter.pb.go b/x/reward/types/promoter.pb.go new file mode 100644 index 00000000..7fd7945a --- /dev/null +++ b/x/reward/types/promoter.pb.go @@ -0,0 +1,1092 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: sge/reward/promoter.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Promoter is type for defining the reward promoter properties and configuration. +type Promoter struct { + // creator is the address of promoter. + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + // uid is the unique identifier of a promoter. + UID string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid"` + // addresses is the list of account addresses of promoter. + Addresses []string `protobuf:"bytes,3,rep,name=addresses,proto3" json:"addresses,omitempty"` + // conf is the configurations of the current promoter for the reward grant. + Conf PromoterConf `protobuf:"bytes,4,opt,name=conf,proto3" json:"conf"` +} + +func (m *Promoter) Reset() { *m = Promoter{} } +func (m *Promoter) String() string { return proto.CompactTextString(m) } +func (*Promoter) ProtoMessage() {} +func (*Promoter) Descriptor() ([]byte, []int) { + return fileDescriptor_35eedf87bdac6383, []int{0} +} +func (m *Promoter) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Promoter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Promoter.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Promoter) XXX_Merge(src proto.Message) { + xxx_messageInfo_Promoter.Merge(m, src) +} +func (m *Promoter) XXX_Size() int { + return m.Size() +} +func (m *Promoter) XXX_DiscardUnknown() { + xxx_messageInfo_Promoter.DiscardUnknown(m) +} + +var xxx_messageInfo_Promoter proto.InternalMessageInfo + +func (m *Promoter) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *Promoter) GetUID() string { + if m != nil { + return m.UID + } + return "" +} + +func (m *Promoter) GetAddresses() []string { + if m != nil { + return m.Addresses + } + return nil +} + +func (m *Promoter) GetConf() PromoterConf { + if m != nil { + return m.Conf + } + return PromoterConf{} +} + +// PromoterConf is type for defining the promoter specific configurations. +type PromoterConf struct { + // category_cap is the maximium allowed cap for each category. + CategoryCap []CategoryCap `protobuf:"bytes,1,rep,name=category_cap,json=categoryCap,proto3" json:"category_cap"` +} + +func (m *PromoterConf) Reset() { *m = PromoterConf{} } +func (m *PromoterConf) String() string { return proto.CompactTextString(m) } +func (*PromoterConf) ProtoMessage() {} +func (*PromoterConf) Descriptor() ([]byte, []int) { + return fileDescriptor_35eedf87bdac6383, []int{1} +} +func (m *PromoterConf) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PromoterConf) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PromoterConf.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PromoterConf) XXX_Merge(src proto.Message) { + xxx_messageInfo_PromoterConf.Merge(m, src) +} +func (m *PromoterConf) XXX_Size() int { + return m.Size() +} +func (m *PromoterConf) XXX_DiscardUnknown() { + xxx_messageInfo_PromoterConf.DiscardUnknown(m) +} + +var xxx_messageInfo_PromoterConf proto.InternalMessageInfo + +func (m *PromoterConf) GetCategoryCap() []CategoryCap { + if m != nil { + return m.CategoryCap + } + return nil +} + +// CategoryCap is type to define category and its maximum cap. +type CategoryCap struct { + Category RewardCategory `protobuf:"varint,1,opt,name=category,proto3,enum=sgenetwork.sge.reward.RewardCategory" json:"category,omitempty"` + CapPerAcc int32 `protobuf:"varint,2,opt,name=cap_per_acc,json=capPerAcc,proto3" json:"cap_per_acc,omitempty"` +} + +func (m *CategoryCap) Reset() { *m = CategoryCap{} } +func (m *CategoryCap) String() string { return proto.CompactTextString(m) } +func (*CategoryCap) ProtoMessage() {} +func (*CategoryCap) Descriptor() ([]byte, []int) { + return fileDescriptor_35eedf87bdac6383, []int{2} +} +func (m *CategoryCap) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CategoryCap) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CategoryCap.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *CategoryCap) XXX_Merge(src proto.Message) { + xxx_messageInfo_CategoryCap.Merge(m, src) +} +func (m *CategoryCap) XXX_Size() int { + return m.Size() +} +func (m *CategoryCap) XXX_DiscardUnknown() { + xxx_messageInfo_CategoryCap.DiscardUnknown(m) +} + +var xxx_messageInfo_CategoryCap proto.InternalMessageInfo + +func (m *CategoryCap) GetCategory() RewardCategory { + if m != nil { + return m.Category + } + return RewardCategory_REWARD_CATEGORY_UNSPECIFIED +} + +func (m *CategoryCap) GetCapPerAcc() int32 { + if m != nil { + return m.CapPerAcc + } + return 0 +} + +// PromoterByAddress is type for defining the promoter by address. +type PromoterByAddress struct { + // promoter_uid is the unique identifier of a certain promoter. + PromoterUID string `protobuf:"bytes,1,opt,name=promoter_uid,proto3" json:"promoter_uid"` + // address is the address of the promoter account. + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *PromoterByAddress) Reset() { *m = PromoterByAddress{} } +func (m *PromoterByAddress) String() string { return proto.CompactTextString(m) } +func (*PromoterByAddress) ProtoMessage() {} +func (*PromoterByAddress) Descriptor() ([]byte, []int) { + return fileDescriptor_35eedf87bdac6383, []int{3} +} +func (m *PromoterByAddress) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PromoterByAddress) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PromoterByAddress.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PromoterByAddress) XXX_Merge(src proto.Message) { + xxx_messageInfo_PromoterByAddress.Merge(m, src) +} +func (m *PromoterByAddress) XXX_Size() int { + return m.Size() +} +func (m *PromoterByAddress) XXX_DiscardUnknown() { + xxx_messageInfo_PromoterByAddress.DiscardUnknown(m) +} + +var xxx_messageInfo_PromoterByAddress proto.InternalMessageInfo + +func (m *PromoterByAddress) GetPromoterUID() string { + if m != nil { + return m.PromoterUID + } + return "" +} + +func (m *PromoterByAddress) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func init() { + proto.RegisterType((*Promoter)(nil), "sgenetwork.sge.reward.Promoter") + proto.RegisterType((*PromoterConf)(nil), "sgenetwork.sge.reward.PromoterConf") + proto.RegisterType((*CategoryCap)(nil), "sgenetwork.sge.reward.CategoryCap") + proto.RegisterType((*PromoterByAddress)(nil), "sgenetwork.sge.reward.PromoterByAddress") +} + +func init() { proto.RegisterFile("sge/reward/promoter.proto", fileDescriptor_35eedf87bdac6383) } + +var fileDescriptor_35eedf87bdac6383 = []byte{ + // 403 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x52, 0xbd, 0xae, 0xd3, 0x30, + 0x18, 0x8d, 0x49, 0x81, 0x1b, 0xa7, 0xba, 0x12, 0x16, 0x88, 0x70, 0x85, 0x92, 0x28, 0x08, 0x29, + 0x0c, 0x24, 0x52, 0x99, 0x19, 0x9a, 0xb0, 0x20, 0x96, 0xca, 0x12, 0x0b, 0x0c, 0x91, 0xeb, 0xb8, + 0xa6, 0x42, 0xad, 0x2d, 0x3b, 0x55, 0xe9, 0x5b, 0xf0, 0x0e, 0xbc, 0x4c, 0xc7, 0x8e, 0x4c, 0x11, + 0x4a, 0x37, 0x9e, 0x02, 0xe5, 0xc7, 0xb4, 0x95, 0x6e, 0x17, 0xdb, 0xdf, 0xf9, 0xce, 0x77, 0x64, + 0x9f, 0x63, 0xf8, 0x42,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xf2, 0xfa, 0x8a, 0x2e, 0xee, + 0x36, 0x33, 0x8b, 0xff, 0x8f, 0x21, 0x1f, 0xba, 0x94, 0xc8, 0x42, 0x32, 0x55, 0x10, 0x4a, 0x3b, + 0xd7, 0x1e, 0x62, 0x87, 0x12, 0x39, 0x63, 0x6a, 0x4a, 0x69, 0xa4, 0xe0, 0x13, 0xf3, 0x9c, 0x6c, + 0x37, 0xed, 0x4d, 0x42, 0x39, 0x1c, 0x9b, 0x84, 0x8b, 0xd6, 0xeb, 0x2e, 0x81, 0x2c, 0x68, 0xea, + 0xc0, 0x35, 0xe4, 0xde, 0xf3, 0x0b, 0x1a, 0xbe, 0xa8, 0xda, 0x04, 0x07, 0xd3, 0xfb, 0xac, 0xb0, + 0x29, 0xb3, 0x7c, 0xdf, 0xf8, 0xe0, 0xd0, 0xf8, 0xe0, 0x4f, 0xe3, 0x83, 0x9f, 0x47, 0xdf, 0x3a, + 0x1c, 0x7d, 0xeb, 0xf7, 0xd1, 0xb7, 0xbe, 0xbc, 0xe1, 0xcb, 0xea, 0xdb, 0x66, 0x9e, 0x50, 0xb1, + 0x4a, 0x35, 0x67, 0x6f, 0x87, 0x97, 0xb6, 0xe7, 0xf4, 0x87, 0xf9, 0x34, 0xd5, 0x4e, 0x32, 0x3d, + 0x7f, 0xd4, 0x7d, 0x9a, 0x77, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0x52, 0x04, 0xe9, 0xf0, 0x97, + 0x02, 0x00, 0x00, +} + +func (m *Promoter) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Promoter) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Promoter) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Conf.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPromoter(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.Addresses) > 0 { + for iNdEx := len(m.Addresses) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Addresses[iNdEx]) + copy(dAtA[i:], m.Addresses[iNdEx]) + i = encodeVarintPromoter(dAtA, i, uint64(len(m.Addresses[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } + if len(m.UID) > 0 { + i -= len(m.UID) + copy(dAtA[i:], m.UID) + i = encodeVarintPromoter(dAtA, i, uint64(len(m.UID))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintPromoter(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *PromoterConf) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PromoterConf) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PromoterConf) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.CategoryCap) > 0 { + for iNdEx := len(m.CategoryCap) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.CategoryCap[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPromoter(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *CategoryCap) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CategoryCap) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CategoryCap) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.CapPerAcc != 0 { + i = encodeVarintPromoter(dAtA, i, uint64(m.CapPerAcc)) + i-- + dAtA[i] = 0x10 + } + if m.Category != 0 { + i = encodeVarintPromoter(dAtA, i, uint64(m.Category)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *PromoterByAddress) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PromoterByAddress) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PromoterByAddress) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintPromoter(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0x12 + } + if len(m.PromoterUID) > 0 { + i -= len(m.PromoterUID) + copy(dAtA[i:], m.PromoterUID) + i = encodeVarintPromoter(dAtA, i, uint64(len(m.PromoterUID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintPromoter(dAtA []byte, offset int, v uint64) int { + offset -= sovPromoter(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Promoter) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovPromoter(uint64(l)) + } + l = len(m.UID) + if l > 0 { + n += 1 + l + sovPromoter(uint64(l)) + } + if len(m.Addresses) > 0 { + for _, s := range m.Addresses { + l = len(s) + n += 1 + l + sovPromoter(uint64(l)) + } + } + l = m.Conf.Size() + n += 1 + l + sovPromoter(uint64(l)) + return n +} + +func (m *PromoterConf) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.CategoryCap) > 0 { + for _, e := range m.CategoryCap { + l = e.Size() + n += 1 + l + sovPromoter(uint64(l)) + } + } + return n +} + +func (m *CategoryCap) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Category != 0 { + n += 1 + sovPromoter(uint64(m.Category)) + } + if m.CapPerAcc != 0 { + n += 1 + sovPromoter(uint64(m.CapPerAcc)) + } + return n +} + +func (m *PromoterByAddress) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PromoterUID) + if l > 0 { + n += 1 + l + sovPromoter(uint64(l)) + } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovPromoter(uint64(l)) + } + return n +} + +func sovPromoter(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozPromoter(x uint64) (n int) { + return sovPromoter(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Promoter) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPromoter + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Promoter: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Promoter: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPromoter + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPromoter + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPromoter + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPromoter + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPromoter + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPromoter + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.UID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Addresses", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPromoter + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPromoter + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPromoter + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Addresses = append(m.Addresses, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Conf", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPromoter + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPromoter + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPromoter + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Conf.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPromoter(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPromoter + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PromoterConf) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPromoter + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PromoterConf: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PromoterConf: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CategoryCap", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPromoter + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPromoter + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPromoter + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CategoryCap = append(m.CategoryCap, CategoryCap{}) + if err := m.CategoryCap[len(m.CategoryCap)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPromoter(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPromoter + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CategoryCap) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPromoter + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CategoryCap: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CategoryCap: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Category", wireType) + } + m.Category = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPromoter + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Category |= RewardCategory(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CapPerAcc", wireType) + } + m.CapPerAcc = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPromoter + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CapPerAcc |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipPromoter(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPromoter + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PromoterByAddress) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPromoter + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PromoterByAddress: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PromoterByAddress: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PromoterUID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPromoter + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPromoter + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPromoter + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PromoterUID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPromoter + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPromoter + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPromoter + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPromoter(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPromoter + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipPromoter(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPromoter + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPromoter + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPromoter + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthPromoter + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupPromoter + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthPromoter + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthPromoter = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowPromoter = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupPromoter = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/reward/types/query.pb.go b/x/reward/types/query.pb.go index 8405e5e4..40424699 100644 --- a/x/reward/types/query.pb.go +++ b/x/reward/types/query.pb.go @@ -113,6 +113,196 @@ func (m *QueryParamsResponse) GetParams() Params { return Params{} } +// QueryPromoterByAddressRequest is request type for the Query/GetPromoterByAddress RPC method. +type QueryPromoterByAddressRequest struct { + Addr string `protobuf:"bytes,1,opt,name=addr,proto3" json:"addr,omitempty"` +} + +func (m *QueryPromoterByAddressRequest) Reset() { *m = QueryPromoterByAddressRequest{} } +func (m *QueryPromoterByAddressRequest) String() string { return proto.CompactTextString(m) } +func (*QueryPromoterByAddressRequest) ProtoMessage() {} +func (*QueryPromoterByAddressRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_324afa5f2186a8c0, []int{2} +} +func (m *QueryPromoterByAddressRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPromoterByAddressRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPromoterByAddressRequest.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 *QueryPromoterByAddressRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPromoterByAddressRequest.Merge(m, src) +} +func (m *QueryPromoterByAddressRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryPromoterByAddressRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPromoterByAddressRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPromoterByAddressRequest proto.InternalMessageInfo + +func (m *QueryPromoterByAddressRequest) GetAddr() string { + if m != nil { + return m.Addr + } + return "" +} + +// QueryPromoterByAddressResponse is response type for the Query/GetPromoterByAddress RPC method. +type QueryPromoterByAddressResponse struct { + // promoter holds the queries promoter. + Promoter Promoter `protobuf:"bytes,1,opt,name=promoter,proto3" json:"promoter"` +} + +func (m *QueryPromoterByAddressResponse) Reset() { *m = QueryPromoterByAddressResponse{} } +func (m *QueryPromoterByAddressResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPromoterByAddressResponse) ProtoMessage() {} +func (*QueryPromoterByAddressResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_324afa5f2186a8c0, []int{3} +} +func (m *QueryPromoterByAddressResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPromoterByAddressResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPromoterByAddressResponse.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 *QueryPromoterByAddressResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPromoterByAddressResponse.Merge(m, src) +} +func (m *QueryPromoterByAddressResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryPromoterByAddressResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPromoterByAddressResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPromoterByAddressResponse proto.InternalMessageInfo + +func (m *QueryPromoterByAddressResponse) GetPromoter() Promoter { + if m != nil { + return m.Promoter + } + return Promoter{} +} + +// QueryPromotersRequest is request body for the query all promoters endpoint. +type QueryPromotersRequest struct { + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryPromotersRequest) Reset() { *m = QueryPromotersRequest{} } +func (m *QueryPromotersRequest) String() string { return proto.CompactTextString(m) } +func (*QueryPromotersRequest) ProtoMessage() {} +func (*QueryPromotersRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_324afa5f2186a8c0, []int{4} +} +func (m *QueryPromotersRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPromotersRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPromotersRequest.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 *QueryPromotersRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPromotersRequest.Merge(m, src) +} +func (m *QueryPromotersRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryPromotersRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPromotersRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPromotersRequest proto.InternalMessageInfo + +func (m *QueryPromotersRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryPromotersResponse is response body of the query all promoters +// endpoint. +type QueryPromotersResponse struct { + Promoter []Promoter `protobuf:"bytes,1,rep,name=promoter,proto3" json:"promoter"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryPromotersResponse) Reset() { *m = QueryPromotersResponse{} } +func (m *QueryPromotersResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPromotersResponse) ProtoMessage() {} +func (*QueryPromotersResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_324afa5f2186a8c0, []int{5} +} +func (m *QueryPromotersResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPromotersResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPromotersResponse.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 *QueryPromotersResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPromotersResponse.Merge(m, src) +} +func (m *QueryPromotersResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryPromotersResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPromotersResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPromotersResponse proto.InternalMessageInfo + +func (m *QueryPromotersResponse) GetPromoter() []Promoter { + if m != nil { + return m.Promoter + } + return nil +} + +func (m *QueryPromotersResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + // QueryCampaignRequest is request body of the query campaign endpoint. type QueryCampaignRequest struct { Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid,omitempty"` @@ -122,7 +312,7 @@ func (m *QueryCampaignRequest) Reset() { *m = QueryCampaignRequest{} } func (m *QueryCampaignRequest) String() string { return proto.CompactTextString(m) } func (*QueryCampaignRequest) ProtoMessage() {} func (*QueryCampaignRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_324afa5f2186a8c0, []int{2} + return fileDescriptor_324afa5f2186a8c0, []int{6} } func (m *QueryCampaignRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -167,7 +357,7 @@ func (m *QueryCampaignResponse) Reset() { *m = QueryCampaignResponse{} } func (m *QueryCampaignResponse) String() string { return proto.CompactTextString(m) } func (*QueryCampaignResponse) ProtoMessage() {} func (*QueryCampaignResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_324afa5f2186a8c0, []int{3} + return fileDescriptor_324afa5f2186a8c0, []int{7} } func (m *QueryCampaignResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -212,7 +402,7 @@ func (m *QueryCampaignsRequest) Reset() { *m = QueryCampaignsRequest{} } func (m *QueryCampaignsRequest) String() string { return proto.CompactTextString(m) } func (*QueryCampaignsRequest) ProtoMessage() {} func (*QueryCampaignsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_324afa5f2186a8c0, []int{4} + return fileDescriptor_324afa5f2186a8c0, []int{8} } func (m *QueryCampaignsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -259,7 +449,7 @@ func (m *QueryCampaignsResponse) Reset() { *m = QueryCampaignsResponse{} func (m *QueryCampaignsResponse) String() string { return proto.CompactTextString(m) } func (*QueryCampaignsResponse) ProtoMessage() {} func (*QueryCampaignsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_324afa5f2186a8c0, []int{5} + return fileDescriptor_324afa5f2186a8c0, []int{9} } func (m *QueryCampaignsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -311,7 +501,7 @@ func (m *QueryRewardRequest) Reset() { *m = QueryRewardRequest{} } func (m *QueryRewardRequest) String() string { return proto.CompactTextString(m) } func (*QueryRewardRequest) ProtoMessage() {} func (*QueryRewardRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_324afa5f2186a8c0, []int{6} + return fileDescriptor_324afa5f2186a8c0, []int{10} } func (m *QueryRewardRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -356,7 +546,7 @@ func (m *QueryRewardResponse) Reset() { *m = QueryRewardResponse{} } func (m *QueryRewardResponse) String() string { return proto.CompactTextString(m) } func (*QueryRewardResponse) ProtoMessage() {} func (*QueryRewardResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_324afa5f2186a8c0, []int{7} + return fileDescriptor_324afa5f2186a8c0, []int{11} } func (m *QueryRewardResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -401,7 +591,7 @@ func (m *QueryRewardsRequest) Reset() { *m = QueryRewardsRequest{} } func (m *QueryRewardsRequest) String() string { return proto.CompactTextString(m) } func (*QueryRewardsRequest) ProtoMessage() {} func (*QueryRewardsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_324afa5f2186a8c0, []int{8} + return fileDescriptor_324afa5f2186a8c0, []int{12} } func (m *QueryRewardsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -447,7 +637,7 @@ func (m *QueryRewardsResponse) Reset() { *m = QueryRewardsResponse{} } func (m *QueryRewardsResponse) String() string { return proto.CompactTextString(m) } func (*QueryRewardsResponse) ProtoMessage() {} func (*QueryRewardsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_324afa5f2186a8c0, []int{9} + return fileDescriptor_324afa5f2186a8c0, []int{13} } func (m *QueryRewardsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -493,15 +683,16 @@ func (m *QueryRewardsResponse) GetPagination() *query.PageResponse { // QueryRewardsByAddressRequest is request body for the query all rewards by // address endpoint. type QueryRewardsByAddressRequest struct { - Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` - Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + PromoterUid string `protobuf:"bytes,3,opt,name=promoter_uid,json=promoterUid,proto3" json:"promoter_uid,omitempty"` } func (m *QueryRewardsByAddressRequest) Reset() { *m = QueryRewardsByAddressRequest{} } func (m *QueryRewardsByAddressRequest) String() string { return proto.CompactTextString(m) } func (*QueryRewardsByAddressRequest) ProtoMessage() {} func (*QueryRewardsByAddressRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_324afa5f2186a8c0, []int{10} + return fileDescriptor_324afa5f2186a8c0, []int{14} } func (m *QueryRewardsByAddressRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -544,6 +735,13 @@ func (m *QueryRewardsByAddressRequest) GetAddress() string { return "" } +func (m *QueryRewardsByAddressRequest) GetPromoterUid() string { + if m != nil { + return m.PromoterUid + } + return "" +} + // QueryRewardsByAddressResponse is response body of the query all rewards by // address endpoint. type QueryRewardsByAddressResponse struct { @@ -555,7 +753,7 @@ func (m *QueryRewardsByAddressResponse) Reset() { *m = QueryRewardsByAdd func (m *QueryRewardsByAddressResponse) String() string { return proto.CompactTextString(m) } func (*QueryRewardsByAddressResponse) ProtoMessage() {} func (*QueryRewardsByAddressResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_324afa5f2186a8c0, []int{11} + return fileDescriptor_324afa5f2186a8c0, []int{15} } func (m *QueryRewardsByAddressResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -601,9 +799,10 @@ func (m *QueryRewardsByAddressResponse) GetPagination() *query.PageResponse { // QueryRewardsByAddressAndCategoryRequest is request body for the query all // rewards by address and category endpoint. type QueryRewardsByAddressAndCategoryRequest struct { - Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` - Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` - Category RewardCategory `protobuf:"varint,3,opt,name=category,proto3,enum=sgenetwork.sge.reward.RewardCategory" json:"category,omitempty"` + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + Category RewardCategory `protobuf:"varint,3,opt,name=category,proto3,enum=sgenetwork.sge.reward.RewardCategory" json:"category,omitempty"` + PromoterUid string `protobuf:"bytes,4,opt,name=promoter_uid,json=promoterUid,proto3" json:"promoter_uid,omitempty"` } func (m *QueryRewardsByAddressAndCategoryRequest) Reset() { @@ -612,7 +811,7 @@ func (m *QueryRewardsByAddressAndCategoryRequest) Reset() { func (m *QueryRewardsByAddressAndCategoryRequest) String() string { return proto.CompactTextString(m) } func (*QueryRewardsByAddressAndCategoryRequest) ProtoMessage() {} func (*QueryRewardsByAddressAndCategoryRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_324afa5f2186a8c0, []int{12} + return fileDescriptor_324afa5f2186a8c0, []int{16} } func (m *QueryRewardsByAddressAndCategoryRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -662,6 +861,13 @@ func (m *QueryRewardsByAddressAndCategoryRequest) GetCategory() RewardCategory { return RewardCategory_REWARD_CATEGORY_UNSPECIFIED } +func (m *QueryRewardsByAddressAndCategoryRequest) GetPromoterUid() string { + if m != nil { + return m.PromoterUid + } + return "" +} + // QueryRewardsByAddressAndCategoryResponse is response body of the query all // rewards by address and category endpoint. type QueryRewardsByAddressAndCategoryResponse struct { @@ -675,7 +881,7 @@ func (m *QueryRewardsByAddressAndCategoryResponse) Reset() { func (m *QueryRewardsByAddressAndCategoryResponse) String() string { return proto.CompactTextString(m) } func (*QueryRewardsByAddressAndCategoryResponse) ProtoMessage() {} func (*QueryRewardsByAddressAndCategoryResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_324afa5f2186a8c0, []int{13} + return fileDescriptor_324afa5f2186a8c0, []int{17} } func (m *QueryRewardsByAddressAndCategoryResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -729,7 +935,7 @@ func (m *QueryRewardsByCampaignRequest) Reset() { *m = QueryRewardsByCam func (m *QueryRewardsByCampaignRequest) String() string { return proto.CompactTextString(m) } func (*QueryRewardsByCampaignRequest) ProtoMessage() {} func (*QueryRewardsByCampaignRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_324afa5f2186a8c0, []int{14} + return fileDescriptor_324afa5f2186a8c0, []int{18} } func (m *QueryRewardsByCampaignRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -783,7 +989,7 @@ func (m *QueryRewardsByCampaignResponse) Reset() { *m = QueryRewardsByCa func (m *QueryRewardsByCampaignResponse) String() string { return proto.CompactTextString(m) } func (*QueryRewardsByCampaignResponse) ProtoMessage() {} func (*QueryRewardsByCampaignResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_324afa5f2186a8c0, []int{15} + return fileDescriptor_324afa5f2186a8c0, []int{19} } func (m *QueryRewardsByCampaignResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -829,6 +1035,10 @@ func (m *QueryRewardsByCampaignResponse) GetPagination() *query.PageResponse { func init() { proto.RegisterType((*QueryParamsRequest)(nil), "sgenetwork.sge.reward.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "sgenetwork.sge.reward.QueryParamsResponse") + proto.RegisterType((*QueryPromoterByAddressRequest)(nil), "sgenetwork.sge.reward.QueryPromoterByAddressRequest") + proto.RegisterType((*QueryPromoterByAddressResponse)(nil), "sgenetwork.sge.reward.QueryPromoterByAddressResponse") + proto.RegisterType((*QueryPromotersRequest)(nil), "sgenetwork.sge.reward.QueryPromotersRequest") + proto.RegisterType((*QueryPromotersResponse)(nil), "sgenetwork.sge.reward.QueryPromotersResponse") proto.RegisterType((*QueryCampaignRequest)(nil), "sgenetwork.sge.reward.QueryCampaignRequest") proto.RegisterType((*QueryCampaignResponse)(nil), "sgenetwork.sge.reward.QueryCampaignResponse") proto.RegisterType((*QueryCampaignsRequest)(nil), "sgenetwork.sge.reward.QueryCampaignsRequest") @@ -848,60 +1058,70 @@ func init() { func init() { proto.RegisterFile("sge/reward/query.proto", fileDescriptor_324afa5f2186a8c0) } var fileDescriptor_324afa5f2186a8c0 = []byte{ - // 848 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x97, 0x4b, 0x4f, 0x13, 0x51, - 0x14, 0xc7, 0x7b, 0x41, 0x0b, 0x5c, 0x8c, 0xc1, 0x23, 0x20, 0x56, 0x18, 0x60, 0xd4, 0x3e, 0x78, - 0xcc, 0x84, 0x87, 0x1a, 0xe3, 0x83, 0x00, 0x89, 0x6c, 0xb1, 0x89, 0x1b, 0x12, 0x43, 0x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0x26, 0x9b, 0x25, 0xf0, 0x75, 0x3b, 0x32, 0x15, 0xcc, 0x58, 0xf2, 0x18, 0x9c, 0x27, 0x0e, 0xd1, - 0x46, 0x3c, 0xaa, 0xbb, 0xe6, 0x76, 0xde, 0x49, 0x17, 0x61, 0x07, 0xe1, 0x9e, 0xf2, 0x4a, 0x85, - 0x40, 0xb9, 0xca, 0x3a, 0x4d, 0x07, 0xb4, 0x96, 0x68, 0x09, 0x8e, 0x76, 0x11, 0xc6, 0x5b, 0xa1, - 0x31, 0x78, 0x85, 0x70, 0x58, 0x1c, 0x97, 0xe6, 0x7d, 0xab, 0x5a, 0xb3, 0xcd, 0xfb, 0x56, 0xbd, - 0x69, 0xf5, 0x29, 0x0e, 0x13, 0x85, 0x4b, 0x8d, 0x60, 0xe4, 0x45, 0xa8, 0xf4, 0x12, 0xe1, 0x2e, - 0xf9, 0x05, 0x40, 0x80, 0x2c, 0x65, 0x85, 0x26, 0x03, 0xd9, 0x4a, 0xa4, 0x18, 0x47, 0x1a, 0x87, - 0xd1, 0xe6, 0x48, 0x0c, 0xde, 0x23, 0xdc, 0xe7, 0x9f, 0x6d, 0x30, 0x17, 0x20, 0x95, 0x7f, 0x23, - 0x46, 0xe6, 0x8f, 0xe6, 0x24, 0x41, 0x67, 0x38, 0xe8, 0x24, 0x24, 0x5a, 0x80, 0x9a, 0xdb, 0x72, - 0xaa, 0x17, 0xe1, 0x07, 0xc2, 0x17, 0x9a, 0x8c, 0x63, 0xb8, 0x7d, 0x14, 0x90, 0xda, 0xc5, 0x14, - 0x59, 0x38, 0xb6, 0xbf, 0xac, 0xe9, 0x26, 0xaf, 0xe9, 0x2a, 0xcc, 0x07, 0xae, 0xc9, 0xdc, 0x56, - 0x1b, 0xa7, 0x08, 0x5f, 0x10, 0x3e, 0x53, 0x33, 0x21, 0x21, 0x98, 0xba, 0xfe, 0xef, 0xfd, 0xca, - 0x11, 0xbd, 0x64, 0x01, 0x0b, 0xbc, 0x80, 0xeb, 0x70, 0xad, 0x55, 0x01, 0x87, 0x03, 0xa0, 0x72, - 0xf8, 0x17, 0x97, 0x96, 0x77, 0xf7, 0x35, 0xb4, 0xb7, 0xaf, 0xa1, 0x5f, 0xfb, 0x1a, 0x7a, 0x7d, - 0xa0, 0x85, 0xf6, 0x0e, 0xb4, 0xd0, 0xf7, 0x03, 0x2d, 0xb4, 0x96, 0xb0, 0x1d, 0xef, 0x41, 0x3e, - 0x65, 0x6c, 0xd0, 0x4c, 0x4d, 0xf0, 0x27, 0x2a, 0xbc, 0x57, 0xc8, 0x11, 0x96, 0x0a, 0xf3, 0x9f, - 0x3f, 0x73, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x25, 0x82, 0xdd, 0x83, 0xdc, 0x0d, 0x00, 0x00, + // 1004 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x98, 0xcf, 0x6f, 0x1b, 0x45, + 0x14, 0xc7, 0x33, 0x4d, 0x70, 0x9a, 0x49, 0x41, 0xed, 0x23, 0x2d, 0xc5, 0xb4, 0x9b, 0x7a, 0x01, + 0xdb, 0x69, 0xe3, 0x5d, 0xd5, 0x49, 0x05, 0x14, 0x41, 0x49, 0x2c, 0xe8, 0x81, 0x4b, 0xb1, 0xc4, + 0xa5, 0x12, 0xaa, 0xd6, 0xde, 0xd1, 0xb2, 0x02, 0x7b, 0xb6, 0x3b, 0x6b, 0x8a, 0x65, 0xf9, 0xc2, + 0x05, 0x09, 0x84, 0x84, 0x54, 0x71, 0xe5, 0x02, 0xe2, 0x0e, 0xe7, 0x4a, 0x88, 0x5b, 0x8f, 0x95, + 0xb8, 0x70, 0x42, 0x28, 0xe1, 0xc6, 0x89, 0xff, 0x00, 0x79, 0x7e, 0xac, 0xbd, 0x5e, 0xef, 0x0f, + 0x5b, 0x0e, 0xea, 0xc9, 0x9b, 0xdd, 0xf7, 0xe6, 0x7d, 0xde, 0xf7, 0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 0x04, 0xdb, 0xe9, 0x48, 0x0c, 0x7e, 0x45, 0xf8, 0xec, 0xf4, 0x85, 0x01, 0x7b, + 0x39, 0x42, 0xc5, 0xda, 0x73, 0x7f, 0x3e, 0x27, 0x09, 0xfa, 0x0e, 0x07, 0xbd, 0x09, 0xaf, 0x67, + 0x80, 0x9a, 0x83, 0xc9, 0xfb, 0x6f, 0x28, 0x1a, 0x94, 0x30, 0x36, 0x84, 0x7f, 0x10, 0x7e, 0x29, + 0xe5, 0xca, 0x83, 0xb7, 0xe7, 0xe1, 0x8a, 0xcf, 0x07, 0xc5, 0x5b, 0x0b, 0xfb, 0xcb, 0x14, 0xdf, + 0xe7, 0x29, 0xbe, 0x0b, 0x8d, 0x45, 0x53, 0x34, 0x07, 0x6a, 0x0e, 0x18, 0xc2, 0x6f, 0x08, 0x9f, + 0x8b, 0x5d, 0x4a, 0x90, 0x4f, 0xfb, 0xe9, 0xd3, 0xe0, 0xc6, 0x9c, 0x5e, 0x32, 0x9f, 0x5b, 0x3c, + 0x9f, 0x37, 0xe0, 0xb5, 0xac, 0x7c, 0xc6, 0xc7, 0xc3, 0xe4, 0x7d, 0x3b, 0x3c, 0x6c, 0x3c, 0x3e, + 0xd2, 0xd0, 0x93, 0x23, 0x0d, 0xfd, 0x75, 0xa4, 0xa1, 0x6f, 0x8f, 0xb5, 0x95, 0x27, 0xc7, 0xda, + 0xca, 0x1f, 0xc7, 0xda, 0xca, 0xdd, 0x1d, 0xc7, 0x0d, 0x3e, 0xee, 0xb5, 0x8c, 0x36, 0xed, 0xc4, + 0x16, 0xff, 0x5c, 0x2d, 0x1f, 0xf4, 0x3d, 0xc2, 0x5a, 0x05, 0xfe, 0x9f, 0x85, 0xbd, 0xff, 0x02, + 0x00, 0x00, 0xff, 0xff, 0x58, 0x4e, 0x9a, 0x90, 0x52, 0x11, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -918,6 +1138,10 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { // Parameters queries the parameters of the module. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // PromoterByAddress queries a certain promoter. + PromoterByAddress(ctx context.Context, in *QueryPromoterByAddressRequest, opts ...grpc.CallOption) (*QueryPromoterByAddressResponse, error) + // Queries list of all Promoter items. + Promoters(ctx context.Context, in *QueryPromotersRequest, opts ...grpc.CallOption) (*QueryPromotersResponse, error) // Queries a specific Campaign item. Campaign(ctx context.Context, in *QueryCampaignRequest, opts ...grpc.CallOption) (*QueryCampaignResponse, error) // Queries list of all Campaign items. @@ -952,6 +1176,24 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . return out, nil } +func (c *queryClient) PromoterByAddress(ctx context.Context, in *QueryPromoterByAddressRequest, opts ...grpc.CallOption) (*QueryPromoterByAddressResponse, error) { + out := new(QueryPromoterByAddressResponse) + err := c.cc.Invoke(ctx, "/sgenetwork.sge.reward.Query/PromoterByAddress", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Promoters(ctx context.Context, in *QueryPromotersRequest, opts ...grpc.CallOption) (*QueryPromotersResponse, error) { + out := new(QueryPromotersResponse) + err := c.cc.Invoke(ctx, "/sgenetwork.sge.reward.Query/Promoters", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *queryClient) Campaign(ctx context.Context, in *QueryCampaignRequest, opts ...grpc.CallOption) (*QueryCampaignResponse, error) { out := new(QueryCampaignResponse) err := c.cc.Invoke(ctx, "/sgenetwork.sge.reward.Query/Campaign", in, out, opts...) @@ -1019,6 +1261,10 @@ func (c *queryClient) RewardsByCampaign(ctx context.Context, in *QueryRewardsByC type QueryServer interface { // Parameters queries the parameters of the module. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // PromoterByAddress queries a certain promoter. + PromoterByAddress(context.Context, *QueryPromoterByAddressRequest) (*QueryPromoterByAddressResponse, error) + // Queries list of all Promoter items. + Promoters(context.Context, *QueryPromotersRequest) (*QueryPromotersResponse, error) // Queries a specific Campaign item. Campaign(context.Context, *QueryCampaignRequest) (*QueryCampaignResponse, error) // Queries list of all Campaign items. @@ -1043,6 +1289,12 @@ type UnimplementedQueryServer struct { func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } +func (*UnimplementedQueryServer) PromoterByAddress(ctx context.Context, req *QueryPromoterByAddressRequest) (*QueryPromoterByAddressResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PromoterByAddress not implemented") +} +func (*UnimplementedQueryServer) Promoters(ctx context.Context, req *QueryPromotersRequest) (*QueryPromotersResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Promoters not implemented") +} func (*UnimplementedQueryServer) Campaign(ctx context.Context, req *QueryCampaignRequest) (*QueryCampaignResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Campaign not implemented") } @@ -1087,6 +1339,42 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } +func _Query_PromoterByAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPromoterByAddressRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).PromoterByAddress(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/sgenetwork.sge.reward.Query/PromoterByAddress", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).PromoterByAddress(ctx, req.(*QueryPromoterByAddressRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Promoters_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPromotersRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Promoters(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/sgenetwork.sge.reward.Query/Promoters", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Promoters(ctx, req.(*QueryPromotersRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_Campaign_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryCampaignRequest) if err := dec(in); err != nil { @@ -1221,6 +1509,14 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Params", Handler: _Query_Params_Handler, }, + { + MethodName: "PromoterByAddress", + Handler: _Query_PromoterByAddress_Handler, + }, + { + MethodName: "Promoters", + Handler: _Query_Promoters_Handler, + }, { MethodName: "Campaign", Handler: _Query_Campaign_Handler, @@ -1310,7 +1606,7 @@ func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *QueryCampaignRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryPromoterByAddressRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1320,27 +1616,27 @@ func (m *QueryCampaignRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryCampaignRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPromoterByAddressRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryCampaignRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPromoterByAddressRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Uid) > 0 { - i -= len(m.Uid) - copy(dAtA[i:], m.Uid) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Uid))) + if len(m.Addr) > 0 { + i -= len(m.Addr) + copy(dAtA[i:], m.Addr) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Addr))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *QueryCampaignResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryPromoterByAddressResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1350,18 +1646,18 @@ func (m *QueryCampaignResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryCampaignResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPromoterByAddressResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryCampaignResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPromoterByAddressResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l { - size, err := m.Campaign.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Promoter.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1373,7 +1669,7 @@ func (m *QueryCampaignResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *QueryCampaignsRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryPromotersRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1383,12 +1679,12 @@ func (m *QueryCampaignsRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryCampaignsRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPromotersRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryCampaignsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPromotersRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1408,7 +1704,7 @@ func (m *QueryCampaignsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *QueryCampaignsResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryPromotersResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1418,12 +1714,12 @@ func (m *QueryCampaignsResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryCampaignsResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPromotersResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryCampaignsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPromotersResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1440,10 +1736,10 @@ func (m *QueryCampaignsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) i-- dAtA[i] = 0x12 } - if len(m.Campaign) > 0 { - for iNdEx := len(m.Campaign) - 1; iNdEx >= 0; iNdEx-- { + if len(m.Promoter) > 0 { + for iNdEx := len(m.Promoter) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.Campaign[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Promoter[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1457,7 +1753,7 @@ func (m *QueryCampaignsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *QueryRewardRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryCampaignRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1467,12 +1763,12 @@ func (m *QueryRewardRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryRewardRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryCampaignRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryRewardRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryCampaignRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1487,7 +1783,7 @@ func (m *QueryRewardRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *QueryRewardResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryCampaignResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1497,18 +1793,18 @@ func (m *QueryRewardResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryRewardResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryCampaignResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryRewardResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryCampaignResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l { - size, err := m.Reward.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Campaign.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1520,7 +1816,7 @@ func (m *QueryRewardResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *QueryRewardsRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryCampaignsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1530,12 +1826,12 @@ func (m *QueryRewardsRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryRewardsRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryCampaignsRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryRewardsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryCampaignsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1555,7 +1851,7 @@ func (m *QueryRewardsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *QueryRewardsResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryCampaignsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1565,12 +1861,12 @@ func (m *QueryRewardsResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryRewardsResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryCampaignsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryRewardsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryCampaignsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1587,10 +1883,10 @@ func (m *QueryRewardsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if len(m.Rewards) > 0 { - for iNdEx := len(m.Rewards) - 1; iNdEx >= 0; iNdEx-- { + if len(m.Campaign) > 0 { + for iNdEx := len(m.Campaign) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.Rewards[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Campaign[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1604,7 +1900,7 @@ func (m *QueryRewardsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *QueryRewardsByAddressRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryRewardRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1614,16 +1910,170 @@ func (m *QueryRewardsByAddressRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryRewardsByAddressRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryRewardRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryRewardsByAddressRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryRewardRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Uid) > 0 { + i -= len(m.Uid) + copy(dAtA[i:], m.Uid) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Uid))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryRewardResponse) 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 *QueryRewardResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRewardResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Reward.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryRewardsRequest) 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 *QueryRewardsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRewardsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryRewardsResponse) 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 *QueryRewardsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRewardsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Rewards) > 0 { + for iNdEx := len(m.Rewards) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Rewards[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryRewardsByAddressRequest) 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 *QueryRewardsByAddressRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRewardsByAddressRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l + if len(m.PromoterUid) > 0 { + i -= len(m.PromoterUid) + copy(dAtA[i:], m.PromoterUid) + i = encodeVarintQuery(dAtA, i, uint64(len(m.PromoterUid))) + i-- + dAtA[i] = 0x1a + } if len(m.Address) > 0 { i -= len(m.Address) copy(dAtA[i:], m.Address) @@ -1715,6 +2165,13 @@ func (m *QueryRewardsByAddressAndCategoryRequest) MarshalToSizedBuffer(dAtA []by _ = i var l int _ = l + if len(m.PromoterUid) > 0 { + i -= len(m.PromoterUid) + copy(dAtA[i:], m.PromoterUid) + i = encodeVarintQuery(dAtA, i, uint64(len(m.PromoterUid))) + i-- + dAtA[i] = 0x22 + } if m.Category != 0 { i = encodeVarintQuery(dAtA, i, uint64(m.Category)) i-- @@ -1913,6 +2370,62 @@ func (m *QueryParamsResponse) Size() (n int) { return n } +func (m *QueryPromoterByAddressRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Addr) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryPromoterByAddressResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Promoter.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryPromotersRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryPromotersResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Promoter) > 0 { + for _, e := range m.Promoter { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func (m *QueryCampaignRequest) Size() (n int) { if m == nil { return 0 @@ -2039,6 +2552,10 @@ func (m *QueryRewardsByAddressRequest) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } + l = len(m.PromoterUid) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } return n } @@ -2078,6 +2595,10 @@ func (m *QueryRewardsByAddressAndCategoryRequest) Size() (n int) { if m.Category != 0 { n += 1 + sovQuery(uint64(m.Category)) } + l = len(m.PromoterUid) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } return n } @@ -2275,7 +2796,7 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryCampaignRequest) Unmarshal(dAtA []byte) error { +func (m *QueryPromoterByAddressRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2298,15 +2819,15 @@ func (m *QueryCampaignRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryCampaignRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPromoterByAddressRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryCampaignRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPromoterByAddressRequest: 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) + return fmt.Errorf("proto: wrong wireType = %d for field Addr", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2334,7 +2855,7 @@ func (m *QueryCampaignRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Uid = string(dAtA[iNdEx:postIndex]) + m.Addr = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -2357,7 +2878,7 @@ func (m *QueryCampaignRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryCampaignResponse) Unmarshal(dAtA []byte) error { +func (m *QueryPromoterByAddressResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2380,15 +2901,15 @@ func (m *QueryCampaignResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryCampaignResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPromoterByAddressResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryCampaignResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPromoterByAddressResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Campaign", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Promoter", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2415,7 +2936,7 @@ func (m *QueryCampaignResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Campaign.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Promoter.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2440,7 +2961,7 @@ func (m *QueryCampaignResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryCampaignsRequest) Unmarshal(dAtA []byte) error { +func (m *QueryPromotersRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2463,10 +2984,10 @@ func (m *QueryCampaignsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryCampaignsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPromotersRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryCampaignsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPromotersRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2526,7 +3047,7 @@ func (m *QueryCampaignsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryCampaignsResponse) Unmarshal(dAtA []byte) error { +func (m *QueryPromotersResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2549,15 +3070,15 @@ func (m *QueryCampaignsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryCampaignsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPromotersResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryCampaignsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPromotersResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Campaign", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Promoter", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2584,8 +3105,8 @@ func (m *QueryCampaignsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Campaign = append(m.Campaign, Campaign{}) - if err := m.Campaign[len(m.Campaign)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Promoter = append(m.Promoter, Promoter{}) + if err := m.Promoter[len(m.Promoter)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2646,7 +3167,7 @@ func (m *QueryCampaignsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryRewardRequest) Unmarshal(dAtA []byte) error { +func (m *QueryCampaignRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2669,10 +3190,10 @@ func (m *QueryRewardRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryRewardRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryCampaignRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryRewardRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryCampaignRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2728,7 +3249,7 @@ func (m *QueryRewardRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryRewardResponse) Unmarshal(dAtA []byte) error { +func (m *QueryCampaignResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2751,15 +3272,15 @@ func (m *QueryRewardResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryRewardResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryCampaignResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryRewardResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryCampaignResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Reward", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Campaign", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2786,7 +3307,7 @@ func (m *QueryRewardResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Reward.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Campaign.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2811,7 +3332,7 @@ func (m *QueryRewardResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryRewardsRequest) Unmarshal(dAtA []byte) error { +func (m *QueryCampaignsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2834,10 +3355,10 @@ func (m *QueryRewardsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryRewardsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryCampaignsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryRewardsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryCampaignsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2897,7 +3418,7 @@ func (m *QueryRewardsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryRewardsResponse) Unmarshal(dAtA []byte) error { +func (m *QueryCampaignsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2920,15 +3441,15 @@ func (m *QueryRewardsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryRewardsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryCampaignsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryRewardsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryCampaignsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Rewards", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Campaign", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2955,7 +3476,378 @@ func (m *QueryRewardsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Rewards = append(m.Rewards, Reward{}) + m.Campaign = append(m.Campaign, Campaign{}) + if err := m.Campaign[len(m.Campaign)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryRewardRequest) 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 ErrIntOverflowQuery + } + 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: QueryRewardRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRewardRequest: 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 ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Uid = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryRewardResponse) 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 ErrIntOverflowQuery + } + 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: QueryRewardResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRewardResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Reward", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Reward.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryRewardsRequest) 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 ErrIntOverflowQuery + } + 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: QueryRewardsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRewardsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryRewardsResponse) 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 ErrIntOverflowQuery + } + 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: QueryRewardsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRewardsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Rewards", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Rewards = append(m.Rewards, Reward{}) if err := m.Rewards[len(m.Rewards)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -3114,6 +4006,38 @@ func (m *QueryRewardsByAddressRequest) Unmarshal(dAtA []byte) error { } m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PromoterUid", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PromoterUid = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -3371,6 +4295,38 @@ func (m *QueryRewardsByAddressAndCategoryRequest) Unmarshal(dAtA []byte) error { break } } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PromoterUid", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PromoterUid = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) diff --git a/x/reward/types/query.pb.gw.go b/x/reward/types/query.pb.gw.go index 6a9886e6..4015978e 100644 --- a/x/reward/types/query.pb.gw.go +++ b/x/reward/types/query.pb.gw.go @@ -51,6 +51,96 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal } +func request_Query_PromoterByAddress_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPromoterByAddressRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["addr"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "addr") + } + + protoReq.Addr, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "addr", err) + } + + msg, err := client.PromoterByAddress(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_PromoterByAddress_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPromoterByAddressRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["addr"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "addr") + } + + protoReq.Addr, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "addr", err) + } + + msg, err := server.PromoterByAddress(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_Promoters_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_Promoters_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPromotersRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Promoters_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Promoters(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Promoters_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPromotersRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Promoters_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Promoters(ctx, &protoReq) + return msg, metadata, err + +} + func request_Query_Campaign_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryCampaignRequest var metadata runtime.ServerMetadata @@ -232,7 +322,7 @@ func local_request_Query_Rewards_0(ctx context.Context, marshaler runtime.Marsha } var ( - filter_Query_RewardsByAddress_0 = &utilities.DoubleArray{Encoding: map[string]int{"address": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} + filter_Query_RewardsByAddress_0 = &utilities.DoubleArray{Encoding: map[string]int{"promoter_uid": 0, "address": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} ) func request_Query_RewardsByAddress_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -246,6 +336,17 @@ func request_Query_RewardsByAddress_0(ctx context.Context, marshaler runtime.Mar _ = err ) + val, ok = pathParams["promoter_uid"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "promoter_uid") + } + + protoReq.PromoterUid, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "promoter_uid", err) + } + val, ok = pathParams["address"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") @@ -280,6 +381,17 @@ func local_request_Query_RewardsByAddress_0(ctx context.Context, marshaler runti _ = err ) + val, ok = pathParams["promoter_uid"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "promoter_uid") + } + + protoReq.PromoterUid, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "promoter_uid", err) + } + val, ok = pathParams["address"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") @@ -304,7 +416,7 @@ func local_request_Query_RewardsByAddress_0(ctx context.Context, marshaler runti } var ( - filter_Query_RewardsByAddressAndCategory_0 = &utilities.DoubleArray{Encoding: map[string]int{"address": 0, "category": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} + filter_Query_RewardsByAddressAndCategory_0 = &utilities.DoubleArray{Encoding: map[string]int{"promoter_uid": 0, "address": 1, "category": 2}, Base: []int{1, 1, 2, 3, 0, 0, 0}, Check: []int{0, 1, 1, 1, 2, 3, 4}} ) func request_Query_RewardsByAddressAndCategory_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -319,6 +431,17 @@ func request_Query_RewardsByAddressAndCategory_0(ctx context.Context, marshaler _ = err ) + val, ok = pathParams["promoter_uid"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "promoter_uid") + } + + protoReq.PromoterUid, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "promoter_uid", err) + } + val, ok = pathParams["address"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") @@ -367,6 +490,17 @@ func local_request_Query_RewardsByAddressAndCategory_0(ctx context.Context, mars _ = err ) + val, ok = pathParams["promoter_uid"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "promoter_uid") + } + + protoReq.PromoterUid, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "promoter_uid", err) + } + val, ok = pathParams["address"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") @@ -504,6 +638,52 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_PromoterByAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_PromoterByAddress_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_PromoterByAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Promoters_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Promoters_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Promoters_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_Campaign_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -726,6 +906,46 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_PromoterByAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_PromoterByAddress_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_PromoterByAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Promoters_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Promoters_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Promoters_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_Campaign_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -872,6 +1092,10 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie var ( pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"sge-network", "sge", "reward", "params"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_PromoterByAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"sge-network", "sge", "reward", "promoter-by-address", "addr"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_Promoters_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"sge-network", "sge", "reward", "promoters"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_Campaign_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"sge-network", "sge", "reward", "campaign", "uid"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_Campaigns_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"sge-network", "sge", "reward", "campaigns"}, "", runtime.AssumeColonVerbOpt(false))) @@ -880,9 +1104,9 @@ var ( pattern_Query_Rewards_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"sge-network", "sge", "reward", "rewards"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_RewardsByAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"sge-network", "sge", "reward", "rewards", "address"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_RewardsByAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"sge-network", "sge", "reward", "rewards", "promoter_uid", "address"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_RewardsByAddressAndCategory_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"sge-network", "sge", "reward", "rewards", "address", "category"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_RewardsByAddressAndCategory_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5, 1, 0, 4, 1, 5, 6}, []string{"sge-network", "sge", "reward", "rewards", "promoter_uid", "address", "category"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_RewardsByCampaign_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"sge-network", "sge", "reward", "rewards", "campaign", "campaign_uid"}, "", runtime.AssumeColonVerbOpt(false))) ) @@ -890,6 +1114,10 @@ var ( var ( forward_Query_Params_0 = runtime.ForwardResponseMessage + forward_Query_PromoterByAddress_0 = runtime.ForwardResponseMessage + + forward_Query_Promoters_0 = runtime.ForwardResponseMessage + forward_Query_Campaign_0 = runtime.ForwardResponseMessage forward_Query_Campaigns_0 = runtime.ForwardResponseMessage diff --git a/x/reward/types/reward_bet_bonus.go b/x/reward/types/reward_bet_bonus.go new file mode 100644 index 00000000..f387dc51 --- /dev/null +++ b/x/reward/types/reward_bet_bonus.go @@ -0,0 +1,117 @@ +package types + +import ( + context "context" + + sdkerrors "cosmossdk.io/errors" + sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrtypes "github.com/cosmos/cosmos-sdk/types/errors" + bettypes "github.com/sge-network/sge/x/bet/types" +) + +var percent = sdk.NewInt(100) + +// BetBonusReward is the type for bet bonus rewards calculations +type BetBonusReward struct{} + +// NewBetBonusReward create new object of bet bonus reward calculator type. +func NewBetBonusReward() BetBonusReward { return BetBonusReward{} } + +// ValidateCampaign validates campaign definitions. +func (sur BetBonusReward) ValidateCampaign(campaign Campaign) error { + if campaign.RewardCategory != RewardCategory_REWARD_CATEGORY_BET_DISCOUNT { + return sdkerrors.Wrapf(ErrWrongRewardCategory, "bet bonus rewards can only have single definition") + } + if campaign.RewardAmount.MainAccountAmount.GT(percent) { + return sdkerrors.Wrapf(ErrWrongAmountForType, "bet bonus rewards percent for main account should be between 0 and 100") + } + if campaign.RewardAmount.SubaccountAmount.GT(percent) { + return sdkerrors.Wrapf(ErrWrongAmountForType, "bet bonus rewards percent for sub account should be between 0 and 100") + } + if campaign.RewardAmount.MainAccountAmount.IsZero() && campaign.RewardAmount.SubaccountAmount.IsZero() { + return sdkerrors.Wrapf(ErrWrongAmountForType, "one of main account and sub account percentage should be higher than zero") + } + if campaign.RewardAmountType != RewardAmountType_REWARD_AMOUNT_TYPE_PERCENTAGE { + return sdkerrors.Wrapf(ErrWrongRewardAmountType, "reward amount type not supported for given reward type.") + } + if campaign.Constraints == nil || campaign.Constraints.MaxBetAmount.IsNil() { + return sdkerrors.Wrapf(ErrMissingConstraintForCampaign, "constraints and max bet amount should be set for the bet bonus reward.") + } + + return nil +} + +// Calculate parses ticket payload and returns the distribution list of bet bonus reward. +func (sur BetBonusReward) Calculate(goCtx context.Context, ctx sdk.Context, keepers RewardFactoryKeepers, + campaign Campaign, ticket, creator string, +) (RewardFactoryData, error) { + var payload GrantBetBonusRewardPayload + if err := keepers.OVMKeeper.VerifyTicketUnmarshal(goCtx, ticket, &payload); err != nil { + return RewardFactoryData{}, sdkerrors.Wrapf(ErrInTicketVerification, "%s", err) + } + + if err := payload.Common.Validate(); err != nil { + return RewardFactoryData{}, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "%s", err) + } + + addr, err := sdk.AccAddressFromBech32(payload.Common.Receiver) + if err != nil { + return RewardFactoryData{}, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidAddress, "%s", err) + } + + if keepers.SubaccountKeeper.IsSubaccount(ctx, addr) { + return RewardFactoryData{}, ErrReceiverAddrCanNotBeSubaccount + } + + subAccountAddressString, err := keepers.getSubaccountAddr(ctx, creator, payload.Common.Receiver) + if err != nil { + return RewardFactoryData{}, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidAddress, "%s", err) + } + + uid2ID, found := keepers.BetKeeper.GetBetID(ctx, payload.BetUID) + if !found { + return RewardFactoryData{}, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "bet id not found for uid %s", payload.BetUID) + } + + bet, found := keepers.BetKeeper.GetBet(ctx, payload.Common.Receiver, uid2ID.ID) + if !found { + return RewardFactoryData{}, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "bet not found with uid %s", payload.BetUID) + } + + if !bet.Meta.IsMainMarket { + return RewardFactoryData{}, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "bet bonus grant is allowed for main market bets only %s", payload.BetUID) + } + + if bet.Result != bettypes.Bet_RESULT_LOST && + bet.Result != bettypes.Bet_RESULT_WON { + return RewardFactoryData{}, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "bet should be winner or loser, requested bet result is %s", bet.Result) + } + + effectiveBetAmount := sdk.NewDecFromInt(bet.Amount) + if campaign.Constraints != nil { + if !campaign.Constraints.MaxBetAmount.IsNil() && campaign.Constraints.MaxBetAmount.GT(sdkmath.ZeroInt()) { + effectiveBetAmount = sdk.NewDecFromInt( + sdkmath.MinInt(campaign.Constraints.MaxBetAmount, bet.Amount), + ) + } + } + + mainAmount := effectiveBetAmount.Mul( + sdk.NewDecFromInt(campaign.RewardAmount.MainAccountAmount).QuoInt(percent), + ).TruncateInt() + subAmount := effectiveBetAmount.Mul( + sdk.NewDecFromInt(campaign.RewardAmount.SubaccountAmount).QuoInt(percent), + ).TruncateInt() + + return NewRewardFactoryData( + NewReceiver( + subAccountAddressString, + payload.Common.Receiver, + subAmount, + mainAmount, + campaign.RewardAmount.UnlockPeriod, + ), + payload.Common, + ), nil +} diff --git a/x/reward/types/reward_signup_affiliator.go b/x/reward/types/reward_signup_affiliator.go index 59d0d5d5..54b72f01 100644 --- a/x/reward/types/reward_signup_affiliator.go +++ b/x/reward/types/reward_signup_affiliator.go @@ -51,7 +51,12 @@ func (sur SignUpAffiliatorReward) Calculate(goCtx context.Context, ctx sdk.Conte return RewardFactoryData{}, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidAddress, "%s", err) } - if !keepers.RewardKeeper.HasRewardByReceiver(ctx, payload.Affiliatee, RewardCategory_REWARD_CATEGORY_SIGNUP) { + promoter, isFound := keepers.GetPromoterByAddress(ctx, campaign.Promoter) + if !isFound { + return RewardFactoryData{}, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "promoter with the address: %s not found", campaign.Promoter) + } + + if !keepers.RewardKeeper.HasRewardOfReceiverByPromoter(ctx, promoter.PromoterUID, payload.Affiliatee, RewardCategory_REWARD_CATEGORY_SIGNUP) { return RewardFactoryData{}, sdkerrors.Wrap(sdkerrtypes.ErrInvalidRequest, "affiliatee account has signed up yet, there is no affiliatee claim record") } diff --git a/x/reward/types/reward_signup_referrer.go b/x/reward/types/reward_signup_referrer.go index 8d195523..fdce94e4 100644 --- a/x/reward/types/reward_signup_referrer.go +++ b/x/reward/types/reward_signup_referrer.go @@ -48,7 +48,12 @@ func (sur SignUpReferrerReward) Calculate(goCtx context.Context, ctx sdk.Context return RewardFactoryData{}, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidAddress, "%s", err) } - if !keepers.RewardKeeper.HasRewardByReceiver(ctx, payload.Referee, RewardCategory_REWARD_CATEGORY_SIGNUP) { + promoter, isFound := keepers.GetPromoterByAddress(ctx, campaign.Promoter) + if !isFound { + return RewardFactoryData{}, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "promoter with the address: %s not found", campaign.Promoter) + } + + if !keepers.RewardKeeper.HasRewardOfReceiverByPromoter(ctx, promoter.PromoterUID, payload.Referee, RewardCategory_REWARD_CATEGORY_SIGNUP) { return RewardFactoryData{}, sdkerrors.Wrap(sdkerrtypes.ErrInvalidRequest, "referee account has signed up yet, there is no referee claim record") } diff --git a/x/reward/types/ticket.go b/x/reward/types/ticket.go index 744035d4..c4b18f37 100644 --- a/x/reward/types/ticket.go +++ b/x/reward/types/ticket.go @@ -7,6 +7,8 @@ import ( sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrtypes "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/sge-network/sge/utils" + "github.com/sge-network/sge/x/bet/types" ) // Validate validates campaign creation ticket payload. @@ -40,10 +42,6 @@ func (payload *CreateCampaignPayload) Validate(blockTime uint64) error { return sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "sub account should have unlock period") } - if payload.ClaimsPerCategory == 0 { - return sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, "claim per category should be a positive number") - } - return nil } @@ -106,3 +104,24 @@ func (payload *RewardPayloadCommon) Validate() error { } return nil } + +// Validate validates promoter config set ticket payload. +func (payload *CreatePromoterPayload) Validate() error { + if !utils.IsValidUID(payload.UID) { + return types.ErrInvalidBetUID + } + if err := payload.Conf.Validate(); err != nil { + return err + } + + return nil +} + +// Validate validates promoter config set ticket payload. +func (payload *SetPromoterConfPayload) Validate() error { + if err := payload.Conf.Validate(); err != nil { + return err + } + + return nil +} diff --git a/x/reward/types/ticket.pb.go b/x/reward/types/ticket.pb.go index 1fafafe4..26bb9f16 100644 --- a/x/reward/types/ticket.pb.go +++ b/x/reward/types/ticket.pb.go @@ -43,12 +43,13 @@ type CreateCampaignPayload struct { RewardAmount *RewardAmount `protobuf:"bytes,7,opt,name=reward_amount,json=rewardAmount,proto3" json:"reward_amount,omitempty"` // is_active is the flag to check if the campaign is active or not. IsActive bool `protobuf:"varint,8,opt,name=is_active,json=isActive,proto3" json:"is_active,omitempty"` - // claims_per_category is the number of times a user can claim a reward for - // category of this campaign. - ClaimsPerCategory uint64 `protobuf:"varint,9,opt,name=claims_per_category,json=claimsPerCategory,proto3" json:"claims_per_category,omitempty"` // meta is the metadata of the campaign. // It is a stringified base64 encoded json. Meta string `protobuf:"bytes,10,opt,name=meta,proto3" json:"meta,omitempty"` + // cap_count is the maximum allowed grant for a certain account. + CapCount uint64 `protobuf:"varint,11,opt,name=cap_count,json=capCount,proto3" json:"cap_count,omitempty"` + // constraints is the constrains of a campaign. + Constraints *CampaignConstraints `protobuf:"bytes,12,opt,name=constraints,proto3" json:"constraints,omitempty"` } func (m *CreateCampaignPayload) Reset() { *m = CreateCampaignPayload{} } @@ -140,18 +141,25 @@ func (m *CreateCampaignPayload) GetIsActive() bool { return false } -func (m *CreateCampaignPayload) GetClaimsPerCategory() uint64 { +func (m *CreateCampaignPayload) GetMeta() string { + if m != nil { + return m.Meta + } + return "" +} + +func (m *CreateCampaignPayload) GetCapCount() uint64 { if m != nil { - return m.ClaimsPerCategory + return m.CapCount } return 0 } -func (m *CreateCampaignPayload) GetMeta() string { +func (m *CreateCampaignPayload) GetConstraints() *CampaignConstraints { if m != nil { - return m.Meta + return m.Constraints } - return "" + return nil } // UpdateCampaignPayload is the type for campaign update payload. @@ -493,6 +501,161 @@ func (m *GrantSignupAffiliatorRewardPayload) GetAffiliatee() string { return "" } +// GrantBetBonusRewardPayload is the type for bet bonus reward +// grant payload. +type GrantBetBonusRewardPayload struct { + // common is the common properties of a reward + Common RewardPayloadCommon `protobuf:"bytes,1,opt,name=common,proto3" json:"common"` + // bet_uid is the list of uids + BetUID string `protobuf:"bytes,2,opt,name=bet_uid,proto3" json:"bet_uid"` +} + +func (m *GrantBetBonusRewardPayload) Reset() { *m = GrantBetBonusRewardPayload{} } +func (m *GrantBetBonusRewardPayload) String() string { return proto.CompactTextString(m) } +func (*GrantBetBonusRewardPayload) ProtoMessage() {} +func (*GrantBetBonusRewardPayload) Descriptor() ([]byte, []int) { + return fileDescriptor_5d710bc1249ca8ae, []int{7} +} +func (m *GrantBetBonusRewardPayload) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GrantBetBonusRewardPayload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GrantBetBonusRewardPayload.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GrantBetBonusRewardPayload) XXX_Merge(src proto.Message) { + xxx_messageInfo_GrantBetBonusRewardPayload.Merge(m, src) +} +func (m *GrantBetBonusRewardPayload) XXX_Size() int { + return m.Size() +} +func (m *GrantBetBonusRewardPayload) XXX_DiscardUnknown() { + xxx_messageInfo_GrantBetBonusRewardPayload.DiscardUnknown(m) +} + +var xxx_messageInfo_GrantBetBonusRewardPayload proto.InternalMessageInfo + +func (m *GrantBetBonusRewardPayload) GetCommon() RewardPayloadCommon { + if m != nil { + return m.Common + } + return RewardPayloadCommon{} +} + +func (m *GrantBetBonusRewardPayload) GetBetUID() string { + if m != nil { + return m.BetUID + } + return "" +} + +// CreatePromoterPayload is the payload for the promoter create. +type CreatePromoterPayload struct { + // uid is the uid of the promoter to be created + UID string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid"` + Conf PromoterConf `protobuf:"bytes,2,opt,name=conf,proto3" json:"conf"` +} + +func (m *CreatePromoterPayload) Reset() { *m = CreatePromoterPayload{} } +func (m *CreatePromoterPayload) String() string { return proto.CompactTextString(m) } +func (*CreatePromoterPayload) ProtoMessage() {} +func (*CreatePromoterPayload) Descriptor() ([]byte, []int) { + return fileDescriptor_5d710bc1249ca8ae, []int{8} +} +func (m *CreatePromoterPayload) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CreatePromoterPayload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CreatePromoterPayload.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 *CreatePromoterPayload) XXX_Merge(src proto.Message) { + xxx_messageInfo_CreatePromoterPayload.Merge(m, src) +} +func (m *CreatePromoterPayload) XXX_Size() int { + return m.Size() +} +func (m *CreatePromoterPayload) XXX_DiscardUnknown() { + xxx_messageInfo_CreatePromoterPayload.DiscardUnknown(m) +} + +var xxx_messageInfo_CreatePromoterPayload proto.InternalMessageInfo + +func (m *CreatePromoterPayload) GetUID() string { + if m != nil { + return m.UID + } + return "" +} + +func (m *CreatePromoterPayload) GetConf() PromoterConf { + if m != nil { + return m.Conf + } + return PromoterConf{} +} + +// SetPromoterConfPayload is the payload for the promoter configuration change. +type SetPromoterConfPayload struct { + Conf PromoterConf `protobuf:"bytes,1,opt,name=conf,proto3" json:"conf"` +} + +func (m *SetPromoterConfPayload) Reset() { *m = SetPromoterConfPayload{} } +func (m *SetPromoterConfPayload) String() string { return proto.CompactTextString(m) } +func (*SetPromoterConfPayload) ProtoMessage() {} +func (*SetPromoterConfPayload) Descriptor() ([]byte, []int) { + return fileDescriptor_5d710bc1249ca8ae, []int{9} +} +func (m *SetPromoterConfPayload) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SetPromoterConfPayload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SetPromoterConfPayload.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *SetPromoterConfPayload) XXX_Merge(src proto.Message) { + xxx_messageInfo_SetPromoterConfPayload.Merge(m, src) +} +func (m *SetPromoterConfPayload) XXX_Size() int { + return m.Size() +} +func (m *SetPromoterConfPayload) XXX_DiscardUnknown() { + xxx_messageInfo_SetPromoterConfPayload.DiscardUnknown(m) +} + +var xxx_messageInfo_SetPromoterConfPayload proto.InternalMessageInfo + +func (m *SetPromoterConfPayload) GetConf() PromoterConf { + if m != nil { + return m.Conf + } + return PromoterConf{} +} + func init() { proto.RegisterType((*CreateCampaignPayload)(nil), "sgenetwork.sge.reward.CreateCampaignPayload") proto.RegisterType((*UpdateCampaignPayload)(nil), "sgenetwork.sge.reward.UpdateCampaignPayload") @@ -501,52 +664,63 @@ func init() { proto.RegisterType((*GrantSignupRewardPayload)(nil), "sgenetwork.sge.reward.GrantSignupRewardPayload") proto.RegisterType((*GrantSignupReferrerRewardPayload)(nil), "sgenetwork.sge.reward.GrantSignupReferrerRewardPayload") proto.RegisterType((*GrantSignupAffiliatorRewardPayload)(nil), "sgenetwork.sge.reward.GrantSignupAffiliatorRewardPayload") + proto.RegisterType((*GrantBetBonusRewardPayload)(nil), "sgenetwork.sge.reward.GrantBetBonusRewardPayload") + proto.RegisterType((*CreatePromoterPayload)(nil), "sgenetwork.sge.reward.CreatePromoterPayload") + proto.RegisterType((*SetPromoterConfPayload)(nil), "sgenetwork.sge.reward.SetPromoterConfPayload") } func init() { proto.RegisterFile("sge/reward/ticket.proto", fileDescriptor_5d710bc1249ca8ae) } var fileDescriptor_5d710bc1249ca8ae = []byte{ - // 633 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0x4f, 0x6b, 0xd4, 0x40, - 0x14, 0xdf, 0x69, 0xb7, 0xbb, 0xd9, 0x57, 0x15, 0x9d, 0x76, 0x31, 0xb6, 0x90, 0xae, 0x11, 0x71, - 0x15, 0xcc, 0xc2, 0x7a, 0x14, 0x84, 0xdd, 0x2d, 0x5a, 0xe9, 0xa5, 0xa4, 0x2d, 0x82, 0x97, 0x30, - 0x4d, 0xa6, 0xe9, 0xb0, 0x4d, 0x26, 0xcc, 0xcc, 0xb6, 0xe6, 0x0b, 0x78, 0x14, 0x3f, 0x93, 0xa7, - 0x1e, 0x7b, 0xf4, 0x54, 0x64, 0x7b, 0xf3, 0xe0, 0x67, 0x90, 0x4c, 0xd2, 0x34, 0x2b, 0x75, 0x29, - 0x88, 0xa7, 0xbc, 0x37, 0xef, 0xf7, 0x7e, 0xef, 0xf7, 0xfe, 0x10, 0x78, 0x28, 0x43, 0xda, 0x13, - 0xf4, 0x94, 0x88, 0xa0, 0xa7, 0x98, 0x3f, 0xa6, 0xca, 0x49, 0x04, 0x57, 0x1c, 0xb7, 0x65, 0x48, - 0x63, 0xaa, 0x4e, 0xb9, 0x18, 0x3b, 0x32, 0xa4, 0x4e, 0x8e, 0x59, 0x5b, 0x0d, 0x79, 0xc8, 0x35, - 0xa2, 0x97, 0x59, 0x39, 0x78, 0x0d, 0x67, 0x2c, 0x2a, 0x4d, 0x68, 0x6f, 0x9c, 0xfa, 0xc5, 0x5b, - 0x95, 0x39, 0xff, 0xe4, 0x01, 0xfb, 0xd7, 0x22, 0xb4, 0x47, 0x82, 0x12, 0x45, 0x47, 0x24, 0x4a, - 0x08, 0x0b, 0xe3, 0x1d, 0x92, 0x1e, 0x73, 0x12, 0xe0, 0x35, 0x30, 0x12, 0xc1, 0x23, 0xae, 0xa8, - 0x30, 0x51, 0x07, 0x75, 0x5b, 0x6e, 0xe9, 0xe3, 0x47, 0x60, 0x48, 0x45, 0x84, 0xf2, 0x94, 0x34, - 0x17, 0x3a, 0xa8, 0x5b, 0x77, 0x9b, 0xda, 0xdf, 0x93, 0xb8, 0x0d, 0x0d, 0x1a, 0x07, 0x59, 0x60, - 0x51, 0x07, 0x96, 0x68, 0x1c, 0xec, 0x49, 0x3c, 0x00, 0xc3, 0x27, 0x8a, 0x86, 0x5c, 0xa4, 0x66, - 0xbd, 0x83, 0xba, 0xf7, 0xfa, 0x4f, 0x9d, 0x1b, 0x9b, 0x72, 0x5c, 0xfd, 0x19, 0x15, 0x60, 0xb7, - 0x4c, 0xc3, 0x43, 0x58, 0xce, 0x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, 0x4d, 0x13, 0x2a, 0x0f, 0x1a, 0xfa, 0x17, 0xf8, 0xea, 0x77, 0x00, 0x00, 0x00, 0xff, - 0xff, 0x28, 0xb9, 0x2a, 0x10, 0x77, 0x05, 0x00, 0x00, + // 759 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xc1, 0x6e, 0xf3, 0x44, + 0x10, 0xce, 0x36, 0x69, 0xe2, 0x4c, 0x4a, 0x85, 0x96, 0x06, 0xdc, 0x54, 0x4a, 0x82, 0x11, 0x22, + 0x20, 0x91, 0x48, 0xe5, 0x88, 0x40, 0x8a, 0x5d, 0x41, 0x51, 0x39, 0x54, 0x6e, 0xab, 0x4a, 0x5c, + 0xa2, 0xed, 0x7a, 0xe3, 0x5a, 0x69, 0xbc, 0xd6, 0xee, 0xa6, 0xad, 0x5f, 0x80, 0x23, 0xe2, 0xc6, + 0x33, 0xf0, 0x1a, 0x9c, 0x7a, 0xec, 0x91, 0x53, 0x84, 0xd2, 0x1b, 0x4f, 0x81, 0xbc, 0xb6, 0x53, + 0x07, 0x25, 0x55, 0xf5, 0xff, 0xea, 0xc5, 0x9e, 0xd9, 0x99, 0xf9, 0xe6, 0xdb, 0x99, 0x4f, 0x36, + 0x7c, 0x22, 0x7d, 0x36, 0x10, 0xec, 0x8e, 0x08, 0x6f, 0xa0, 0x02, 0x3a, 0x61, 0xaa, 0x1f, 0x09, + 0xae, 0x38, 0x6e, 0x4a, 0x9f, 0x85, 0x4c, 0xdd, 0x71, 0x31, 0xe9, 0x4b, 0x9f, 0xf5, 0xd3, 0x9c, + 0xd6, 0x9e, 0xcf, 0x7d, 0xae, 0x33, 0x06, 0x89, 0x95, 0x26, 0xb7, 0x70, 0x82, 0xa2, 0xe2, 0x88, + 0x0d, 0x26, 0x31, 0xcd, 0xce, 0xf6, 0x0b, 0xc8, 0x94, 0x4c, 0x23, 0x12, 0xf8, 0x61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0xd4, 0x2e, 0x3d, 0x3e, 0xb5, 0x4b, 0x7f, 0x3f, 0xb5, 0x4b, 0xbf, 0x7c, 0xe9, 0x07, 0xea, 0x7a, + 0x76, 0xd5, 0xa7, 0x7c, 0x3a, 0x90, 0x3e, 0xfb, 0x3a, 0x43, 0x4d, 0xec, 0xc1, 0xfd, 0xf2, 0xd7, + 0x19, 0x47, 0x4c, 0x5e, 0x55, 0xf5, 0xaf, 0xea, 0x9b, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0x02, + 0xbd, 0x7a, 0x8d, 0x55, 0x07, 0x00, 0x00, } func (m *CreateCampaignPayload) Marshal() (dAtA []byte, err error) { @@ -569,6 +743,23 @@ func (m *CreateCampaignPayload) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Constraints != nil { + { + size, err := m.Constraints.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTicket(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x62 + } + if m.CapCount != 0 { + i = encodeVarintTicket(dAtA, i, uint64(m.CapCount)) + i-- + dAtA[i] = 0x58 + } if len(m.Meta) > 0 { i -= len(m.Meta) copy(dAtA[i:], m.Meta) @@ -576,11 +767,6 @@ func (m *CreateCampaignPayload) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x52 } - if m.ClaimsPerCategory != 0 { - i = encodeVarintTicket(dAtA, i, uint64(m.ClaimsPerCategory)) - i-- - dAtA[i] = 0x48 - } if m.IsActive { i-- if m.IsActive { @@ -875,6 +1061,119 @@ func (m *GrantSignupAffiliatorRewardPayload) MarshalToSizedBuffer(dAtA []byte) ( return len(dAtA) - i, nil } +func (m *GrantBetBonusRewardPayload) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GrantBetBonusRewardPayload) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GrantBetBonusRewardPayload) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.BetUID) > 0 { + i -= len(m.BetUID) + copy(dAtA[i:], m.BetUID) + i = encodeVarintTicket(dAtA, i, uint64(len(m.BetUID))) + i-- + dAtA[i] = 0x12 + } + { + size, err := m.Common.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTicket(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *CreatePromoterPayload) 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 *CreatePromoterPayload) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CreatePromoterPayload) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Conf.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTicket(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.UID) > 0 { + i -= len(m.UID) + copy(dAtA[i:], m.UID) + i = encodeVarintTicket(dAtA, i, uint64(len(m.UID))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *SetPromoterConfPayload) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SetPromoterConfPayload) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SetPromoterConfPayload) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Conf.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTicket(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func encodeVarintTicket(dAtA []byte, offset int, v uint64) int { offset -= sovTicket(v) base := offset @@ -918,13 +1217,17 @@ func (m *CreateCampaignPayload) Size() (n int) { if m.IsActive { n += 2 } - if m.ClaimsPerCategory != 0 { - n += 1 + sovTicket(uint64(m.ClaimsPerCategory)) - } l = len(m.Meta) if l > 0 { n += 1 + l + sovTicket(uint64(l)) } + if m.CapCount != 0 { + n += 1 + sovTicket(uint64(m.CapCount)) + } + if m.Constraints != nil { + l = m.Constraints.Size() + n += 1 + l + sovTicket(uint64(l)) + } return n } @@ -1022,6 +1325,47 @@ func (m *GrantSignupAffiliatorRewardPayload) Size() (n int) { return n } +func (m *GrantBetBonusRewardPayload) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Common.Size() + n += 1 + l + sovTicket(uint64(l)) + l = len(m.BetUID) + if l > 0 { + n += 1 + l + sovTicket(uint64(l)) + } + return n +} + +func (m *CreatePromoterPayload) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.UID) + if l > 0 { + n += 1 + l + sovTicket(uint64(l)) + } + l = m.Conf.Size() + n += 1 + l + sovTicket(uint64(l)) + return n +} + +func (m *SetPromoterConfPayload) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Conf.Size() + n += 1 + l + sovTicket(uint64(l)) + return n +} + func sovTicket(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1240,11 +1584,11 @@ func (m *CreateCampaignPayload) Unmarshal(dAtA []byte) error { } } m.IsActive = bool(v != 0) - case 9: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ClaimsPerCategory", wireType) + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Meta", wireType) } - m.ClaimsPerCategory = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTicket @@ -1254,16 +1598,29 @@ func (m *CreateCampaignPayload) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ClaimsPerCategory |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - case 10: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Meta", wireType) - } - var stringLen uint64 + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTicket + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTicket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Meta = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 11: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CapCount", wireType) + } + m.CapCount = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTicket @@ -1273,23 +1630,46 @@ func (m *CreateCampaignPayload) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.CapCount |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + case 12: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Constraints", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTicket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { return ErrInvalidLengthTicket } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTicket } if postIndex > l { return io.ErrUnexpectedEOF } - m.Meta = string(dAtA[iNdEx:postIndex]) + if m.Constraints == nil { + m.Constraints = &CampaignConstraints{} + } + if err := m.Constraints.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex @@ -1978,6 +2358,319 @@ func (m *GrantSignupAffiliatorRewardPayload) Unmarshal(dAtA []byte) error { } return nil } +func (m *GrantBetBonusRewardPayload) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTicket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GrantBetBonusRewardPayload: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GrantBetBonusRewardPayload: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Common", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTicket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTicket + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTicket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Common.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BetUID", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTicket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTicket + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTicket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BetUID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTicket(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTicket + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CreatePromoterPayload) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTicket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CreatePromoterPayload: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CreatePromoterPayload: 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 ErrIntOverflowTicket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTicket + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTicket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.UID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Conf", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTicket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTicket + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTicket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Conf.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTicket(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTicket + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SetPromoterConfPayload) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTicket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SetPromoterConfPayload: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SetPromoterConfPayload: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Conf", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTicket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTicket + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTicket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Conf.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTicket(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTicket + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTicket(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/reward/types/ticket_test.go b/x/reward/types/ticket_test.go index 061a4ab3..069a9ff0 100644 --- a/x/reward/types/ticket_test.go +++ b/x/reward/types/ticket_test.go @@ -61,9 +61,8 @@ func TestCreateCampaignPayloadValidation(t *testing.T) { SubaccountAmount: sdkmath.NewInt(1000), UnlockPeriod: uint64(time.Now().Add(10 * time.Minute).Unix()), }, - ClaimsPerCategory: 1, - IsActive: true, - Meta: "sample campaign", + IsActive: true, + Meta: "sample campaign", }, }, } diff --git a/x/reward/types/tx.pb.go b/x/reward/types/tx.pb.go index 6c7fa231..35bdc886 100644 --- a/x/reward/types/tx.pb.go +++ b/x/reward/types/tx.pb.go @@ -29,6 +29,199 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// MsgCreatePromoter is msg to create a promoter. +type MsgCreatePromoter struct { + // creator is the address of message signer account. + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + // ticket is the payload data. + Ticket string `protobuf:"bytes,2,opt,name=ticket,proto3" json:"ticket,omitempty"` +} + +func (m *MsgCreatePromoter) Reset() { *m = MsgCreatePromoter{} } +func (m *MsgCreatePromoter) String() string { return proto.CompactTextString(m) } +func (*MsgCreatePromoter) ProtoMessage() {} +func (*MsgCreatePromoter) Descriptor() ([]byte, []int) { + return fileDescriptor_ad69e28332238e66, []int{0} +} +func (m *MsgCreatePromoter) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreatePromoter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreatePromoter.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 *MsgCreatePromoter) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreatePromoter.Merge(m, src) +} +func (m *MsgCreatePromoter) XXX_Size() int { + return m.Size() +} +func (m *MsgCreatePromoter) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreatePromoter.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreatePromoter proto.InternalMessageInfo + +func (m *MsgCreatePromoter) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgCreatePromoter) GetTicket() string { + if m != nil { + return m.Ticket + } + return "" +} + +// MsgCreatePromoterResponse promoter create message response type. +type MsgCreatePromoterResponse struct { +} + +func (m *MsgCreatePromoterResponse) Reset() { *m = MsgCreatePromoterResponse{} } +func (m *MsgCreatePromoterResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreatePromoterResponse) ProtoMessage() {} +func (*MsgCreatePromoterResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_ad69e28332238e66, []int{1} +} +func (m *MsgCreatePromoterResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreatePromoterResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreatePromoterResponse.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 *MsgCreatePromoterResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreatePromoterResponse.Merge(m, src) +} +func (m *MsgCreatePromoterResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreatePromoterResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreatePromoterResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreatePromoterResponse proto.InternalMessageInfo + +// MsgSetPromoterConf is msg to set promoter configuration. +type MsgSetPromoterConf struct { + // creator is the address of message signer account. + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + // uid is the unique identifier of the promoter. + Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid,omitempty"` + // ticket is the payload data. + Ticket string `protobuf:"bytes,3,opt,name=ticket,proto3" json:"ticket,omitempty"` +} + +func (m *MsgSetPromoterConf) Reset() { *m = MsgSetPromoterConf{} } +func (m *MsgSetPromoterConf) String() string { return proto.CompactTextString(m) } +func (*MsgSetPromoterConf) ProtoMessage() {} +func (*MsgSetPromoterConf) Descriptor() ([]byte, []int) { + return fileDescriptor_ad69e28332238e66, []int{2} +} +func (m *MsgSetPromoterConf) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetPromoterConf) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetPromoterConf.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgSetPromoterConf) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetPromoterConf.Merge(m, src) +} +func (m *MsgSetPromoterConf) XXX_Size() int { + return m.Size() +} +func (m *MsgSetPromoterConf) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetPromoterConf.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetPromoterConf proto.InternalMessageInfo + +func (m *MsgSetPromoterConf) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgSetPromoterConf) GetUid() string { + if m != nil { + return m.Uid + } + return "" +} + +func (m *MsgSetPromoterConf) GetTicket() string { + if m != nil { + return m.Ticket + } + return "" +} + +// MsgCreateCampaignResponse campaign create message response type. +type MsgSetPromoterConfResponse struct { +} + +func (m *MsgSetPromoterConfResponse) Reset() { *m = MsgSetPromoterConfResponse{} } +func (m *MsgSetPromoterConfResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSetPromoterConfResponse) ProtoMessage() {} +func (*MsgSetPromoterConfResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_ad69e28332238e66, []int{3} +} +func (m *MsgSetPromoterConfResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetPromoterConfResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetPromoterConfResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgSetPromoterConfResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetPromoterConfResponse.Merge(m, src) +} +func (m *MsgSetPromoterConfResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSetPromoterConfResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetPromoterConfResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetPromoterConfResponse proto.InternalMessageInfo + // MsgCreateCampaign is msg to create a reward campaign type MsgCreateCampaign struct { // creator is the address of campaign creator account. @@ -45,7 +238,7 @@ func (m *MsgCreateCampaign) Reset() { *m = MsgCreateCampaign{} } func (m *MsgCreateCampaign) String() string { return proto.CompactTextString(m) } func (*MsgCreateCampaign) ProtoMessage() {} func (*MsgCreateCampaign) Descriptor() ([]byte, []int) { - return fileDescriptor_ad69e28332238e66, []int{0} + return fileDescriptor_ad69e28332238e66, []int{4} } func (m *MsgCreateCampaign) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -103,7 +296,7 @@ func (m *MsgCreateCampaignResponse) Reset() { *m = MsgCreateCampaignResp func (m *MsgCreateCampaignResponse) String() string { return proto.CompactTextString(m) } func (*MsgCreateCampaignResponse) ProtoMessage() {} func (*MsgCreateCampaignResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ad69e28332238e66, []int{1} + return fileDescriptor_ad69e28332238e66, []int{5} } func (m *MsgCreateCampaignResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -149,7 +342,7 @@ func (m *MsgUpdateCampaign) Reset() { *m = MsgUpdateCampaign{} } func (m *MsgUpdateCampaign) String() string { return proto.CompactTextString(m) } func (*MsgUpdateCampaign) ProtoMessage() {} func (*MsgUpdateCampaign) Descriptor() ([]byte, []int) { - return fileDescriptor_ad69e28332238e66, []int{2} + return fileDescriptor_ad69e28332238e66, []int{6} } func (m *MsgUpdateCampaign) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -207,7 +400,7 @@ func (m *MsgUpdateCampaignResponse) Reset() { *m = MsgUpdateCampaignResp func (m *MsgUpdateCampaignResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateCampaignResponse) ProtoMessage() {} func (*MsgUpdateCampaignResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ad69e28332238e66, []int{3} + return fileDescriptor_ad69e28332238e66, []int{7} } func (m *MsgUpdateCampaignResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -252,7 +445,7 @@ func (m *MsgGrantReward) Reset() { *m = MsgGrantReward{} } func (m *MsgGrantReward) String() string { return proto.CompactTextString(m) } func (*MsgGrantReward) ProtoMessage() {} func (*MsgGrantReward) Descriptor() ([]byte, []int) { - return fileDescriptor_ad69e28332238e66, []int{4} + return fileDescriptor_ad69e28332238e66, []int{8} } func (m *MsgGrantReward) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -317,7 +510,7 @@ func (m *MsgGrantRewardResponse) Reset() { *m = MsgGrantRewardResponse{} func (m *MsgGrantRewardResponse) String() string { return proto.CompactTextString(m) } func (*MsgGrantRewardResponse) ProtoMessage() {} func (*MsgGrantRewardResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ad69e28332238e66, []int{5} + return fileDescriptor_ad69e28332238e66, []int{9} } func (m *MsgGrantRewardResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -354,13 +547,15 @@ type MsgWithdrawFunds struct { Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid,omitempty"` // ticket is the payload data. Ticket string `protobuf:"bytes,3,opt,name=ticket,proto3" json:"ticket,omitempty"` + // amount is the requested withdrawal amount + Amount cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=amount,proto3,customtype=cosmossdk.io/math.Int" json:"amount"` } func (m *MsgWithdrawFunds) Reset() { *m = MsgWithdrawFunds{} } func (m *MsgWithdrawFunds) String() string { return proto.CompactTextString(m) } func (*MsgWithdrawFunds) ProtoMessage() {} func (*MsgWithdrawFunds) Descriptor() ([]byte, []int) { - return fileDescriptor_ad69e28332238e66, []int{6} + return fileDescriptor_ad69e28332238e66, []int{10} } func (m *MsgWithdrawFunds) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -418,7 +613,7 @@ func (m *MsgWithdrawFundsResponse) Reset() { *m = MsgWithdrawFundsRespon func (m *MsgWithdrawFundsResponse) String() string { return proto.CompactTextString(m) } func (*MsgWithdrawFundsResponse) ProtoMessage() {} func (*MsgWithdrawFundsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ad69e28332238e66, []int{7} + return fileDescriptor_ad69e28332238e66, []int{11} } func (m *MsgWithdrawFundsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -448,6 +643,10 @@ func (m *MsgWithdrawFundsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgWithdrawFundsResponse proto.InternalMessageInfo func init() { + proto.RegisterType((*MsgCreatePromoter)(nil), "sgenetwork.sge.reward.MsgCreatePromoter") + proto.RegisterType((*MsgCreatePromoterResponse)(nil), "sgenetwork.sge.reward.MsgCreatePromoterResponse") + proto.RegisterType((*MsgSetPromoterConf)(nil), "sgenetwork.sge.reward.MsgSetPromoterConf") + proto.RegisterType((*MsgSetPromoterConfResponse)(nil), "sgenetwork.sge.reward.MsgSetPromoterConfResponse") proto.RegisterType((*MsgCreateCampaign)(nil), "sgenetwork.sge.reward.MsgCreateCampaign") proto.RegisterType((*MsgCreateCampaignResponse)(nil), "sgenetwork.sge.reward.MsgCreateCampaignResponse") proto.RegisterType((*MsgUpdateCampaign)(nil), "sgenetwork.sge.reward.MsgUpdateCampaign") @@ -461,37 +660,42 @@ func init() { func init() { proto.RegisterFile("sge/reward/tx.proto", fileDescriptor_ad69e28332238e66) } var fileDescriptor_ad69e28332238e66 = []byte{ - // 468 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x94, 0x41, 0x6f, 0xd3, 0x30, - 0x14, 0xc7, 0x1b, 0x82, 0x86, 0x78, 0x85, 0x69, 0x04, 0x36, 0x85, 0x20, 0xa5, 0x50, 0x09, 0x31, - 0x0e, 0x73, 0x10, 0xbb, 0x71, 0x5c, 0x25, 0x10, 0x87, 0x5e, 0x22, 0x06, 0x12, 0x97, 0xc9, 0x4b, - 0x8c, 0x6b, 0xb5, 0x89, 0x2d, 0xdb, 0x51, 0xb7, 0x6f, 0xc1, 0x17, 0xe1, 0xc0, 0xb7, 0xd8, 0x71, - 0x47, 0xc4, 0xa1, 0x42, 0xed, 0x37, 0xe0, 0x13, 0x20, 0xbb, 0x4d, 0x68, 0xba, 0x75, 0x4a, 0xe1, - 0xe6, 0xe7, 0xf7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0xce, 0x05, - 0x51, 0xa7, 0x5b, 0xf6, 0x81, 0x3a, 0xfc, 0x13, 0x00, 0x00, 0xff, 0xff, 0xb8, 0x77, 0xc5, 0x13, - 0xe4, 0x04, 0x00, 0x00, + // 551 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x95, 0xcf, 0x6e, 0xd3, 0x40, + 0x10, 0xc6, 0x63, 0x02, 0x41, 0x4c, 0xa0, 0x14, 0x43, 0x2b, 0x63, 0xc0, 0x01, 0x4b, 0x88, 0xf6, + 0x50, 0x1b, 0xa8, 0xb8, 0x70, 0x4c, 0x04, 0x88, 0x83, 0x25, 0x64, 0xa8, 0x40, 0x5c, 0xaa, 0xad, + 0xbd, 0xdd, 0x58, 0x89, 0xbd, 0xd6, 0xee, 0x5a, 0x69, 0x1f, 0x02, 0xa9, 0x2f, 0xc2, 0x7b, 0xf4, + 0xd8, 0x23, 0xe2, 0x10, 0xa1, 0xe4, 0x0d, 0x78, 0x02, 0xe4, 0xbf, 0xb2, 0x9d, 0x26, 0x75, 0x81, + 0xdb, 0x8e, 0xe7, 0xdb, 0xf9, 0xcd, 0x67, 0xcd, 0xd8, 0x70, 0x97, 0x13, 0x6c, 0x32, 0x3c, 0x41, + 0xcc, 0x35, 0xc5, 0x91, 0x11, 0x32, 0x2a, 0xa8, 0xbc, 0xc1, 0x09, 0x0e, 0xb0, 0x98, 0x50, 0x36, + 0x32, 0x38, 0xc1, 0x46, 0x9a, 0x57, 0xef, 0x11, 0x4a, 0x68, 0xa2, 0x30, 0xe3, 0x53, 0x2a, 0xd6, + 0xdf, 0xc0, 0x1d, 0x8b, 0x93, 0x01, 0xc3, 0x48, 0xe0, 0x0f, 0x8c, 0xfa, 0x54, 0x60, 0x26, 0x2b, + 0x70, 0xdd, 0x89, 0x9f, 0x50, 0xa6, 0x48, 0x8f, 0xa5, 0xad, 0x1b, 0x76, 0x1e, 0xca, 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, 0x64, 0x35, 0xe3, 0xb3, 0x79, 0x54, 0xfc, 0xbc, + 0x8e, 0x43, 0xcc, 0x0f, 0x3a, 0xc9, 0x3f, 0x69, 0xf7, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x47, + 0xc3, 0x34, 0xe6, 0xd7, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -506,6 +710,10 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { + // SetPromoterConf is a method to set the configurations of a promoter. + SetPromoterConf(ctx context.Context, in *MsgSetPromoterConf, opts ...grpc.CallOption) (*MsgSetPromoterConfResponse, error) + // CreatePromoter is a method to create a promoter + CreatePromoter(ctx context.Context, in *MsgCreatePromoter, opts ...grpc.CallOption) (*MsgCreatePromoterResponse, error) // CreateCampaign is a method to create a campaign CreateCampaign(ctx context.Context, in *MsgCreateCampaign, opts ...grpc.CallOption) (*MsgCreateCampaignResponse, error) // UpdateCampaign is a method to update campaign @@ -524,6 +732,24 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } +func (c *msgClient) SetPromoterConf(ctx context.Context, in *MsgSetPromoterConf, opts ...grpc.CallOption) (*MsgSetPromoterConfResponse, error) { + out := new(MsgSetPromoterConfResponse) + err := c.cc.Invoke(ctx, "/sgenetwork.sge.reward.Msg/SetPromoterConf", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) CreatePromoter(ctx context.Context, in *MsgCreatePromoter, opts ...grpc.CallOption) (*MsgCreatePromoterResponse, error) { + out := new(MsgCreatePromoterResponse) + err := c.cc.Invoke(ctx, "/sgenetwork.sge.reward.Msg/CreatePromoter", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *msgClient) CreateCampaign(ctx context.Context, in *MsgCreateCampaign, opts ...grpc.CallOption) (*MsgCreateCampaignResponse, error) { out := new(MsgCreateCampaignResponse) err := c.cc.Invoke(ctx, "/sgenetwork.sge.reward.Msg/CreateCampaign", in, out, opts...) @@ -562,6 +788,10 @@ func (c *msgClient) GrantReward(ctx context.Context, in *MsgGrantReward, opts .. // MsgServer is the server API for Msg service. type MsgServer interface { + // SetPromoterConf is a method to set the configurations of a promoter. + SetPromoterConf(context.Context, *MsgSetPromoterConf) (*MsgSetPromoterConfResponse, error) + // CreatePromoter is a method to create a promoter + CreatePromoter(context.Context, *MsgCreatePromoter) (*MsgCreatePromoterResponse, error) // CreateCampaign is a method to create a campaign CreateCampaign(context.Context, *MsgCreateCampaign) (*MsgCreateCampaignResponse, error) // UpdateCampaign is a method to update campaign @@ -576,6 +806,12 @@ type MsgServer interface { type UnimplementedMsgServer struct { } +func (*UnimplementedMsgServer) SetPromoterConf(ctx context.Context, req *MsgSetPromoterConf) (*MsgSetPromoterConfResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetPromoterConf not implemented") +} +func (*UnimplementedMsgServer) CreatePromoter(ctx context.Context, req *MsgCreatePromoter) (*MsgCreatePromoterResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreatePromoter not implemented") +} func (*UnimplementedMsgServer) CreateCampaign(ctx context.Context, req *MsgCreateCampaign) (*MsgCreateCampaignResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateCampaign not implemented") } @@ -593,6 +829,42 @@ func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } +func _Msg_SetPromoterConf_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSetPromoterConf) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SetPromoterConf(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/sgenetwork.sge.reward.Msg/SetPromoterConf", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SetPromoterConf(ctx, req.(*MsgSetPromoterConf)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_CreatePromoter_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreatePromoter) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CreatePromoter(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/sgenetwork.sge.reward.Msg/CreatePromoter", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreatePromoter(ctx, req.(*MsgCreatePromoter)) + } + return interceptor(ctx, in, info, handler) +} + func _Msg_CreateCampaign_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgCreateCampaign) if err := dec(in); err != nil { @@ -669,6 +941,14 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "sgenetwork.sge.reward.Msg", HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ + { + MethodName: "SetPromoterConf", + Handler: _Msg_SetPromoterConf_Handler, + }, + { + MethodName: "CreatePromoter", + Handler: _Msg_CreatePromoter_Handler, + }, { MethodName: "CreateCampaign", Handler: _Msg_CreateCampaign_Handler, @@ -690,7 +970,7 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Metadata: "sge/reward/tx.proto", } -func (m *MsgCreateCampaign) Marshal() (dAtA []byte, err error) { +func (m *MsgCreatePromoter) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -700,12 +980,12 @@ func (m *MsgCreateCampaign) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgCreateCampaign) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgCreatePromoter) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgCreateCampaign) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgCreatePromoter) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -715,23 +995,6 @@ func (m *MsgCreateCampaign) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Ticket) i = encodeVarintTx(dAtA, i, uint64(len(m.Ticket))) i-- - dAtA[i] = 0x22 - } - { - size := m.TotalFunds.Size() - i -= size - if _, err := m.TotalFunds.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if len(m.Uid) > 0 { - i -= len(m.Uid) - copy(dAtA[i:], m.Uid) - i = encodeVarintTx(dAtA, i, uint64(len(m.Uid))) - i-- dAtA[i] = 0x12 } if len(m.Creator) > 0 { @@ -744,7 +1007,7 @@ func (m *MsgCreateCampaign) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgCreateCampaignResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgCreatePromoterResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -754,12 +1017,12 @@ func (m *MsgCreateCampaignResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgCreateCampaignResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgCreatePromoterResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgCreateCampaignResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgCreatePromoterResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -767,7 +1030,7 @@ func (m *MsgCreateCampaignResponse) MarshalToSizedBuffer(dAtA []byte) (int, erro return len(dAtA) - i, nil } -func (m *MsgUpdateCampaign) Marshal() (dAtA []byte, err error) { +func (m *MsgSetPromoterConf) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -777,12 +1040,12 @@ func (m *MsgUpdateCampaign) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgUpdateCampaign) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgSetPromoterConf) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgUpdateCampaign) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgSetPromoterConf) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -792,18 +1055,8 @@ func (m *MsgUpdateCampaign) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Ticket) i = encodeVarintTx(dAtA, i, uint64(len(m.Ticket))) i-- - dAtA[i] = 0x22 - } - { - size := m.TopupFunds.Size() - i -= size - if _, err := m.TopupFunds.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTx(dAtA, i, uint64(size)) + dAtA[i] = 0x1a } - i-- - dAtA[i] = 0x1a if len(m.Uid) > 0 { i -= len(m.Uid) copy(dAtA[i:], m.Uid) @@ -821,7 +1074,7 @@ func (m *MsgUpdateCampaign) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgUpdateCampaignResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgSetPromoterConfResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -831,12 +1084,12 @@ func (m *MsgUpdateCampaignResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgUpdateCampaignResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgSetPromoterConfResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgUpdateCampaignResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgSetPromoterConfResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -844,7 +1097,7 @@ func (m *MsgUpdateCampaignResponse) MarshalToSizedBuffer(dAtA []byte) (int, erro return len(dAtA) - i, nil } -func (m *MsgGrantReward) Marshal() (dAtA []byte, err error) { +func (m *MsgCreateCampaign) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -854,12 +1107,12 @@ func (m *MsgGrantReward) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgGrantReward) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgCreateCampaign) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgGrantReward) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgCreateCampaign) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -871,13 +1124,16 @@ func (m *MsgGrantReward) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x22 } - if len(m.CampaignUid) > 0 { - i -= len(m.CampaignUid) - copy(dAtA[i:], m.CampaignUid) - i = encodeVarintTx(dAtA, i, uint64(len(m.CampaignUid))) - i-- - dAtA[i] = 0x1a + { + size := m.TotalFunds.Size() + i -= size + if _, err := m.TotalFunds.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x1a if len(m.Uid) > 0 { i -= len(m.Uid) copy(dAtA[i:], m.Uid) @@ -895,7 +1151,7 @@ func (m *MsgGrantReward) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgGrantRewardResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgCreateCampaignResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -905,12 +1161,12 @@ func (m *MsgGrantRewardResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgGrantRewardResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgCreateCampaignResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgGrantRewardResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgCreateCampaignResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -918,7 +1174,7 @@ func (m *MsgGrantRewardResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *MsgWithdrawFunds) Marshal() (dAtA []byte, err error) { +func (m *MsgUpdateCampaign) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -928,12 +1184,12 @@ func (m *MsgWithdrawFunds) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgWithdrawFunds) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUpdateCampaign) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgWithdrawFunds) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdateCampaign) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -943,7 +1199,168 @@ func (m *MsgWithdrawFunds) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Ticket) i = encodeVarintTx(dAtA, i, uint64(len(m.Ticket))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 + } + { + size := m.TopupFunds.Size() + i -= size + if _, err := m.TopupFunds.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.Uid) > 0 { + i -= len(m.Uid) + copy(dAtA[i:], m.Uid) + i = encodeVarintTx(dAtA, i, uint64(len(m.Uid))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateCampaignResponse) 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 *MsgUpdateCampaignResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateCampaignResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgGrantReward) 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 *MsgGrantReward) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgGrantReward) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Ticket) > 0 { + i -= len(m.Ticket) + copy(dAtA[i:], m.Ticket) + i = encodeVarintTx(dAtA, i, uint64(len(m.Ticket))) + i-- + dAtA[i] = 0x22 + } + if len(m.CampaignUid) > 0 { + i -= len(m.CampaignUid) + copy(dAtA[i:], m.CampaignUid) + i = encodeVarintTx(dAtA, i, uint64(len(m.CampaignUid))) + i-- + dAtA[i] = 0x1a + } + if len(m.Uid) > 0 { + i -= len(m.Uid) + copy(dAtA[i:], m.Uid) + i = encodeVarintTx(dAtA, i, uint64(len(m.Uid))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgGrantRewardResponse) 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 *MsgGrantRewardResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgGrantRewardResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgWithdrawFunds) 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 *MsgWithdrawFunds) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgWithdrawFunds) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Amount.Size() + i -= size + if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.Ticket) > 0 { + i -= len(m.Ticket) + copy(dAtA[i:], m.Ticket) + i = encodeVarintTx(dAtA, i, uint64(len(m.Ticket))) + i-- + dAtA[i] = 0x1a } if len(m.Uid) > 0 { i -= len(m.Uid) @@ -996,6 +1413,62 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *MsgCreatePromoter) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Ticket) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgCreatePromoterResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgSetPromoterConf) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Uid) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Ticket) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgSetPromoterConfResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func (m *MsgCreateCampaign) Size() (n int) { if m == nil { return 0 @@ -1089,46 +1562,408 @@ func (m *MsgGrantRewardResponse) Size() (n int) { if m == nil { return 0 } - var l int - _ = l - return n -} + var l int + _ = l + return n +} + +func (m *MsgWithdrawFunds) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Uid) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Ticket) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Amount.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgWithdrawFundsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgCreatePromoter) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgCreatePromoter: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreatePromoter: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Ticket", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Ticket = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCreatePromoterResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgCreatePromoterResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreatePromoterResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } -func (m *MsgWithdrawFunds) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Creator) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Uid) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Ticket) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if iNdEx > l { + return io.ErrUnexpectedEOF } - return n + return nil } +func (m *MsgSetPromoterConf) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSetPromoterConf: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetPromoterConf: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Uid", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Uid = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Ticket", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Ticket = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } -func (m *MsgWithdrawFundsResponse) Size() (n int) { - if m == nil { - return 0 + if iNdEx > l { + return io.ErrUnexpectedEOF } - var l int - _ = l - return n + return nil } +func (m *MsgSetPromoterConfResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSetPromoterConfResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetPromoterConfResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } -func sovTx(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTx(x uint64) (n int) { - return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil } func (m *MsgCreateCampaign) Unmarshal(dAtA []byte) error { l := len(dAtA) @@ -1943,6 +2778,40 @@ func (m *MsgWithdrawFunds) Unmarshal(dAtA []byte) error { } m.Ticket = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 4: + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:])