diff --git a/app/app.go b/app/app.go index 64f5ab1e..cadf7eb3 100644 --- a/app/app.go +++ b/app/app.go @@ -44,6 +44,8 @@ import ( v4 "github.com/sge-network/sge/app/upgrades/v4" 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" @@ -80,6 +82,8 @@ var ( v4.Upgrade, v5.Upgrade, v6.Upgrade, + v7.Upgrade, + v8.Upgrade, } ) diff --git a/app/upgrades/v7/consts.go b/app/upgrades/v7/consts.go new file mode 100644 index 00000000..94aea065 --- /dev/null +++ b/app/upgrades/v7/consts.go @@ -0,0 +1,19 @@ +package v7 + +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.5.3 upgrade. +const UpgradeName = "v1.5.3" + +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: CreateUpgradeHandler, + StoreUpgrades: store.StoreUpgrades{ + Added: []string{}, + Deleted: []string{}, + }, +} diff --git a/app/upgrades/v7/upgrades.go b/app/upgrades/v7/upgrades.go new file mode 100644 index 00000000..e26a7b58 --- /dev/null +++ b/app/upgrades/v7/upgrades.go @@ -0,0 +1,44 @@ +package v7 + +import ( + "fmt" + + 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/sge-network/sge/app/keepers" + subaccounttypes "github.com/sge-network/sge/x/subaccount/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) { + allSubaccounts := k.SubaccountKeeper.GetAllSubaccounts(ctx) + + for _, sa := range allSubaccounts { + subAccAddr := sdk.MustAccAddressFromBech32(sa.Address) + accSummary, found := k.SubaccountKeeper.GetAccountSummary(ctx, subAccAddr) + if !found { + panic(fmt.Errorf("account summary for the subaccount not found %s", subAccAddr)) + } + + _, totalBalances := k.SubaccountKeeper.GetBalances(ctx, subAccAddr, subaccounttypes.LockedBalanceStatus_LOCKED_BALANCE_STATUS_UNSPECIFIED) + + missingBalance := accSummary.DepositedAmount.Sub(totalBalances) + if missingBalance.GT(sdkmath.ZeroInt()) { + k.SubaccountKeeper.SetLockedBalances(ctx, subAccAddr, []subaccounttypes.LockedBalance{ + { + Amount: missingBalance, + UnlockTS: 1710830000, + }, + }) + } + } + + return mm.RunMigrations(ctx, configurator, fromVM) + } +} 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..41a912c5 --- /dev/null +++ b/app/upgrades/v8/upgrades.go @@ -0,0 +1,52 @@ +package v8 + +import ( + 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 + k.RewardKeeper.SetCampaign(ctx, c) + promoters[c.Promoter] = struct{}{} + } + + promoterAddresses := []string{} + for addr := range promoters { + promoterAddresses = append(promoterAddresses, addr) + } + + 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/go.mod b/go.mod index 9a837c21..abf98555 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/rakyll/statik v0.1.7 github.com/spf13/cast v1.6.0 github.com/spf13/cobra v1.8.0 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 github.com/tendermint/tendermint v0.34.29 github.com/tendermint/tm-db v0.6.7 google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e @@ -261,7 +261,7 @@ require ( github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect github.com/stbenjam/no-sprintf-host-port v0.1.1 // indirect - github.com/stretchr/objx v0.5.0 // indirect + github.com/stretchr/objx v0.5.2 // indirect github.com/subosito/gotenv v1.4.1 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect github.com/t-yuki/gocover-cobertura v0.0.0-20180217150009-aaee18c8195c // indirect diff --git a/go.sum b/go.sum index bf91dda3..0861900a 100644 --- a/go.sum +++ b/go.sum @@ -1379,8 +1379,9 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.0/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= @@ -1391,8 +1392,9 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs= github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= diff --git a/proto/sge/orderbook/query.proto b/proto/sge/orderbook/query.proto index 88aeb517..8e026857 100644 --- a/proto/sge/orderbook/query.proto +++ b/proto/sge/orderbook/query.proto @@ -95,9 +95,9 @@ service Query { } // Queries list of settled Orderbook Participation items of a certain height. - rpc SettledOrderbookParticipationsOfHeight( + rpc SettledOrderBookParticipationsOfHeight( QuerySettledOrderBookParticipationsOfHeightRequest) - returns (QuerySettledOrderbookParticipationsOfHeightResponse) { + returns (QuerySettledOrderBookParticipationsOfHeightResponse) { option (google.api.http).get = "/sge/orderbook/participations/settled/{block_height}"; } @@ -320,9 +320,9 @@ message QuerySettledOrderBookParticipationsOfHeightRequest { int64 block_height = 2; } -// QuerySettledOrderbookParticipationsOfHeightResponse is the response type for +// QuerySettledOrderBookParticipationsOfHeightResponse is the response type for // the settled orderbook participations of a certain height list query. -message QuerySettledOrderbookParticipationsOfHeightResponse { +message QuerySettledOrderBookParticipationsOfHeightResponse { repeated OrderBookParticipation participations = 1 [ (gogoproto.nullable) = false ]; cosmos.base.query.v1beta1.PageResponse pagination = 2; diff --git a/proto/sge/reward/query.proto b/proto/sge/reward/query.proto index 12921ea4..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}"; @@ -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; } diff --git a/proto/sge/reward/ticket.proto b/proto/sge/reward/ticket.proto index 9f92b0f7..9dea2dab 100644 --- a/proto/sge/reward/ticket.proto +++ b/proto/sge/reward/ticket.proto @@ -125,6 +125,17 @@ message GrantBetBonusRewardPayload { ]; } +// 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 ]; diff --git a/proto/sge/reward/tx.proto b/proto/sge/reward/tx.proto index a7760dab..03f4e63f 100644 --- a/proto/sge/reward/tx.proto +++ b/proto/sge/reward/tx.proto @@ -10,6 +10,8 @@ option go_package = "github.com/sge-network/sge/x/reward/types"; 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 @@ -20,6 +22,17 @@ 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. diff --git a/proto/sge/subaccount/balance.proto b/proto/sge/subaccount/balance.proto index 197b4adf..595a1425 100644 --- a/proto/sge/subaccount/balance.proto +++ b/proto/sge/subaccount/balance.proto @@ -48,3 +48,13 @@ message LockedBalance { (gogoproto.nullable) = false ]; } + +// LockedBalanceStatus type. +enum LockedBalanceStatus { + // the invalid or unknown + LOCKED_BALANCE_STATUS_UNSPECIFIED = 0; + // locked + LOCKED_BALANCE_STATUS_LOCKED = 1; + // unlocked + LOCKED_BALANCE_STATUS_UNLOCKED = 2; +} diff --git a/proto/sge/subaccount/query.proto b/proto/sge/subaccount/query.proto index 882953ae..96e8dbe0 100644 --- a/proto/sge/subaccount/query.proto +++ b/proto/sge/subaccount/query.proto @@ -36,4 +36,10 @@ message QuerySubaccountResponse { sge.subaccount.AccountSummary balance = 2 [ (gogoproto.nullable) = false ]; repeated sge.subaccount.LockedBalance locked_balance = 3 [ (gogoproto.nullable) = false ]; + repeated sge.subaccount.LockedBalance unlocked_balance = 4 + [ (gogoproto.nullable) = false ]; + string withdrawable_unlocked_balance = 5 [ + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false + ]; } diff --git a/x/orderbook/keeper/grpc_query_participation.go b/x/orderbook/keeper/grpc_query_participation.go index 22a38803..ed15afef 100644 --- a/x/orderbook/keeper/grpc_query_participation.go +++ b/x/orderbook/keeper/grpc_query_participation.go @@ -93,8 +93,8 @@ func (k Keeper) OrderBookParticipations( }, nil } -// SettledOrderbookParticipationsOfHeight returns settled orderbook participations of a certain height -func (k Keeper) SettledOrderbookParticipationsOfHeight( +// SettledOrderBookParticipationsOfHeight returns settled orderbook participations of a certain height +func (k Keeper) SettledOrderBookParticipationsOfHeight( c context.Context, req *types.QuerySettledOrderBookParticipationsOfHeightRequest, ) (*types.QuerySettledOrderBookParticipationsOfHeightResponse, error) { diff --git a/x/orderbook/types/participation.pb.go b/x/orderbook/types/participation.pb.go index b39f24d7..f59b1c63 100644 --- a/x/orderbook/types/participation.pb.go +++ b/x/orderbook/types/participation.pb.go @@ -57,9 +57,11 @@ type OrderBookParticipation struct { ActualProfit cosmossdk_io_math.Int `protobuf:"bytes,13,opt,name=actual_profit,json=actualProfit,proto3,customtype=cosmossdk.io/math.Int" json:"actual_profit" yaml:"actual_profit"` // is_settled represents if the participation is settled or not. IsSettled bool `protobuf:"varint,14,opt,name=is_settled,json=isSettled,proto3" json:"is_settled,omitempty" yaml:"is_settled"` - // returned_amount is the total returned amount to the user's account including reimbursed fees. + // returned_amount is the total returned amount to the user's account + // including reimbursed fees. ReturnedAmount cosmossdk_io_math.Int `protobuf:"bytes,15,opt,name=returned_amount,json=returnedAmount,proto3,customtype=cosmossdk.io/math.Int" json:"returned_amount" yaml:"returned_amount"` - // reimbursed_fee is the fee reimbursed because of reasons such as market calcellation. + // reimbursed_fee is the fee reimbursed because of reasons such as market + // calcellation. ReimbursedFee cosmossdk_io_math.Int `protobuf:"bytes,16,opt,name=reimbursed_fee,json=reimbursedFee,proto3,customtype=cosmossdk.io/math.Int" json:"reimbursed_fee" yaml:"reimbursed_fee"` } @@ -161,7 +163,8 @@ func (m *ParticipationBetPair) GetBetUID() string { return "" } -// SettledOrderbookParticipation is the type for a settled orderbook participation. +// SettledOrderbookParticipation is the type for a settled orderbook +// participation. type SettledOrderbookParticipation struct { // index is the index of the participation in the participation queue. Index uint64 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty" yaml:"index"` @@ -234,55 +237,59 @@ func init() { func init() { proto.RegisterFile("sge/orderbook/participation.proto", fileDescriptor_2962bcb47b63c36a) } var fileDescriptor_2962bcb47b63c36a = []byte{ - // 762 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x56, 0x3f, 0x6f, 0xd3, 0x4e, - 0x18, 0x8e, 0xfb, 0x3f, 0xd7, 0xb4, 0xbf, 0xfe, 0xdc, 0xb4, 0xb5, 0x82, 0xea, 0x2b, 0x27, 0x51, - 0x75, 0xa0, 0xc9, 0x00, 0x53, 0xc5, 0x52, 0x83, 0x2a, 0x05, 0x95, 0x26, 0x18, 0x10, 0x12, 0x42, - 0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3b, 0xae, 0xeb, 0x13, 0xce, 0x8d, 0x69, 0x09, 0x68, 0xf6, - 0x42, 0x98, 0x53, 0x0a, 0x26, 0x14, 0x21, 0x5b, 0x1f, 0x89, 0xee, 0xab, 0xa0, 0xfe, 0x0a, 0xa4, - 0x9b, 0xf4, 0x4d, 0x40, 0x5d, 0x2a, 0x8e, 0x8d, 0x19, 0x09, 0x63, 0x9d, 0x85, 0x30, 0xf5, 0x35, - 0x84, 0xdb, 0x75, 0x2a, 0x5e, 0x07, 0x95, 0x7c, 0x95, 0xb5, 0x0a, 0x55, 0xc6, 0x5b, 0x8c, 0xf7, - 0x7f, 0x76, 0xb9, 0xdb, 0x28, 0x88, 0xe3, 0x36, 0xe1, 0xf9, 0xa2, 0x27, 0x7a, 0x21, 0x5c, 0x51, - 0xa4, 0x31, 0x10, 0xb2, 0x87, 0xa0, 0xfa, 0x11, 0x98, 0xae, 0x11, 0x62, 0xcc, 0x4a, 0xec, 0x7b, - 0x89, 0xb1, 0x81, 0xc2, 0xae, 0x11, 0x82, 0xec, 0x08, 0x48, 0x3f, 0xd1, 0xc0, 0x46, 0x35, 0xf0, - 0x7d, 0xe2, 0x09, 0xec, 0xb3, 0xc0, 0x73, 0xf1, 0xb0, 0x81, 0x39, 0x49, 0x52, 0x4e, 0x4c, 0x62, - 0x2a, 0x92, 0xdf, 0xc0, 0x22, 0x7b, 0xad, 0x9f, 0xb1, 0xa3, 0xc4, 0x61, 0xdc, 0xda, 0x63, 0x90, - 0x25, 0x9d, 0x36, 0xe3, 0x81, 0x4f, 0x38, 0xf6, 0x98, 0xc0, 0x35, 0xda, 0x6c, 0x12, 0xd7, 0x98, - 0x97, 0x17, 0x02, 0xf6, 0x42, 0x78, 0x43, 0x01, 0x4f, 0xaa, 0x42, 0xb6, 0x1e, 0x87, 0x8f, 0x98, - 0x38, 0x90, 0x41, 0x9d, 0x83, 0x15, 0xc1, 0x84, 0xd3, 0xc4, 0x15, 0x22, 0xb0, 0xd3, 0x62, 0x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0xde, 0xd2, 0x76, 0x16, 0xac, 0xb5, 0x5e, 0x08, 0xff, 0xef, - 0xdb, 0x6e, 0x9c, 0x43, 0x76, 0x9a, 0xf2, 0x27, 0x6a, 0xbd, 0x97, 0x39, 0x39, 0x85, 0xa9, 0x0f, - 0xa7, 0x30, 0xf5, 0xe3, 0x14, 0xa6, 0xd0, 0x77, 0x0d, 0x64, 0xc7, 0x7c, 0xdc, 0x22, 0xa2, 0xec, - 0x50, 0x7f, 0x82, 0x4d, 0x6b, 0x7f, 0xc5, 0xa6, 0x23, 0x0e, 0xac, 0x06, 0xc5, 0x94, 0xf4, 0x85, - 0x49, 0x36, 0x3d, 0x2c, 0x1a, 0xb5, 0xe9, 0x28, 0x5a, 0x94, 0x33, 0xa4, 0x00, 0xe6, 0xa3, 0xe7, - 0x12, 0xa9, 0x52, 0x5e, 0xbf, 0xd6, 0x0d, 0xe1, 0x9c, 0x45, 0x84, 0xd2, 0x33, 0x48, 0xda, 0x83, - 0x45, 0xd4, 0xe6, 0x66, 0xff, 0x00, 0x4a, 0x83, 0x11, 0xf7, 0xef, 0x8d, 0x2f, 0xeb, 0xe0, 0xac, - 0x6b, 0x6a, 0xe7, 0x5d, 0x53, 0xfb, 0xd6, 0x35, 0xb5, 0xf7, 0x17, 0x66, 0xea, 0xfc, 0xc2, 0x4c, - 0x7d, 0xb9, 0x30, 0x53, 0x2f, 0x6e, 0x8f, 0xdc, 0x3c, 0x5e, 0x27, 0xbb, 0xfd, 0xa1, 0x1f, 0xad, - 0x0b, 0x9d, 0x91, 0x8f, 0x04, 0x79, 0x07, 0x2b, 0x73, 0x72, 0xda, 0xdf, 0xf9, 0x15, 0x00, 0x00, - 0xff, 0xff, 0x19, 0x1e, 0xdc, 0xad, 0x42, 0x08, 0x00, 0x00, + // 817 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x56, 0x4f, 0x6f, 0xfb, 0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, 0x7f, 0xb7, 0x9e, 0xd3, 0xb8, 0x1f, 0xd9, 0xc6, + 0xc3, 0xc8, 0x36, 0xfe, 0x18, 0xd9, 0xc6, 0xcf, 0x8f, 0x76, 0xee, 0xe1, 0xd1, 0xce, 0xfd, 0xf6, + 0x68, 0xe7, 0xae, 0x5e, 0xeb, 0x52, 0x79, 0x1d, 0xb5, 0x6a, 0x6d, 0x16, 0xd4, 0x45, 0x97, 0xbc, + 0x3e, 0x79, 0x2b, 0x24, 0xe3, 0xfa, 0x70, 0xee, 0x6d, 0x21, 0x6f, 0x07, 0x44, 0xb4, 0x36, 0xd5, + 0x23, 0xe1, 0xad, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xe5, 0x1d, 0x34, 0x98, 0x79, 0x08, 0x00, + 0x00, } func (m *OrderBookParticipation) Marshal() (dAtA []byte, err error) { diff --git a/x/orderbook/types/query.pb.go b/x/orderbook/types/query.pb.go index 9c92294b..ebef66cf 100644 --- a/x/orderbook/types/query.pb.go +++ b/x/orderbook/types/query.pb.go @@ -1234,8 +1234,8 @@ func (m *QueryParticipationFulfilledBetsResponse) GetPagination() *query.PageRes return nil } -// QuerySettledOrderBookParticipationsOfHeightRequest is the request type for the settled orderbook participations of a -// certain height list query. +// QuerySettledOrderBookParticipationsOfHeightRequest is the request type for +// the settled orderbook participations of a certain height list query. type QuerySettledOrderBookParticipationsOfHeightRequest struct { Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` BlockHeight int64 `protobuf:"varint,2,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` @@ -1292,8 +1292,8 @@ func (m *QuerySettledOrderBookParticipationsOfHeightRequest) GetBlockHeight() in return 0 } -// QuerySettledOrderBookParticipationsOfHeightResponse is the response type for the settled orderbook participations of -// a certain height list query. +// QuerySettledOrderBookParticipationsOfHeightResponse is the response type for +// the settled orderbook participations of a certain height list query. type QuerySettledOrderBookParticipationsOfHeightResponse struct { Participations []OrderBookParticipation `protobuf:"bytes,1,rep,name=participations,proto3" json:"participations"` Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` @@ -1380,7 +1380,7 @@ func init() { func init() { proto.RegisterFile("sge/orderbook/query.proto", fileDescriptor_8b016841afa49a45) } var fileDescriptor_8b016841afa49a45 = []byte{ - // 1241 bytes of a gzipped FileDescriptorProto + // 1238 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x59, 0x5f, 0x4f, 0x1c, 0x55, 0x14, 0xe7, 0xd2, 0x8a, 0x72, 0x68, 0x9a, 0xf4, 0x40, 0x59, 0x98, 0x94, 0x05, 0xa6, 0x0d, 0x54, 0x0b, 0x33, 0x40, 0x4d, 0xff, 0x24, 0x50, 0x75, 0xd3, 0x52, 0x6a, 0xda, 0x80, 0xdb, 0xf0, 0xa2, @@ -1452,13 +1452,13 @@ var fileDescriptor_8b016841afa49a45 = []byte{ 0x21, 0xc6, 0xbb, 0x5c, 0x8c, 0x9b, 0x58, 0x88, 0x13, 0x63, 0xc3, 0xcf, 0x38, 0x1d, 0x65, 0xf8, 0xdf, 0x04, 0xa4, 0xe8, 0xd9, 0x11, 0xdf, 0x4e, 0x63, 0x5b, 0xd8, 0x00, 0x2d, 0xbd, 0x73, 0x8c, 0x0c, 0x82, 0xef, 0x07, 0x9c, 0xef, 0x2a, 0xde, 0xef, 0xc4, 0xe1, 0xaa, 0xae, 0x7b, 0x35, 0xf8, - 0xfc, 0x8b, 0x9f, 0x75, 0xc3, 0x44, 0xf3, 0x00, 0x57, 0x8a, 0x1c, 0xe0, 0xf0, 0x6e, 0x0c, 0x95, - 0x54, 0x93, 0xaa, 0x74, 0xaf, 0x43, 0xd9, 0x62, 0xce, 0xba, 0x16, 0x4d, 0x2c, 0x37, 0xab, 0xba, - 0xd3, 0x3c, 0xdd, 0xee, 0x16, 0x16, 0x9f, 0xec, 0xe7, 0xc9, 0xde, 0x7e, 0x9e, 0xfc, 0xb6, 0x9f, - 0x27, 0x5f, 0x1d, 0xe4, 0xbb, 0xf6, 0x0e, 0xf2, 0x5d, 0xbf, 0x1e, 0xe4, 0xbb, 0xde, 0x9f, 0xd2, - 0x0d, 0x7b, 0xa3, 0x51, 0x52, 0xca, 0x6c, 0xcb, 0xc9, 0x3c, 0x2d, 0x10, 0xf3, 0x2a, 0xdb, 0x4d, - 0x75, 0xec, 0x87, 0x26, 0xb5, 0x4a, 0x3d, 0xfc, 0x3f, 0x27, 0x97, 0xff, 0x0d, 0x00, 0x00, 0xff, - 0xff, 0xeb, 0x7c, 0xb0, 0x77, 0x4c, 0x1a, 0x00, 0x00, + 0xfc, 0x8b, 0x9f, 0x75, 0xc3, 0x44, 0xb2, 0x01, 0x0e, 0xef, 0xc6, 0x50, 0x49, 0x35, 0xa9, 0x4a, + 0xf7, 0x3a, 0x94, 0x2d, 0xe6, 0xac, 0x6b, 0xd1, 0xc4, 0x72, 0xb3, 0xaa, 0x3b, 0xcd, 0xd3, 0xed, + 0x6e, 0x61, 0xf1, 0xc9, 0x7e, 0x9e, 0xec, 0xed, 0xe7, 0xc9, 0x6f, 0xfb, 0x79, 0xf2, 0xd5, 0x41, + 0xbe, 0x6b, 0xef, 0x20, 0xdf, 0xf5, 0xeb, 0x41, 0xbe, 0xeb, 0xfd, 0x29, 0xdd, 0xb0, 0x37, 0x1a, + 0x25, 0xa5, 0xcc, 0xb6, 0x9c, 0xcc, 0xd3, 0x02, 0x31, 0xaf, 0xb2, 0xdd, 0x54, 0xc7, 0x7e, 0x68, + 0x52, 0xab, 0xd4, 0xc3, 0xff, 0x73, 0x72, 0xf9, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa5, 0x86, + 0x58, 0x22, 0x4c, 0x1a, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1503,7 +1503,7 @@ type QueryClient interface { // participation. ParticipationFulfilledBets(ctx context.Context, in *QueryParticipationFulfilledBetsRequest, opts ...grpc.CallOption) (*QueryParticipationFulfilledBetsResponse, error) // Queries list of settled Orderbook Participation items of a certain height. - SettledOrderbookParticipationsOfHeight(ctx context.Context, in *QuerySettledOrderBookParticipationsOfHeightRequest, opts ...grpc.CallOption) (*QuerySettledOrderBookParticipationsOfHeightResponse, error) + SettledOrderBookParticipationsOfHeight(ctx context.Context, in *QuerySettledOrderBookParticipationsOfHeightRequest, opts ...grpc.CallOption) (*QuerySettledOrderBookParticipationsOfHeightResponse, error) } type queryClient struct { @@ -1613,9 +1613,9 @@ func (c *queryClient) ParticipationFulfilledBets(ctx context.Context, in *QueryP return out, nil } -func (c *queryClient) SettledOrderbookParticipationsOfHeight(ctx context.Context, in *QuerySettledOrderBookParticipationsOfHeightRequest, opts ...grpc.CallOption) (*QuerySettledOrderBookParticipationsOfHeightResponse, error) { +func (c *queryClient) SettledOrderBookParticipationsOfHeight(ctx context.Context, in *QuerySettledOrderBookParticipationsOfHeightRequest, opts ...grpc.CallOption) (*QuerySettledOrderBookParticipationsOfHeightResponse, error) { out := new(QuerySettledOrderBookParticipationsOfHeightResponse) - err := c.cc.Invoke(ctx, "/sgenetwork.sge.orderbook.Query/SettledOrderbookParticipationsOfHeight", in, out, opts...) + err := c.cc.Invoke(ctx, "/sgenetwork.sge.orderbook.Query/SettledOrderBookParticipationsOfHeight", in, out, opts...) if err != nil { return nil, err } @@ -1654,7 +1654,7 @@ type QueryServer interface { // participation. ParticipationFulfilledBets(context.Context, *QueryParticipationFulfilledBetsRequest) (*QueryParticipationFulfilledBetsResponse, error) // Queries list of settled Orderbook Participation items of a certain height. - SettledOrderbookParticipationsOfHeight(context.Context, *QuerySettledOrderBookParticipationsOfHeightRequest) (*QuerySettledOrderBookParticipationsOfHeightResponse, error) + SettledOrderBookParticipationsOfHeight(context.Context, *QuerySettledOrderBookParticipationsOfHeightRequest) (*QuerySettledOrderBookParticipationsOfHeightResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -1694,8 +1694,8 @@ func (*UnimplementedQueryServer) HistoricalParticipationExposures(ctx context.Co func (*UnimplementedQueryServer) ParticipationFulfilledBets(ctx context.Context, req *QueryParticipationFulfilledBetsRequest) (*QueryParticipationFulfilledBetsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ParticipationFulfilledBets not implemented") } -func (*UnimplementedQueryServer) SettledOrderbookParticipationsOfHeight(ctx context.Context, req *QuerySettledOrderBookParticipationsOfHeightRequest) (*QuerySettledOrderBookParticipationsOfHeightResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method SettledOrderbookParticipationsOfHeight not implemented") +func (*UnimplementedQueryServer) SettledOrderBookParticipationsOfHeight(ctx context.Context, req *QuerySettledOrderBookParticipationsOfHeightRequest) (*QuerySettledOrderBookParticipationsOfHeightResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SettledOrderBookParticipationsOfHeight not implemented") } func RegisterQueryServer(s grpc1.Server, srv QueryServer) { @@ -1900,20 +1900,20 @@ func _Query_ParticipationFulfilledBets_Handler(srv interface{}, ctx context.Cont return interceptor(ctx, in, info, handler) } -func _Query_SettledOrderbookParticipationsOfHeight_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Query_SettledOrderBookParticipationsOfHeight_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QuerySettledOrderBookParticipationsOfHeightRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).SettledOrderbookParticipationsOfHeight(ctx, in) + return srv.(QueryServer).SettledOrderBookParticipationsOfHeight(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/sgenetwork.sge.orderbook.Query/SettledOrderbookParticipationsOfHeight", + FullMethod: "/sgenetwork.sge.orderbook.Query/SettledOrderBookParticipationsOfHeight", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).SettledOrderbookParticipationsOfHeight(ctx, req.(*QuerySettledOrderBookParticipationsOfHeightRequest)) + return srv.(QueryServer).SettledOrderBookParticipationsOfHeight(ctx, req.(*QuerySettledOrderBookParticipationsOfHeightRequest)) } return interceptor(ctx, in, info, handler) } @@ -1967,8 +1967,8 @@ var _Query_serviceDesc = grpc.ServiceDesc{ Handler: _Query_ParticipationFulfilledBets_Handler, }, { - MethodName: "SettledOrderbookParticipationsOfHeight", - Handler: _Query_SettledOrderbookParticipationsOfHeight_Handler, + MethodName: "SettledOrderBookParticipationsOfHeight", + Handler: _Query_SettledOrderBookParticipationsOfHeight_Handler, }, }, Streams: []grpc.StreamDesc{}, diff --git a/x/orderbook/types/query.pb.gw.go b/x/orderbook/types/query.pb.gw.go index 21a77d62..485f7637 100644 --- a/x/orderbook/types/query.pb.gw.go +++ b/x/orderbook/types/query.pb.gw.go @@ -806,10 +806,10 @@ func local_request_Query_ParticipationFulfilledBets_0(ctx context.Context, marsh } var ( - filter_Query_SettledOrderbookParticipationsOfHeight_0 = &utilities.DoubleArray{Encoding: map[string]int{"block_height": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} + filter_Query_SettledOrderBookParticipationsOfHeight_0 = &utilities.DoubleArray{Encoding: map[string]int{"block_height": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} ) -func request_Query_SettledOrderbookParticipationsOfHeight_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_Query_SettledOrderBookParticipationsOfHeight_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QuerySettledOrderBookParticipationsOfHeightRequest var metadata runtime.ServerMetadata @@ -834,16 +834,16 @@ func request_Query_SettledOrderbookParticipationsOfHeight_0(ctx context.Context, if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_SettledOrderbookParticipationsOfHeight_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_SettledOrderBookParticipationsOfHeight_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.SettledOrderbookParticipationsOfHeight(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.SettledOrderBookParticipationsOfHeight(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_SettledOrderbookParticipationsOfHeight_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_Query_SettledOrderBookParticipationsOfHeight_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QuerySettledOrderBookParticipationsOfHeightRequest var metadata runtime.ServerMetadata @@ -868,11 +868,11 @@ func local_request_Query_SettledOrderbookParticipationsOfHeight_0(ctx context.Co if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_SettledOrderbookParticipationsOfHeight_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_SettledOrderBookParticipationsOfHeight_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.SettledOrderbookParticipationsOfHeight(ctx, &protoReq) + msg, err := server.SettledOrderBookParticipationsOfHeight(ctx, &protoReq) return msg, metadata, err } @@ -1136,7 +1136,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_SettledOrderbookParticipationsOfHeight_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_SettledOrderBookParticipationsOfHeight_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -1147,7 +1147,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_SettledOrderbookParticipationsOfHeight_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_SettledOrderBookParticipationsOfHeight_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 { @@ -1155,7 +1155,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_SettledOrderbookParticipationsOfHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_SettledOrderBookParticipationsOfHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -1420,7 +1420,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_SettledOrderbookParticipationsOfHeight_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_SettledOrderBookParticipationsOfHeight_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) @@ -1429,14 +1429,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_SettledOrderbookParticipationsOfHeight_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_SettledOrderBookParticipationsOfHeight_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_SettledOrderbookParticipationsOfHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_SettledOrderBookParticipationsOfHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -1466,7 +1466,7 @@ var ( pattern_Query_ParticipationFulfilledBets_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"sge", "orderbook", "order_book_uid", "participations", "participation_index", "fulfilled_bets"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_SettledOrderbookParticipationsOfHeight_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"sge", "orderbook", "participations", "settled", "block_height"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_SettledOrderBookParticipationsOfHeight_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"sge", "orderbook", "participations", "settled", "block_height"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -1492,5 +1492,5 @@ var ( forward_Query_ParticipationFulfilledBets_0 = runtime.ForwardResponseMessage - forward_Query_SettledOrderbookParticipationsOfHeight_0 = runtime.ForwardResponseMessage + forward_Query_SettledOrderBookParticipationsOfHeight_0 = runtime.ForwardResponseMessage ) 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 f4aec33a..ed1a3ef8 100644 --- a/x/reward/client/cli/tx.go +++ b/x/reward/client/cli/tx.go @@ -24,6 +24,7 @@ func GetTxCmd() *cobra.Command { RunE: client.ValidateCmd, } + cmd.AddCommand(CmdCreatePromoter()) cmd.AddCommand(CmdSetPromoterConf()) cmd.AddCommand(CmdCreateCampaign()) cmd.AddCommand(CmdUpdateCampaign()) diff --git a/x/reward/client/cli/tx_promoter.go b/x/reward/client/cli/tx_promoter.go index be0286fe..762f3ad6 100644 --- a/x/reward/client/cli/tx_promoter.go +++ b/x/reward/client/cli/tx_promoter.go @@ -10,6 +10,37 @@ import ( "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]", diff --git a/x/reward/keeper/campaign.go b/x/reward/keeper/campaign.go index c894a927..333b1fa6 100644 --- a/x/reward/keeper/campaign.go +++ b/x/reward/keeper/campaign.go @@ -55,7 +55,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 + totalAmount := receiver.SubaccountAmount.Add(receiver.MainAccountAmount) // Fixme: Check if the logic is correct campaign.Pool.Spent = campaign.Pool.Spent.Add(totalAmount) k.SetCampaign(ctx, campaign) diff --git a/x/reward/keeper/distribution.go b/x/reward/keeper/distribution.go index 2deec6ed..9eb020d1 100644 --- a/x/reward/keeper/distribution.go +++ b/x/reward/keeper/distribution.go @@ -12,17 +12,17 @@ import ( // DistributeRewards distributes the rewards according to the input distribution list. func (k Keeper) DistributeRewards(ctx sdk.Context, receiver types.Receiver) (uint64, error) { unlockTS := uint64(0) - if receiver.SubAccountAmount.GT(sdk.ZeroInt()) { + if receiver.SubaccountAmount.GT(sdk.ZeroInt()) { moduleAccAddr := types.RewardPoolFunder{}.GetModuleAcc() unlockTS = cast.ToUint64(ctx.BlockTime().Unix()) + receiver.UnlockPeriod if _, err := k.subaccountKeeper.TopUp(ctx, k.accountKeeper.GetModuleAddress(moduleAccAddr).String(), receiver.MainAccountAddr, []subaccounttypes.LockedBalance{ { UnlockTS: unlockTS, - Amount: receiver.SubAccountAmount, + Amount: receiver.SubaccountAmount, }, }); err != nil { - return unlockTS, sdkerrors.Wrapf(types.ErrSubAccRewardTopUp, "subaccount address %s, %s", receiver.SubAccountAddr, err) + return unlockTS, sdkerrors.Wrapf(types.ErrSubaccountRewardTopUp, "subaccount address %s, %s", receiver.SubaccountAddr, err) } } if receiver.MainAccountAmount.GT(sdk.ZeroInt()) { diff --git a/x/reward/keeper/keeper.go b/x/reward/keeper/keeper.go index 48bd1646..7cee10d7 100644 --- a/x/reward/keeper/keeper.go +++ b/x/reward/keeper/keeper.go @@ -25,7 +25,7 @@ type ( authzKeeper types.AuthzKeeper betKeeper types.BetKeeper ovmKeeper types.OVMKeeper - subaccountKeeper types.SubAccountKeeper + subaccountKeeper types.SubaccountKeeper } ) @@ -43,7 +43,7 @@ func NewKeeper( ps paramtypes.Subspace, betKeeper types.BetKeeper, ovmKeeper types.OVMKeeper, - subaccountKeeper types.SubAccountKeeper, + subaccountKeeper types.SubaccountKeeper, expectedKeepers SdkExpectedKeepers, ) *Keeper { // set KeyTable if it has not already been set diff --git a/x/reward/keeper/msg_server_promoter.go b/x/reward/keeper/msg_server_promoter.go index 9fcaa4bb..2126c2ed 100644 --- a/x/reward/keeper/msg_server_promoter.go +++ b/x/reward/keeper/msg_server_promoter.go @@ -9,6 +9,36 @@ import ( "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, + }) + + 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) diff --git a/x/reward/keeper/msg_server_reward.go b/x/reward/keeper/msg_server_reward.go index a649b9a4..ab488963 100644 --- a/x/reward/keeper/msg_server_reward.go +++ b/x/reward/keeper/msg_server_reward.go @@ -40,7 +40,7 @@ func (k msgServer) GrantReward(goCtx context.Context, msg *types.MsgGrantReward) types.RewardFactoryKeepers{ OVMKeeper: k.ovmKeeper, BetKeeper: k.betKeeper, - SubAccountKeeper: k.subaccountKeeper, + SubaccountKeeper: k.subaccountKeeper, RewardKeeper: k.Keeper, AccountKeeper: k.accountKeeper, }, campaign, msg.Ticket, msg.Creator) @@ -84,7 +84,7 @@ func (k msgServer) GrantReward(goCtx context.Context, msg *types.MsgGrantReward) } } - if err := campaign.CheckPoolBalance(factData.Receiver.SubAccountAmount.Add(factData.Receiver.MainAccountAmount)); err != nil { + if err := campaign.CheckPoolBalance(factData.Receiver.SubaccountAmount.Add(factData.Receiver.MainAccountAmount)); err != nil { return nil, types.ErrInsufficientPoolBalance } diff --git a/x/reward/keeper/msg_server_reward_test.go b/x/reward/keeper/msg_server_reward_test.go index bc3134b4..a4c2e79d 100644 --- a/x/reward/keeper/msg_server_reward_test.go +++ b/x/reward/keeper/msg_server_reward_test.go @@ -86,7 +86,7 @@ func TestMsgApplySignupReward(t *testing.T) { promoter := simapp.TestParamUsers["user1"].Address.String() receiverAddr := simapp.TestParamUsers["user2"].Address.String() - _, err := tApp.SubaccountKeeper.CreateSubAccount(ctx, receiverAddr, receiverAddr, []subaccounttypes.LockedBalance{ + _, err := tApp.SubaccountKeeper.CreateSubaccount(ctx, receiverAddr, receiverAddr, []subaccounttypes.LockedBalance{ { Amount: sdk.ZeroInt(), UnlockTS: uint64(ctx.BlockTime().Add(60 * time.Minute).Unix()), @@ -163,7 +163,7 @@ func TestMsgApplySignupRewardWithCap(t *testing.T) { promoter := simapp.TestParamUsers["user1"].Address.String() receiverAddr := simapp.TestParamUsers["user2"].Address.String() - _, err := tApp.SubaccountKeeper.CreateSubAccount(ctx, receiverAddr, receiverAddr, []subaccounttypes.LockedBalance{ + _, err := tApp.SubaccountKeeper.CreateSubaccount(ctx, receiverAddr, receiverAddr, []subaccounttypes.LockedBalance{ { Amount: sdk.ZeroInt(), UnlockTS: uint64(ctx.BlockTime().Add(60 * time.Minute).Unix()), @@ -221,7 +221,7 @@ func TestMsgApplySignupRefereeReward(t *testing.T) { referrer := simapp.TestParamUsers["user3"].Address.String() - _, err := tApp.SubaccountKeeper.CreateSubAccount(ctx, receiverAddr, receiverAddr, []subaccounttypes.LockedBalance{ + _, err := tApp.SubaccountKeeper.CreateSubaccount(ctx, receiverAddr, receiverAddr, []subaccounttypes.LockedBalance{ { Amount: sdk.ZeroInt(), UnlockTS: uint64(ctx.BlockTime().Add(60 * time.Minute).Unix()), @@ -314,7 +314,7 @@ func TestMsgApplySignupReferrerReward(t *testing.T) { referee := simapp.TestParamUsers["user3"].Address.String() referrer := simapp.TestParamUsers["user4"].Address.String() - _, err := tApp.SubaccountKeeper.CreateSubAccount(ctx, receiverAddr, receiverAddr, []subaccounttypes.LockedBalance{ + _, err := tApp.SubaccountKeeper.CreateSubaccount(ctx, receiverAddr, receiverAddr, []subaccounttypes.LockedBalance{ { Amount: sdk.ZeroInt(), UnlockTS: uint64(ctx.BlockTime().Add(60 * time.Minute).Unix()), @@ -453,7 +453,7 @@ func TestMsgApplySignupAffiliateReward(t *testing.T) { leadGen := simapp.TestParamUsers["user3"].Address.String() - _, err := tApp.SubaccountKeeper.CreateSubAccount(ctx, receiverAddr, receiverAddr, []subaccounttypes.LockedBalance{ + _, err := tApp.SubaccountKeeper.CreateSubaccount(ctx, receiverAddr, receiverAddr, []subaccounttypes.LockedBalance{ { Amount: sdk.ZeroInt(), UnlockTS: uint64(ctx.BlockTime().Add(60 * time.Minute).Unix()), @@ -546,7 +546,7 @@ func TestMsgApplySignupAffiliateeReward(t *testing.T) { affiliatee := simapp.TestParamUsers["user3"].Address.String() affiliator := simapp.TestParamUsers["user4"].Address.String() - _, err := tApp.SubaccountKeeper.CreateSubAccount(ctx, receiverAddr, receiverAddr, []subaccounttypes.LockedBalance{ + _, err := tApp.SubaccountKeeper.CreateSubaccount(ctx, receiverAddr, receiverAddr, []subaccounttypes.LockedBalance{ { Amount: sdk.ZeroInt(), UnlockTS: uint64(ctx.BlockTime().Add(60 * time.Minute).Unix()), @@ -674,7 +674,7 @@ func TestMsgApplySignupAffiliateeReward(t *testing.T) { } } -func TestMsgApplySignupRewardSubAcc(t *testing.T) { +func TestMsgApplySignupRewardSubaccount(t *testing.T) { tApp, k, ctx := setupKeeperAndApp(t) srv := keeper.NewMsgServerImpl(*k) ctx = ctx.WithBlockTime(time.Now()) @@ -693,7 +693,7 @@ func TestMsgApplySignupRewardSubAcc(t *testing.T) { campUID := createCampaign(t, k, srv, ctx, promoter, campClaims, defaultCategoryCap) - _, err := tApp.SubaccountKeeper.CreateSubAccount(ctx, receiverAddr, receiverAddr, []subaccounttypes.LockedBalance{ + _, err := tApp.SubaccountKeeper.CreateSubaccount(ctx, receiverAddr, receiverAddr, []subaccounttypes.LockedBalance{ { Amount: sdk.ZeroInt(), UnlockTS: uint64(ctx.BlockTime().Add(60 * time.Minute).Unix()), @@ -786,7 +786,7 @@ func TestMsgApplySignupRewardSubAcc(t *testing.T) { } } -func TestMsgApplySubAccFunds(t *testing.T) { +func TestMsgApplySubaccountFunds(t *testing.T) { tApp, k, ctx := setupKeeperAndApp(t) srv := keeper.NewMsgServerImpl(*k) ctx = ctx.WithBlockTime(time.Now()) @@ -834,7 +834,7 @@ func TestMsgApplySubAccFunds(t *testing.T) { _, err = srv.GrantReward(wctx, reward) require.NoError(t, err) - subAccAddr, found := tApp.SubaccountKeeper.GetSubAccountByOwner(ctx, sdk.MustAccAddressFromBech32(receiverAddr)) + subAccAddr, found := tApp.SubaccountKeeper.GetSubaccountByOwner(ctx, sdk.MustAccAddressFromBech32(receiverAddr)) require.True(t, found) balance, found := tApp.SubaccountKeeper.GetAccountSummary(ctx, subAccAddr) 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/types/errors.go b/x/reward/types/errors.go index 093a078d..87170e29 100644 --- a/x/reward/types/errors.go +++ b/x/reward/types/errors.go @@ -8,35 +8,35 @@ import ( // x/reward module sentinel errors var ( - ErrInTicketVerification = sdkerrors.Register(ModuleName, 7100, "ticket verification failed") - ErrInTicketValidation = sdkerrors.Register(ModuleName, 7101, "ticket validation failed") - ErrAuthorizationNotFound = sdkerrors.Register(ModuleName, 7102, "no authorization found") - ErrAuthorizationNotAccepted = sdkerrors.Register(ModuleName, 7103, "authorization not accepted") - ErrorBank = sdkerrors.Register(ModuleName, 7104, "bank error") - ErrExpiredCampaign = sdkerrors.Register(ModuleName, 7105, "campaign is expired") - ErrCampaignPoolBalance = sdkerrors.Register(ModuleName, 7106, "not enough campaign pool balance") - ErrUnknownRewardType = sdkerrors.Register(ModuleName, 7107, "unknown reward type") - ErrInFundingCampaignPool = sdkerrors.Register(ModuleName, 7108, "error in funding the campaign pool") - ErrWithdrawFromCampaignPool = sdkerrors.Register(ModuleName, 7109, "error in withdrawing from the campaign pool") - ErrCampaignEnded = sdkerrors.Register(ModuleName, 7110, "campaign validity period is ended") - ErrInsufficientPoolBalance = sdkerrors.Register(ModuleName, 7111, "insufficient campaign pool balance") - ErrInDistributionOfRewards = sdkerrors.Register(ModuleName, 7112, "reward distribution failed") - ErrInvalidGranteeType = sdkerrors.Register(ModuleName, 7113, "inappropriate reward grantee account type") - ErrWrongRewardCategory = sdkerrors.Register(ModuleName, 7114, "wrong reward category") - ErrMissingDefinition = sdkerrors.Register(ModuleName, 7115, "missing reward definition") - ErrSubAccRewardTopUp = sdkerrors.Register(ModuleName, 7116, "subaccount reward topup failed") - 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") - ErrSubAccountCreationFailed = sdkerrors.Register(ModuleName, 7122, "subaccount creation failed") - ErrWrongRewardAmountType = sdkerrors.Register(ModuleName, 7123, "wrong reward amount type") - ErrUnknownAccType = sdkerrors.Register(ModuleName, 7124, "unknown account type") - ErrReceiverAddrCanNotBeSubAcc = sdkerrors.Register(ModuleName, 7125, "receiver account can not be sub account address") - ErrInvalidFunds = sdkerrors.Register(ModuleName, 7126, "invalid funds") - 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") + ErrInTicketVerification = sdkerrors.Register(ModuleName, 7100, "ticket verification failed") + ErrInTicketValidation = sdkerrors.Register(ModuleName, 7101, "ticket validation failed") + ErrAuthorizationNotFound = sdkerrors.Register(ModuleName, 7102, "no authorization found") + ErrAuthorizationNotAccepted = sdkerrors.Register(ModuleName, 7103, "authorization not accepted") + ErrorBank = sdkerrors.Register(ModuleName, 7104, "bank error") + ErrExpiredCampaign = sdkerrors.Register(ModuleName, 7105, "campaign is expired") + ErrCampaignPoolBalance = sdkerrors.Register(ModuleName, 7106, "not enough campaign pool balance") + ErrUnknownRewardType = sdkerrors.Register(ModuleName, 7107, "unknown reward type") + ErrInFundingCampaignPool = sdkerrors.Register(ModuleName, 7108, "error in funding the campaign pool") + ErrWithdrawFromCampaignPool = sdkerrors.Register(ModuleName, 7109, "error in withdrawing from the campaign pool") + ErrCampaignEnded = sdkerrors.Register(ModuleName, 7110, "campaign validity period is ended") + ErrInsufficientPoolBalance = sdkerrors.Register(ModuleName, 7111, "insufficient campaign pool balance") + ErrInDistributionOfRewards = sdkerrors.Register(ModuleName, 7112, "reward distribution failed") + ErrInvalidGranteeType = sdkerrors.Register(ModuleName, 7113, "inappropriate reward grantee account type") + 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") + 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") + ErrSubaccountCreationFailed = sdkerrors.Register(ModuleName, 7122, "subaccount creation failed") + ErrWrongRewardAmountType = sdkerrors.Register(ModuleName, 7123, "wrong reward amount type") + ErrUnknownAccType = sdkerrors.Register(ModuleName, 7124, "unknown account type") + ErrReceiverAddrCanNotBeSubaccount = sdkerrors.Register(ModuleName, 7125, "receiver account can not be sub account address") + ErrInvalidFunds = sdkerrors.Register(ModuleName, 7126, "invalid funds") + ErrCampaignHasNotStarted = sdkerrors.Register(ModuleName, 7127, "campaign validity period is not started yet") + ErrUserKycFailed = sdkerrors.Register(ModuleName, 7128, "KYC Validation failed for receiver account address") + ErrUserKycNotProvided = sdkerrors.Register(ModuleName, 7129, "KYC data not provided") + ErrDuplicateCategoryInConf = sdkerrors.Register(ModuleName, 7130, "duplicate category in promoter configurations") + ErrCategoryCapShouldBePos = sdkerrors.Register(ModuleName, 7131, "category cap should be a positive number") ) diff --git a/x/reward/types/expected_keepers.go b/x/reward/types/expected_keepers.go index eac09a54..c91495f4 100644 --- a/x/reward/types/expected_keepers.go +++ b/x/reward/types/expected_keepers.go @@ -61,12 +61,12 @@ type AuthzKeeper interface { ) error } -// SubAccountKeeper defines the expected interface needed to get/create/topup a subaccount. -type SubAccountKeeper interface { +// SubaccountKeeper defines the expected interface needed to get/create/topup a subaccount. +type SubaccountKeeper interface { TopUp(ctx sdk.Context, creator, subAccOwnerAddr string, lockedBalance []subaccounttypes.LockedBalance) (string, error) - GetSubAccountByOwner(ctx sdk.Context, mainAccountAddress sdk.AccAddress) (sdk.AccAddress, bool) - CreateSubAccount(ctx sdk.Context, creator, owner string, lockedBalances []subaccounttypes.LockedBalance) (string, error) - IsSubAccount(ctx sdk.Context, subAccAddr sdk.AccAddress) bool + GetSubaccountByOwner(ctx sdk.Context, mainAccountAddress sdk.AccAddress) (sdk.AccAddress, bool) + CreateSubaccount(ctx sdk.Context, creator, owner string, lockedBalances []subaccounttypes.LockedBalance) (string, error) + IsSubaccount(ctx sdk.Context, subAccAddr sdk.AccAddress) bool } // RewardKeeper defines the expected interface needed to get and filter the rewards. diff --git a/x/reward/types/messages_promoter.go b/x/reward/types/messages_promoter.go index 3de553e5..c83924b1 100644 --- a/x/reward/types/messages_promoter.go +++ b/x/reward/types/messages_promoter.go @@ -10,9 +10,13 @@ import ( const ( TypeMsgSetPromoterConf = "set_promoter_conf" + TypeMsgCreatePromoter = "create_promoter" ) -var _ sdk.Msg = &MsgSetPromoterConf{} +var ( + _ sdk.Msg = &MsgSetPromoterConf{} + _ sdk.Msg = &MsgCreatePromoter{} +) func NewMsgSetPromoterConfig( creator string, @@ -73,3 +77,57 @@ func (msg *MsgSetPromoterConf) EmitEvent(ctx *sdk.Context, conf PromoterConf) { ) 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/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/query.pb.go b/x/reward/types/query.pb.go index b7a3cc6b..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) @@ -502,7 +692,7 @@ func (m *QueryRewardsByAddressRequest) Reset() { *m = QueryRewardsByAddr 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) @@ -563,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) @@ -621,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) @@ -691,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) @@ -745,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) @@ -799,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) @@ -845,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") @@ -864,62 +1058,70 @@ func init() { func init() { proto.RegisterFile("sge/reward/query.proto", fileDescriptor_324afa5f2186a8c0) } var fileDescriptor_324afa5f2186a8c0 = []byte{ - // 878 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x97, 0x4b, 0x4f, 0x13, 0x5d, - 0x18, 0xc7, 0x7b, 0x80, 0xb7, 0xc0, 0x81, 0xbc, 0xe1, 0x3d, 0x2f, 0x20, 0x56, 0x18, 0xe8, 0xa8, - 0x6d, 0xb9, 0xcd, 0x04, 0xd0, 0x78, 0x8b, 0x22, 0x34, 0xca, 0xc2, 0x0d, 0x36, 0x71, 0x43, 0x62, - 0xc8, 0x94, 0x9e, 0x8c, 0x13, 0x6d, 0xcf, 0x30, 0x67, 0x2a, 0x36, 0x4d, 0x37, 0x6e, 0x4c, 0x34, - 0x26, 0x26,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0x83, 0xf3, 0xc7, 0xcc, - 0x12, 0xf3, 0x2c, 0xb3, 0x79, 0x2e, 0xa1, 0x0b, 0xad, 0xe6, 0x39, 0xba, 0x1e, 0xaa, 0x57, 0x43, - 0x69, 0x35, 0xb9, 0x77, 0xa0, 0x80, 0xfd, 0x03, 0x05, 0x7c, 0x3b, 0x50, 0xc0, 0x8b, 0x43, 0x25, - 0xb4, 0x7f, 0xa8, 0x84, 0xbe, 0x1c, 0x2a, 0xa1, 0x8d, 0x69, 0xd3, 0x72, 0xef, 0xe5, 0xd3, 0xda, - 0x16, 0xc9, 0xfa, 0x8a, 0x3f, 0x92, 0xe5, 0xdd, 0x82, 0x8d, 0x69, 0x3a, 0xcc, 0xfe, 0xc4, 0x5a, - 0xfa, 0x15, 0x00, 0x00, 0xff, 0xff, 0x0a, 0x7f, 0x1b, 0x06, 0x40, 0x0e, 0x00, 0x00, + // 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, + 0x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ference imports to suppress errors if they are not otherwise used. @@ -936,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. @@ -970,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...) @@ -1037,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. @@ -1061,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") } @@ -1105,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 { @@ -1239,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, @@ -1328,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]) @@ -1338,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]) @@ -1368,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 } @@ -1391,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]) @@ -1401,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 @@ -1426,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]) @@ -1436,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 @@ -1458,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 } @@ -1475,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]) @@ -1485,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 @@ -1505,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]) @@ -1515,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 } @@ -1538,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]) @@ -1548,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 @@ -1573,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]) @@ -1583,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 @@ -1605,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 } @@ -1622,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]) @@ -1632,26 +1910,173 @@ 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.PromoterUid) > 0 { - i -= len(m.PromoterUid) - copy(dAtA[i:], m.PromoterUid) - i = encodeVarintQuery(dAtA, i, uint64(len(m.PromoterUid))) + 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] = 0x1a + dAtA[i] = 0xa } - if len(m.Address) > 0 { - i -= len(m.Address) - copy(dAtA[i:], m.Address) + 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) i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) i-- dAtA[i] = 0x12 @@ -1945,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 @@ -2315,6 +2796,377 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryPromoterByAddressRequest) 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: QueryPromoterByAddressRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + 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 Addr", 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.Addr = 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 *QueryPromoterByAddressResponse) 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: QueryPromoterByAddressResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + 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 Promoter", 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.Promoter.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 *QueryPromotersRequest) 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: QueryPromotersRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPromotersRequest: 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 *QueryPromotersResponse) 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: QueryPromotersResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + 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 Promoter", 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.Promoter = append(m.Promoter, Promoter{}) + if err := m.Promoter[len(m.Promoter)-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 *QueryCampaignRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/reward/types/query.pb.gw.go b/x/reward/types/query.pb.gw.go index 70134ca9..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 @@ -548,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() @@ -770,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() @@ -916,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))) @@ -934,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.go b/x/reward/types/reward.go index a745ba73..f599de45 100644 --- a/x/reward/types/reward.go +++ b/x/reward/types/reward.go @@ -13,8 +13,8 @@ import ( ) type Receiver struct { - SubAccountAddr string - SubAccountAmount sdkmath.Int + SubaccountAddr string + SubaccountAmount sdkmath.Int UnlockPeriod uint64 MainAccountAddr string MainAccountAmount sdkmath.Int @@ -24,21 +24,21 @@ type Receiver struct { type RewardFactoryKeepers struct { OVMKeeper BetKeeper - SubAccountKeeper + SubaccountKeeper RewardKeeper AccountKeeper } -func (keepers *RewardFactoryKeepers) getSubAccAddr(ctx sdk.Context, creator, receiver string) (string, error) { +func (keepers *RewardFactoryKeepers) getSubaccountAddr(ctx sdk.Context, creator, receiver string) (string, error) { var ( subAccountAddressString string err error ) - subAccountAddress, found := keepers.SubAccountKeeper.GetSubAccountByOwner(ctx, sdk.MustAccAddressFromBech32(receiver)) + subAccountAddress, found := keepers.SubaccountKeeper.GetSubaccountByOwner(ctx, sdk.MustAccAddressFromBech32(receiver)) if !found { - subAccountAddressString, err = keepers.SubAccountKeeper.CreateSubAccount(ctx, creator, receiver, []subaccounttypes.LockedBalance{}) + subAccountAddressString, err = keepers.SubaccountKeeper.CreateSubaccount(ctx, creator, receiver, []subaccounttypes.LockedBalance{}) if err != nil { - return "", sdkerrors.Wrapf(ErrSubAccountCreationFailed, "%s", receiver) + return "", sdkerrors.Wrapf(ErrSubaccountCreationFailed, "%s", receiver) } } else { subAccountAddressString = subAccountAddress.String() @@ -102,8 +102,8 @@ type IRewardFactory interface { // NewReceiver creates receiver object. func NewReceiver(saAddr, maAddr string, saAmount, maAmount sdkmath.Int, unlockPeriod uint64) Receiver { return Receiver{ - SubAccountAddr: saAddr, - SubAccountAmount: saAmount, + SubaccountAddr: saAddr, + SubaccountAmount: saAmount, UnlockPeriod: unlockPeriod, MainAccountAddr: maAddr, MainAccountAmount: maAmount, diff --git a/x/reward/types/reward_bet_bonus.go b/x/reward/types/reward_bet_bonus.go index 9156a9d1..9bfb849e 100644 --- a/x/reward/types/reward_bet_bonus.go +++ b/x/reward/types/reward_bet_bonus.go @@ -55,11 +55,11 @@ func (sur BetBonusReward) Calculate(goCtx context.Context, ctx sdk.Context, keep return RewardFactoryData{}, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidAddress, "%s", err) } - if keepers.SubAccountKeeper.IsSubAccount(ctx, addr) { - return RewardFactoryData{}, ErrReceiverAddrCanNotBeSubAcc + if keepers.SubaccountKeeper.IsSubaccount(ctx, addr) { + return RewardFactoryData{}, ErrReceiverAddrCanNotBeSubaccount } - subAccountAddressString, err := keepers.getSubAccAddr(ctx, creator, payload.Common.Receiver) + subAccountAddressString, err := keepers.getSubaccountAddr(ctx, creator, payload.Common.Receiver) if err != nil { return RewardFactoryData{}, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidAddress, "%s", err) } diff --git a/x/reward/types/reward_signup.go b/x/reward/types/reward_signup.go index e3091107..db590acc 100644 --- a/x/reward/types/reward_signup.go +++ b/x/reward/types/reward_signup.go @@ -48,11 +48,11 @@ func (sur SignUpReward) Calculate(goCtx context.Context, ctx sdk.Context, keeper return RewardFactoryData{}, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidAddress, "%s", err) } - if keepers.SubAccountKeeper.IsSubAccount(ctx, addr) { - return RewardFactoryData{}, ErrReceiverAddrCanNotBeSubAcc + if keepers.SubaccountKeeper.IsSubaccount(ctx, addr) { + return RewardFactoryData{}, ErrReceiverAddrCanNotBeSubaccount } - subAccountAddressString, err := keepers.getSubAccAddr(ctx, creator, payload.Common.Receiver) + subAccountAddressString, err := keepers.getSubaccountAddr(ctx, creator, payload.Common.Receiver) if err != nil { return RewardFactoryData{}, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidAddress, "%s", err) } diff --git a/x/reward/types/reward_signup_affiliatee.go b/x/reward/types/reward_signup_affiliatee.go index d210f5ff..f3772d86 100644 --- a/x/reward/types/reward_signup_affiliatee.go +++ b/x/reward/types/reward_signup_affiliatee.go @@ -52,11 +52,11 @@ func (sur SignUpAffiliateeReward) Calculate(goCtx context.Context, ctx sdk.Conte return RewardFactoryData{}, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidAddress, "source address is invalid %s", err) } - if keepers.SubAccountKeeper.IsSubAccount(ctx, receiverAddr) { - return RewardFactoryData{}, ErrReceiverAddrCanNotBeSubAcc + if keepers.SubaccountKeeper.IsSubaccount(ctx, receiverAddr) { + return RewardFactoryData{}, ErrReceiverAddrCanNotBeSubaccount } - subAccAddrStr, err := keepers.getSubAccAddr(ctx, creator, payload.Common.Receiver) + subAccAddrStr, err := keepers.getSubaccountAddr(ctx, creator, payload.Common.Receiver) if err != nil { return RewardFactoryData{}, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidAddress, "%s", err) } diff --git a/x/reward/types/reward_signup_affiliator.go b/x/reward/types/reward_signup_affiliator.go index 7f969f0b..54b72f01 100644 --- a/x/reward/types/reward_signup_affiliator.go +++ b/x/reward/types/reward_signup_affiliator.go @@ -60,11 +60,11 @@ func (sur SignUpAffiliatorReward) Calculate(goCtx context.Context, ctx sdk.Conte return RewardFactoryData{}, sdkerrors.Wrap(sdkerrtypes.ErrInvalidRequest, "affiliatee account has signed up yet, there is no affiliatee claim record") } - if keepers.SubAccountKeeper.IsSubAccount(ctx, receiverAddr) { - return RewardFactoryData{}, ErrReceiverAddrCanNotBeSubAcc + if keepers.SubaccountKeeper.IsSubaccount(ctx, receiverAddr) { + return RewardFactoryData{}, ErrReceiverAddrCanNotBeSubaccount } - subAccAddrStr, err := keepers.getSubAccAddr(ctx, creator, payload.Common.Receiver) + subAccAddrStr, err := keepers.getSubaccountAddr(ctx, creator, payload.Common.Receiver) if err != nil { return RewardFactoryData{}, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidAddress, "%s", err) } diff --git a/x/reward/types/reward_signup_referee.go b/x/reward/types/reward_signup_referee.go index f74b9b69..6c014f39 100644 --- a/x/reward/types/reward_signup_referee.go +++ b/x/reward/types/reward_signup_referee.go @@ -52,11 +52,11 @@ func (sur SignUpRefereelReward) Calculate(goCtx context.Context, ctx sdk.Context return RewardFactoryData{}, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidAddress, "source address is invalid %s", err) } - if keepers.SubAccountKeeper.IsSubAccount(ctx, receiverAddr) { - return RewardFactoryData{}, ErrReceiverAddrCanNotBeSubAcc + if keepers.SubaccountKeeper.IsSubaccount(ctx, receiverAddr) { + return RewardFactoryData{}, ErrReceiverAddrCanNotBeSubaccount } - subAccAddrStr, err := keepers.getSubAccAddr(ctx, creator, payload.Common.Receiver) + subAccAddrStr, err := keepers.getSubaccountAddr(ctx, creator, payload.Common.Receiver) if err != nil { return RewardFactoryData{}, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidAddress, "%s", err) } diff --git a/x/reward/types/reward_signup_referrer.go b/x/reward/types/reward_signup_referrer.go index 7a8c344a..fdce94e4 100644 --- a/x/reward/types/reward_signup_referrer.go +++ b/x/reward/types/reward_signup_referrer.go @@ -57,11 +57,11 @@ func (sur SignUpReferrerReward) Calculate(goCtx context.Context, ctx sdk.Context return RewardFactoryData{}, sdkerrors.Wrap(sdkerrtypes.ErrInvalidRequest, "referee account has signed up yet, there is no referee claim record") } - if keepers.SubAccountKeeper.IsSubAccount(ctx, receiverAddr) { - return RewardFactoryData{}, ErrReceiverAddrCanNotBeSubAcc + if keepers.SubaccountKeeper.IsSubaccount(ctx, receiverAddr) { + return RewardFactoryData{}, ErrReceiverAddrCanNotBeSubaccount } - subAccAddrStr, err := keepers.getSubAccAddr(ctx, creator, payload.Common.Receiver) + subAccAddrStr, err := keepers.getSubaccountAddr(ctx, creator, payload.Common.Receiver) if err != nil { return RewardFactoryData{}, sdkerrors.Wrapf(sdkerrtypes.ErrInvalidAddress, "%s", err) } diff --git a/x/reward/types/ticket.go b/x/reward/types/ticket.go index b8f9d2dd..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. @@ -104,18 +106,21 @@ func (payload *RewardPayloadCommon) Validate() error { } // Validate validates promoter config set ticket payload. -func (payload *SetPromoterConfPayload) Validate() error { - catMap := make(map[RewardCategory]struct{}) - for _, v := range payload.Conf.CategoryCap { - _, ok := catMap[v.Category] - if ok { - return sdkerrors.Wrapf(ErrDuplicateCategoryInConf, "%s", v.Category) - } - if v.CapPerAcc <= 0 { - return sdkerrors.Wrapf(ErrCategoryCapShouldBePos, "%s", v.Category) - } +func (payload *CreatePromoterPayload) Validate() error { + if !utils.IsValidUID(payload.UID) { + return types.ErrInvalidBetUID + } + if err := payload.Conf.Validate(); err != nil { + return err + } - catMap[v.Category] = struct{}{} + 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 178c3d0a..1cff863e 100644 --- a/x/reward/types/ticket.pb.go +++ b/x/reward/types/ticket.pb.go @@ -548,6 +548,60 @@ func (m *GrantBetBonusRewardPayload) GetBetUID() string { 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"` @@ -557,7 +611,7 @@ func (m *SetPromoterConfPayload) Reset() { *m = SetPromoterConfPayload{} func (m *SetPromoterConfPayload) String() string { return proto.CompactTextString(m) } func (*SetPromoterConfPayload) ProtoMessage() {} func (*SetPromoterConfPayload) Descriptor() ([]byte, []int) { - return fileDescriptor_5d710bc1249ca8ae, []int{8} + return fileDescriptor_5d710bc1249ca8ae, []int{9} } func (m *SetPromoterConfPayload) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -602,57 +656,60 @@ func init() { 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{ - // 698 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0x41, 0x6b, 0xdb, 0x4a, - 0x10, 0xf6, 0x26, 0x8e, 0x2d, 0x8f, 0xdf, 0x7b, 0x3c, 0xf6, 0xc5, 0xaf, 0x8a, 0x03, 0xb6, 0xab, - 0x52, 0xea, 0x16, 0x6a, 0x83, 0x7b, 0x2c, 0x2d, 0xd8, 0x0e, 0x6d, 0x4a, 0x2e, 0x41, 0x49, 0x08, - 0xf4, 0x62, 0x36, 0xd2, 0x58, 0x11, 0x8e, 0xb5, 0x62, 0x77, 0x9d, 0x54, 0x7f, 0xa0, 0xc7, 0xd2, - 0x5b, 0xff, 0x4f, 0x4f, 0x39, 0xe6, 0x58, 0x28, 0x98, 0xe2, 0xdc, 0xfa, 0x2b, 0x8a, 0x56, 0xb2, - 0x23, 0x97, 0x24, 0x04, 0x4a, 0x4e, 0x9a, 0xd9, 0xf9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 0xc8, 0xc5, 0xac, 0x46, 0x7e, - 0xcc, 0x6a, 0xe4, 0xf3, 0x65, 0x2d, 0x77, 0x71, 0x59, 0xcb, 0x7d, 0xbb, 0xac, 0xe5, 0xde, 0x3f, - 0xf5, 0x7c, 0x75, 0x3c, 0x39, 0x6a, 0x39, 0x7c, 0xdc, 0x96, 0x1e, 0x3e, 0x4f, 0x59, 0x63, 0xbb, - 0xfd, 0x61, 0xf1, 0x5f, 0x89, 0x42, 0x94, 0x47, 0x05, 0xfd, 0xc4, 0xbf, 0xf8, 0x15, 0x00, 0x00, - 0xff, 0xff, 0x36, 0x67, 0x85, 0x1c, 0x72, 0x06, 0x00, 0x00, + // 728 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xc1, 0x6a, 0xdb, 0x40, + 0x10, 0xf5, 0xc6, 0x8e, 0x2d, 0x8f, 0xdb, 0x50, 0xb6, 0x71, 0xab, 0x38, 0x60, 0xbb, 0x2a, 0xa5, + 0x6e, 0xa1, 0x36, 0xb8, 0xc7, 0xd2, 0x82, 0xe5, 0xd0, 0xa6, 0xe4, 0x12, 0x94, 0x84, 0x40, 0x2f, + 0x66, 0x23, 0xad, 0x15, 0xe1, 0x58, 0x2b, 0x76, 0xd7, 0x49, 0xf4, 0x03, 0x3d, 0x96, 0xde, 0xfa, + 0x3f, 0x3d, 0xe5, 0x98, 0x63, 0xa1, 0x60, 0x8a, 0x73, 0xeb, 0x57, 0x14, 0xad, 0x24, 0x47, 0x2e, + 0x49, 0x08, 0x2d, 0xb9, 0x48, 0x33, 0x3b, 0x33, 0xef, 0xbd, 0xd9, 0x19, 0x24, 0x78, 0x2c, 0x5c, + 0xda, 0xe1, 0xf4, 0x84, 0x70, 0xa7, 0x23, 0x3d, 0x7b, 0x44, 0x65, 0x3b, 0xe0, 0x4c, 0x32, 0x5c, + 0x15, 0x2e, 0xf5, 0xa9, 0x3c, 0x61, 0x7c, 0xd4, 0x16, 0x2e, 0x6d, 0xc7, 0x39, 0xb5, 0x55, 0x97, + 0xb9, 0x4c, 0x65, 0x74, 0x22, 0x2b, 0x4e, 0xae, 0xe1, 0x08, 0x45, 0x86, 0x01, 0xed, 0x8c, 0x42, + 0x3b, 0x39, 0xcb, 0x22, 0xc7, 0xaf, 0x24, 0xb0, 0x96, 0x09, 0x04, 0x9c, 0x8d, 0x99, 0xa4, 0x3c, + 0x0e, 0x19, 0x3f, 0xf3, 0x50, 0xed, 0x73, 0x4a, 0x24, 0xed, 0x93, 0x71, 0x40, 0x3c, 0xd7, 0xdf, + 0x26, 0xe1, 0x11, 0x23, 0x0e, 0xae, 0x81, 0x96, 0xe6, 0xea, 0xa8, 0x89, 0x5a, 0x65, 0x6b, 0xee, + 0xe3, 0x35, 0xd0, 0x84, 0x24, 0x5c, 0x0e, 0xa4, 0xd0, 0x97, 0x9a, 0xa8, 0x55, 0xb0, 0x4a, 0xca, + 0xdf, 0x15, 0xb8, 0x0a, 0x45, 0xea, 0x3b, 0x51, 0x20, 0xaf, 0x02, 0xcb, 0xd4, 0x77, 0x76, 0x05, + 0xee, 0x81, 0x66, 0x13, 0x49, 0x5d, 0xc6, 0x43, 0xbd, 0xd0, 0x44, 0xad, 0x95, 0xee, 0xb3, 0xf6, + 0x95, 0xfd, 0xb6, 0x2d, 0xf5, 0xea, 0x27, 0xc9, 0xd6, 0xbc, 0x0c, 0x9b, 0x50, 0x89, 0x53, 0x06, + 0x51, 0xdf, 0xfa, 0xb2, 0x42, 0x79, 0x72, 0x23, 0xca, 0x6e, 0x18, 0x50, 0x0b, 0xf8, 0xdc, 0xc6, + 0x7b, 0x80, 0x13, 0x0c, 0x32, 0x66, 0x13, 0x5f, 0xc6, 0x50, 0x45, 0x05, 0xf5, 0xfc, 0x46, 0xa8, + 0x9e, 0xca, 0x57, 0x80, 0x0f, 0xf8, 0x5f, 0x27, 0x78, 0x13, 0xee, 0x2f, 0xc0, 0xea,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 0x7c, 0xb9, 0xe3, 0xb9, 0xfe, 0x24, 0x58, 0x68, 0x07, 0x6f, 0x42, + 0xd1, 0x56, 0x2d, 0x29, 0xa1, 0x95, 0xee, 0xcb, 0x1b, 0x47, 0xbe, 0x70, 0x09, 0x66, 0xe1, 0x6c, + 0xda, 0xc8, 0x59, 0x49, 0xbd, 0xf1, 0x19, 0x41, 0x73, 0x81, 0x66, 0x48, 0x39, 0xa7, 0xfc, 0x3a, + 0x3a, 0xf4, 0x7f, 0x74, 0x58, 0x87, 0x12, 0x8f, 0x28, 0x68, 0x3c, 0xe8, 0xb2, 0x95, 0xba, 0xc6, + 0x17, 0x04, 0x46, 0x46, 0x48, 0x6f, 0x38, 0xf4, 0x8e, 0x3c, 0x22, 0xd9, 0x9d, 0x49, 0xa9, 0x03, + 0x90, 0x84, 0x64, 0xae, 0x26, 0x73, 0x62, 0x7c, 0x43, 0x50, 0x53, 0x82, 0x4c, 0x2a, 0x4d, 0xe6, + 0x4f, 0xc4, 0x5d, 0x09, 0xe9, 0x40, 0xe9, 0x80, 0xca, 0xcc, 0xda, 0x55, 0x67, 0xd3, 0x46, 0xd1, + 0xa4, 0x32, 0xde, 0xb9, 0x34, 0x68, 0xa5, 0x86, 0x71, 0x9a, 0x7e, 0x3c, 0xb7, 0x93, 0x85, 0x4f, + 0x35, 0x35, 0x21, 0x1f, 0xa1, 0xa8, 0xd5, 0x36, 0x57, 0x66, 0xd3, 0x46, 0x3e, 0x86, 0x88, 0x4e, + 0xad, 0xe8, 0x81, 0xdf, 0x42, 0xc1, 0x66, 0xfe, 0x30, 0x59, 0x9b, 0xeb, 0xbe, 0x14, 0x29, 0x6e, + 0x9f, 0xf9, 0xc3, 0x44, 0xac, 0x2a, 0x33, 0xf6, 0xe1, 0xd1, 0x0e, 0x95, 0xd9, 0x70, 0x4a, 0x9d, + 0x02, 0xa3, 0x7f, 0x02, 0x36, 0xfb, 0x67, 0xb3, 0x3a, 0x3a, 0x9f, 0xd5, 0xd1, 0xaf, 0x59, 0x1d, + 0x7d, 0xbd, 0xa8, 0xe7, 0xce, 0x2f, 0xea, 0xb9, 0x1f, 0x17, 0xf5, 0xdc, 0xa7, 0x17, 0xae, 0x27, + 0x0f, 0x27, 0x07, 0x6d, 0x9b, 0x8d, 0x3b, 0xc2, 0xa5, 0xaf, 0x12, 0xd4, 0xc8, 0xee, 0x9c, 0xce, + 0xff, 0x68, 0x61, 0x40, 0xc5, 0x41, 0x51, 0xfd, 0x5c, 0x5e, 0xff, 0x09, 0x00, 0x00, 0xff, 0xff, + 0x8b, 0x46, 0xd0, 0x88, 0xec, 0x06, 0x00, 0x00, } func (m *CreateCampaignPayload) Marshal() (dAtA []byte, err error) { @@ -1021,6 +1078,46 @@ func (m *GrantBetBonusRewardPayload) MarshalToSizedBuffer(dAtA []byte) (int, err 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) @@ -1216,6 +1313,21 @@ func (m *GrantBetBonusRewardPayload) Size() (n int) { 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 @@ -2298,6 +2410,121 @@ func (m *GrantBetBonusRewardPayload) Unmarshal(dAtA []byte) error { } 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 diff --git a/x/reward/types/tx.pb.go b/x/reward/types/tx.pb.go index 70c55422..43a552f9 100644 --- a/x/reward/types/tx.pb.go +++ b/x/reward/types/tx.pb.go @@ -29,6 +29,98 @@ 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. @@ -43,7 +135,7 @@ func (m *MsgSetPromoterConf) Reset() { *m = MsgSetPromoterConf{} } func (m *MsgSetPromoterConf) String() string { return proto.CompactTextString(m) } func (*MsgSetPromoterConf) ProtoMessage() {} func (*MsgSetPromoterConf) Descriptor() ([]byte, []int) { - return fileDescriptor_ad69e28332238e66, []int{0} + return fileDescriptor_ad69e28332238e66, []int{2} } func (m *MsgSetPromoterConf) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -101,7 +193,7 @@ func (m *MsgSetPromoterConfResponse) Reset() { *m = MsgSetPromoterConfRe func (m *MsgSetPromoterConfResponse) String() string { return proto.CompactTextString(m) } func (*MsgSetPromoterConfResponse) ProtoMessage() {} func (*MsgSetPromoterConfResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ad69e28332238e66, []int{1} + return fileDescriptor_ad69e28332238e66, []int{3} } func (m *MsgSetPromoterConfResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -146,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{2} + return fileDescriptor_ad69e28332238e66, []int{4} } func (m *MsgCreateCampaign) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -204,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{3} + return fileDescriptor_ad69e28332238e66, []int{5} } func (m *MsgCreateCampaignResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -250,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{4} + return fileDescriptor_ad69e28332238e66, []int{6} } func (m *MsgUpdateCampaign) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -308,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{5} + return fileDescriptor_ad69e28332238e66, []int{7} } func (m *MsgUpdateCampaignResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -353,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{6} + return fileDescriptor_ad69e28332238e66, []int{8} } func (m *MsgGrantReward) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -418,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{7} + return fileDescriptor_ad69e28332238e66, []int{9} } func (m *MsgGrantRewardResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -461,7 +553,7 @@ func (m *MsgWithdrawFunds) Reset() { *m = MsgWithdrawFunds{} } func (m *MsgWithdrawFunds) String() string { return proto.CompactTextString(m) } func (*MsgWithdrawFunds) ProtoMessage() {} func (*MsgWithdrawFunds) Descriptor() ([]byte, []int) { - return fileDescriptor_ad69e28332238e66, []int{8} + return fileDescriptor_ad69e28332238e66, []int{10} } func (m *MsgWithdrawFunds) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -519,7 +611,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{9} + return fileDescriptor_ad69e28332238e66, []int{11} } func (m *MsgWithdrawFundsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -549,6 +641,8 @@ 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") @@ -564,39 +658,41 @@ func init() { func init() { proto.RegisterFile("sge/reward/tx.proto", fileDescriptor_ad69e28332238e66) } var fileDescriptor_ad69e28332238e66 = []byte{ - // 505 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x41, 0x6e, 0xd3, 0x40, - 0x14, 0x8d, 0x49, 0x55, 0xc4, 0x0f, 0x94, 0x62, 0x68, 0x65, 0x0c, 0x72, 0xc0, 0x12, 0xa2, 0x5d, - 0xd4, 0x06, 0xba, 0x63, 0xd9, 0x48, 0x20, 0x16, 0x96, 0x50, 0xa0, 0x80, 0xd8, 0x54, 0x53, 0x7b, - 0x3a, 0xb1, 0x12, 0x7b, 0x46, 0x33, 0x63, 0xa5, 0xbd, 0x05, 0x67, 0x60, 0xcf, 0x3d, 0xba, 0xec, - 0x12, 0xb1, 0x88, 0x50, 0x72, 0x03, 0x4e, 0x80, 0x6c, 0xc7, 0x96, 0xc7, 0x69, 0x2a, 0x07, 0xba, - 0x9b, 0x3f, 0x7e, 0xff, 0xbd, 0xff, 0xe4, 0xf7, 0x07, 0xee, 0x0b, 0x82, 0x5d, 0x8e, 0xc7, 0x88, - 0x07, 0xae, 0x3c, 0x75, 0x18, 0xa7, 0x92, 0xea, 0x5b, 0x82, 0xe0, 0x18, 0xcb, 0x31, 0xe5, 0x43, - 0x47, 0x10, 0xec, 0xe4, 0xdf, 0xcd, 0x07, 0x84, 0x12, 0x9a, 0x21, 0xdc, 0xf4, 0x94, 0x83, 0xed, - 0x2f, 0xa0, 0x7b, 0x82, 0x7c, 0xc0, 0xf2, 0x3d, 0xa7, 0x11, 0x95, 0x98, 0xf7, 0x68, 0x7c, 0xa2, - 0x1b, 0x70, 0xd3, 0xe7, 0x18, 0x49, 0xca, 0x0d, 0xed, 0x89, 0xb6, 0x73, 0xab, 0x5f, 0x94, 0xfa, - 0x26, 0xb4, 0x93, 0x30, 0x30, 0x6e, 0x64, 0xb7, 0xe9, 0x51, 0xdf, 0x86, 0x75, 0x19, 0xfa, 0x43, - 0x2c, 0x8d, 0x76, 0x76, 0x39, 0xaf, 0xec, 0xc7, 0x60, 0x2e, 0x32, 0xf7, 0xb1, 0x60, 0x34, 0x16, - 0xd8, 0xfe, 0xa1, 0xc1, 0x3d, 0x4f, 0x90, 0x5e, 0x4a, 0x8b, 0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b6, 0x15, 0x3b, 0xcb, 0x49, 0x54, 0xa4, 0xf9, 0xa2, 0x29, 0xb2, 0xaa, 0x56, 0x8b, 0xed, - 0x15, 0x6a, 0x2a, 0xf2, 0x2a, 0xb5, 0xcb, 0xb3, 0xa5, 0x87, 0x70, 0x47, 0xfd, 0x8b, 0xcf, 0x97, - 0x53, 0x28, 0x40, 0xd3, 0x6d, 0x08, 0x2c, 0xa5, 0x7c, 0xe8, 0x54, 0x33, 0xfc, 0x6c, 0x79, 0x7f, - 0x05, 0x66, 0xee, 0x35, 0x82, 0x15, 0x22, 0x07, 0xbd, 0xf3, 0xa9, 0xa5, 0x5d, 0x4c, 0x2d, 0xed, - 0xf7, 0xd4, 0xd2, 0xbe, 0xcd, 0xac, 0xd6, 0xc5, 0xcc, 0x6a, 0xfd, 0x9c, 0x59, 0xad, 0xaf, 0xbb, - 0x24, 0x94, 0x83, 0xe4, 0xd8, 0xf1, 0x69, 0xe4, 0x0a, 0x82, 0xf7, 0xe6, 0x9c, 0xe9, 0xd9, 0x3d, - 0x2d, 0x9f, 0xec, 0x33, 0x86, 0xc5, 0xf1, 0x7a, 0xf6, 0x12, 0xef, 0xff, 0x0d, 0x00, 0x00, 0xff, - 0xff, 0x85, 0x43, 0xde, 0x62, 0xcd, 0x05, 0x00, 0x00, + // 531 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x95, 0xc1, 0x6e, 0xd3, 0x30, + 0x18, 0xc7, 0x1b, 0x06, 0x43, 0x7c, 0x85, 0x31, 0x02, 0x9b, 0x42, 0x40, 0x29, 0x44, 0x42, 0x6c, + 0x87, 0x25, 0xc0, 0x6e, 0x1c, 0x57, 0x01, 0xe2, 0x10, 0x09, 0x15, 0x06, 0x88, 0xcb, 0xe4, 0x25, + 0x9e, 0x1b, 0xb5, 0x89, 0x2d, 0xdb, 0x51, 0xb7, 0xb7, 0xd8, 0x8b, 0xf0, 0x1e, 0x3b, 0xee, 0x88, + 0x38, 0x54, 0xa8, 0x7d, 0x03, 0x9e, 0x00, 0x25, 0x69, 0xa2, 0x38, 0x5d, 0xbb, 0x0c, 0xb8, 0xd9, + 0xf1, 0xdf, 0xdf, 0xef, 0xfb, 0x47, 0xff, 0x4f, 0x86, 0xfb, 0x82, 0x60, 0x97, 0xe3, 0x11, 0xe2, + 0x81, 0x2b, 0x8f, 0x1d, 0xc6, 0xa9, 0xa4, 0xfa, 0x86, 0x20, 0x38, 0xc6, 0x72, 0x44, 0xf9, 0xc0, + 0x11, 0x04, 0x3b, 0xf9, 0xb9, 0xf9, 0x80, 0x50, 0x42, 0x33, 0x85, 0x9b, 0xae, 0x72, 0xb1, 0xfd, + 0x06, 0xee, 0x79, 0x82, 0x74, 0x39, 0x46, 0x12, 0x7f, 0xe0, 0x34, 0xa2, 0x12, 0x73, 0xdd, 0x80, + 0x9b, 0x7e, 0xfa, 0x85, 0x72, 0x43, 0x7b, 0xa2, 0x6d, 0xdd, 0xea, 0x15, 0x5b, 0x7d, 0x13, 0x56, + 0x65, 0xe8, 0x0f, 0xb0, 0x34, 0xae, 0x65, 0x07, 0xb3, 0x9d, 0xfd, 0x08, 0x1e, 0xce, 0x95, 0xe9, + 0x61, 0xc1, 0x68, 0x2c, 0xb0, 0xfd, 0x15, 0x74, 0x4f, 0x90, 0x8f, 0x58, 0x16, 0x27, 0x5d, 0x1a, + 0x1f, 0x2d, 0x81, 0xac, 0xc3, 0x4a, 0x12, 0x06, 0x33, 0x42, 0xba, 0xac, 0x60, 0x57, 0x14, 0xec, + 0x63, 0x30, 0xe7, 0x2b, 0x97, 0xdc, 0xef, 0x5a, 0xc5, 0x5c, 0x17, 0x45, 0x0c, 0x85, 0x24, 0xbe, + 0x12, 0xf7, 0x13, 0xb4, 0x25, 0x95, 0x68, 0x78, 0x70, 0x94, 0xc4, 0x81, 0xc8, 0xe1, 0x7b, 0xbb, + 0x67, 0xe3, 0x4e, 0xeb, 0xe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x96, 0xd0, 0x54, 0xe5, 0x32, 0xda, + 0xc5, 0x49, 0xd6, 0x43, 0xb8, 0xa3, 0x66, 0xe6, 0xf9, 0xe2, 0x12, 0x8a, 0xd0, 0x74, 0x1b, 0x0a, + 0x4b, 0x94, 0x0f, 0xed, 0xea, 0xc4, 0x3c, 0x5b, 0x7c, 0xbf, 0x22, 0x33, 0x77, 0x1a, 0xc9, 0x0a, + 0xc8, 0x5e, 0xf7, 0x6c, 0x62, 0x69, 0xe7, 0x13, 0x4b, 0xfb, 0x35, 0xb1, 0xb4, 0xd3, 0xa9, 0xd5, + 0x3a, 0x9f, 0x5a, 0xad, 0x1f, 0x53, 0xab, 0xf5, 0x6d, 0x9b, 0x84, 0xb2, 0x9f, 0x1c, 0x3a, 0x3e, + 0x8d, 0x5c, 0x41, 0xf0, 0xce, 0xac, 0x66, 0xba, 0x76, 0x8f, 0xcb, 0x47, 0xe8, 0x84, 0x61, 0x71, + 0xb8, 0x9a, 0xbd, 0x2d, 0xbb, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xb1, 0xba, 0x9b, 0xc3, 0x9f, + 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -613,6 +709,8 @@ const _ = grpc.SupportPackageIsVersion4 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 @@ -640,6 +738,15 @@ func (c *msgClient) SetPromoterConf(ctx context.Context, in *MsgSetPromoterConf, 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...) @@ -680,6 +787,8 @@ func (c *msgClient) GrantReward(ctx context.Context, in *MsgGrantReward, opts .. 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 @@ -697,6 +806,9 @@ 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") } @@ -732,6 +844,24 @@ func _Msg_SetPromoterConf_Handler(srv interface{}, ctx context.Context, dec func 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 { @@ -812,6 +942,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "SetPromoterConf", Handler: _Msg_SetPromoterConf_Handler, }, + { + MethodName: "CreatePromoter", + Handler: _Msg_CreatePromoter_Handler, + }, { MethodName: "CreateCampaign", Handler: _Msg_CreateCampaign_Handler, @@ -833,6 +967,66 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Metadata: "sge/reward/tx.proto", } +func (m *MsgCreatePromoter) 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 *MsgCreatePromoter) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreatePromoter) 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] = 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 *MsgCreatePromoterResponse) 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 *MsgCreatePromoterResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreatePromoterResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func (m *MsgSetPromoterConf) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1206,6 +1400,32 @@ 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 @@ -1370,6 +1590,170 @@ func sovTx(x uint64) (n int) { 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 + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *MsgSetPromoterConf) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/subaccount/genesis.go b/x/subaccount/genesis.go index fc8124c3..067c5db8 100644 --- a/x/subaccount/genesis.go +++ b/x/subaccount/genesis.go @@ -17,7 +17,7 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) for _, acc := range genState.Subaccounts { owner := sdk.MustAccAddressFromBech32(acc.Owner) addr := sdk.MustAccAddressFromBech32(acc.Address) - k.SetSubAccountOwner(ctx, addr, owner) + k.SetSubaccountOwner(ctx, addr, owner) k.SetLockedBalances(ctx, addr, acc.LockedBalances) k.SetAccountSummary(ctx, addr, acc.Balance) } diff --git a/x/subaccount/keeper/balance.go b/x/subaccount/keeper/balance.go index 3852153e..2d4c738a 100644 --- a/x/subaccount/keeper/balance.go +++ b/x/subaccount/keeper/balance.go @@ -28,12 +28,21 @@ func (k Keeper) SetLockedBalances(ctx sdk.Context, subAccountAddress sdk.AccAddr } } -// GetLockedBalances returns the locked balances of an account. -func (k Keeper) GetLockedBalances(ctx sdk.Context, subAccountAddress sdk.AccAddress) []types.LockedBalance { - iterator := prefix.NewStore(ctx.KVStore(k.storeKey), types.LockedBalancePrefixKey(subAccountAddress)).Iterator(nil, nil) +// etBalances returns the locked balances of an account. +func (k Keeper) GetBalances(ctx sdk.Context, subAccountAddress sdk.AccAddress, balanceType types.LockedBalanceStatus) ([]types.LockedBalance, sdkmath.Int) { + var start, end []byte + switch balanceType { + case types.LockedBalanceStatus_LOCKED_BALANCE_STATUS_LOCKED: + start = utils.Int64ToBytes(ctx.BlockTime().Unix()) + case types.LockedBalanceStatus_LOCKED_BALANCE_STATUS_UNLOCKED: + end = utils.Int64ToBytes(ctx.BlockTime().Unix()) + } + + iterator := prefix.NewStore(ctx.KVStore(k.storeKey), types.LockedBalancePrefixKey(subAccountAddress)).Iterator(start, end) defer iterator.Close() var lockedBalances []types.LockedBalance + totalAmount := sdkmath.ZeroInt() for ; iterator.Valid(); iterator.Next() { unlockTime := utils.Uint64FromBytes(iterator.Key()) @@ -46,29 +55,16 @@ func (k Keeper) GetLockedBalances(ctx sdk.Context, subAccountAddress sdk.AccAddr UnlockTS: unlockTime, Amount: *amount, }) + totalAmount = totalAmount.Add(*amount) } - return lockedBalances + return lockedBalances, totalAmount } -// GetUnlockedBalance returns the unlocked balance of an account. -func (k Keeper) GetUnlockedBalance(ctx sdk.Context, subAccountAddress sdk.AccAddress) sdkmath.Int { - iterator := prefix.NewStore(ctx.KVStore(k.storeKey), types.LockedBalancePrefixKey(subAccountAddress)). - Iterator(nil, utils.Int64ToBytes(ctx.BlockTime().Unix())) - - unlockedBalance := sdk.ZeroInt() - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - amount := new(sdkmath.Int) - err := amount.Unmarshal(iterator.Value()) - if err != nil { - panic(err) - } - unlockedBalance = unlockedBalance.Add(*amount) - } - - return unlockedBalance +// HasLockedBalances returns true if there is an existing locked balance for the sub account address. +func (k Keeper) HasLockedBalances(ctx sdk.Context, subAccAddr sdk.AccAddress, time uint64) bool { + store := ctx.KVStore(k.storeKey) + return store.Has(types.LockedBalanceKey(subAccAddr, time)) } // SetAccountSummary saves the balance of an account. @@ -87,17 +83,17 @@ func (k Keeper) GetAccountSummary(ctx sdk.Context, subAccountAddress sdk.AccAddr return types.AccountSummary{}, false } - balance := types.AccountSummary{} - k.cdc.MustUnmarshal(bz, &balance) + accSummary := types.AccountSummary{} + k.cdc.MustUnmarshal(bz, &accSummary) - return balance, true + return accSummary, true } // TopUp tops up the subaccount balance. func (k Keeper) TopUp(ctx sdk.Context, creator, subAccOwnerAddr string, - lockedBalance []types.LockedBalance, + topUpBalances []types.LockedBalance, ) (string, error) { - addedBalance, err := sumlockedBalance(ctx, lockedBalance) + addedBalance, err := sumLockedBalance(ctx, topUpBalances) if err != nil { return "", err } @@ -105,18 +101,24 @@ func (k Keeper) TopUp(ctx sdk.Context, creator, subAccOwnerAddr string, creatorAddr := sdk.MustAccAddressFromBech32(creator) subaccountOwner := sdk.MustAccAddressFromBech32(subAccOwnerAddr) - subAccAddr, exists := k.GetSubAccountByOwner(ctx, subaccountOwner) + subAccAddr, exists := k.GetSubaccountByOwner(ctx, subaccountOwner) if !exists { return "", types.ErrSubaccountDoesNotExist } - balance, exists := k.GetAccountSummary(ctx, subAccAddr) + accSummary, exists := k.GetAccountSummary(ctx, subAccAddr) if !exists { panic("data corruption: subaccount exists but balance does not") } - balance.DepositedAmount = balance.DepositedAmount.Add(addedBalance) - k.SetAccountSummary(ctx, subAccAddr, balance) - k.SetLockedBalances(ctx, subAccAddr, lockedBalance) + for _, v := range topUpBalances { + if k.HasLockedBalances(ctx, subAccAddr, v.UnlockTS) { + return "", sdkerrors.Wrapf(types.ErrLockedBalanceExists, "%d", v.UnlockTS) + } + } + + accSummary.DepositedAmount = accSummary.DepositedAmount.Add(addedBalance) + k.SetAccountSummary(ctx, subAccAddr, accSummary) + k.SetLockedBalances(ctx, subAccAddr, topUpBalances) err = k.sendCoinsToSubaccount(ctx, creatorAddr, subAccAddr, addedBalance) if err != nil { @@ -125,34 +127,34 @@ func (k Keeper) TopUp(ctx sdk.Context, creator, subAccOwnerAddr string, return subAccAddr.String(), nil } -// getAccountSummary returns the balance, unlocked balance and bank balance of a subaccount -func (k Keeper) getAccountSummary(sdkContext sdk.Context, subaccountAddr sdk.AccAddress) (types.AccountSummary, sdkmath.Int, sdk.Coin) { - balance, exists := k.GetAccountSummary(sdkContext, subaccountAddr) +// getSubaccountSummary returns the balance, unlocked balance and bank balance of a subaccount +func (k Keeper) getSubaccountSummary(sdkContext sdk.Context, subaccountAddr sdk.AccAddress) (types.AccountSummary, sdkmath.Int, sdk.Coin) { + accSummary, exists := k.GetAccountSummary(sdkContext, subaccountAddr) if !exists { panic("data corruption: subaccount exists but balance does not") } - unlockedBalance := k.GetUnlockedBalance(sdkContext, subaccountAddr) + _, unlockedAmount := k.GetBalances(sdkContext, subaccountAddr, types.LockedBalanceStatus_LOCKED_BALANCE_STATUS_UNLOCKED) bankBalance := k.bankKeeper.GetBalance(sdkContext, subaccountAddr, params.DefaultBondDenom) - return balance, unlockedBalance, bankBalance + return accSummary, unlockedAmount, bankBalance } // withdrawUnlocked returns the balance, unlocked balance and bank balance of a subaccount func (k Keeper) withdrawUnlocked(ctx sdk.Context, subAccAddr sdk.AccAddress, ownerAddr sdk.AccAddress) error { - accSummary, unlockedBalance, bankBalance := k.getAccountSummary(ctx, subAccAddr) + accSummary, unlockedAmount, bankBalance := k.getSubaccountSummary(ctx, subAccAddr) - withdrawableBalance := accSummary.WithdrawableBalance(unlockedBalance, bankBalance.Amount) - if withdrawableBalance.IsZero() { + withdrawableUnlockedBalance := accSummary.WithdrawableUnlockedBalance(unlockedAmount, bankBalance.Amount) + if withdrawableUnlockedBalance.IsZero() { return types.ErrNothingToWithdraw } - if err := accSummary.Withdraw(withdrawableBalance); err != nil { + if err := accSummary.Withdraw(withdrawableUnlockedBalance); err != nil { return err } k.SetAccountSummary(ctx, subAccAddr, accSummary) - err := k.bankKeeper.SendCoins(ctx, subAccAddr, ownerAddr, sdk.NewCoins(sdk.NewCoin(params.DefaultBondDenom, withdrawableBalance))) + err := k.bankKeeper.SendCoins(ctx, subAccAddr, ownerAddr, sdk.NewCoins(sdk.NewCoin(params.DefaultBondDenom, withdrawableUnlockedBalance))) if err != nil { return err } @@ -164,41 +166,17 @@ func (k Keeper) withdrawUnlocked(ctx sdk.Context, subAccAddr sdk.AccAddress, own // modifies the locked balances accordingly func (k Keeper) withdrawLockedAndUnlocked(ctx sdk.Context, subAccAddr sdk.AccAddress, ownerAddr sdk.AccAddress, subAmountDeduct sdkmath.Int, ) error { - accSummary, unlockedBalance, bankBalance := k.getAccountSummary(ctx, subAccAddr) - withdrawableBalance := accSummary.WithdrawableBalance(unlockedBalance, bankBalance.Amount) + accSummary, _, bankBalance := k.getSubaccountSummary(ctx, subAccAddr) + withdrawableBalance := accSummary.WithdrawableBalance(bankBalance.Amount) // take the minimum of the withdrawable balance and the amount that need to be transferred from sub account withdrawableToSend := sdkmath.MinInt(withdrawableBalance, subAmountDeduct) - // calculate the amount that need to be deducted from locked balances - lockedAmountToWithdraw := subAmountDeduct.Sub(withdrawableToSend) - - if lockedAmountToWithdraw.GT(sdkmath.ZeroInt()) { - // calculate locked balances - lockedBalances := k.GetLockedBalances(ctx, subAccAddr) - updatedLockedBalances := []types.LockedBalance{} - for _, lb := range lockedBalances { - if lb.Amount.GTE(lockedAmountToWithdraw) { - lb.Amount = lb.Amount.Sub(lockedAmountToWithdraw) - updatedLockedBalances = append(updatedLockedBalances, lb) - - lockedAmountToWithdraw = sdkmath.ZeroInt() - break - } - - lb.Amount = sdkmath.ZeroInt() - updatedLockedBalances = append(updatedLockedBalances, lb) - - lockedAmountToWithdraw = lockedAmountToWithdraw.Sub(lb.Amount) - } - - if lockedAmountToWithdraw.GT(sdkmath.ZeroInt()) { - return sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, - "not enough balance in sub account locked balances, need more %s tokens", - lockedAmountToWithdraw) - } - - k.SetLockedBalances(ctx, subAccAddr, updatedLockedBalances) + // check total withdrawable balance to be enough for withdrawal. + if subAmountDeduct.GT(withdrawableToSend) { + return sdkerrors.Wrapf(sdkerrtypes.ErrInvalidRequest, + "not enough balance in sub account locked balances, need more %s tokens", + subAmountDeduct.Sub(withdrawableToSend)) } // send the total calculated amount to the owner diff --git a/x/subaccount/keeper/balance_test.go b/x/subaccount/keeper/balance_test.go new file mode 100644 index 00000000..949c60a4 --- /dev/null +++ b/x/subaccount/keeper/balance_test.go @@ -0,0 +1,49 @@ +package keeper_test + +import ( + "testing" + "time" + + sdkmath "cosmossdk.io/math" + "github.com/sge-network/sge/testutil/sample" + "github.com/sge-network/sge/x/subaccount/types" + "github.com/spf13/cast" + "github.com/stretchr/testify/require" +) + +func TestUnlockedBalanceQuery(t *testing.T) { + _, k, ctx := setupKeeperAndApp(t) + + subAccAddr := sample.NativeAccAddress() + blockTime := time.Now() + ctx = ctx.WithBlockTime(blockTime) + k.SetLockedBalances(ctx, subAccAddr, []types.LockedBalance{ + { + UnlockTS: cast.ToUint64(blockTime.Unix()), + Amount: sdkmath.NewInt(100), + }, + { + UnlockTS: cast.ToUint64(blockTime.Add(1 * time.Second).Unix()), + Amount: sdkmath.NewInt(200), + }, + { + UnlockTS: cast.ToUint64(blockTime.Add(-1 * time.Second).Unix()), + Amount: sdkmath.NewInt(1000), + }, + }) + + locked, _ := k.GetBalances(ctx, subAccAddr, types.LockedBalanceStatus_LOCKED_BALANCE_STATUS_LOCKED) + require.Equal(t, []types.LockedBalance{ + { + UnlockTS: cast.ToUint64(blockTime.Unix()), + Amount: sdkmath.NewInt(100), + }, + { + UnlockTS: cast.ToUint64(blockTime.Add(1 * time.Second).Unix()), + Amount: sdkmath.NewInt(200), + }, + }, locked) + + _, unlockedAmount := k.GetBalances(ctx, subAccAddr, types.LockedBalanceStatus_LOCKED_BALANCE_STATUS_UNLOCKED) + require.Equal(t, int64(1000), unlockedAmount.Int64()) +} diff --git a/x/subaccount/keeper/hooks.go b/x/subaccount/keeper/hooks.go index 7c7d3998..01f83e8a 100644 --- a/x/subaccount/keeper/hooks.go +++ b/x/subaccount/keeper/hooks.go @@ -34,7 +34,7 @@ func (h Hooks) AfterHouseWin(ctx sdk.Context, house sdk.AccAddress, originalAmou h.k.SetAccountSummary(ctx, house, balance) // send profits - subAccountOwner, exists := h.k.GetSubAccountOwner(ctx, house) + subAccountOwner, exists := h.k.GetSubaccountOwner(ctx, house) if !exists { panic("data corruption: subaccount owner not found") } diff --git a/x/subaccount/keeper/msg_server_balance.go b/x/subaccount/keeper/msg_server_balance.go index 7655c4c8..e7680849 100644 --- a/x/subaccount/keeper/msg_server_balance.go +++ b/x/subaccount/keeper/msg_server_balance.go @@ -27,7 +27,7 @@ func (k msgServer) WithdrawUnlockedBalances(goCtx context.Context, msg *types.Ms ctx := sdk.UnwrapSDKContext(goCtx) ownerAddr := sdk.MustAccAddressFromBech32(msg.Creator) - subAccAddr, exists := k.keeper.GetSubAccountByOwner(ctx, ownerAddr) + subAccAddr, exists := k.keeper.GetSubaccountByOwner(ctx, ownerAddr) if !exists { return nil, types.ErrSubaccountDoesNotExist } diff --git a/x/subaccount/keeper/msg_server_balance_test.go b/x/subaccount/keeper/msg_server_balance_test.go index efaa4b12..a18b07a3 100644 --- a/x/subaccount/keeper/msg_server_balance_test.go +++ b/x/subaccount/keeper/msg_server_balance_test.go @@ -184,7 +184,7 @@ func TestMsgServerTopUp_HappyPath(t *testing.T) { balance, exists := k.GetAccountSummary(ctx, subAccountAddr) require.True(t, exists) require.Equal(t, sdkmath.NewInt(0), balance.DepositedAmount) - balances := k.GetLockedBalances(ctx, subAccountAddr) + balances, _ := k.GetBalances(ctx, subAccountAddr, types.LockedBalanceStatus_LOCKED_BALANCE_STATUS_LOCKED) require.Len(t, balances, 0) msgTopUp := &types.MsgTopUp{ @@ -204,7 +204,7 @@ func TestMsgServerTopUp_HappyPath(t *testing.T) { balance, exists = k.GetAccountSummary(ctx, subAccountAddr) require.True(t, exists) require.Equal(t, sdkmath.NewInt(123), balance.DepositedAmount) - balances = k.GetLockedBalances(ctx, subAccountAddr) + balances, _ = k.GetBalances(ctx, subAccountAddr, types.LockedBalanceStatus_LOCKED_BALANCE_STATUS_LOCKED) require.Len(t, balances, 1) require.True(t, afterTime == balances[0].UnlockTS) require.Equal(t, sdkmath.NewInt(123), balances[0].Amount) diff --git a/x/subaccount/keeper/msg_server_bet.go b/x/subaccount/keeper/msg_server_bet.go index 092009c5..55ca2913 100644 --- a/x/subaccount/keeper/msg_server_bet.go +++ b/x/subaccount/keeper/msg_server_bet.go @@ -24,7 +24,7 @@ func (k msgServer) Wager(goCtx context.Context, msg *types.MsgWager) (*types.Msg subAccOwner := sdk.MustAccAddressFromBech32(msg.Creator) // find subaccount - subAccAddr, exists := k.keeper.GetSubAccountByOwner(ctx, subAccOwner) + subAccAddr, exists := k.keeper.GetSubaccountByOwner(ctx, subAccOwner) if !exists { return nil, status.Error(codes.NotFound, "subaccount not found") } diff --git a/x/subaccount/keeper/msg_server_house.go b/x/subaccount/keeper/msg_server_house.go index 015ded0c..27a09c72 100644 --- a/x/subaccount/keeper/msg_server_house.go +++ b/x/subaccount/keeper/msg_server_house.go @@ -19,7 +19,7 @@ func (k msgServer) HouseDeposit(goCtx context.Context, msg *types.MsgHouseDeposi } // check if subaccount exists - subAccAddr, exists := k.keeper.GetSubAccountByOwner(ctx, sdk.MustAccAddressFromBech32(msg.Msg.Creator)) + subAccAddr, exists := k.keeper.GetSubaccountByOwner(ctx, sdk.MustAccAddressFromBech32(msg.Msg.Creator)) if !exists { return nil, types.ErrSubaccountDoesNotExist } @@ -70,7 +70,7 @@ func (k msgServer) HouseWithdraw(goCtx context.Context, msg *types.MsgHouseWithd ctx := sdk.UnwrapSDKContext(goCtx) // check if subaccount exists - subAccAddr, exists := k.keeper.GetSubAccountByOwner(ctx, sdk.MustAccAddressFromBech32(msg.Msg.Creator)) + subAccAddr, exists := k.keeper.GetSubaccountByOwner(ctx, sdk.MustAccAddressFromBech32(msg.Msg.Creator)) if !exists { return nil, types.ErrSubaccountDoesNotExist } diff --git a/x/subaccount/keeper/msg_server_subaccount.go b/x/subaccount/keeper/msg_server_subaccount.go index 7dbff36c..202f7829 100644 --- a/x/subaccount/keeper/msg_server_subaccount.go +++ b/x/subaccount/keeper/msg_server_subaccount.go @@ -20,7 +20,7 @@ func (k msgServer) Create( return nil, sdkerrors.Wrap(err, "invalid request") } - subAccAddr, err := k.keeper.CreateSubAccount(ctx, msg.Creator, msg.Owner, msg.LockedBalances) + subAccAddr, err := k.keeper.CreateSubaccount(ctx, msg.Creator, msg.Owner, msg.LockedBalances) if err != nil { return nil, err } diff --git a/x/subaccount/keeper/msg_server_subaccount_test.go b/x/subaccount/keeper/msg_server_subaccount_test.go index 67f37fc0..244d24ad 100644 --- a/x/subaccount/keeper/msg_server_subaccount_test.go +++ b/x/subaccount/keeper/msg_server_subaccount_test.go @@ -51,12 +51,12 @@ func TestMsgServer_Create(t *testing.T) { require.Equal(t, sdkmath.NewInt(123), balance.Amount) // Check that we can get the account by owner - owner, exists := app.SubaccountKeeper.GetSubAccountOwner(ctx, types.NewAddressFromSubaccount(1)) + owner, exists := app.SubaccountKeeper.GetSubaccountOwner(ctx, types.NewAddressFromSubaccount(1)) require.True(t, exists) require.Equal(t, account, owner) // check that balance unlocks are set correctly - lockedBalances := app.SubaccountKeeper.GetLockedBalances(ctx, types.NewAddressFromSubaccount(1)) + lockedBalances, _ := app.SubaccountKeeper.GetBalances(ctx, types.NewAddressFromSubaccount(1), types.LockedBalanceStatus_LOCKED_BALANCE_STATUS_LOCKED) require.Len(t, lockedBalances, 1) require.True(t, someTime == lockedBalances[0].UnlockTS) require.Equal(t, sdkmath.NewInt(123), lockedBalances[0].Amount) @@ -70,7 +70,7 @@ func TestMsgServer_Create(t *testing.T) { require.Equal(t, sdkmath.NewInt(123), subaccountBalance.DepositedAmount) } -func TestMsgServer_CreateSubAccount_Errors(t *testing.T) { +func TestMsgServer_CreateSubaccount_Errors(t *testing.T) { beforeTime := uint64(time.Now().Add(-10 * time.Minute).Unix()) afterTime := uint64(time.Now().Add(10 * time.Minute).Unix()) account := sample.NativeAccAddress() @@ -110,7 +110,7 @@ func TestMsgServer_CreateSubAccount_Errors(t *testing.T) { }, }, prepare: func(ctx sdk.Context, k *keeper.Keeper) { - k.SetSubAccountOwner(ctx, types.NewAddressFromSubaccount(1), account) + k.SetSubaccountOwner(ctx, types.NewAddressFromSubaccount(1), account) }, expectedErr: types.ErrSubaccountAlreadyExist.Error(), }, diff --git a/x/subaccount/keeper/query_server.go b/x/subaccount/keeper/query_server.go index 2384be1a..4138545f 100644 --- a/x/subaccount/keeper/query_server.go +++ b/x/subaccount/keeper/query_server.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/sge-network/sge/app/params" "github.com/sge-network/sge/x/subaccount/types" ) @@ -23,21 +24,27 @@ func (q queryServer) Subaccount(goCtx context.Context, request *types.QuerySubac } ctx := sdk.UnwrapSDKContext(goCtx) - subaccountAddr, exists := q.keeper.GetSubAccountByOwner(ctx, addr) + subaccountAddr, exists := q.keeper.GetSubaccountByOwner(ctx, addr) if !exists { return nil, types.ErrSubaccountDoesNotExist } - balance, exists := q.keeper.GetAccountSummary(ctx, subaccountAddr) + accSummary, exists := q.keeper.GetAccountSummary(ctx, subaccountAddr) if !exists { panic("subaccount exists but balance not found") } - balanceLocks := q.keeper.GetLockedBalances(ctx, subaccountAddr) + lockedBalances, _ := q.keeper.GetBalances(ctx, subaccountAddr, types.LockedBalanceStatus_LOCKED_BALANCE_STATUS_LOCKED) + unlockedBalances, unlockedAmount := q.keeper.GetBalances(ctx, subaccountAddr, types.LockedBalanceStatus_LOCKED_BALANCE_STATUS_UNLOCKED) + + bankBalance := q.keeper.bankKeeper.GetBalance(ctx, subaccountAddr, params.DefaultBondDenom) + return &types.QuerySubaccountResponse{ - Address: subaccountAddr.String(), - Balance: balance, - LockedBalance: balanceLocks, + Address: subaccountAddr.String(), + Balance: accSummary, + LockedBalance: lockedBalances, + UnlockedBalance: unlockedBalances, + WithdrawableUnlockedBalance: accSummary.WithdrawableUnlockedBalance(unlockedAmount, bankBalance.Amount), }, nil } diff --git a/x/subaccount/keeper/subaccount.go b/x/subaccount/keeper/subaccount.go index 3aa823d0..a863261c 100644 --- a/x/subaccount/keeper/subaccount.go +++ b/x/subaccount/keeper/subaccount.go @@ -34,41 +34,41 @@ func (k Keeper) SetID(ctx sdk.Context, id uint64) { ctx.KVStore(k.storeKey).Set(types.SubaccountIDPrefix, sdk.Uint64ToBigEndian(id)) } -// SetSubAccountOwner sets the owner of a subaccount. -func (k Keeper) SetSubAccountOwner(ctx sdk.Context, subAccountAddress, ownerAddress sdk.AccAddress) { +// SetSubaccountOwner sets the owner of a subaccount. +func (k Keeper) SetSubaccountOwner(ctx sdk.Context, subAccountAddress, ownerAddress sdk.AccAddress) { store := ctx.KVStore(k.storeKey) - store.Set(types.SubAccountOwnerKey(ownerAddress), subAccountAddress) + store.Set(types.SubaccountOwnerKey(ownerAddress), subAccountAddress) // and reverse mapping - store.Set(types.SubAccountKey(subAccountAddress), ownerAddress) + store.Set(types.SubaccountKey(subAccountAddress), ownerAddress) } -// GetSubAccountByOwner returns the subaccount ID of an owner. -func (k Keeper) GetSubAccountByOwner(ctx sdk.Context, address sdk.AccAddress) (sdk.AccAddress, bool) { +// GetSubaccountByOwner returns the subaccount ID of an owner. +func (k Keeper) GetSubaccountByOwner(ctx sdk.Context, address sdk.AccAddress) (sdk.AccAddress, bool) { store := ctx.KVStore(k.storeKey) - addr := store.Get(types.SubAccountOwnerKey(address)) + addr := store.Get(types.SubaccountOwnerKey(address)) return addr, addr != nil } -// GetSubAccountOwner returns the owner of a subaccount given the subaccount address. -func (k Keeper) GetSubAccountOwner(ctx sdk.Context, subAccAddr sdk.AccAddress) (sdk.AccAddress, bool) { +// GetSubaccountOwner returns the owner of a subaccount given the subaccount address. +func (k Keeper) GetSubaccountOwner(ctx sdk.Context, subAccAddr sdk.AccAddress) (sdk.AccAddress, bool) { store := ctx.KVStore(k.storeKey) - addr := store.Get(types.SubAccountKey(subAccAddr)) + addr := store.Get(types.SubaccountKey(subAccAddr)) return addr, addr != nil } -// IsSubAccount returns true if the address blongs to a sub account. -func (k Keeper) IsSubAccount(ctx sdk.Context, subAccAddr sdk.AccAddress) bool { +// IsSubaccount returns true if the address blongs to a sub account. +func (k Keeper) IsSubaccount(ctx sdk.Context, subAccAddr sdk.AccAddress) bool { store := ctx.KVStore(k.storeKey) - return store.Has(types.SubAccountKey(subAccAddr)) + return store.Has(types.SubaccountKey(subAccAddr)) } func (k Keeper) IterateSubaccounts(ctx sdk.Context, cb func(subAccountAddress, subaccountOwner sdk.AccAddress) (stop bool)) { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, types.SubAccountOwnerReversePrefix) + iterator := sdk.KVStorePrefixIterator(store, types.SubaccountOwnerReversePrefix) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - if cb(iterator.Key()[len(types.SubAccountOwnerReversePrefix):], iterator.Value()) { + if cb(iterator.Key()[len(types.SubaccountOwnerReversePrefix):], iterator.Value()) { break } } @@ -81,7 +81,7 @@ func (k Keeper) GetAllSubaccounts(ctx sdk.Context) []types.GenesisSubaccount { if !exists { panic("subaccount balance does not exist") } - lockedBalances := k.GetLockedBalances(ctx, subAccountAddress) + lockedBalances, _ := k.GetBalances(ctx, subAccountAddress, types.LockedBalanceStatus_LOCKED_BALANCE_STATUS_UNSPECIFIED) subaccounts = append(subaccounts, types.GenesisSubaccount{ Address: subAccountAddress.String(), Owner: ownerAddress.String(), @@ -93,17 +93,17 @@ func (k Keeper) GetAllSubaccounts(ctx sdk.Context) []types.GenesisSubaccount { return subaccounts } -func (k Keeper) CreateSubAccount(ctx sdk.Context, creator, owner string, +func (k Keeper) CreateSubaccount(ctx sdk.Context, creator, owner string, lockedBalances []types.LockedBalance, ) (string, error) { - lockedBalance, err := sumlockedBalance(ctx, lockedBalances) + lockedBalance, err := sumLockedBalance(ctx, lockedBalances) if err != nil { return "", err } creatorAddr := sdk.MustAccAddressFromBech32(creator) - subAccOwnerAddr := sdk.MustAccAddressFromBech32(owner) - if _, exists := k.GetSubAccountByOwner(ctx, subAccOwnerAddr); exists { + subaccountOwnerAddr := sdk.MustAccAddressFromBech32(owner) + if _, exists := k.GetSubaccountByOwner(ctx, subaccountOwnerAddr); exists { return "", types.ErrSubaccountAlreadyExist } @@ -119,7 +119,7 @@ func (k Keeper) CreateSubAccount(ctx sdk.Context, creator, owner string, return "", sdkerrors.Wrap(err, "unable to send coins") } - k.SetSubAccountOwner(ctx, subAccAddr, subAccOwnerAddr) + k.SetSubaccountOwner(ctx, subAccAddr, subaccountOwnerAddr) k.SetLockedBalances(ctx, subAccAddr, lockedBalances) k.SetAccountSummary(ctx, subAccAddr, types.AccountSummary{ DepositedAmount: lockedBalance, @@ -140,9 +140,9 @@ func (k Keeper) sendCoinsToSubaccount(ctx sdk.Context, creatorAccount, subAccoun return nil } -// sumlockedBalance sums all the balances to unlock and returns the total amount. It +// sumLockedBalance sums all the balances to unlock and returns the total amount. It // returns an error if any of to unlock times is expired. -func sumlockedBalance(ctx sdk.Context, lockedBalances []types.LockedBalance) (sdkmath.Int, error) { +func sumLockedBalance(ctx sdk.Context, lockedBalances []types.LockedBalance) (sdkmath.Int, error) { lockedBalance := sdkmath.NewInt(0) for _, lb := range lockedBalances { diff --git a/x/subaccount/keeper/subaccount_test.go b/x/subaccount/keeper/subaccount_test.go index 71ae68f2..7c670367 100644 --- a/x/subaccount/keeper/subaccount_test.go +++ b/x/subaccount/keeper/subaccount_test.go @@ -28,36 +28,36 @@ func TestSubaccountID(t *testing.T) { require.Equal(t, uint64(100), k.Peek(ctx)) } -func TestSubAccountOwner(t *testing.T) { +func TestSubaccountOwner(t *testing.T) { _, k, ctx := setupKeeperAndApp(t) owner := sample.NativeAccAddress() // Account should not have subaccount - _, exists := k.GetSubAccountOwner(ctx, owner) + _, exists := k.GetSubaccountOwner(ctx, owner) require.False(t, exists) // Set subaccount owner id := k.NextID(ctx) - k.SetSubAccountOwner(ctx, types.NewAddressFromSubaccount(id), owner) + k.SetSubaccountOwner(ctx, types.NewAddressFromSubaccount(id), owner) // Account should have subaccount - _, exists = k.GetSubAccountByOwner(ctx, owner) + _, exists = k.GetSubaccountByOwner(ctx, owner) require.True(t, exists) // Get subaccount ID - subAccountAddress, exists := k.GetSubAccountByOwner(ctx, owner) + subAccountAddress, exists := k.GetSubaccountByOwner(ctx, owner) require.True(t, exists) require.Equal(t, types.NewAddressFromSubaccount(id), subAccountAddress) // Get owner of subaccount - gotOwner, exists := k.GetSubAccountOwner(ctx, subAccountAddress) + gotOwner, exists := k.GetSubaccountOwner(ctx, subAccountAddress) require.True(t, exists) require.Equal(t, owner, gotOwner) // Get account ID by owner - gotSubAccount, exists := k.GetSubAccountByOwner(ctx, owner) + gotSubaccount, exists := k.GetSubaccountByOwner(ctx, owner) require.True(t, exists) - require.Equal(t, types.NewAddressFromSubaccount(id), gotSubAccount) + require.Equal(t, types.NewAddressFromSubaccount(id), gotSubaccount) } func TestSetLockedBalances(t *testing.T) { @@ -82,7 +82,7 @@ func TestSetLockedBalances(t *testing.T) { k.SetLockedBalances(ctx, addr, balanceUnlocks) // Get locked balances - lockedBalances := k.GetLockedBalances(ctx, addr) + lockedBalances, _ := k.GetBalances(ctx, addr, types.LockedBalanceStatus_LOCKED_BALANCE_STATUS_LOCKED) for i, lockedBalance := range lockedBalances { require.Equal(t, lockedBalance.Amount, balanceUnlocks[i].Amount) require.True(t, lockedBalance.UnlockTS == balanceUnlocks[i].UnlockTS) @@ -141,6 +141,6 @@ func TestKeeper_GetLockedBalances(t *testing.T) { k.SetLockedBalances(ctx, addr, balanceUnlocks) // get unlocked balance - unlockedBalance := k.GetUnlockedBalance(ctx, addr) - require.True(t, unlockedBalance.Equal(sdkmath.NewInt(10000+20000))) + _, unlockedAmount := k.GetBalances(ctx, addr, types.LockedBalanceStatus_LOCKED_BALANCE_STATUS_UNLOCKED) + require.True(t, unlockedAmount.Equal(sdkmath.NewInt(10000+20000))) } diff --git a/x/subaccount/simulation/decoder.go b/x/subaccount/simulation/decoder.go index d2d51499..d7cf0297 100644 --- a/x/subaccount/simulation/decoder.go +++ b/x/subaccount/simulation/decoder.go @@ -20,11 +20,11 @@ func NewDecodeStore(cdc codec.BinaryCodec) func(kvA, kvB kv.Pair) string { idA := sdk.BigEndianToUint64(kvA.Value) idB := sdk.BigEndianToUint64(kvB.Value) return fmt.Sprintf("%v\n%v", idA, idB) - case bytes.Equal(kvA.Key, types.SubAccountOwnerPrefix): + case bytes.Equal(kvA.Key, types.SubaccountOwnerPrefix): idA := sdk.AccAddress(kvA.Value) idB := sdk.AccAddress(kvB.Value) return fmt.Sprintf("%v\n%v", idA, idB) - case bytes.Equal(kvA.Key, types.SubAccountOwnerReversePrefix): + case bytes.Equal(kvA.Key, types.SubaccountOwnerReversePrefix): idA := sdk.AccAddress(kvA.Value) idB := sdk.AccAddress(kvB.Value) return fmt.Sprintf("%v\n%v", idA, idB) diff --git a/x/subaccount/simulation/decoder_test.go b/x/subaccount/simulation/decoder_test.go index 81423948..74eefb6e 100644 --- a/x/subaccount/simulation/decoder_test.go +++ b/x/subaccount/simulation/decoder_test.go @@ -38,8 +38,8 @@ func TestDecodeStore(t *testing.T) { kvPairs := kv.Pairs{ Pairs: []kv.Pair{ {Key: types.SubaccountIDPrefix, Value: sdk.Uint64ToBigEndian(uint64(subID))}, - {Key: types.SubAccountOwnerPrefix, Value: address}, - {Key: types.SubAccountOwnerReversePrefix, Value: address}, + {Key: types.SubaccountOwnerPrefix, Value: address}, + {Key: types.SubaccountOwnerReversePrefix, Value: address}, {Key: types.LockedBalancePrefix, Value: cdc.MustMarshal(&lockedBalance)}, {Key: types.AccountSummaryPrefix, Value: cdc.MustMarshal(&accSummary)}, {Key: []byte{0x99}, Value: []byte{0x99}}, diff --git a/x/subaccount/types/accsummary.go b/x/subaccount/types/accsummary.go index 66dd0813..8d87994c 100644 --- a/x/subaccount/types/accsummary.go +++ b/x/subaccount/types/accsummary.go @@ -77,10 +77,18 @@ func (as *AccountSummary) Withdraw(amt sdkmath.Int) error { return nil } -// WithdrawableBalance returns withdrawable balance of a subaccount -func (as *AccountSummary) WithdrawableBalance(unlockedBalance, bankBalance sdkmath.Int) sdkmath.Int { +// WithdrawableUnlockedBalance returns withdrawable unlocked balance of a subaccount +func (as *AccountSummary) WithdrawableUnlockedBalance(unlockedBalance, bankBalance sdkmath.Int) sdkmath.Int { // calculate withdrawable balance, which is the minimum between the available balance, and // what has been unlocked so far. Also, it cannot be greater than the bank balance. // Available reports the deposited amount - spent amount - lost amount - withdrawn amount. return sdkmath.MinInt(sdkmath.MinInt(as.Available(), unlockedBalance), bankBalance) } + +// WithdrawableBalance returns total (unlocked and locked) withdrawable balance of a subaccount +func (as *AccountSummary) WithdrawableBalance(bankBalance sdkmath.Int) sdkmath.Int { + // calculate withdrawable balance, which is the minimum between the available balance, and + // what has been unlocked so far. Also, it cannot be greater than the bank balance. + // Available reports the deposited amount - spent amount - lost amount - withdrawn amount. + return sdkmath.MinInt(as.Available(), bankBalance) +} diff --git a/x/subaccount/types/balance.pb.go b/x/subaccount/types/balance.pb.go index 6537c021..9881c9da 100644 --- a/x/subaccount/types/balance.pb.go +++ b/x/subaccount/types/balance.pb.go @@ -24,6 +24,38 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// LockedBalanceStatus type. +type LockedBalanceStatus int32 + +const ( + // the invalid or unknown + LockedBalanceStatus_LOCKED_BALANCE_STATUS_UNSPECIFIED LockedBalanceStatus = 0 + // locked + LockedBalanceStatus_LOCKED_BALANCE_STATUS_LOCKED LockedBalanceStatus = 1 + // unlocked + LockedBalanceStatus_LOCKED_BALANCE_STATUS_UNLOCKED LockedBalanceStatus = 2 +) + +var LockedBalanceStatus_name = map[int32]string{ + 0: "LOCKED_BALANCE_STATUS_UNSPECIFIED", + 1: "LOCKED_BALANCE_STATUS_LOCKED", + 2: "LOCKED_BALANCE_STATUS_UNLOCKED", +} + +var LockedBalanceStatus_value = map[string]int32{ + "LOCKED_BALANCE_STATUS_UNSPECIFIED": 0, + "LOCKED_BALANCE_STATUS_LOCKED": 1, + "LOCKED_BALANCE_STATUS_UNLOCKED": 2, +} + +func (x LockedBalanceStatus) String() string { + return proto.EnumName(LockedBalanceStatus_name, int32(x)) +} + +func (LockedBalanceStatus) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_19a80bd2939d53e2, []int{0} +} + // AccountSummary defines the balance of a subaccount. type AccountSummary struct { // deposited_amount keeps track of how much was deposited so far in the @@ -120,6 +152,7 @@ func (m *LockedBalance) GetUnlockTS() uint64 { } func init() { + proto.RegisterEnum("sgenetwork.sge.subaccount.LockedBalanceStatus", LockedBalanceStatus_name, LockedBalanceStatus_value) proto.RegisterType((*AccountSummary)(nil), "sgenetwork.sge.subaccount.AccountSummary") proto.RegisterType((*LockedBalance)(nil), "sgenetwork.sge.subaccount.LockedBalance") } @@ -127,29 +160,33 @@ func init() { func init() { proto.RegisterFile("sge/subaccount/balance.proto", fileDescriptor_19a80bd2939d53e2) } var fileDescriptor_19a80bd2939d53e2 = []byte{ - // 340 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0x3d, 0x4b, 0xc3, 0x40, - 0x18, 0xc7, 0x93, 0x5a, 0x8a, 0xbd, 0xfa, 0x52, 0x82, 0x82, 0x15, 0x4d, 0xa4, 0x93, 0x4b, 0x93, - 0x41, 0xc4, 0x4d, 0x6c, 0x16, 0x2b, 0x38, 0xb5, 0xba, 0xb8, 0x94, 0xcb, 0xe5, 0xb8, 0x86, 0x34, - 0xf7, 0x84, 0xdc, 0x85, 0xda, 0xc9, 0xaf, 0xe0, 0xa7, 0xf0, 0xb3, 0x74, 0xec, 0x28, 0x0e, 0x41, - 0xd2, 0xcd, 0x4f, 0x21, 0x79, 0x69, 0xeb, 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0x8c, - 0xdd, 0xe7, 0xfc, 0xe3, 0xd3, 0xe8, 0x27, 0x31, 0xb6, 0x81, 0xe1, 0x76, 0xd4, 0xae, 0x51, 0xe3, - 0x3f, 0x7d, 0x94, 0x61, 0xfb, 0x7e, 0x91, 0xea, 0xea, 0x32, 0xd5, 0xd5, 0xef, 0x54, 0x57, 0xdf, - 0x57, 0xba, 0xb2, 0x5c, 0xe9, 0xca, 0xe7, 0x4a, 0x57, 0x5e, 0x7a, 0xcc, 0x93, 0x93, 0xd8, 0x31, - 0x09, 0x04, 0x96, 0x60, 0xb4, 0x57, 0x1e, 0x40, 0x36, 0x5b, 0xaf, 0x7f, 0x6f, 0x45, 0xce, 0x43, - 0x2a, 0x9c, 0x46, 0xfe, 0xf2, 0x57, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x92, 0x1a, 0xd0, 0xeb, - 0x4a, 0x02, 0x00, 0x00, + // 412 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xcd, 0xaa, 0xd3, 0x40, + 0x18, 0x86, 0x93, 0x5a, 0x8a, 0x9d, 0xfa, 0x13, 0x46, 0x05, 0x2b, 0x35, 0xa9, 0x05, 0x41, 0x84, + 0x26, 0x0b, 0x11, 0x77, 0x62, 0xd2, 0x46, 0x5b, 0x2c, 0x55, 0x9a, 0x76, 0xe3, 0x26, 0x4c, 0x92, + 0x21, 0x0d, 0x69, 0x32, 0x21, 0x33, 0xa1, 0x76, 0x25, 0x78, 0x05, 0x5e, 0x85, 0xd7, 0xd2, 0x65, + 0x97, 0xe2, 0x22, 0x48, 0xba, 0xf3, 0x2a, 0x0e, 0xf9, 0x69, 0x7b, 0x0e, 0x9c, 0x03, 0x3d, 0xbb, + 0x8f, 0x99, 0xf7, 0x79, 0xf8, 0xf8, 0x78, 0x41, 0x87, 0xba, 0x58, 0xa1, 0x89, 0x85, 0x6c, 0x9b, + 0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xc2, 0xb7, 0xa0, 0x71, 0x9b, 0x7b, 0x54, 0xe1, 0xd7, + 0x3f, 0x79, 0xf0, 0xe8, 0xca, 0x06, 0x06, 0x43, 0x2c, 0xa1, 0xf0, 0x25, 0x78, 0x31, 0xf9, 0x32, + 0xf8, 0xac, 0x0f, 0x4d, 0x4d, 0x9d, 0xa8, 0xd3, 0x81, 0x6e, 0x1a, 0x73, 0x75, 0xbe, 0x30, 0xcc, + 0xc5, 0xd4, 0xf8, 0xaa, 0x0f, 0xc6, 0x1f, 0xc7, 0xfa, 0x50, 0xe0, 0x60, 0x17, 0x74, 0xae, 0x8f, + 0x95, 0xaf, 0x02, 0x0f, 0x7b, 0x40, 0xbc, 0x49, 0x54, 0x65, 0x6a, 0xda, 0xa7, 0x6d, 0x26, 0xf2, + 0xbb, 0x4c, 0xe4, 0xff, 0x65, 0x22, 0xff, 0x6b, 0x2f, 0x72, 0xbb, 0xbd, 0xc8, 0xfd, 0xd9, 0x8b, + 0xdc, 0xb7, 0xbe, 0xeb, 0xb1, 0x65, 0x62, 0xc9, 0x36, 0x09, 0x14, 0xea, 0xe2, 0x7e, 0xd5, 0xc2, + 0x7c, 0x56, 0xbe, 0x5f, 0x2e, 0x2c, 0xdb, 0x44, 0x98, 0x5a, 0x8d, 0xa2, 0x7e, 0x6f, 0x2e, 0x02, + 0x00, 0x00, 0xff, 0xff, 0x49, 0x49, 0xeb, 0x57, 0xcf, 0x02, 0x00, 0x00, } func (m *AccountSummary) Marshal() (dAtA []byte, err error) { diff --git a/x/subaccount/types/errors.go b/x/subaccount/types/errors.go index 87914209..ab6a5af3 100644 --- a/x/subaccount/types/errors.go +++ b/x/subaccount/types/errors.go @@ -16,4 +16,5 @@ var ( ErrInvalidLockedBalance = sdkerrors.Register(ModuleName, 8007, "invalid locked balance") ErrSendCoinError = sdkerrors.Register(ModuleName, 8008, "send coin error") ErrWithdrawLocked = sdkerrors.Register(ModuleName, 8009, "withdrawal of locked coins failed") + ErrLockedBalanceExists = sdkerrors.Register(ModuleName, 8010, "locked balance for the expire time exists") ) diff --git a/x/subaccount/types/events.go b/x/subaccount/types/events.go index cab96e47..1eac11d8 100644 --- a/x/subaccount/types/events.go +++ b/x/subaccount/types/events.go @@ -12,14 +12,14 @@ const ( const ( attributeKeyDepositCreator = "creator" - attributeKeySubAccDepositor = "subacc_depositor" - attributeKeySubAccDepositFee = "subacc_deposit_fee" + attributeKeySubaccountDepositor = "subacc_depositor" + attributeKeySubaccountDepositFee = "subacc_deposit_fee" attributeKeyWithdrawalID = "withdrawal_id" attributeKeyDepositMarketUIDParticipantIndex = "deposit_market_index" attributeKeyWithdrawMarketUIDParticipantIndex = "withdraw_market_index" ) const ( - attributeKeySubAccOwner = "subacc_owner" - attributeKeySubAcc = "subacc" + attributeKeySubaccountOwner = "subacc_owner" + attributeKeySubaccount = "subacc" ) diff --git a/x/subaccount/types/keys.go b/x/subaccount/types/keys.go index 0d425c6a..c095b60c 100644 --- a/x/subaccount/types/keys.go +++ b/x/subaccount/types/keys.go @@ -26,11 +26,11 @@ var ( // SubaccountIDPrefix is the key used to store the subaccount ID in the keeper KVStore SubaccountIDPrefix = []byte{0x00} - // SubAccountOwnerPrefix is the key used to store the subaccount owner in the keeper KVStore - SubAccountOwnerPrefix = []byte{0x01} + // SubaccountOwnerPrefix is the key used to store the subaccount owner in the keeper KVStore + SubaccountOwnerPrefix = []byte{0x01} - // SubAccountOwnerReversePrefix is the key used to store the subaccount owner by ID in the keeper KVStore - SubAccountOwnerReversePrefix = []byte{0x02} + // SubaccountOwnerReversePrefix is the key used to store the subaccount owner by ID in the keeper KVStore + SubaccountOwnerReversePrefix = []byte{0x02} // LockedBalancePrefix is the key used to store the locked balance in the keeper KVStore LockedBalancePrefix = []byte{0x03} @@ -39,12 +39,12 @@ var ( AccountSummaryPrefix = []byte{0x04} ) -func SubAccountOwnerKey(address sdk.AccAddress) []byte { - return append(SubAccountOwnerPrefix, address...) +func SubaccountOwnerKey(address sdk.AccAddress) []byte { + return append(SubaccountOwnerPrefix, address...) } -func SubAccountKey(subAccountAddress sdk.AccAddress) []byte { - return append(SubAccountOwnerReversePrefix, subAccountAddress...) +func SubaccountKey(subAccountAddress sdk.AccAddress) []byte { + return append(SubaccountOwnerReversePrefix, subAccountAddress...) } func LockedBalanceKey(subAccountAddress sdk.AccAddress, unlockTime uint64) []byte { diff --git a/x/subaccount/types/messages_balance.go b/x/subaccount/types/messages_balance.go index 8e6c744e..7c20942f 100644 --- a/x/subaccount/types/messages_balance.go +++ b/x/subaccount/types/messages_balance.go @@ -38,7 +38,7 @@ func (msg *MsgTopUp) GetSigners() []sdk.AccAddress { func (msg *MsgTopUp) EmitEvent(ctx *sdk.Context, subAccAddr string) { emitter := utils.NewEventEmitter(ctx, attributeValueCategory) emitter.AddMsg(typeMsgTopUp, msg.Creator, - sdk.NewAttribute(attributeKeySubAcc, subAccAddr), + sdk.NewAttribute(attributeKeySubaccount, subAccAddr), ) emitter.Emit() } @@ -90,7 +90,7 @@ func (msg *MsgWithdrawUnlockedBalances) ValidateBasic() error { func (msg *MsgWithdrawUnlockedBalances) EmitEvent(ctx *sdk.Context, subAccAddr string) { emitter := utils.NewEventEmitter(ctx, attributeValueCategory) emitter.AddMsg(typeMsgWithdrawUnlockedBalances, msg.Creator, - sdk.NewAttribute(attributeKeySubAcc, subAccAddr), + sdk.NewAttribute(attributeKeySubaccount, subAccAddr), ) emitter.Emit() } diff --git a/x/subaccount/types/messages_house.go b/x/subaccount/types/messages_house.go index 42a6a8b2..834dac37 100644 --- a/x/subaccount/types/messages_house.go +++ b/x/subaccount/types/messages_house.go @@ -52,8 +52,8 @@ func (msg *MsgHouseDeposit) EmitEvent(ctx *sdk.Context, subAccAddr string, parti emitter := utils.NewEventEmitter(ctx, attributeValueCategory) emitter.AddMsg(typeMsgHouseDeposit, msg.Msg.Creator, sdk.NewAttribute(attributeKeyDepositCreator, msg.Msg.Creator), - sdk.NewAttribute(attributeKeySubAccDepositor, subAccAddr), - sdk.NewAttribute(attributeKeySubAccDepositFee, feeAmount.String()), + sdk.NewAttribute(attributeKeySubaccountDepositor, subAccAddr), + sdk.NewAttribute(attributeKeySubaccountDepositFee, feeAmount.String()), sdk.NewAttribute(attributeKeyDepositMarketUIDParticipantIndex, strings.Join([]string{msg.Msg.MarketUID, cast.ToString(participationIndex)}, "#"), ), @@ -89,7 +89,7 @@ func (msg *MsgHouseWithdraw) EmitEvent(ctx *sdk.Context, subAccAddr string, with emitter := utils.NewEventEmitter(ctx, attributeValueCategory) emitter.AddMsg(typeHouseWithdraw, msg.Msg.Creator, sdk.NewAttribute(attributeKeyDepositCreator, msg.Msg.Creator), - sdk.NewAttribute(attributeKeySubAccDepositor, subAccAddr), + sdk.NewAttribute(attributeKeySubaccountDepositor, subAccAddr), sdk.NewAttribute(attributeKeyWithdrawalID, cast.ToString(withdrawalID)), sdk.NewAttribute(attributeKeyWithdrawMarketUIDParticipantIndex, strings.Join([]string{msg.Msg.MarketUID, cast.ToString(msg.Msg.ParticipationIndex)}, "#"), diff --git a/x/subaccount/types/messages_subaccount.go b/x/subaccount/types/messages_subaccount.go index d9d65433..84c21194 100644 --- a/x/subaccount/types/messages_subaccount.go +++ b/x/subaccount/types/messages_subaccount.go @@ -60,8 +60,8 @@ func (msg *MsgCreate) ValidateBasic() error { func (msg *MsgCreate) EmitEvent(ctx *sdk.Context, subAccAddr string) { emitter := utils.NewEventEmitter(ctx, attributeValueCategory) emitter.AddMsg(typeMsgCreate, msg.Creator, - sdk.NewAttribute(attributeKeySubAccOwner, msg.Owner), - sdk.NewAttribute(attributeKeySubAcc, subAccAddr), + sdk.NewAttribute(attributeKeySubaccountOwner, msg.Owner), + sdk.NewAttribute(attributeKeySubaccount, subAccAddr), ) emitter.Emit() } diff --git a/x/subaccount/types/query.pb.go b/x/subaccount/types/query.pb.go index 74a603cc..1a799a31 100644 --- a/x/subaccount/types/query.pb.go +++ b/x/subaccount/types/query.pb.go @@ -5,6 +5,7 @@ package types import ( context "context" + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" @@ -158,9 +159,11 @@ func (m *QuerySubaccountRequest) GetAddress() string { // QuerySubaccountResponse is the response type for the Query/Subaccount RPC type QuerySubaccountResponse struct { - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - Balance AccountSummary `protobuf:"bytes,2,opt,name=balance,proto3" json:"balance"` - LockedBalance []LockedBalance `protobuf:"bytes,3,rep,name=locked_balance,json=lockedBalance,proto3" json:"locked_balance"` + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + Balance AccountSummary `protobuf:"bytes,2,opt,name=balance,proto3" json:"balance"` + LockedBalance []LockedBalance `protobuf:"bytes,3,rep,name=locked_balance,json=lockedBalance,proto3" json:"locked_balance"` + UnlockedBalance []LockedBalance `protobuf:"bytes,4,rep,name=unlocked_balance,json=unlockedBalance,proto3" json:"unlocked_balance"` + WithdrawableUnlockedBalance cosmossdk_io_math.Int `protobuf:"bytes,5,opt,name=withdrawable_unlocked_balance,json=withdrawableUnlockedBalance,proto3,customtype=cosmossdk.io/math.Int" json:"withdrawable_unlocked_balance"` } func (m *QuerySubaccountResponse) Reset() { *m = QuerySubaccountResponse{} } @@ -217,6 +220,13 @@ func (m *QuerySubaccountResponse) GetLockedBalance() []LockedBalance { return nil } +func (m *QuerySubaccountResponse) GetUnlockedBalance() []LockedBalance { + if m != nil { + return m.UnlockedBalance + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "sgenetwork.sge.subaccount.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "sgenetwork.sge.subaccount.QueryParamsResponse") @@ -227,34 +237,39 @@ func init() { func init() { proto.RegisterFile("sge/subaccount/query.proto", fileDescriptor_e8576ea34550c199) } var fileDescriptor_e8576ea34550c199 = []byte{ - // 431 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0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0x49, 0x70, 0xb1, 0x27, - 0xa6, 0xa4, 0x14, 0xa5, 0x16, 0x43, 0xcc, 0xe6, 0x0c, 0x82, 0x71, 0x95, 0xae, 0x32, 0x72, 0x89, - 0x63, 0x68, 0x82, 0x3a, 0x08, 0xa7, 0x2e, 0x21, 0x4f, 0x2e, 0x76, 0x68, 0x28, 0x48, 0x30, 0x81, - 0xdd, 0xaa, 0x89, 0xc7, 0xad, 0x8e, 0x10, 0x3a, 0xb8, 0x34, 0x37, 0x37, 0xb1, 0xa8, 0x12, 0xea, - 0x66, 0x98, 0x7e, 0xa1, 0x50, 0x2e, 0xbe, 0x9c, 0xfc, 0xe4, 0xec, 0xd4, 0x94, 0x78, 0x98, 0x89, - 0xcc, 0x0a, 0xcc, 0x1a, 0xdc, 0x46, 0x1a, 0x78, 0x4c, 0xf4, 0x01, 0x6b, 0x70, 0x82, 0xa8, 0x87, - 0x1a, 0xc8, 0x9b, 0x83, 0x2c, 0x68, 0xb4, 0x95, 0x89, 0x8b, 0x15, 0xec, 0x2f, 0xa1, 0x85, 0x8c, - 0x5c, 0x5c, 0x08, 0xcf, 0x09, 0x19, 0xe2, 0x31, 0x17, 0x7b, 0xe8, 0x49, 0x19, 0x91, 0xa2, 0x05, - 0x12, 0x76, 0x4a, 0x3a, 0x4d, 0x97, 0x9f, 0x4c, 0x66, 0x52, 0x13, 0x52, 0xd1, 0x47, 0x4b, 0x1f, - 0x48, 0xcc, 0x6a, 0x68, 0x70, 0xd6, 0x0a, 0xb5, 0x33, 0x72, 0xb1, 0x41, 0xa2, 0x54, 0x48, 0x97, - 0x90, 0x65, 0x28, 0x69, 0x49, 0x4a, 0x8f, 0x58, 0xe5, 0x50, 0x77, 0xc9, 0x81, 0xdd, 0x25, 0x21, - 0x24, 0xa6, 0x8f, 0x35, 0xdd, 0x3a, 0xb9, 0x9f, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, - 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, - 0x43, 0x94, 0x6e, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0x2e, 0x48, 0xaf, 0x2e, - 0xd4, 0x52, 0xb0, 0x39, 0x15, 0xc8, 0x26, 0x95, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x73, - 0x80, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xb3, 0x1e, 0x5b, 0x4e, 0xa9, 0x03, 0x00, 0x00, + // 501 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x93, 0x4f, 0x6f, 0xd3, 0x30, + 0x18, 0xc6, 0x9b, 0x76, 0xeb, 0x84, 0x27, 0xfe, 0xc8, 0x8c, 0x51, 0x32, 0x96, 0x8d, 0x08, 0xa1, + 0x22, 0x51, 0x47, 0x84, 0x0f, 0x80, 0xe8, 0x05, 0x4d, 0xe2, 0x00, 0x9d, 0x86, 0x04, 0x97, 0xc9, + 0x49, 0xac, 0x34, 0x6a, 0xe2, 0x37, 0x8b, 0x1d, 0x95, 0x0a, 0x71, 0xe1, 0xc2, 0x15, 0x69, 0x9f, + 0x80, 0x0f, 0xc1, 0x77, 0xd8, 0x71, 0x12, 0x17, 0xc4, 0x61, 0x42, 0x2d, 0x1f, 0x04, 0xc5, 0x71, + 0x58, 0xdb, 0x6d, 0x05, 0x76, 0xaa, 0x6b, 0xbf, 0xcf, 0xef, 0x79, 0xe2, 0xd7, 0x2f, 0x32, 0x45, + 0xc8, 0x1c, 0x91, 0x7b, 0xd4, 0xf7, 0x21, 0xe7, 0xd2, 0x39, 0xc8, 0x59, 0x36, 0x22, 0x69, 0x06, + 0x12, 0xf0, 0x1d, 0x11, 0x32, 0xce, 0xe4, 0x10, 0xb2, 0x01, 0x11, 0x21, 0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 0x0e, 0x00, 0x00, 0xff, 0xff, 0x05, 0x5b, 0x51, + 0xc8, 0x67, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -483,6 +498,30 @@ func (m *QuerySubaccountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) _ = i var l int _ = l + { + size := m.WithdrawableUnlockedBalance.Size() + i -= size + if _, err := m.WithdrawableUnlockedBalance.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + if len(m.UnlockedBalance) > 0 { + for iNdEx := len(m.UnlockedBalance) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.UnlockedBalance[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } if len(m.LockedBalance) > 0 { for iNdEx := len(m.LockedBalance) - 1; iNdEx >= 0; iNdEx-- { { @@ -579,6 +618,14 @@ func (m *QuerySubaccountResponse) Size() (n int) { n += 1 + l + sovQuery(uint64(l)) } } + if len(m.UnlockedBalance) > 0 { + for _, e := range m.UnlockedBalance { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + l = m.WithdrawableUnlockedBalance.Size() + n += 1 + l + sovQuery(uint64(l)) return n } @@ -931,6 +978,74 @@ func (m *QuerySubaccountResponse) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UnlockedBalance", 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.UnlockedBalance = append(m.UnlockedBalance, LockedBalance{}) + if err := m.UnlockedBalance[len(m.UnlockedBalance)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WithdrawableUnlockedBalance", 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 + } + if err := m.WithdrawableUnlockedBalance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:])