diff --git a/app/app.go b/app/app.go index 05afd7af8..fc533d51a 100644 --- a/app/app.go +++ b/app/app.go @@ -355,16 +355,16 @@ func NewComposableApp( groupmodule.NewAppModule(appCodec, app.GroupKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), gov.NewAppModule(appCodec, &app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)), + transferModule, mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil), slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName)), distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)), - customstaking.NewAppModule(appCodec, *&app.CustomStakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)), + customstaking.NewAppModule(appCodec, *&app.CustomStakingKeeper, app.AccountKeeper, app.BankKeeper, app.MintKeeper, app.GetSubspace(stakingtypes.ModuleName)), authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), upgrade.NewAppModule(app.UpgradeKeeper), evidence.NewAppModule(app.EvidenceKeeper), ibc.NewAppModule(app.IBCKeeper), params.NewAppModule(app.ParamsKeeper), - transferModule, icqModule, ibcHooksModule, consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper), diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 7f1a3b94a..806ad84bd 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -185,13 +185,13 @@ func (appKeepers *AppKeepers) InitNormalKeepers( appCodec, appKeepers.keys[stakingtypes.StoreKey], appKeepers.AccountKeeper, appKeepers.BankKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) - appKeepers.CustomStakingKeeper = customstaking.NewBaseKeeper( - appCodec /*appKeepers.keys[customstakingtypes.StoreKey],*/, *appKeepers.StakingKeeper, appKeepers.AccountKeeper, appKeepers.MintKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) - appKeepers.MintKeeper = mintkeeper.NewKeeper( appCodec, appKeepers.keys[minttypes.StoreKey], appKeepers.StakingKeeper, - appKeepers.AccountKeeper, appKeepers.BankKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String(), + appKeepers.AccountKeeper, appKeepers.BankKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String(), &appKeepers.TransferMiddlewareKeeper, + ) + + appKeepers.CustomStakingKeeper = customstaking.NewBaseKeeper( + appCodec, appKeepers.keys[stakingtypes.StoreKey], *appKeepers.StakingKeeper, appKeepers.AccountKeeper, appKeepers.MintKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) appKeepers.DistrKeeper = distrkeeper.NewKeeper( diff --git a/custom/staking/keeper/keeper.go b/custom/staking/keeper/keeper.go index b9ce0df91..0d1d9a184 100644 --- a/custom/staking/keeper/keeper.go +++ b/custom/staking/keeper/keeper.go @@ -3,18 +3,18 @@ package keeper import ( "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" - accountkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + accountkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" mintkeeper "github.com/notional-labs/composable/v6/x/mint/keeper" ) type Keeper struct { stakingkeeper.Keeper + keys storetypes.StoreKey cdc codec.BinaryCodec - storeKey storetypes.StoreKey - acck accountkeeper.AccountKeeper mintkeeper mintkeeper.Keeper + acck accountkeeper.AccountKeeper authority string } @@ -35,7 +35,7 @@ type Keeper struct { func NewBaseKeeper( cdc codec.BinaryCodec, - // keys storetypes.StoreKey, + keys storetypes.StoreKey, staking stakingkeeper.Keeper, acck accountkeeper.AccountKeeper, mintkeeper mintkeeper.Keeper, @@ -43,6 +43,7 @@ func NewBaseKeeper( ) Keeper { keeper := Keeper{ Keeper: staking, + keys: keys, acck: acck, authority: authority, mintkeeper: mintkeeper, diff --git a/custom/staking/module.go b/custom/staking/module.go index 5697a6a58..e759d8f47 100644 --- a/custom/staking/module.go +++ b/custom/staking/module.go @@ -13,22 +13,25 @@ import ( // custombankkeeper "github.com/notional-labs/composable/v6/custom/bank/keeper" customstakingkeeper "github.com/notional-labs/composable/v6/custom/staking/keeper" + minttypes "github.com/notional-labs/composable/v6/custom/staking/types" ) // AppModule wraps around the bank module and the bank keeper to return the right total supply type AppModule struct { stakingmodule.AppModule - keeper customstakingkeeper.Keeper - subspace exported.Subspace + keeper customstakingkeeper.Keeper + mintkeeper minttypes.MintKeeper + subspace exported.Subspace } // NewAppModule creates a new AppModule object -func NewAppModule(cdc codec.Codec, keeper customstakingkeeper.Keeper, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, ss exported.Subspace) AppModule { +func NewAppModule(cdc codec.Codec, keeper customstakingkeeper.Keeper, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, mintkeeper minttypes.MintKeeper, ss exported.Subspace) AppModule { stakingModule := stakingmodule.NewAppModule(cdc, &keeper.Keeper, accountKeeper, bankKeeper, ss) return AppModule{ - AppModule: stakingModule, - keeper: keeper, - subspace: ss, + AppModule: stakingModule, + keeper: keeper, + mintkeeper: mintkeeper, + subspace: ss, } } diff --git a/proto/centauri/stakingmiddleware/v1beta1/genesis.proto b/proto/centauri/stakingmiddleware/v1beta1/genesis.proto new file mode 100644 index 000000000..84ddb87a0 --- /dev/null +++ b/proto/centauri/stakingmiddleware/v1beta1/genesis.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; +package centauri.stakingmiddleware.v1beta1; + +import "gogoproto/gogo.proto"; + +option go_package = "x/stakingmiddleware/types"; + +// GenesisState defines the stakingmiddleware module's genesis state. +message GenesisState { + // last_total_power tracks the total amounts of bonded tokens recorded during + // the previous end block. + bytes last_total_power = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; +} diff --git a/x/mint/keeper/keeper.go b/x/mint/keeper/keeper.go index 733844740..470899194 100644 --- a/x/mint/keeper/keeper.go +++ b/x/mint/keeper/keeper.go @@ -12,16 +12,18 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/notional-labs/composable/v6/x/mint/types" + transferMiddlewareKeeper "github.com/notional-labs/composable/v6/x/transfermiddleware/keeper" ) // Keeper of the mint store type Keeper struct { - cdc codec.BinaryCodec - storeKey storetypes.StoreKey - accountKeeper types.AccountKeeper - stakingKeeper types.StakingKeeper - bankKeeper types.BankKeeper - feeCollectorName string + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + accountKeeper types.AccountKeeper + stakingKeeper types.StakingKeeper + bankKeeper types.BankKeeper + transferMiddlewareKeeper *transferMiddlewareKeeper.Keeper + feeCollectorName string // the address capable of executing a MsgUpdateParams message. Typically, this // should be the x/gov module account. @@ -37,6 +39,7 @@ func NewKeeper( bk types.BankKeeper, feeCollectorName string, authority string, + transferMiddlewareKeeper *transferMiddlewareKeeper.Keeper, ) Keeper { // ensure mint module account is set if addr := ak.GetModuleAddress(types.ModuleName); addr == nil { @@ -44,12 +47,13 @@ func NewKeeper( } return Keeper{ - cdc: cdc, - storeKey: key, - stakingKeeper: sk, - bankKeeper: bk, - feeCollectorName: feeCollectorName, - authority: authority, + cdc: cdc, + storeKey: key, + stakingKeeper: sk, + bankKeeper: bk, + feeCollectorName: feeCollectorName, + authority: authority, + transferMiddlewareKeeper: transferMiddlewareKeeper, } } @@ -168,7 +172,12 @@ func (k Keeper) StoreDelegation(ctx sdk.Context, delegation stakingtypes.Delegat // SetLastTotalPower Set the last total validator power. func (k Keeper) SetLastTotalPower(ctx sdk.Context, power math.Int) { - // store := ctx.KVStore(k.storeKey) - // bz := k.cdc.MustMarshal(&sdk.IntProto{Int: power}) - // store.Set(types.DelegationKey, bz) + log := k.Logger(ctx) + log.Info("k.storeKey", k.storeKey) + log.Info("ctx", ctx) + fmt.Println("k.storeKey", k.storeKey) + fmt.Println("ctx", ctx) + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(&sdk.IntProto{Int: power}) + store.Set(types.DelegationKey, bz) } diff --git a/x/mint/keeper/msg_server.go b/x/mint/keeper/msg_server.go index 7290c5b8d..330a6e3e8 100644 --- a/x/mint/keeper/msg_server.go +++ b/x/mint/keeper/msg_server.go @@ -4,7 +4,6 @@ import ( "context" errorsmod "cosmossdk.io/errors" - "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" @@ -44,8 +43,11 @@ func (ms msgServer) FundModuleAccount(goCtx context.Context, req *types.MsgFundM // Unwrap context ctx := sdk.UnwrapSDKContext(goCtx) - ms.SetLastTotalPower(ctx, math.Int{}) - return nil, errorsmod.Wrapf(types.ErrInvalidAddress, "Custom error: nikita") + ms.transferMiddlewareKeeper.AddParachainIBCInfoToRemoveList(ctx, "pica") + + // ms.SetLastTotalPower(ctx, math.Int{}) + // return nil, errorsmod.Wrapf(types.ErrInvalidAddress, "Custom error: nikita") + return &types.MsgFundModuleAccountResponse{}, nil // Check sender address sender, err := sdk.AccAddressFromBech32(req.FromAddress) if err != nil { diff --git a/x/mint/module.go b/x/mint/module.go index 5205a408d..066ab27d0 100644 --- a/x/mint/module.go +++ b/x/mint/module.go @@ -89,6 +89,7 @@ type AppModule struct { keeper keeper.Keeper authKeeper types.AccountKeeper + // tfmk transferkeeper.Keeper // inflationCalculator is used to calculate the inflation rate during BeginBlock. // If inflationCalculator is nil, the default inflation calculation logic is used. @@ -102,9 +103,10 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak types.AccountKeeper, ic = types.DefaultInflationCalculationFn } return AppModule{ - AppModuleBasic: AppModuleBasic{cdc: cdc}, - keeper: keeper, - authKeeper: ak, + AppModuleBasic: AppModuleBasic{cdc: cdc}, + keeper: keeper, + authKeeper: ak, + // tfmk: transferMKeeper, inflationCalculator: ic, } } diff --git a/x/stakingmiddleware/types/genesis.pb.go b/x/stakingmiddleware/types/genesis.pb.go new file mode 100644 index 000000000..5aad5c330 --- /dev/null +++ b/x/stakingmiddleware/types/genesis.pb.go @@ -0,0 +1,321 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: centauri/stakingmiddleware/v1beta1/genesis.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines the stakingmiddleware module's genesis state. +type GenesisState struct { + // last_total_power tracks the total amounts of bonded tokens recorded during + // the previous end block. + LastTotalPower github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=last_total_power,json=lastTotalPower,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"last_total_power"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_1aa0bd912277c095, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func init() { + proto.RegisterType((*GenesisState)(nil), "centauri.stakingmiddleware.v1beta1.GenesisState") +} + +func init() { + proto.RegisterFile("centauri/stakingmiddleware/v1beta1/genesis.proto", fileDescriptor_1aa0bd912277c095) +} + +var fileDescriptor_1aa0bd912277c095 = []byte{ + // 229 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0x48, 0x4e, 0xcd, 0x2b, + 0x49, 0x2c, 0x2d, 0xca, 0xd4, 0x2f, 0x2e, 0x49, 0xcc, 0xce, 0xcc, 0x4b, 0xcf, 0xcd, 0x4c, 0x49, + 0xc9, 0x49, 0x2d, 0x4f, 0x2c, 0x4a, 0xd5, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x4f, + 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x52, 0x82, 0xe9, + 0xd0, 0xc3, 0xd0, 0xa1, 0x07, 0xd5, 0x21, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x56, 0xae, 0x0f, + 0x62, 0x41, 0x74, 0x2a, 0x65, 0x70, 0xf1, 0xb8, 0x43, 0x8c, 0x0a, 0x2e, 0x49, 0x2c, 0x49, 0x15, + 0x8a, 0xe0, 0x12, 0xc8, 0x49, 0x2c, 0x2e, 0x89, 0x2f, 0xc9, 0x2f, 0x49, 0xcc, 0x89, 0x2f, 0xc8, + 0x2f, 0x4f, 0x2d, 0x92, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x71, 0xd2, 0x3b, 0x71, 0x4f, 0x9e, 0xe1, + 0xd6, 0x3d, 0x79, 0xb5, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xfd, 0xe4, + 0xfc, 0xe2, 0xdc, 0xfc, 0x62, 0x28, 0xa5, 0x5b, 0x9c, 0x92, 0xad, 0x5f, 0x52, 0x59, 0x90, 0x5a, + 0xac, 0xe7, 0x99, 0x57, 0x12, 0xc4, 0x07, 0x32, 0x27, 0x04, 0x64, 0x4c, 0x00, 0xc8, 0x14, 0x27, + 0xe3, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, + 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x92, 0xac, 0xc0, 0xe2, 0x51, + 0xb0, 0x41, 0x49, 0x6c, 0x60, 0x57, 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x11, 0xb1, 0xd1, + 0x9a, 0x13, 0x01, 0x00, 0x00, +} + +func (m *GenesisState) 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 *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.LastTotalPower.Size() + i -= size + if _, err := m.LastTotalPower.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.LastTotalPower.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) 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 ErrIntOverflowGenesis + } + 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: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LastTotalPower", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.LastTotalPower.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(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, ErrIntOverflowGenesis + } + 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, ErrIntOverflowGenesis + } + 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, ErrIntOverflowGenesis + } + 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, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/stakingmiddleware/types/keys.go b/x/stakingmiddleware/types/keys.go new file mode 100644 index 000000000..5e459620f --- /dev/null +++ b/x/stakingmiddleware/types/keys.go @@ -0,0 +1,37 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/address" +) + +// MinterKey is the key to use for the keeper store. +var ( + DelegationKey = []byte{0x02} // key for a delegation +) + +const ( + // module name + ModuleName = "mint" + + // StoreKey is the default store key for mint + StoreKey = ModuleName + + // QuerierRoute is the querier route for the minting store. + QuerierRoute = StoreKey + + // Query endpoints supported by the minting querier + QueryParameters = "parameters" + QueryInflation = "inflation" + QueryAnnualProvisions = "annual_provisions" +) + +// GetDelegationKey creates the key for delegator bond with validator +// VALUE: staking/Delegation +func GetDelegationKey(delAddr sdk.AccAddress, valAddr sdk.ValAddress) []byte { + return append(GetDelegationsKey(delAddr), address.MustLengthPrefix(valAddr)...) +} + +func GetDelegationsKey(delAddr sdk.AccAddress) []byte { + return append(DelegationKey, address.MustLengthPrefix(delAddr)...) +} diff --git a/x/transfermiddleware/keeper/keeper.go b/x/transfermiddleware/keeper/keeper.go index 095f33dc0..2ec89048c 100644 --- a/x/transfermiddleware/keeper/keeper.go +++ b/x/transfermiddleware/keeper/keeper.go @@ -1,6 +1,7 @@ package keeper import ( + "fmt" "time" errorsmod "cosmossdk.io/errors" @@ -9,7 +10,6 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" @@ -92,14 +92,23 @@ func (keeper Keeper) AddParachainIBCInfo(ctx sdk.Context, ibcDenom, channelID, n // TODO: testing // AddParachainIBCInfoToRemoveList add parachain token information token to remove list. func (keeper Keeper) AddParachainIBCInfoToRemoveList(ctx sdk.Context, nativeDenom string) (time.Time, error) { - params := keeper.GetParams(ctx) + // params := keeper.GetParams(ctx) + log := keeper.Logger(ctx) + log.Info("k.storeKey", keeper.storeKey) + log.Info("ctx", ctx) + fmt.Println("k.storeKey", keeper.storeKey) + fmt.Println("ctx", ctx) + fmt.Println("k.storeKey", keeper) + fmt.Println("keeper", keeper) + log.Info("keeper", keeper) store := ctx.KVStore(keeper.storeKey) - if !store.Has(types.GetKeyParachainIBCTokenInfoByNativeDenom(nativeDenom)) { - return time.Time{}, errorsmod.Wrapf(sdkerrors.ErrKeyNotFound, "Token %v info not found", nativeDenom) - } + + // if !store.Has(types.GetKeyParachainIBCTokenInfoByNativeDenom(nativeDenom)) { + // return time.Time{}, errorsmod.Wrapf(sdkerrors.ErrKeyNotFound, "Token %v info not found", nativeDenom) + // } // Add to remove list - removeTime := ctx.BlockTime().Add(params.Duration) + removeTime := ctx.BlockTime() removeToken := types.RemoveParachainIBCTokenInfo{ NativeDenom: nativeDenom, RemoveTime: removeTime,