diff --git a/proto/cosmos/accumulator/admin.proto b/proto/cosmos/accumulator/admin.proto new file mode 100644 index 000000000..8f85fc732 --- /dev/null +++ b/proto/cosmos/accumulator/admin.proto @@ -0,0 +1,28 @@ +syntax = "proto3"; +package cosmos.accumulator; + +import "google/protobuf/any.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "google/api/annotations.proto"; +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/accumulator/types"; + +message Admin { + string address = 1; + + int64 vesting_period = 2; + + cosmos.base.v1beta1.Coin reward_per_period = 3 [(gogoproto.nullable) = false]; + + int64 vesting_periods_count = 4; + + int64 last_vesting_time = 5; + + int64 vesting_counter = 6; + + string denom = 7; +} + + diff --git a/proto/cosmos/accumulator/genesis.proto b/proto/cosmos/accumulator/genesis.proto index 89198106e..0a4227ba4 100644 --- a/proto/cosmos/accumulator/genesis.proto +++ b/proto/cosmos/accumulator/genesis.proto @@ -1,15 +1,18 @@ syntax = "proto3"; -package accumulator; +package cosmos.accumulator; import "gogoproto/gogo.proto"; import "cosmos/accumulator/params.proto"; +import "cosmos/accumulator/admin.proto"; + // this line is used by starport scaffolding # genesis/proto/import option go_package = "github.com/cosmos/cosmos-sdk/x/accumulator/types"; -// GenesisState defines the bruhaccumulator module's genesis state. +// GenesisState defines the accumulator module's genesis state. message GenesisState { Params params = 1 [(gogoproto.nullable) = false]; + repeated cosmos.accumulator.Admin admins = 2 [(gogoproto.nullable) = false]; // this line is used by starport scaffolding # genesis/proto/state } diff --git a/proto/cosmos/accumulator/params.proto b/proto/cosmos/accumulator/params.proto index e6a0bdc16..c06cf7476 100644 --- a/proto/cosmos/accumulator/params.proto +++ b/proto/cosmos/accumulator/params.proto @@ -1,5 +1,5 @@ syntax = "proto3"; -package accumulator; +package cosmos.accumulator; import "gogoproto/gogo.proto"; // this line is used by starport scaffolding # proto/tx/import @@ -9,4 +9,5 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/accumulator/types"; // Params defines the parameters for the module. message Params { + string master_admin = 1; } diff --git a/proto/cosmos/accumulator/query.proto b/proto/cosmos/accumulator/query.proto index b072f4054..1836548e4 100644 --- a/proto/cosmos/accumulator/query.proto +++ b/proto/cosmos/accumulator/query.proto @@ -1,5 +1,5 @@ syntax = "proto3"; -package accumulator; +package cosmos.accumulator; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; diff --git a/proto/cosmos/accumulator/tx.proto b/proto/cosmos/accumulator/tx.proto index 557a3374f..a83f24c17 100644 --- a/proto/cosmos/accumulator/tx.proto +++ b/proto/cosmos/accumulator/tx.proto @@ -1,5 +1,5 @@ syntax = "proto3"; -package accumulator; +package cosmos.accumulator; // this line is used by starport scaffolding # proto/tx/import import "gogoproto/gogo.proto"; @@ -10,6 +10,26 @@ import "cosmos/base/v1beta1/coin.proto"; option go_package = "github.com/cosmos/cosmos-sdk/x/accumulator/types"; -service Msg {} +service Msg { + rpc AddAdmin(MsgAddAdmin) returns (MsgAddAdminResponse); +} // this line is used by starport scaffolding # proto/tx/message + +message MsgAddAdmin { + string creator = 1; + + string address = 2; + + cosmos.base.v1beta1.Coin reward_per_period = 3 [(gogoproto.nullable) = false]; + + int64 vesting_periods_count = 4; + + string denom = 5; + + int64 vesting_period = 6; + +} + +message MsgAddAdminResponse {} + diff --git a/proto/cosmos/nft/tx.proto b/proto/cosmos/nft/tx.proto index af6452361..92d68b6cc 100644 --- a/proto/cosmos/nft/tx.proto +++ b/proto/cosmos/nft/tx.proto @@ -39,7 +39,6 @@ message MsgDelegate { string address = 2; string validator = 3; cosmos.base.v1beta1.Coin amount = 5 [(gogoproto.nullable) = false]; - } message MsgDelegateResponse {} diff --git a/x/accumulator/abci.go b/x/accumulator/abci.go new file mode 100644 index 000000000..ed1e3c177 --- /dev/null +++ b/x/accumulator/abci.go @@ -0,0 +1,36 @@ +package accumulator + +import ( + "github.com/cosmos/cosmos-sdk/telemetry" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/accumulator/keeper" + "github.com/cosmos/cosmos-sdk/x/accumulator/types" + "time" +) + +// update vesting state for each admin +func EndBlocker(ctx sdk.Context, k keeper.Keeper) { + defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) + + for _, admin := range k.GetAllAdmins(ctx) { + if ctx.BlockTime().Unix()-admin.LastVestingTime < admin.VestingPeriod { + return + } + + if admin.VestingCounter >= admin.VestingPeriodsCount { + return + } + + address, _ := sdk.AccAddressFromBech32(admin.Address) + err := k.DistributeToAccount(ctx, types.AdminPoolName, sdk.NewCoins(sdk.NewCoin(admin.Denom, admin.RewardPerPeriod.Amount)), address) + if err != nil { + return + } + + admin.VestingCounter++ + admin.LastVestingTime = ctx.BlockTime().Unix() + + k.SetAdmin(ctx, admin) + } + +} diff --git a/x/accumulator/client/cli/query_derive_address.go b/x/accumulator/client/cli/query_derive_address.go index 28c2594c2..db4edc033 100644 --- a/x/accumulator/client/cli/query_derive_address.go +++ b/x/accumulator/client/cli/query_derive_address.go @@ -13,14 +13,14 @@ func CmdDerivePoolAddress() *cobra.Command { Use: "derive-pool", Short: "Derive pool addressess", RunE: func(cmd *cobra.Command, args []string) error { + fmt.Printf("Pool %s address: %s\n", types.AdminPoolName, keeper.GetPoolAddress(types.AdminPoolName).String()) + fmt.Printf("Pool %s address: %s\n", types.ValidatorPoolName, keeper.GetPoolAddress(types.ValidatorPoolName).String()) + fmt.Printf("Pool %s address: %s\n", types.NFTPoolName, keeper.GetPoolAddress(types.NFTPoolName).String()) return nil }, } - fmt.Printf("Pool %s address: %s\n", types.AdminPoolName, keeper.GetPoolAddress(types.AdminPoolName).String()) - fmt.Printf("Pool %s address: %s\n", types.ValidatorPoolName, keeper.GetPoolAddress(types.ValidatorPoolName).String()) - fmt.Printf("Pool %s address: %s\n", types.NFTPoolName, keeper.GetPoolAddress(types.NFTPoolName).String()) flags.AddQueryFlagsToCmd(cmd) return cmd diff --git a/x/accumulator/genesis.go b/x/accumulator/genesis.go index a1ba0287b..54b2453fd 100644 --- a/x/accumulator/genesis.go +++ b/x/accumulator/genesis.go @@ -9,6 +9,10 @@ import ( // InitGenesis initializes the module's state from a provided genesis state. func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { // This line is used by starport scaffolding # genesis/module/init + for _, admin := range genState.Admins { + k.SetAdmin(ctx, admin) + } + k.SetParams(ctx, genState.Params) } @@ -16,6 +20,7 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { genesis := types.DefaultGenesis() genesis.Params = k.GetParams(ctx) + genesis.Admins = k.GetAllAdmins(ctx) // this line is used by starport scaffolding # genesis/module/export return genesis diff --git a/x/accumulator/handler.go b/x/accumulator/handler.go index cbf124ea9..bb627fc40 100644 --- a/x/accumulator/handler.go +++ b/x/accumulator/handler.go @@ -3,16 +3,25 @@ package accumulator import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/accumulator/keeper" + "github.com/cosmos/cosmos-sdk/x/accumulator/types" ) // NewHandler ... func NewHandler(k keeper.Keeper) sdk.Handler { // this line is used by starport scaffolding # handler/msgServer + msgServer := keeper.NewMsgServerImpl(k) return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { + ctx = ctx.WithEventManager(sdk.NewEventManager()) + switch msg := msg.(type) { + case *types.MsgAddAdmin: + res, err := msgServer.AddAdmin(ctx, msg) + return sdk.WrapServiceResult(ctx, res, err) + + } return nil, nil - } - // this line is used by starport scaffolding # 1 + // this line is used by starport scaffolding # 1 + } } diff --git a/x/accumulator/keeper/accumulator.go b/x/accumulator/keeper/accumulator.go new file mode 100644 index 000000000..79d221f42 --- /dev/null +++ b/x/accumulator/keeper/accumulator.go @@ -0,0 +1,59 @@ +package keeper + +import ( + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/accumulator/types" +) + +// SetAdmin set a specific deposit in the store from its index +func (k BaseKeeper) SetAdmin(ctx sdk.Context, v types.Admin) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.AdminKeyPrefix)) + b := k.cdc.MustMarshal(&v) + store.Set(types.AdminKey(v.Address), b) +} + +// GetAdmin returns a Admin from its index +func (k BaseKeeper) GetAdmin( + ctx sdk.Context, + address string, +) (val types.Admin, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.AdminKeyPrefix)) + b := store.Get(types.AdminKey( + address, + )) + + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +// RemoveAdmin removes a Admin from the store +func (k BaseKeeper) RemoveAdmin( + ctx sdk.Context, + address string, +) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.AdminKeyPrefix)) + store.Delete(types.AdminKey( + address, + )) +} + +// GetAllAdmin returns all Admin +func (k BaseKeeper) GetAllAdmins(ctx sdk.Context) (list []types.Admin) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.AdminKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.Admin + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} diff --git a/x/accumulator/keeper/keeper.go b/x/accumulator/keeper/keeper.go index be12adf75..4987f06f6 100644 --- a/x/accumulator/keeper/keeper.go +++ b/x/accumulator/keeper/keeper.go @@ -23,6 +23,10 @@ type ( Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) DistributeToModule(ctx sdk.Context, pool string, amount sdk.Coins, receiverModule string) error DistributeToAccount(ctx sdk.Context, pool string, amount sdk.Coins, receiver sdk.AccAddress) error + SetAdmin(ctx sdk.Context, admin types.Admin) + GetAdmin(ctx sdk.Context, address string) (val types.Admin, found bool) + RemoveAdmin(ctx sdk.Context, address string) + GetAllAdmins(ctx sdk.Context) []types.Admin } BaseKeeper struct { diff --git a/x/accumulator/keeper/msg_server.go b/x/accumulator/keeper/msg_server.go index 081cb7d4a..546f3e09c 100644 --- a/x/accumulator/keeper/msg_server.go +++ b/x/accumulator/keeper/msg_server.go @@ -1,5 +1,42 @@ package keeper +import ( + "context" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/accumulator/types" +) + type msgServer struct { Keeper } + +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +var _ types.MsgServer = msgServer{} + +func (m msgServer) AddAdmin(goctx context.Context, req *types.MsgAddAdmin) (*types.MsgAddAdminResponse, error) { + ctx := sdk.UnwrapSDKContext(goctx) + + if m.GetParams(ctx).MasterAdmin != req.Creator { + return nil, types.ErrForbidden + } + + if _, ok := m.GetAdmin(ctx, req.Address); ok { + return nil, types.ErrAdminExists + } + newAdmin := types.Admin{ + Address: req.Address, + VestingPeriod: req.VestingPeriod, + RewardPerPeriod: req.RewardPerPeriod, + VestingPeriodsCount: req.VestingPeriodsCount, + VestingCounter: 0, + LastVestingTime: 0, + Denom: req.Denom, + } + + m.SetAdmin(ctx, newAdmin) + + return new(types.MsgAddAdminResponse), nil +} diff --git a/x/accumulator/module.go b/x/accumulator/module.go index 1101cf6d8..8a9574579 100644 --- a/x/accumulator/module.go +++ b/x/accumulator/module.go @@ -155,6 +155,7 @@ func (AppModule) ConsensusVersion() uint64 { return 1 } func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} // EndBlock contains the logic that is automatically triggered at the end of each block -func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { +func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + EndBlocker(ctx, am.keeper) return []abci.ValidatorUpdate{} } diff --git a/x/accumulator/types/admin.pb.go b/x/accumulator/types/admin.pb.go new file mode 100644 index 000000000..b05be55d7 --- /dev/null +++ b/x/accumulator/types/admin.pb.go @@ -0,0 +1,578 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cosmos/accumulator/admin.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/codec/types" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type Admin struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + VestingPeriod int64 `protobuf:"varint,2,opt,name=vesting_period,json=vestingPeriod,proto3" json:"vesting_period,omitempty"` + RewardPerPeriod types.Coin `protobuf:"bytes,3,opt,name=reward_per_period,json=rewardPerPeriod,proto3" json:"reward_per_period"` + VestingPeriodsCount int64 `protobuf:"varint,4,opt,name=vesting_periods_count,json=vestingPeriodsCount,proto3" json:"vesting_periods_count,omitempty"` + LastVestingTime int64 `protobuf:"varint,5,opt,name=last_vesting_time,json=lastVestingTime,proto3" json:"last_vesting_time,omitempty"` + VestingCounter int64 `protobuf:"varint,6,opt,name=vesting_counter,json=vestingCounter,proto3" json:"vesting_counter,omitempty"` + Denom string `protobuf:"bytes,7,opt,name=denom,proto3" json:"denom,omitempty"` +} + +func (m *Admin) Reset() { *m = Admin{} } +func (m *Admin) String() string { return proto.CompactTextString(m) } +func (*Admin) ProtoMessage() {} +func (*Admin) Descriptor() ([]byte, []int) { + return fileDescriptor_ea173fc964753617, []int{0} +} +func (m *Admin) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Admin) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Admin.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 *Admin) XXX_Merge(src proto.Message) { + xxx_messageInfo_Admin.Merge(m, src) +} +func (m *Admin) XXX_Size() int { + return m.Size() +} +func (m *Admin) XXX_DiscardUnknown() { + xxx_messageInfo_Admin.DiscardUnknown(m) +} + +var xxx_messageInfo_Admin proto.InternalMessageInfo + +func (m *Admin) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *Admin) GetVestingPeriod() int64 { + if m != nil { + return m.VestingPeriod + } + return 0 +} + +func (m *Admin) GetRewardPerPeriod() types.Coin { + if m != nil { + return m.RewardPerPeriod + } + return types.Coin{} +} + +func (m *Admin) GetVestingPeriodsCount() int64 { + if m != nil { + return m.VestingPeriodsCount + } + return 0 +} + +func (m *Admin) GetLastVestingTime() int64 { + if m != nil { + return m.LastVestingTime + } + return 0 +} + +func (m *Admin) GetVestingCounter() int64 { + if m != nil { + return m.VestingCounter + } + return 0 +} + +func (m *Admin) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +func init() { + proto.RegisterType((*Admin)(nil), "cosmos.accumulator.Admin") +} + +func init() { proto.RegisterFile("cosmos/accumulator/admin.proto", fileDescriptor_ea173fc964753617) } + +var fileDescriptor_ea173fc964753617 = []byte{ + // 393 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x52, 0xcd, 0x8e, 0xda, 0x30, + 0x10, 0x4e, 0xf8, 0x55, 0x5d, 0xb5, 0x08, 0x97, 0x4a, 0x01, 0x55, 0x2e, 0xaa, 0x54, 0x15, 0x21, + 0x35, 0x2e, 0xf4, 0x09, 0x0a, 0xb7, 0xf6, 0x82, 0x50, 0xd5, 0x43, 0x2f, 0xc8, 0x49, 0xdc, 0xd4, + 0x2a, 0xf1, 0xa4, 0xb6, 0xc3, 0x2e, 0x6f, 0xb1, 0x0f, 0xb3, 0x0f, 0xc1, 0x91, 0xe3, 0x9e, 0x56, + 0x2b, 0x78, 0x91, 0x55, 0x1c, 0x47, 0x82, 0x53, 0x66, 0xbe, 0xef, 0x9b, 0x6f, 0xbe, 0x4c, 0x82, + 0x48, 0x0c, 0x3a, 0x03, 0x4d, 0x59, 0x1c, 0x17, 0x59, 0xb1, 0x65, 0x06, 0x14, 0x65, 0x49, 0x26, + 0x64, 0x98, 0x2b, 0x30, 0x80, 0x71, 0xc5, 0x87, 0x17, 0xfc, 0x68, 0x98, 0x02, 0xa4, 0x5b, 0x4e, + 0xad, 0x22, 0x2a, 0xfe, 0x50, 0x26, 0xf7, 0x95, 0x7c, 0x34, 0x75, 0x76, 0x11, 0xd3, 0x9c, 0xfe, + 0x2f, 0xb8, 0xda, 0xd3, 0xdd, 0x2c, 0xe2, 0x86, 0xcd, 0x68, 0xce, 0x52, 0x21, 0x99, 0x11, 0xe0, + 0xac, 0x47, 0xef, 0x9c, 0x0d, 0xcb, 0x05, 0x65, 0x52, 0x82, 0xb1, 0xa4, 0x76, 0xec, 0x20, 0x85, + 0x14, 0x6c, 0x49, 0xcb, 0xca, 0xa1, 0xe4, 0xd2, 0xbf, 0x76, 0x8e, 0xa1, 0x8e, 0xfb, 0xe1, 0xbe, + 0x81, 0xda, 0xdf, 0xca, 0xf8, 0x38, 0x40, 0x5d, 0x96, 0x24, 0x8a, 0x6b, 0x1d, 0xf8, 0x63, 0x7f, + 0xf2, 0x62, 0x5d, 0xb7, 0xf8, 0x23, 0x7a, 0xbd, 0xe3, 0xda, 0x08, 0x99, 0x6e, 0x72, 0xae, 0x04, + 0x24, 0x41, 0x63, 0xec, 0x4f, 0x9a, 0xeb, 0x57, 0x0e, 0x5d, 0x59, 0x10, 0xff, 0x40, 0x7d, 0xc5, + 0x6f, 0x98, 0x4a, 0x4a, 0x55, 0xad, 0x6c, 0x8e, 0xfd, 0xc9, 0xcb, 0xf9, 0x30, 0x74, 0x57, 0x29, + 0x63, 0x84, 0x2e, 0x46, 0xb8, 0x04, 0x21, 0x17, 0xad, 0xc3, 0xe3, 0x7b, 0x6f, 0xdd, 0xab, 0x26, + 0x57, 0x5c, 0x39, 0xb3, 0x39, 0x7a, 0x7b, 0xbd, 0x53, 0x6f, 0x62, 0x28, 0xa4, 0x09, 0x5a, 0x76, + 0xf5, 0x9b, 0xab, 0xd5, 0x7a, 0x59, 0x52, 0x78, 0x8a, 0xfa, 0x5b, 0xa6, 0xcd, 0xa6, 0x1e, 0x34, + 0x22, 0xe3, 0x41, 0xdb, 0xea, 0x7b, 0x25, 0xf1, 0xab, 0xc2, 0x7f, 0x8a, 0x8c, 0xe3, 0x4f, 0xa8, + 0x57, 0xcb, 0xac, 0x2f, 0x57, 0x41, 0xc7, 0x2a, 0xeb, 0x57, 0x5d, 0x56, 0x28, 0x1e, 0xa0, 0x76, + 0xc2, 0x25, 0x64, 0x41, 0xd7, 0x1e, 0xa5, 0x6a, 0x16, 0xdf, 0x0f, 0x27, 0xe2, 0x1f, 0x4f, 0xc4, + 0x7f, 0x3a, 0x11, 0xff, 0xee, 0x4c, 0xbc, 0xe3, 0x99, 0x78, 0x0f, 0x67, 0xe2, 0xfd, 0xfe, 0x92, + 0x0a, 0xf3, 0xb7, 0x88, 0xc2, 0x18, 0x32, 0xea, 0x6e, 0x5f, 0x3d, 0x3e, 0xeb, 0xe4, 0x1f, 0xbd, + 0xbd, 0xfa, 0x6f, 0xcc, 0x3e, 0xe7, 0x3a, 0xea, 0xd8, 0x2f, 0xf1, 0xf5, 0x39, 0x00, 0x00, 0xff, + 0xff, 0xef, 0x01, 0x2a, 0xaa, 0x5a, 0x02, 0x00, 0x00, +} + +func (m *Admin) 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 *Admin) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Admin) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintAdmin(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0x3a + } + if m.VestingCounter != 0 { + i = encodeVarintAdmin(dAtA, i, uint64(m.VestingCounter)) + i-- + dAtA[i] = 0x30 + } + if m.LastVestingTime != 0 { + i = encodeVarintAdmin(dAtA, i, uint64(m.LastVestingTime)) + i-- + dAtA[i] = 0x28 + } + if m.VestingPeriodsCount != 0 { + i = encodeVarintAdmin(dAtA, i, uint64(m.VestingPeriodsCount)) + i-- + dAtA[i] = 0x20 + } + { + size, err := m.RewardPerPeriod.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAdmin(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if m.VestingPeriod != 0 { + i = encodeVarintAdmin(dAtA, i, uint64(m.VestingPeriod)) + i-- + dAtA[i] = 0x10 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintAdmin(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintAdmin(dAtA []byte, offset int, v uint64) int { + offset -= sovAdmin(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Admin) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovAdmin(uint64(l)) + } + if m.VestingPeriod != 0 { + n += 1 + sovAdmin(uint64(m.VestingPeriod)) + } + l = m.RewardPerPeriod.Size() + n += 1 + l + sovAdmin(uint64(l)) + if m.VestingPeriodsCount != 0 { + n += 1 + sovAdmin(uint64(m.VestingPeriodsCount)) + } + if m.LastVestingTime != 0 { + n += 1 + sovAdmin(uint64(m.LastVestingTime)) + } + if m.VestingCounter != 0 { + n += 1 + sovAdmin(uint64(m.VestingCounter)) + } + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovAdmin(uint64(l)) + } + return n +} + +func sovAdmin(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozAdmin(x uint64) (n int) { + return sovAdmin(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Admin) 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 ErrIntOverflowAdmin + } + 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: Admin: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Admin: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAdmin + } + 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 ErrInvalidLengthAdmin + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAdmin + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field VestingPeriod", wireType) + } + m.VestingPeriod = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAdmin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.VestingPeriod |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardPerPeriod", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAdmin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAdmin + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAdmin + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.RewardPerPeriod.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field VestingPeriodsCount", wireType) + } + m.VestingPeriodsCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAdmin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.VestingPeriodsCount |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LastVestingTime", wireType) + } + m.LastVestingTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAdmin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LastVestingTime |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field VestingCounter", wireType) + } + m.VestingCounter = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAdmin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.VestingCounter |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAdmin + } + 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 ErrInvalidLengthAdmin + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAdmin + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAdmin(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAdmin + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipAdmin(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAdmin + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAdmin + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAdmin + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthAdmin + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupAdmin + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthAdmin + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthAdmin = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowAdmin = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupAdmin = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/accumulator/types/codec.go b/x/accumulator/types/codec.go index 332b0ba26..701626015 100644 --- a/x/accumulator/types/codec.go +++ b/x/accumulator/types/codec.go @@ -3,6 +3,8 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" ) func RegisterCodec(cdc *codec.LegacyAmino) { @@ -10,6 +12,15 @@ func RegisterCodec(cdc *codec.LegacyAmino) { } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { - // this line is used by starport scaffolding # 3 + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgAddAdmin{}, + ) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } + +var ( + Amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) +) diff --git a/x/accumulator/types/errors.go b/x/accumulator/types/errors.go index 131e81fae..ca8f02b75 100644 --- a/x/accumulator/types/errors.go +++ b/x/accumulator/types/errors.go @@ -10,4 +10,6 @@ import ( var ( ErrInvalidPool = sdkerrors.Register(ModuleName, 1100, "invalid pool address") ErrInvalidReceiver = sdkerrors.Register(ModuleName, 1101, "invalid receiver address") + ErrForbidden = sdkerrors.Register(ModuleName, 1102, "permission denied") + ErrAdminExists = sdkerrors.Register(ModuleName, 1103, "admin already exists") ) diff --git a/x/accumulator/types/genesis.pb.go b/x/accumulator/types/genesis.pb.go index 935761bfb..078f2b7eb 100644 --- a/x/accumulator/types/genesis.pb.go +++ b/x/accumulator/types/genesis.pb.go @@ -23,9 +23,10 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// GenesisState defines the bruhaccumulator module's genesis state. +// GenesisState defines the accumulator module's genesis state. type GenesisState struct { - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + Admins []Admin `protobuf:"bytes,2,rep,name=admins,proto3" json:"admins"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -68,26 +69,36 @@ func (m *GenesisState) GetParams() Params { return Params{} } +func (m *GenesisState) GetAdmins() []Admin { + if m != nil { + return m.Admins + } + return nil +} + func init() { - proto.RegisterType((*GenesisState)(nil), "accumulator.GenesisState") + proto.RegisterType((*GenesisState)(nil), "cosmos.accumulator.GenesisState") } func init() { proto.RegisterFile("cosmos/accumulator/genesis.proto", fileDescriptor_67273f269329c5bf) } var fileDescriptor_67273f269329c5bf = []byte{ - // 191 bytes of a gzipped FileDescriptorProto + // 232 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x48, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0xd6, 0x4f, 0x4c, 0x4e, 0x2e, 0xcd, 0x2d, 0xcd, 0x49, 0x2c, 0xc9, 0x2f, 0xd2, 0x4f, - 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x46, 0x92, - 0x92, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x8b, 0xeb, 0x83, 0x58, 0x10, 0x25, 0x52, 0xf2, 0x58, - 0x0c, 0x29, 0x48, 0x2c, 0x4a, 0xcc, 0x85, 0x9a, 0xa1, 0xe4, 0xc8, 0xc5, 0xe3, 0x0e, 0x31, 0x34, - 0xb8, 0x24, 0xb1, 0x24, 0x55, 0xc8, 0x90, 0x8b, 0x0d, 0x22, 0x2f, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, - 0x6d, 0x24, 0xac, 0x87, 0xa4, 0x55, 0x2f, 0x00, 0x2c, 0xe5, 0xc4, 0x72, 0xe2, 0x9e, 0x3c, 0x43, - 0x10, 0x54, 0xa1, 0x93, 0xd7, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, - 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x19, - 0xa4, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x43, 0x1d, 0x02, 0xa1, 0x74, - 0x8b, 0x53, 0xb2, 0xf5, 0x2b, 0x50, 0x5c, 0x55, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x76, - 0x95, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x38, 0xf8, 0x5d, 0xf3, 0xfd, 0x00, 0x00, 0x00, + 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x82, 0xa8, + 0xd0, 0x43, 0x52, 0x21, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x96, 0xd6, 0x07, 0xb1, 0x20, 0x2a, + 0xa5, 0xe4, 0xb1, 0x98, 0x55, 0x90, 0x58, 0x94, 0x98, 0x0b, 0x35, 0x4a, 0x4a, 0x0e, 0x8b, 0x82, + 0xc4, 0x94, 0xdc, 0xcc, 0x3c, 0x88, 0xbc, 0x52, 0x23, 0x23, 0x17, 0x8f, 0x3b, 0xc4, 0xf2, 0xe0, + 0x92, 0xc4, 0x92, 0x54, 0x21, 0x0b, 0x2e, 0x36, 0x88, 0x01, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0xdc, + 0x46, 0x52, 0x7a, 0x98, 0x8e, 0xd1, 0x0b, 0x00, 0xab, 0x70, 0x62, 0x39, 0x71, 0x4f, 0x9e, 0x21, + 0x08, 0xaa, 0x5e, 0xc8, 0x9c, 0x8b, 0x0d, 0x6c, 0x72, 0xb1, 0x04, 0x93, 0x02, 0xb3, 0x06, 0xb7, + 0x91, 0x24, 0x36, 0x9d, 0x8e, 0x20, 0x15, 0x30, 0x8d, 0x10, 0xe5, 0x4e, 0x5e, 0x27, 0x1e, 0xc9, + 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, + 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0x65, 0x90, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, + 0x9c, 0x9f, 0xab, 0x0f, 0xf5, 0x08, 0x84, 0xd2, 0x2d, 0x4e, 0xc9, 0xd6, 0xaf, 0x40, 0xf1, 0x55, + 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x5b, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xd6, 0x66, 0xbb, 0x7d, 0x65, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -110,6 +121,20 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Admins) > 0 { + for iNdEx := len(m.Admins) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Admins[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } { size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -142,6 +167,12 @@ func (m *GenesisState) Size() (n int) { _ = l l = m.Params.Size() n += 1 + l + sovGenesis(uint64(l)) + if len(m.Admins) > 0 { + for _, e := range m.Admins { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -213,6 +244,40 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Admins", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Admins = append(m.Admins, Admin{}) + if err := m.Admins[len(m.Admins)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/accumulator/types/keys_accumulator.go b/x/accumulator/types/keys_accumulator.go new file mode 100644 index 000000000..c0a858951 --- /dev/null +++ b/x/accumulator/types/keys_accumulator.go @@ -0,0 +1,24 @@ +package types + +import ( + "encoding/binary" +) + +var _ binary.ByteOrder + +const ( + // AdminKeyPrefix is the prefix to retrieve all admin + AdminKeyPrefix = "admin/value/" +) + +// AdminKey returns the store key to retrieve an admin from the index fields +func AdminKey( + address string, +) []byte { + var key []byte + + key = append(key, []byte(address)...) + key = append(key, []byte("/")...) + + return key +} diff --git a/x/accumulator/types/message_add_admin.go b/x/accumulator/types/message_add_admin.go new file mode 100644 index 000000000..0e34d12c0 --- /dev/null +++ b/x/accumulator/types/message_add_admin.go @@ -0,0 +1,66 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const ( + TypeAddAdmin = "send" +) + +var _ sdk.Msg = &MsgAddAdmin{} + +func NewMsgAddAdmin(creator, denom, address string, rewardPerPeriod sdk.Coin, vestingPeriodsCount int64, vestingPeriod int64) *MsgAddAdmin { + return &MsgAddAdmin{ + Creator: creator, + RewardPerPeriod: rewardPerPeriod, + Address: address, + VestingPeriodsCount: vestingPeriodsCount, + VestingPeriod: vestingPeriod, + Denom: denom, + } +} + +func (msg *MsgAddAdmin) Route() string { + return RouterKey +} + +func (msg *MsgAddAdmin) Type() string { + return TypeAddAdmin +} + +func (msg *MsgAddAdmin) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgAddAdmin) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgAddAdmin) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + + _, err = sdk.AccAddressFromBech32(msg.Address) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid account address (%s)", err) + } + + if msg.VestingPeriod <= 0 { + return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, "invalid vesting period") + } + + if msg.VestingPeriodsCount <= 0 { + return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, "invalid vesting period count") + } + + return nil +} diff --git a/x/accumulator/types/params.pb.go b/x/accumulator/types/params.pb.go index f9a4f35f6..64c41ea3b 100644 --- a/x/accumulator/types/params.pb.go +++ b/x/accumulator/types/params.pb.go @@ -26,6 +26,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the module. type Params struct { + MasterAdmin string `protobuf:"bytes,1,opt,name=master_admin,json=masterAdmin,proto3" json:"master_admin,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -61,25 +62,34 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo +func (m *Params) GetMasterAdmin() string { + if m != nil { + return m.MasterAdmin + } + return "" +} + func init() { - proto.RegisterType((*Params)(nil), "accumulator.Params") + proto.RegisterType((*Params)(nil), "cosmos.accumulator.Params") } func init() { proto.RegisterFile("cosmos/accumulator/params.proto", fileDescriptor_87854f734092a833) } var fileDescriptor_87854f734092a833 = []byte{ - // 165 bytes of a gzipped FileDescriptorProto + // 197 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0xd6, 0x4f, 0x4c, 0x4e, 0x2e, 0xcd, 0x2d, 0xcd, 0x49, 0x2c, 0xc9, 0x2f, 0xd2, 0x2f, - 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x46, 0x92, 0x91, - 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x8b, 0xeb, 0x83, 0x58, 0x10, 0x25, 0x52, 0xd2, 0xe9, 0xf9, - 0xf9, 0xe9, 0x39, 0xa9, 0xfa, 0x60, 0x5e, 0x52, 0x69, 0x9a, 0x7e, 0x6a, 0x6e, 0x41, 0x49, 0x25, - 0x44, 0x52, 0x89, 0x83, 0x8b, 0x2d, 0x00, 0x6c, 0x9e, 0x93, 0xd7, 0x89, 0x47, 0x72, 0x8c, 0x17, - 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, - 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x19, 0xa4, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, - 0xea, 0x43, 0xdd, 0x03, 0xa1, 0x74, 0x8b, 0x53, 0xb2, 0xf5, 0x2b, 0x50, 0x1c, 0x57, 0x52, 0x59, - 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x36, 0xdc, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x69, 0xa4, 0xbf, - 0x96, 0xbf, 0x00, 0x00, 0x00, + 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x82, 0x28, 0xd0, + 0x43, 0x52, 0x20, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x96, 0xd6, 0x07, 0xb1, 0x20, 0x2a, 0xa5, + 0xa4, 0xd3, 0xf3, 0xf3, 0xd3, 0x73, 0x52, 0xf5, 0xc1, 0xbc, 0xa4, 0xd2, 0x34, 0xfd, 0xd4, 0xdc, + 0x82, 0x92, 0x4a, 0x88, 0xa4, 0x92, 0x36, 0x17, 0x5b, 0x00, 0xd8, 0x58, 0x21, 0x45, 0x2e, 0x9e, + 0xdc, 0xc4, 0xe2, 0x92, 0xd4, 0xa2, 0xf8, 0xc4, 0x94, 0xdc, 0xcc, 0x3c, 0x09, 0x46, 0x05, 0x46, + 0x0d, 0xce, 0x20, 0x6e, 0x88, 0x98, 0x23, 0x48, 0xc8, 0xc9, 0xeb, 0xc4, 0x23, 0x39, 0xc6, 0x0b, + 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, + 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x0c, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, + 0xf5, 0xa1, 0x2e, 0x87, 0x50, 0xba, 0xc5, 0x29, 0xd9, 0xfa, 0x15, 0x28, 0xde, 0x28, 0xa9, 0x2c, + 0x48, 0x2d, 0x4e, 0x62, 0x03, 0xdb, 0x6f, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xa1, 0xaf, 0xe4, + 0x5b, 0xe9, 0x00, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -102,6 +112,13 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.MasterAdmin) > 0 { + i -= len(m.MasterAdmin) + copy(dAtA[i:], m.MasterAdmin) + i = encodeVarintParams(dAtA, i, uint64(len(m.MasterAdmin))) + i-- + dAtA[i] = 0xa + } return len(dAtA) - i, nil } @@ -122,6 +139,10 @@ func (m *Params) Size() (n int) { } var l int _ = l + l = len(m.MasterAdmin) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } return n } @@ -160,6 +181,38 @@ func (m *Params) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MasterAdmin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MasterAdmin = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/accumulator/types/query.pb.go b/x/accumulator/types/query.pb.go index 8fa61500b..6f079858d 100644 --- a/x/accumulator/types/query.pb.go +++ b/x/accumulator/types/query.pb.go @@ -114,33 +114,33 @@ func (m *QueryParamsResponse) GetParams() Params { } func init() { - proto.RegisterType((*QueryParamsRequest)(nil), "accumulator.QueryParamsRequest") - proto.RegisterType((*QueryParamsResponse)(nil), "accumulator.QueryParamsResponse") + proto.RegisterType((*QueryParamsRequest)(nil), "cosmos.accumulator.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "cosmos.accumulator.QueryParamsResponse") } func init() { proto.RegisterFile("cosmos/accumulator/query.proto", fileDescriptor_c7a2f9753e81ed3a) } var fileDescriptor_c7a2f9753e81ed3a = []byte{ - // 296 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x90, 0xb1, 0x4e, 0xc3, 0x30, - 0x10, 0x86, 0x63, 0x04, 0x1d, 0xdc, 0xcd, 0xed, 0x80, 0x2a, 0xe4, 0x54, 0x91, 0x10, 0x08, 0xa9, - 0x31, 0x29, 0x6f, 0xd0, 0x09, 0x31, 0x41, 0x47, 0x36, 0x27, 0x58, 0x26, 0xa2, 0xc9, 0xb9, 0xb1, - 0x83, 0x28, 0x23, 0xbc, 0x00, 0x12, 0x2f, 0xd5, 0xb1, 0x12, 0x0b, 0x13, 0x42, 0x09, 0x0f, 0x82, - 0x1a, 0x7b, 0x68, 0x44, 0x98, 0x12, 0xfd, 0xf7, 0xdd, 0x77, 0x77, 0xc6, 0x34, 0x01, 0x9d, 0x81, - 0x66, 0x3c, 0x49, 0xca, 0xac, 0x5c, 0x70, 0x03, 0x05, 0x5b, 0x96, 0xa2, 0x58, 0x85, 0xaa, 0x00, - 0x03, 0xa4, 0xbf, 0x53, 0x18, 0x0d, 0x25, 0x48, 0x68, 0x72, 0xb6, 0xfd, 0xb3, 0xc8, 0xe8, 0x48, - 0x02, 0xc8, 0x85, 0x60, 0x5c, 0xa5, 0x8c, 0xe7, 0x39, 0x18, 0x6e, 0x52, 0xc8, 0xb5, 0xab, 0x9e, - 0xb9, 0x01, 0x31, 0xd7, 0xc2, 0x9a, 0xd9, 0x63, 0x14, 0x0b, 0xc3, 0x23, 0xa6, 0xb8, 0x4c, 0xf3, - 0x06, 0x76, 0xac, 0xdf, 0xb1, 0x8c, 0xe2, 0x05, 0xcf, 0x9c, 0x2c, 0x18, 0x62, 0x72, 0xb3, 0x55, - 0x5c, 0x37, 0xe1, 0x5c, 0x2c, 0x4b, 0xa1, 0x4d, 0x70, 0x89, 0x07, 0xad, 0x54, 0x2b, 0xc8, 0xb5, - 0x20, 0x11, 0xee, 0xd9, 0xe6, 0x43, 0x34, 0x46, 0xa7, 0xfd, 0xe9, 0x20, 0xdc, 0xf1, 0x86, 0x16, - 0x9e, 0xed, 0xaf, 0xbf, 0x7c, 0x6f, 0xee, 0xc0, 0xe9, 0x2b, 0xc2, 0x07, 0x8d, 0x8a, 0x3c, 0xe3, - 0x9e, 0x25, 0x88, 0xdf, 0x6a, 0xfb, 0x3b, 0x7e, 0x34, 0xfe, 0x1f, 0xb0, 0x9b, 0x04, 0x93, 0x97, - 0x8f, 0x9f, 0xf7, 0xbd, 0x13, 0x72, 0xcc, 0xdc, 0x81, 0xf6, 0x33, 0xd1, 0x77, 0x0f, 0x1d, 0xb7, - 0xce, 0xae, 0xd6, 0x15, 0x45, 0x9b, 0x8a, 0xa2, 0xef, 0x8a, 0xa2, 0xb7, 0x9a, 0x7a, 0x9b, 0x9a, - 0x7a, 0x9f, 0x35, 0xf5, 0x6e, 0xcf, 0x65, 0x6a, 0xee, 0xcb, 0x38, 0x4c, 0x20, 0xeb, 0x50, 0x3d, - 0xb5, 0x64, 0x66, 0xa5, 0x84, 0x8e, 0x7b, 0xcd, 0xc3, 0x5d, 0xfc, 0x06, 0x00, 0x00, 0xff, 0xff, - 0x9b, 0xa4, 0xde, 0x90, 0xe8, 0x01, 0x00, 0x00, + // 300 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x90, 0x31, 0x4f, 0xc3, 0x30, + 0x10, 0x85, 0x63, 0x04, 0x1d, 0xcc, 0x66, 0x3a, 0xa0, 0x08, 0xb9, 0x28, 0x12, 0x14, 0x21, 0x35, + 0xa6, 0x65, 0x61, 0xee, 0xc8, 0x02, 0x74, 0x64, 0x73, 0x82, 0x65, 0x22, 0x9a, 0x9c, 0x1b, 0x3b, + 0x88, 0xae, 0x4c, 0x8c, 0x08, 0xfe, 0x54, 0xc7, 0x4a, 0x2c, 0x4c, 0x08, 0x25, 0xfc, 0x10, 0x54, + 0xdb, 0x03, 0x55, 0x23, 0x31, 0xd9, 0xba, 0xf7, 0xdd, 0xbb, 0x77, 0x87, 0x69, 0x0a, 0x3a, 0x07, + 0xcd, 0x78, 0x9a, 0x56, 0x79, 0x35, 0xe5, 0x06, 0x4a, 0x36, 0xab, 0x44, 0x39, 0x8f, 0x55, 0x09, + 0x06, 0x08, 0x71, 0x7a, 0xfc, 0x47, 0x0f, 0xbb, 0x12, 0x24, 0x58, 0x99, 0xad, 0x7e, 0x8e, 0x0c, + 0x0f, 0x24, 0x80, 0x9c, 0x0a, 0xc6, 0x55, 0xc6, 0x78, 0x51, 0x80, 0xe1, 0x26, 0x83, 0x42, 0x7b, + 0xf5, 0xd4, 0xcf, 0x49, 0xb8, 0x16, 0x6e, 0x00, 0x7b, 0x1c, 0x26, 0xc2, 0xf0, 0x21, 0x53, 0x5c, + 0x66, 0x85, 0x85, 0x3d, 0xdb, 0x6b, 0xc9, 0xa4, 0x78, 0xc9, 0x73, 0x6f, 0x16, 0x75, 0x31, 0xb9, + 0x59, 0x59, 0x5c, 0xdb, 0xe2, 0x44, 0xcc, 0x2a, 0xa1, 0x4d, 0x74, 0x85, 0xf7, 0xd6, 0xaa, 0x5a, + 0x41, 0xa1, 0x05, 0xb9, 0xc0, 0x1d, 0xd7, 0xbc, 0x8f, 0x0e, 0xd1, 0xc9, 0xee, 0x28, 0x8c, 0x37, + 0x57, 0x8a, 0x5d, 0xcf, 0x78, 0x7b, 0xf1, 0xd5, 0x0b, 0x26, 0x9e, 0x1f, 0xbd, 0x21, 0xbc, 0x63, + 0x1d, 0xc9, 0x0b, 0xc2, 0x1d, 0x87, 0x90, 0xe3, 0xb6, 0xf6, 0xcd, 0x34, 0x61, 0xff, 0x5f, 0xce, + 0xe5, 0x8b, 0x06, 0xcf, 0x1f, 0x3f, 0xef, 0x5b, 0x7d, 0x72, 0xc4, 0xfc, 0xda, 0xee, 0x19, 0xe8, + 0xbb, 0x87, 0x96, 0x0b, 0x8c, 0x2f, 0x17, 0x35, 0x45, 0xcb, 0x9a, 0xa2, 0xef, 0x9a, 0xa2, 0xd7, + 0x86, 0x06, 0xcb, 0x86, 0x06, 0x9f, 0x0d, 0x0d, 0x6e, 0xcf, 0x64, 0x66, 0xee, 0xab, 0x24, 0x4e, + 0x21, 0x6f, 0xb1, 0x7a, 0x5a, 0x33, 0x33, 0x73, 0x25, 0x74, 0xd2, 0xb1, 0xe7, 0x3c, 0xff, 0x0d, + 0x00, 0x00, 0xff, 0xff, 0x9b, 0x6e, 0xe7, 0x89, 0x05, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -169,7 +169,7 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { out := new(QueryParamsResponse) - err := c.cc.Invoke(ctx, "/accumulator.Query/Params", in, out, opts...) + err := c.cc.Invoke(ctx, "/cosmos.accumulator.Query/Params", in, out, opts...) if err != nil { return nil, err } @@ -204,7 +204,7 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/accumulator.Query/Params", + FullMethod: "/cosmos.accumulator.Query/Params", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) @@ -213,7 +213,7 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf } var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "accumulator.Query", + ServiceName: "cosmos.accumulator.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ { diff --git a/x/accumulator/types/tx.pb.go b/x/accumulator/types/tx.pb.go index 2a2ad51c0..7999fa5de 100644 --- a/x/accumulator/types/tx.pb.go +++ b/x/accumulator/types/tx.pb.go @@ -6,14 +6,18 @@ package types import ( context "context" fmt "fmt" - _ "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" _ "google.golang.org/protobuf/types/known/emptypb" + io "io" math "math" + math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. @@ -27,23 +31,160 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +type MsgAddAdmin struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + RewardPerPeriod types.Coin `protobuf:"bytes,3,opt,name=reward_per_period,json=rewardPerPeriod,proto3" json:"reward_per_period"` + VestingPeriodsCount int64 `protobuf:"varint,4,opt,name=vesting_periods_count,json=vestingPeriodsCount,proto3" json:"vesting_periods_count,omitempty"` + Denom string `protobuf:"bytes,5,opt,name=denom,proto3" json:"denom,omitempty"` + VestingPeriod int64 `protobuf:"varint,6,opt,name=vesting_period,json=vestingPeriod,proto3" json:"vesting_period,omitempty"` +} + +func (m *MsgAddAdmin) Reset() { *m = MsgAddAdmin{} } +func (m *MsgAddAdmin) String() string { return proto.CompactTextString(m) } +func (*MsgAddAdmin) ProtoMessage() {} +func (*MsgAddAdmin) Descriptor() ([]byte, []int) { + return fileDescriptor_afd031c57abc8350, []int{0} +} +func (m *MsgAddAdmin) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAddAdmin) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAddAdmin.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 *MsgAddAdmin) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAddAdmin.Merge(m, src) +} +func (m *MsgAddAdmin) XXX_Size() int { + return m.Size() +} +func (m *MsgAddAdmin) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAddAdmin.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgAddAdmin proto.InternalMessageInfo + +func (m *MsgAddAdmin) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgAddAdmin) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *MsgAddAdmin) GetRewardPerPeriod() types.Coin { + if m != nil { + return m.RewardPerPeriod + } + return types.Coin{} +} + +func (m *MsgAddAdmin) GetVestingPeriodsCount() int64 { + if m != nil { + return m.VestingPeriodsCount + } + return 0 +} + +func (m *MsgAddAdmin) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +func (m *MsgAddAdmin) GetVestingPeriod() int64 { + if m != nil { + return m.VestingPeriod + } + return 0 +} + +type MsgAddAdminResponse struct { +} + +func (m *MsgAddAdminResponse) Reset() { *m = MsgAddAdminResponse{} } +func (m *MsgAddAdminResponse) String() string { return proto.CompactTextString(m) } +func (*MsgAddAdminResponse) ProtoMessage() {} +func (*MsgAddAdminResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_afd031c57abc8350, []int{1} +} +func (m *MsgAddAdminResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAddAdminResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAddAdminResponse.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 *MsgAddAdminResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAddAdminResponse.Merge(m, src) +} +func (m *MsgAddAdminResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgAddAdminResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAddAdminResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgAddAdminResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgAddAdmin)(nil), "cosmos.accumulator.MsgAddAdmin") + proto.RegisterType((*MsgAddAdminResponse)(nil), "cosmos.accumulator.MsgAddAdminResponse") +} + func init() { proto.RegisterFile("cosmos/accumulator/tx.proto", fileDescriptor_afd031c57abc8350) } var fileDescriptor_afd031c57abc8350 = []byte{ - // 202 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4e, 0xce, 0x2f, 0xce, - 0xcd, 0x2f, 0xd6, 0x4f, 0x4c, 0x4e, 0x2e, 0xcd, 0x2d, 0xcd, 0x49, 0x2c, 0xc9, 0x2f, 0xd2, 0x2f, - 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x46, 0x12, 0x95, 0x12, 0x49, 0xcf, 0x4f, - 0xcf, 0x07, 0x8b, 0xeb, 0x83, 0x58, 0x10, 0x25, 0x52, 0x32, 0xe9, 0xf9, 0xf9, 0xe9, 0x39, 0xa9, - 0xfa, 0x89, 0x05, 0x99, 0xfa, 0x89, 0x79, 0x79, 0xf9, 0x25, 0x89, 0x25, 0x99, 0xf9, 0x79, 0xc5, - 0x50, 0x59, 0x69, 0xa8, 0x2c, 0x98, 0x97, 0x54, 0x9a, 0xa6, 0x9f, 0x9a, 0x5b, 0x50, 0x52, 0x09, - 0x95, 0x94, 0x83, 0x5a, 0x9d, 0x94, 0x58, 0x9c, 0xaa, 0x5f, 0x66, 0x98, 0x94, 0x5a, 0x92, 0x68, - 0xa8, 0x9f, 0x9c, 0x9f, 0x99, 0x07, 0x91, 0x37, 0x62, 0xe5, 0x62, 0xf6, 0x2d, 0x4e, 0x77, 0xf2, - 0x3a, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, - 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0x83, 0xf4, 0xcc, 0x92, 0x8c, - 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0xa8, 0x59, 0x10, 0x4a, 0xb7, 0x38, 0x25, 0x5b, 0xbf, - 0x02, 0xd5, 0x4f, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0x93, 0x8d, 0x01, 0x01, 0x00, 0x00, - 0xff, 0xff, 0x77, 0xb7, 0xca, 0x3d, 0xf6, 0x00, 0x00, 0x00, + // 392 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xc1, 0x6e, 0x13, 0x31, + 0x10, 0x86, 0xd7, 0xa4, 0x2d, 0xe0, 0x0a, 0x10, 0x6e, 0x2b, 0x2d, 0x29, 0xda, 0x46, 0x95, 0x10, + 0xb9, 0x60, 0xd3, 0xf0, 0x04, 0x6d, 0x6f, 0xa0, 0x4a, 0xd1, 0x8a, 0x13, 0x1c, 0x22, 0xef, 0xda, + 0x18, 0x8b, 0xac, 0x67, 0x65, 0x7b, 0x43, 0xf2, 0x16, 0x3c, 0x56, 0x8e, 0x39, 0x72, 0x42, 0x28, + 0x79, 0x10, 0xd0, 0xae, 0x1d, 0x94, 0x88, 0x43, 0x0f, 0xab, 0xf5, 0xaf, 0x6f, 0xe6, 0x9f, 0xf1, + 0x8c, 0xf1, 0x79, 0x09, 0xae, 0x02, 0xc7, 0x78, 0x59, 0x36, 0x55, 0x33, 0xe5, 0x1e, 0x2c, 0xf3, + 0x73, 0x5a, 0x5b, 0xf0, 0x40, 0x48, 0x80, 0x74, 0x07, 0xf6, 0x4f, 0x15, 0x28, 0xe8, 0x30, 0x6b, + 0x4f, 0x21, 0xb2, 0xff, 0x52, 0x01, 0xa8, 0xa9, 0x64, 0xbc, 0xd6, 0x8c, 0x1b, 0x03, 0x9e, 0x7b, + 0x0d, 0xc6, 0x45, 0x7a, 0x1e, 0x69, 0xa7, 0x8a, 0xe6, 0x0b, 0x93, 0x55, 0xed, 0x17, 0x11, 0x66, + 0xb1, 0x83, 0x82, 0x3b, 0xc9, 0x66, 0x57, 0x85, 0xf4, 0xfc, 0x8a, 0x95, 0xa0, 0x4d, 0xe0, 0x97, + 0x7f, 0x10, 0x3e, 0xbe, 0x73, 0xea, 0x5a, 0x88, 0x6b, 0x51, 0x69, 0x43, 0x52, 0xfc, 0xb0, 0xb4, + 0xb2, 0xed, 0x25, 0x45, 0x03, 0x34, 0x7c, 0x9c, 0x6f, 0x65, 0x4b, 0xb8, 0x10, 0x56, 0x3a, 0x97, + 0x3e, 0x08, 0x24, 0x4a, 0xf2, 0x01, 0x3f, 0xb7, 0xf2, 0x3b, 0xb7, 0x62, 0x52, 0x4b, 0xdb, 0x7e, + 0x1a, 0x44, 0xda, 0x1b, 0xa0, 0xe1, 0xf1, 0xe8, 0x05, 0x8d, 0x97, 0x6c, 0xeb, 0xd3, 0x58, 0x9f, + 0xde, 0x82, 0x36, 0x37, 0x07, 0xcb, 0x5f, 0x17, 0x49, 0xfe, 0x2c, 0x64, 0x8e, 0xa5, 0x1d, 0x77, + 0x79, 0x64, 0x84, 0xcf, 0x66, 0xd2, 0x79, 0x6d, 0x54, 0x74, 0x72, 0x93, 0x12, 0x1a, 0xe3, 0xd3, + 0x83, 0x01, 0x1a, 0xf6, 0xf2, 0x93, 0x08, 0x43, 0xb4, 0xbb, 0x6d, 0x11, 0x39, 0xc5, 0x87, 0x42, + 0x1a, 0xa8, 0xd2, 0xc3, 0xae, 0xb1, 0x20, 0xc8, 0x2b, 0xfc, 0x74, 0xdf, 0x29, 0x3d, 0xea, 0x2c, + 0x9e, 0xec, 0x59, 0x5c, 0x9e, 0xe1, 0x93, 0x9d, 0x01, 0xe4, 0xd2, 0xd5, 0x60, 0x9c, 0x1c, 0x7d, + 0xc6, 0xbd, 0x3b, 0xa7, 0xc8, 0x47, 0xfc, 0xe8, 0xdf, 0x6c, 0x2e, 0xe8, 0xff, 0x1b, 0xa3, 0x3b, + 0xb9, 0xfd, 0xd7, 0xf7, 0x04, 0x6c, 0xcd, 0x6f, 0xde, 0x2f, 0xd7, 0x19, 0x5a, 0xad, 0x33, 0xf4, + 0x7b, 0x9d, 0xa1, 0x1f, 0x9b, 0x2c, 0x59, 0x6d, 0xb2, 0xe4, 0xe7, 0x26, 0x4b, 0x3e, 0xbd, 0x55, + 0xda, 0x7f, 0x6d, 0x0a, 0x5a, 0x42, 0xc5, 0xe2, 0xea, 0xc2, 0xef, 0x8d, 0x13, 0xdf, 0xd8, 0x7c, + 0xff, 0x25, 0x2d, 0x6a, 0xe9, 0x8a, 0xa3, 0x6e, 0x91, 0xef, 0xfe, 0x06, 0x00, 0x00, 0xff, 0xff, + 0xe4, 0xc6, 0xc4, 0x93, 0x6c, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -58,6 +199,7 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { + AddAdmin(ctx context.Context, in *MsgAddAdmin, opts ...grpc.CallOption) (*MsgAddAdminResponse, error) } type msgClient struct { @@ -68,22 +210,553 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } +func (c *msgClient) AddAdmin(ctx context.Context, in *MsgAddAdmin, opts ...grpc.CallOption) (*MsgAddAdminResponse, error) { + out := new(MsgAddAdminResponse) + err := c.cc.Invoke(ctx, "/cosmos.accumulator.Msg/AddAdmin", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { + AddAdmin(context.Context, *MsgAddAdmin) (*MsgAddAdminResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. type UnimplementedMsgServer struct { } +func (*UnimplementedMsgServer) AddAdmin(ctx context.Context, req *MsgAddAdmin) (*MsgAddAdminResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddAdmin not implemented") +} + func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } +func _Msg_AddAdmin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgAddAdmin) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).AddAdmin(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.accumulator.Msg/AddAdmin", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).AddAdmin(ctx, req.(*MsgAddAdmin)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "accumulator.Msg", + ServiceName: "cosmos.accumulator.Msg", HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{}, - Metadata: "cosmos/accumulator/tx.proto", + Methods: []grpc.MethodDesc{ + { + MethodName: "AddAdmin", + Handler: _Msg_AddAdmin_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "cosmos/accumulator/tx.proto", +} + +func (m *MsgAddAdmin) 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 *MsgAddAdmin) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAddAdmin) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.VestingPeriod != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.VestingPeriod)) + i-- + dAtA[i] = 0x30 + } + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintTx(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0x2a + } + if m.VestingPeriodsCount != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.VestingPeriodsCount)) + i-- + dAtA[i] = 0x20 + } + { + size, err := m.RewardPerPeriod.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) + 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 *MsgAddAdminResponse) 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 *MsgAddAdminResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAddAdminResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgAddAdmin) 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.Address) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.RewardPerPeriod.Size() + n += 1 + l + sovTx(uint64(l)) + if m.VestingPeriodsCount != 0 { + n += 1 + sovTx(uint64(m.VestingPeriodsCount)) + } + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.VestingPeriod != 0 { + n += 1 + sovTx(uint64(m.VestingPeriod)) + } + return n +} + +func (m *MsgAddAdminResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgAddAdmin) 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: MsgAddAdmin: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgAddAdmin: 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 Address", 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.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardPerPeriod", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.RewardPerPeriod.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field VestingPeriodsCount", wireType) + } + m.VestingPeriodsCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.VestingPeriodsCount |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", 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.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field VestingPeriod", wireType) + } + m.VestingPeriod = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.VestingPeriod |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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 *MsgAddAdminResponse) 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: MsgAddAdminResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgAddAdminResponse: 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 skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/nft/abci.go b/x/nft/abci.go index 7491221e8..3e95377f1 100644 --- a/x/nft/abci.go +++ b/x/nft/abci.go @@ -11,9 +11,8 @@ import ( // update vesting state for each nft func EndBlocker(ctx sdk.Context, k keeper.Keeper) { defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) - for _, nft := range k.GetAllNFT(ctx) { - if nft.LastVestingTime-ctx.BlockTime().Unix() < nft.VestingPeriod { + if ctx.BlockTime().Unix()-nft.LastVestingTime < nft.VestingPeriod { return } diff --git a/x/nft/client/cli/query_derive_address.go b/x/nft/client/cli/query_derive_address.go index 5529c0a1a..ae5cced11 100644 --- a/x/nft/client/cli/query_derive_address.go +++ b/x/nft/client/cli/query_derive_address.go @@ -12,14 +12,14 @@ func CmdDerivePoolAddress() *cobra.Command { Use: "derive-pool", Short: "Derive pool addressess", RunE: func(cmd *cobra.Command, args []string) error { + fmt.Printf("Pool %s address: %s\n", "nft 1", keeper.GetPoolAddress("1").String()) + fmt.Printf("Pool %s address: %s\n", "nft 2", keeper.GetPoolAddress("2").String()) + fmt.Printf("Pool %s address: %s\n", "nft 3", keeper.GetPoolAddress("3").String()) return nil }, } - fmt.Printf("Pool %s address: %s\n", "nft 1", keeper.GetPoolAddress("1").String()) - fmt.Printf("Pool %s address: %s\n", "nft 2", keeper.GetPoolAddress("2").String()) - fmt.Printf("Pool %s address: %s\n", "nft 3", keeper.GetPoolAddress("3").String()) flags.AddQueryFlagsToCmd(cmd) return cmd diff --git a/x/nft/module.go b/x/nft/module.go index 594ee96c8..92663c54b 100644 --- a/x/nft/module.go +++ b/x/nft/module.go @@ -154,6 +154,7 @@ func (AppModule) ConsensusVersion() uint64 { return 1 } func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} // EndBlock contains the logic that is automatically triggered at the end of each block -func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { +func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + EndBlocker(ctx, am.keeper) return []abci.ValidatorUpdate{} }