diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 07ab0dbb0..4a9c5d0f9 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -100,8 +100,6 @@ import ( ibc_hooks "github.com/notional-labs/composable/v6/x/ibc-hooks" ibchookskeeper "github.com/notional-labs/composable/v6/x/ibc-hooks/keeper" ibchookstypes "github.com/notional-labs/composable/v6/x/ibc-hooks/types" - - customstakingtypes "github.com/notional-labs/composable/v6/custom/staking/types" ) const ( @@ -187,15 +185,15 @@ func (appKeepers *AppKeepers) InitNormalKeepers( appCodec, appKeepers.keys[stakingtypes.StoreKey], appKeepers.AccountKeeper, appKeepers.BankKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) - appKeepers.CustomStakingKeeper = customstaking.NewBaseKeeper2( - appCodec, appKeepers.keys[customstakingtypes.StoreKey], *appKeepers.StakingKeeper, appKeepers.AccountKeeper, 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.CustomStakingKeeper = customstaking.NewKeeper( + appCodec /*appKeepers.keys[stakingtypes.StoreKey],*/, *appKeepers.StakingKeeper, appKeepers.AccountKeeper, &appKeepers.MintKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + appKeepers.DistrKeeper = distrkeeper.NewKeeper( appCodec, appKeepers.keys[distrtypes.StoreKey], appKeepers.AccountKeeper, appKeepers.BankKeeper, appKeepers.StakingKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String(), diff --git a/app/keepers/keys.go b/app/keepers/keys.go index 5151ca7a2..464b3dcc0 100644 --- a/app/keepers/keys.go +++ b/app/keepers/keys.go @@ -41,8 +41,7 @@ import ( "github.com/CosmWasm/wasmd/x/wasm" wasm08types "github.com/cosmos/ibc-go/v7/modules/light-clients/08-wasm/types" - - customstakingtypes "github.com/notional-labs/composable/v6/custom/staking/types" + // customstakingtypes "github.com/notional-labs/composable/v6/custom/staking/types" ) // GenerateKeys generates new keys (KV Store, Transient store, and memory store). @@ -54,7 +53,7 @@ func (appKeepers *AppKeepers) GenerateKeys() { govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey, icqtypes.StoreKey, capabilitytypes.StoreKey, consensusparamtypes.StoreKey, wasm08types.StoreKey, crisistypes.StoreKey, routertypes.StoreKey, transfermiddlewaretypes.StoreKey, group.StoreKey, minttypes.StoreKey, wasm.StoreKey, ibchookstypes.StoreKey, icahosttypes.StoreKey, ratelimitmoduletypes.StoreKey, txBoundaryTypes.StoreKey, - authzkeeper.StoreKey, customstakingtypes.StoreKey, + authzkeeper.StoreKey, /*customstakingtypes.StoreKey,*/ ) // Define transient store keys diff --git a/custom/staking/keeper/keeper.go b/custom/staking/keeper/keeper.go index f8235f3d1..33c843e4d 100644 --- a/custom/staking/keeper/keeper.go +++ b/custom/staking/keeper/keeper.go @@ -2,25 +2,20 @@ package keeper import ( "github.com/cosmos/cosmos-sdk/codec" - storetypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" accountkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" - "github.com/cosmos/cosmos-sdk/x/staking/types" - customstakingtypes "github.com/notional-labs/composable/v6/custom/staking/types" + mintkeeper "github.com/notional-labs/composable/v6/x/mint/keeper" ) type Keeper struct { stakingkeeper.Keeper - cdc codec.BinaryCodec - storeKey storetypes.StoreKey - acck accountkeeper.AccountKeeper - authority string + cdc codec.BinaryCodec + acck accountkeeper.AccountKeeper + mintkeeper *mintkeeper.Keeper + authority string } -var _ stakingkeeper.Keeper = stakingkeeper.Keeper{} //??? - // func NewBaseKeeper( // cdc codec.BinaryCodec, // key storetypes.StoreKey, @@ -36,17 +31,19 @@ var _ stakingkeeper.Keeper = stakingkeeper.Keeper{} //??? // return keeper // } -func NewBaseKeeper2( +func NewKeeper( cdc codec.BinaryCodec, - keys storetypes.StoreKey, staking stakingkeeper.Keeper, acck accountkeeper.AccountKeeper, + mintkeeper *mintkeeper.Keeper, authority string, ) Keeper { keeper := Keeper{ - Keeper: staking, - acck: acck, - authority: authority, + Keeper: staking, + acck: acck, + authority: authority, + mintkeeper: mintkeeper, + cdc: cdc, } return keeper } @@ -55,10 +52,10 @@ func NewBaseKeeper2( // k.acck = sk // } -func (k Keeper) StoreDelegation(ctx sdk.Context, delegation types.Delegation) { - delegatorAddress := sdk.MustAccAddressFromBech32(delegation.DelegatorAddress) +// func (k Keeper) StoreDelegation(ctx sdk.Context, delegation types.Delegation) { +// delegatorAddress := sdk.MustAccAddressFromBech32(delegation.DelegatorAddress) - store := ctx.KVStore(k.storeKey) - b := types.MustMarshalDelegation(k.cdc, delegation) - store.Set(customstakingtypes.GetDelegationKey(delegatorAddress, delegation.GetValidatorAddr()), b) -} +// store := ctx.KVStore(k.storeKey) +// b := types.MustMarshalDelegation(k.cdc, delegation) +// store.Set(customstakingtypes.GetDelegationKey(delegatorAddress, delegation.GetValidatorAddr()), b) +// } diff --git a/custom/staking/keeper/msg_server.go b/custom/staking/keeper/msg_server.go index 059076959..d3ba7396a 100644 --- a/custom/staking/keeper/msg_server.go +++ b/custom/staking/keeper/msg_server.go @@ -3,8 +3,8 @@ package keeper import ( "context" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -16,8 +16,8 @@ type msgServer struct { var _ types.MsgServer = msgServer{} -func NewMsgServerImpl(stakingKeeper stakingkeeper.Keeper) types.MsgServer { - return &msgServer{msgServer: stakingkeeper.NewMsgServerImpl(&stakingKeeper)} +func NewMsgServerImpl(stakingKeeper stakingkeeper.Keeper, customstakingkeeper Keeper) types.MsgServer { + return &msgServer{Keeper: customstakingkeeper, msgServer: stakingkeeper.NewMsgServerImpl(&stakingKeeper)} } func (k msgServer) CreateValidator(goCtx context.Context, msg *types.MsgCreateValidator) (*types.MsgCreateValidatorResponse, error) { @@ -32,19 +32,19 @@ func (k msgServer) Delegate(goCtx context.Context, msg *types.MsgDelegate) (*typ ctx := sdk.UnwrapSDKContext(goCtx) - bondDenom := k.BondDenom(ctx) - if msg.Amount.Denom != bondDenom { - return nil, sdkerrors.Wrapf( - sdkerrors.ErrInvalidRequest, "invalid coin denomination: got %s, expected %s", msg.Amount.Denom, bondDenom, - ) - } - - delegation := types.Delegation{ - DelegatorAddress: msg.DelegatorAddress, - ValidatorAddress: msg.ValidatorAddress, - Shares: msg.Amount.Amount.ToLegacyDec(), - } - k.StoreDelegation(ctx, delegation) + // bondDenom := k.BondDenom(ctx) + // if msg.Amount.Denom != bondDenom { + // return nil, sdkerrors.Wrapf( + // sdkerrors.ErrInvalidRequest, "invalid coin denomination: got %s, expected %s", msg.Amount.Denom, bondDenom, + // ) + // } + + // delegation := types.Delegation{ + // DelegatorAddress: msg.DelegatorAddress, + // ValidatorAddress: msg.ValidatorAddress, + // Shares: msg.Amount.Amount.ToLegacyDec(), + // } + k.mintkeeper.SetLastTotalPower(ctx, math.Int{}) return &types.MsgDelegateResponse{}, nil // return nil, fmt.Errorf("My custom error: Nikita") diff --git a/custom/staking/module.go b/custom/staking/module.go index 5697a6a58..6f982554b 100644 --- a/custom/staking/module.go +++ b/custom/staking/module.go @@ -37,7 +37,7 @@ func NewAppModule(cdc codec.Codec, keeper customstakingkeeper.Keeper, accountKee // when trying to force this custom keeper into a bankkeeper.BaseKeeper func (am AppModule) RegisterServices(cfg module.Configurator) { // types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(&am.keeper)) - types.RegisterMsgServer(cfg.MsgServer(), customstakingkeeper.NewMsgServerImpl(am.keeper.Keeper)) + types.RegisterMsgServer(cfg.MsgServer(), customstakingkeeper.NewMsgServerImpl(am.keeper.Keeper, am.keeper)) querier := keeper.Querier{Keeper: &am.keeper.Keeper} types.RegisterQueryServer(cfg.QueryServer(), querier) diff --git a/custom/staking/types/keeper_interfaces.go b/custom/staking/types/keeper_interfaces.go new file mode 100644 index 000000000..0907289a7 --- /dev/null +++ b/custom/staking/types/keeper_interfaces.go @@ -0,0 +1,10 @@ +package types + +import ( + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type MintKeeper interface { + SetLastTotalPower(ctx sdk.Context, power math.Int) +} diff --git a/custom/staking/types/keys.go b/custom/staking/types/keys.go deleted file mode 100644 index 507171b5b..000000000 --- a/custom/staking/types/keys.go +++ /dev/null @@ -1,39 +0,0 @@ -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{0x37} // key for a delegation -) - -const ( - // module name - ModuleName = "customstaking" - - // 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" -) - -var () - -// 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/go.mod b/go.mod index 622f00df1..3a2ff703b 100644 --- a/go.mod +++ b/go.mod @@ -304,8 +304,8 @@ require ( github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect github.com/tendermint/go-amino v0.16.0 // indirect github.com/tidwall/btree v1.6.0 // indirect - github.com/zondax/hid v0.9.1 // indirect - github.com/zondax/ledger-go v0.14.1 // indirect + github.com/zondax/hid v0.9.2 // indirect + github.com/zondax/ledger-go v0.14.3 // indirect go.etcd.io/bbolt v1.3.7 // indirect golang.org/x/crypto v0.11.0 // indirect golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb // indirect @@ -331,6 +331,9 @@ replace ( // ibc-go with wasm client github.com/cosmos/ibc-go/v7 => github.com/notional-labs/ibc-go/v7 v7.2.1-0.20231010040541-6cf43006971f + github.com/cosmos/ledger-cosmos-go => github.com/cosmos/ledger-cosmos-go v0.12.4 + github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 github.com/terra-money/alliance => github.com/notional-labs/alliance v1.0.1-0.20231106184124-5cc1ff759647 + github.com/zondax/ledger-go => github.com/zondax/ledger-go v0.14.3 ) diff --git a/go.sum b/go.sum index 214a6f8a1..d108453da 100644 --- a/go.sum +++ b/go.sum @@ -387,8 +387,8 @@ github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZD github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 h1:DdzS1m6o/pCqeZ8VOAit/gyATedRgjvkVI+UCrLpyuU= github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76/go.mod h1:0mkLWIoZuQ7uBoospo5Q9zIpqq6rYCPJDSUdeCJvPM8= -github.com/cosmos/ledger-cosmos-go v0.12.2 h1:/XYaBlE2BJxtvpkHiBm97gFGSGmYGKunKyF3nNqAXZA= -github.com/cosmos/ledger-cosmos-go v0.12.2/go.mod h1:ZcqYgnfNJ6lAXe4HPtWgarNEY+B74i+2/8MhZw4ziiI= +github.com/cosmos/ledger-cosmos-go v0.12.4 h1:drvWt+GJP7Aiw550yeb3ON/zsrgW0jgh5saFCr7pDnw= +github.com/cosmos/ledger-cosmos-go v0.12.4/go.mod h1:fjfVWRf++Xkygt9wzCsjEBdjcf7wiiY35fv3ctT+k4M= github.com/cosmos/rosetta-sdk-go v0.10.0 h1:E5RhTruuoA7KTIXUcMicL76cffyeoyvNybzUGSKFTcM= github.com/cosmos/rosetta-sdk-go v0.10.0/go.mod h1:SImAZkb96YbwvoRkzSMQB6noNJXFgWl/ENIznEoYQI4= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= @@ -1257,10 +1257,10 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/zondax/hid v0.9.1 h1:gQe66rtmyZ8VeGFcOpbuH3r7erYtNEAezCAYu8LdkJo= -github.com/zondax/hid v0.9.1/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= -github.com/zondax/ledger-go v0.14.1 h1:Pip65OOl4iJ84WTpA4BKChvOufMhhbxED3BaihoZN4c= -github.com/zondax/ledger-go v0.14.1/go.mod h1:fZ3Dqg6qcdXWSOJFKMG8GCTnD7slO/RL2feOQv8K320= +github.com/zondax/hid v0.9.2 h1:WCJFnEDMiqGF64nlZz28E9qLVZ0KSJ7xpc5DLEyma2U= +github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= +github.com/zondax/ledger-go v0.14.3 h1:wEpJt2CEcBJ428md/5MgSLsXLBos98sBOyxNmCjfUCw= +github.com/zondax/ledger-go v0.14.3/go.mod h1:IKKaoxupuB43g4NxeQmbLXv7T9AlQyie1UpHb342ycI= gitlab.com/bosi/decorder v0.2.3 h1:gX4/RgK16ijY8V+BRQHAySfQAb354T7/xQpDB2n10P0= gitlab.com/bosi/decorder v0.2.3/go.mod h1:9K1RB5+VPNQYtXtTDAzd2OEftsZb1oV0IrJrzChSdGE= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= diff --git a/proto/buf.gen.gogo.yaml b/proto/buf.gen.gogo.yaml old mode 100644 new mode 100755 diff --git a/proto/buf.yaml b/proto/buf.yaml old mode 100644 new mode 100755 diff --git a/proto/centauri/mint/v1beta1/genesis.proto b/proto/centauri/mint/v1beta1/genesis.proto index a30271a06..f984181b3 100644 --- a/proto/centauri/mint/v1beta1/genesis.proto +++ b/proto/centauri/mint/v1beta1/genesis.proto @@ -19,4 +19,11 @@ message GenesisState { (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin", (gogoproto.nullable) = false ]; + + // last_total_power tracks the total amounts of bonded tokens recorded during + // the previous end block. + bytes last_total_power = 4 [ + (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 70ff6ddf3..0b9d0fa65 100644 --- a/x/mint/keeper/keeper.go +++ b/x/mint/keeper/keeper.go @@ -9,6 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/notional-labs/composable/v6/x/mint/types" ) @@ -153,3 +154,21 @@ func (k Keeper) MintCoins(ctx sdk.Context, newCoins sdk.Coins) error { func (k Keeper) AddCollectedFees(ctx sdk.Context, fees sdk.Coins) error { return k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, k.feeCollectorName, fees) } + +func (k Keeper) StoreDelegation(ctx sdk.Context, delegation stakingtypes.Delegation) { + delegatorAddress := sdk.MustAccAddressFromBech32(delegation.DelegatorAddress) + log := k.Logger(ctx) + log.Info("StoreDelegation", "delegatorAddress", delegatorAddress, "validatorAddress", delegation.GetValidatorAddr()) + store := ctx.KVStore(k.storeKey) + b := stakingtypes.MustMarshalDelegation(k.cdc, delegation) + kkk := types.GetDelegationKey(delegatorAddress, delegation.GetValidatorAddr()) + // log.Info() + store.Set(kkk, b) +} + +// 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) +} diff --git a/x/mint/keeper/msg_server.go b/x/mint/keeper/msg_server.go index 4feafae33..7290c5b8d 100644 --- a/x/mint/keeper/msg_server.go +++ b/x/mint/keeper/msg_server.go @@ -4,6 +4,7 @@ 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" @@ -42,6 +43,9 @@ func (ms msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdatePara func (ms msgServer) FundModuleAccount(goCtx context.Context, req *types.MsgFundModuleAccount) (*types.MsgFundModuleAccountResponse, error) { // Unwrap context ctx := sdk.UnwrapSDKContext(goCtx) + + ms.SetLastTotalPower(ctx, math.Int{}) + return nil, errorsmod.Wrapf(types.ErrInvalidAddress, "Custom error: nikita") // Check sender address sender, err := sdk.AccAddressFromBech32(req.FromAddress) if err != nil { diff --git a/x/mint/simulation/decoder.go b/x/mint/simulation/decoder.go index c8128bcfc..2d1ee4a9e 100644 --- a/x/mint/simulation/decoder.go +++ b/x/mint/simulation/decoder.go @@ -8,6 +8,8 @@ import ( "github.com/cosmos/cosmos-sdk/types/kv" "github.com/notional-labs/composable/v6/x/mint/types" + + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) // NewDecodeStore returns a decoder function closure that unmarshals the KVPair's @@ -23,6 +25,14 @@ func NewDecodeStore(cdc codec.Codec) func(kvA, kvB kv.Pair) string { cdc.MustUnmarshal(kvB.Value, &minterB) return fmt.Sprintf("%v\n%v", minterA, minterB) + case bytes.Equal(kvA.Key[:1], types.DelegationKey): + var delegationA, delegationB stakingtypes.Delegation + + cdc.MustUnmarshal(kvA.Value, &delegationA) + cdc.MustUnmarshal(kvB.Value, &delegationB) + + return fmt.Sprintf("%v\n%v", delegationA, delegationB) + // case bytes.Equal(kvA.Key[:1], types.ParamsKey): // var paramsA, paramsB types.Params // cdc.MustUnmarshal(kvA.Value, ¶msA) diff --git a/x/mint/types/genesis.pb.go b/x/mint/types/genesis.pb.go index 4c2486d24..93b5c6d44 100644 --- a/x/mint/types/genesis.pb.go +++ b/x/mint/types/genesis.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" @@ -31,6 +32,9 @@ type GenesisState struct { // params defines all the paramaters of the module. Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` IncentivesSupply types.Coin `protobuf:"bytes,3,opt,name=incentives_supply,json=incentivesSupply,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coin" json:"incentives_supply"` + // 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,4,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{} } @@ -96,26 +100,29 @@ func init() { } var fileDescriptor_dc8b577617211e57 = []byte{ - // 296 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x90, 0x3f, 0x4e, 0xc3, 0x30, - 0x14, 0x87, 0xe3, 0x82, 0x3a, 0x84, 0x0e, 0x10, 0x81, 0x14, 0x2a, 0xe1, 0x56, 0x20, 0x01, 0x0b, - 0xb6, 0x0a, 0x23, 0x5b, 0x18, 0x98, 0x90, 0x50, 0xbb, 0xb1, 0x20, 0x27, 0x58, 0xc1, 0x82, 0xd8, - 0x56, 0x9e, 0x53, 0xe8, 0xc8, 0x0d, 0x38, 0x07, 0x27, 0xe9, 0xd8, 0x91, 0x09, 0x50, 0x72, 0x11, - 0x64, 0x3b, 0x2d, 0x4b, 0xc5, 0x64, 0x4b, 0xef, 0xfb, 0x7e, 0xef, 0x4f, 0x78, 0x94, 0x71, 0x69, - 0x58, 0x55, 0x0a, 0x5a, 0x08, 0x69, 0xe8, 0x74, 0x94, 0x72, 0xc3, 0x46, 0x34, 0xe7, 0x92, 0x83, - 0x00, 0xa2, 0x4b, 0x65, 0x54, 0xb4, 0xb7, 0x84, 0x88, 0x85, 0x48, 0x0b, 0xf5, 0x77, 0x73, 0x95, - 0x2b, 0x47, 0x50, 0xfb, 0xf3, 0x70, 0x7f, 0xb8, 0x3e, 0xd1, 0x99, 0x9e, 0xc0, 0x99, 0x82, 0x42, - 0x01, 0x4d, 0x19, 0xf0, 0x55, 0x3d, 0x53, 0x42, 0xfa, 0xfa, 0xe1, 0x5b, 0x27, 0xec, 0x5d, 0xfb, - 0x01, 0x26, 0x86, 0x19, 0x1e, 0x5d, 0x86, 0x5d, 0xab, 0xf3, 0x32, 0x46, 0x43, 0x74, 0xba, 0x75, - 0x7e, 0x40, 0xd6, 0x0e, 0x44, 0x6e, 0x1c, 0x94, 0x6c, 0xce, 0xbf, 0x06, 0xc1, 0xb8, 0x55, 0xac, - 0xac, 0x59, 0xc9, 0x0a, 0x88, 0x3b, 0xff, 0xca, 0xb7, 0x0e, 0x5a, 0xca, 0x5e, 0x89, 0x5e, 0xc2, - 0x1d, 0x21, 0x2d, 0x2f, 0xa6, 0x1c, 0xee, 0xa1, 0xd2, 0xfa, 0x79, 0x16, 0x6f, 0xb8, 0x9c, 0x7d, - 0xe2, 0xd7, 0x20, 0x76, 0x8d, 0x55, 0xca, 0x95, 0x12, 0x32, 0xa1, 0x36, 0xe3, 0xe3, 0x7b, 0x70, - 0x92, 0x0b, 0xf3, 0x58, 0xa5, 0x24, 0x53, 0x05, 0x6d, 0x77, 0xf6, 0xcf, 0x19, 0x3c, 0x3c, 0x51, - 0x33, 0xd3, 0x1c, 0x9c, 0x30, 0xde, 0xfe, 0x6b, 0x32, 0x71, 0x3d, 0x92, 0xe3, 0x79, 0x8d, 0xd1, - 0xa2, 0xc6, 0xe8, 0xa7, 0xc6, 0xe8, 0xbd, 0xc1, 0xc1, 0xa2, 0xc1, 0xc1, 0x67, 0x83, 0x83, 0xbb, - 0xde, 0xab, 0x3f, 0xac, 0xd3, 0xd3, 0xae, 0x3b, 0xd9, 0xc5, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, - 0x7c, 0x38, 0xd2, 0x82, 0xc8, 0x01, 0x00, 0x00, + // 340 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0x41, 0x4b, 0xf3, 0x30, + 0x18, 0x80, 0xdb, 0x7d, 0x63, 0x87, 0x7e, 0x43, 0x66, 0x51, 0xa8, 0x03, 0xb3, 0xa1, 0x30, 0x77, + 0x31, 0x61, 0x7a, 0xf4, 0x56, 0x0f, 0xe2, 0x41, 0x18, 0x9b, 0x07, 0xf1, 0x32, 0xd2, 0x1a, 0x6a, + 0x70, 0x4d, 0x4a, 0xf3, 0x6e, 0x73, 0xff, 0xc2, 0xdf, 0xe1, 0x2f, 0xd9, 0x71, 0x47, 0x51, 0x98, + 0xb2, 0xfd, 0x11, 0x49, 0xd2, 0xcd, 0xcb, 0x10, 0x4f, 0x2d, 0xe4, 0x79, 0x9e, 0xe4, 0xe5, 0xf5, + 0x8e, 0x63, 0x26, 0x80, 0x8e, 0x72, 0x4e, 0x52, 0x2e, 0x80, 0x8c, 0x3b, 0x11, 0x03, 0xda, 0x21, + 0x09, 0x13, 0x4c, 0x71, 0x85, 0xb3, 0x5c, 0x82, 0xf4, 0xf7, 0xd7, 0x10, 0xd6, 0x10, 0x2e, 0xa0, + 0xfa, 0x5e, 0x22, 0x13, 0x69, 0x08, 0xa2, 0xff, 0x2c, 0x5c, 0x6f, 0x6e, 0x2f, 0x1a, 0xd3, 0x12, + 0x28, 0x96, 0x2a, 0x95, 0x8a, 0x44, 0x54, 0xb1, 0xcd, 0x79, 0x2c, 0xb9, 0xb0, 0xe7, 0x47, 0x1f, + 0x25, 0xaf, 0x7a, 0x65, 0x1f, 0xd0, 0x07, 0x0a, 0xcc, 0xbf, 0xf0, 0x2a, 0x5a, 0x67, 0x79, 0xe0, + 0x36, 0xdd, 0xf6, 0xff, 0xb3, 0x43, 0xbc, 0xf5, 0x41, 0xf8, 0xc6, 0x40, 0x61, 0x79, 0xb6, 0x68, + 0x38, 0xbd, 0x42, 0xd1, 0x72, 0x46, 0x73, 0x9a, 0xaa, 0xa0, 0xf4, 0xab, 0xdc, 0x35, 0xd0, 0x5a, + 0xb6, 0x8a, 0x3f, 0xf1, 0x76, 0xb9, 0xd0, 0x3c, 0x1f, 0x33, 0x35, 0x50, 0xa3, 0x2c, 0x1b, 0x4e, + 0x83, 0x7f, 0xa6, 0x73, 0x80, 0xed, 0x18, 0x58, 0x8f, 0xb1, 0xa9, 0x5c, 0x4a, 0x2e, 0x42, 0xa2, + 0x1b, 0xaf, 0x9f, 0x8d, 0x93, 0x84, 0xc3, 0xe3, 0x28, 0xc2, 0xb1, 0x4c, 0x49, 0x31, 0xb3, 0xfd, + 0x9c, 0xaa, 0x87, 0x27, 0x02, 0xd3, 0x8c, 0x29, 0x23, 0xf4, 0x6a, 0x3f, 0x97, 0xf4, 0xcd, 0x1d, + 0xfe, 0x9d, 0x57, 0x1b, 0x52, 0x05, 0x03, 0x90, 0x40, 0x87, 0x83, 0x4c, 0x4e, 0x58, 0x1e, 0x94, + 0x9b, 0x6e, 0xbb, 0x1a, 0x62, 0x1d, 0x7f, 0x5f, 0x34, 0x5a, 0x7f, 0x88, 0x5f, 0x0b, 0xe8, 0xed, + 0xe8, 0xce, 0xad, 0xce, 0x74, 0x75, 0x25, 0x6c, 0xcd, 0x96, 0xc8, 0x9d, 0x2f, 0x91, 0xfb, 0xb5, + 0x44, 0xee, 0xcb, 0x0a, 0x39, 0xf3, 0x15, 0x72, 0xde, 0x56, 0xc8, 0xb9, 0xaf, 0x3e, 0xdb, 0x95, + 0x19, 0x37, 0xaa, 0x98, 0x65, 0x9c, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, 0x51, 0x7e, 0xb8, 0x8b, + 0x22, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -138,6 +145,16 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = 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] = 0x22 { size, err := m.IncentivesSupply.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -194,6 +211,8 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) l = m.IncentivesSupply.Size() n += 1 + l + sovGenesis(uint64(l)) + l = m.LastTotalPower.Size() + n += 1 + l + sovGenesis(uint64(l)) return n } @@ -331,6 +350,39 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 4: + 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:]) diff --git a/x/mint/types/keys.go b/x/mint/types/keys.go index 4878b55d8..de93188e0 100644 --- a/x/mint/types/keys.go +++ b/x/mint/types/keys.go @@ -1,9 +1,15 @@ 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 ( MinterKey = []byte{0x00} AllowedAddressKey = []byte{0x01} + DelegationKey = []byte{0x02} // key for a delegation ) const ( @@ -25,3 +31,13 @@ const ( func GetAllowedAddressStoreKey(address string) []byte { return append(AllowedAddressKey, []byte(address)...) } + +// 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/types/parachain_token_info.pb.go b/x/transfermiddleware/types/parachain_token_info.pb.go index c20c80a58..222eee8df 100644 --- a/x/transfermiddleware/types/parachain_token_info.pb.go +++ b/x/transfermiddleware/types/parachain_token_info.pb.go @@ -28,7 +28,7 @@ var _ = time.Kitchen const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // ParachainIBCTokenInfo represents information about transferable IBC tokens -// from Parachain(Substrate based network). +// from Parachain. type ParachainIBCTokenInfo struct { // ibc_denom is the denomination of the ibced token transferred from the // dotsama chain.