diff --git a/app/app.go b/app/app.go index c89eaf597..7e82d3e1a 100644 --- a/app/app.go +++ b/app/app.go @@ -1143,7 +1143,7 @@ func (a *App) ModuleAccountsPermissions() map[string][]string { func (a *App) registerUpgradeHandlers() { a.UpgradeKeeper.SetUpgradeHandler( tv4_0_0.UpgradeName, - tv4_0_0.CreateUpgradeHandler(a.mm, a.configurator, a.VaultKeeper, a.LockerKeeper, a.CollectorKeeper, a.LiquidationKeeper), + tv4_0_0.CreateUpgradeHandler(a.mm, a.configurator, a.VaultKeeper, a.LockerKeeper, a.CollectorKeeper, a.LiquidationKeeper, a.Rewardskeeper), ) // When a planned update height is reached, the old binary will panic diff --git a/app/upgrades/testnet/v4_0_0/upgrades.go b/app/upgrades/testnet/v4_0_0/upgrades.go index 8f3c51fbf..0bb47aa78 100644 --- a/app/upgrades/testnet/v4_0_0/upgrades.go +++ b/app/upgrades/testnet/v4_0_0/upgrades.go @@ -10,6 +10,9 @@ import ( locker "github.com/comdex-official/comdex/x/locker" lockerKeeper "github.com/comdex-official/comdex/x/locker/keeper" lockertypes "github.com/comdex-official/comdex/x/locker/types" + rewards "github.com/comdex-official/comdex/x/rewards" + rewardsKeeper "github.com/comdex-official/comdex/x/rewards/keeper" + rewardstypes "github.com/comdex-official/comdex/x/rewards/types" vault "github.com/comdex-official/comdex/x/vault" vaultKeeper "github.com/comdex-official/comdex/x/vault/keeper" @@ -28,6 +31,7 @@ func CreateUpgradeHandler( lockerKeeper lockerKeeper.Keeper, collectorKeeper collectorKeeper.Keeper, liquidationKeeper liquidationKeeper.Keeper, + rewardsKeeper rewardsKeeper.Keeper, ) upgradetypes.UpgradeHandler { return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { // This change is only for testnet upgrade @@ -35,6 +39,7 @@ func CreateUpgradeHandler( locker.InitGenesis(ctx, lockerKeeper, lockertypes.DefaultGenesisState()) collector.InitGenesis(ctx, collectorKeeper, collectortypes.DefaultGenesisState()) liquidation.InitGenesis(ctx, liquidationKeeper, liquidationtypes.DefaultGenesisState()) + rewards.InitGenesis(ctx, rewardsKeeper, rewardstypes.DefaultGenesisState()) newVM, err := mm.RunMigrations(ctx, configurator, fromVM) if err != nil { diff --git a/proto/comdex/rewards/v1beta1/genesis.proto b/proto/comdex/rewards/v1beta1/genesis.proto index 90ac09bec..915f4bf4f 100644 --- a/proto/comdex/rewards/v1beta1/genesis.proto +++ b/proto/comdex/rewards/v1beta1/genesis.proto @@ -3,10 +3,51 @@ package comdex.rewards.v1beta1; import "gogoproto/gogo.proto"; import "comdex/rewards/v1beta1/params.proto"; +import "comdex/rewards/v1beta1/rewards.proto"; +import "comdex/rewards/v1beta1/epochs.proto"; +import "comdex/rewards/v1beta1/gauge.proto"; option go_package = "github.com/comdex-official/comdex/x/rewards/types"; // GenesisState defines the rewards module's genesis state. message GenesisState { - Params params = 1 [(gogoproto.nullable) = false]; + repeated Internal_rewards internal_rewards = 1 [ + (gogoproto.moretags) = "yaml:\"internal_rewards\"", + (gogoproto.nullable) = false + ]; + repeated Locker_rewards_tracker locker_rewards_tracker = 2 [ + (gogoproto.moretags) = "yaml:\"locker_rewards_tracker\"", + (gogoproto.nullable) = false + ]; + repeated Vault_interest_tracker vault_interest_tracker = 3 [ + (gogoproto.moretags) = "yaml:\"vault_interest_tracker\"", + (gogoproto.nullable) = false + ]; + repeated Locker_external_rewards locker_external_rewards = 4 [ + (gogoproto.moretags) = "yaml:\"locker_external_rewards\"", + (gogoproto.nullable) = false + ]; + repeated Vault_external_rewards vault_external_rewards = 5 [ + (gogoproto.moretags) = "yaml:\"vault_external_rewards\"", + (gogoproto.nullable) = false + ]; + repeated uint64 appIDs = 6 [ + (gogoproto.moretags) = "yaml:\"vault_external_rewards\"" + ]; + repeated EpochInfo epochInfo = 7 [ + (gogoproto.moretags) = "yaml:\"epochInfo\"", + (gogoproto.nullable) = false + ]; + repeated Gauge gauge = 8 [ + (gogoproto.moretags) = "yaml:\"gauge\"", + (gogoproto.nullable) = false + ]; + repeated GaugeByTriggerDuration gaugeByTriggerDuration = 9 [ + (gogoproto.moretags) = "yaml:\"gaugeByTriggerDuration\"", + (gogoproto.nullable) = false + ]; + Params params = 10 [ + (gogoproto.moretags) = "yaml:\"params\"", + (gogoproto.nullable) = false + ]; } diff --git a/proto/comdex/rewards/v1beta1/rewards.proto b/proto/comdex/rewards/v1beta1/rewards.proto index d6058c140..ca079e33d 100644 --- a/proto/comdex/rewards/v1beta1/rewards.proto +++ b/proto/comdex/rewards/v1beta1/rewards.proto @@ -140,12 +140,6 @@ message Vault_external_rewards{ ]; } -// message WhitelistedAppIdsVault{ -// repeated uint64 whitelisted_app_mapping_ids_vaults = 1 [ -// (gogoproto.moretags) = "yaml:\"whitelisted_app_mapping_ids_vaults\"" -// ]; -// } - message EpochTime{ uint64 id = 1 [ (gogoproto.moretags) = "yaml:\"id\"" diff --git a/proto/comdex/vault/v1beta1/vault.proto b/proto/comdex/vault/v1beta1/vault.proto index 7f4edcc08..31556ba4d 100644 --- a/proto/comdex/vault/v1beta1/vault.proto +++ b/proto/comdex/vault/v1beta1/vault.proto @@ -57,30 +57,6 @@ message Vault { } -//user_address is the key -// message UserVaultAssetMapping { -// string owner = 1 [ -// (gogoproto.moretags) = "yaml:\"owner\"" -// ]; - -// repeated VaultToAppMapping user_vault_app = 2 [ -// (gogoproto.moretags) = "yaml:\"user_vault_app\"" -// ]; -// } - -// message VaultToAppMapping { -// uint64 app_id = 1; -// repeated ExtendedPairToVaultMapping user_extended_pair_vault = 2 [ -// (gogoproto.moretags) = "yaml:\"user_extended_pair_vault\"" -// ]; -// } -// message ExtendedPairToVaultMapping { -// uint64 extended_pair_id = 1; -// uint64 vault_id = 2 [ -// (gogoproto.moretags) = "yaml:\"vault_id\""]; - -// } - message OwnerAppExtendedPairVaultMappingData { string owner = 1 [ (gogoproto.moretags) = "yaml:\"owner\"" @@ -92,26 +68,6 @@ message OwnerAppExtendedPairVaultMappingData { } - -//app_id is the key -// message AppExtendedPairVaultMapping { -// uint64 app_id = 1 ; -// repeated ExtendedPairVaultMapping extended_pair_vaults = 2 [(gogoproto.moretags) = "yaml:\"extended_pair_vaults\""]; -// } - -// message ExtendedPairVaultMapping -// { -// uint64 extended_pair_id = 1 [(gogoproto.moretags) = "yaml:\"extended_pair_id\""]; -// repeated uint64 vault_ids = 2 [(gogoproto.moretags) = "yaml:\"vault_ids\""]; -// string token_minted_amount = 3[ -// (gogoproto.moretags) = "yaml:\"token_minted_amount\"", -// (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", -// (gogoproto.nullable) = false]; -// string collateral_locked_amount = 4[(gogoproto.moretags) = "yaml:\"collateral_locked_amount\"", -// (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", -// (gogoproto.nullable) = false]; -// } - message AppExtendedPairVaultMappingData { uint64 app_id = 1 ; diff --git a/x/collector/keeper/collector.go b/x/collector/keeper/collector.go index 7d60db2f4..45c50dc19 100644 --- a/x/collector/keeper/collector.go +++ b/x/collector/keeper/collector.go @@ -4,7 +4,6 @@ import ( "github.com/comdex-official/comdex/app/wasm/bindings" auctiontypes "github.com/comdex-official/comdex/x/auction/types" "github.com/comdex-official/comdex/x/collector/types" - collectortypes "github.com/comdex-official/comdex/x/collector/types" lockertypes "github.com/comdex-official/comdex/x/locker/types" rewardstypes "github.com/comdex-official/comdex/x/rewards/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -786,7 +785,7 @@ func (k Keeper) LockerIterateRewards(ctx sdk.Context, collectorLsr sdk.Dec, coll assetData, _ := k.GetAsset(ctx, assetID) newrewards := rewards.TruncateInt() if newrewards.GT(sdk.ZeroInt()) { - err = k.SendCoinFromModuleToModule(ctx, collectortypes.ModuleName, lockertypes.ModuleName, sdk.NewCoins(sdk.NewCoin(assetData.Denom, newrewards))) + err = k.SendCoinFromModuleToModule(ctx, types.ModuleName, lockertypes.ModuleName, sdk.NewCoins(sdk.NewCoin(assetData.Denom, newrewards))) if err != nil { continue } diff --git a/x/rewards/genesis.go b/x/rewards/genesis.go index f6d0aeb3e..8a2a3bd61 100644 --- a/x/rewards/genesis.go +++ b/x/rewards/genesis.go @@ -6,19 +6,68 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// InitGenesis initializes the capability 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 - k.SetParams(ctx, genState.Params) -} +func InitGenesis(ctx sdk.Context, k keeper.Keeper, state *types.GenesisState) { -// ExportGenesis returns the capability module's exported genesis. -func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { - genesis := types.DefaultGenesis() - genesis.Params = k.GetParams(ctx) + var ( + gaugeID uint64 = 0 + ) + + k.SetParams(ctx, state.Params) + + for _, item := range state.InternalRewards { + k.SetReward(ctx, item) + } + + for _, item := range state.LockerRewardsTracker { + k.SetLockerRewardTracker(ctx, item) + } + + for _, item := range state.VaultInterestTracker { + k.SetVaultInterestTracker(ctx, item) + + } + + for _, item := range state.LockerExternalRewards { + k.SetExternalRewardsLockers(ctx, item) + } - // this line is used by starport scaffolding # genesis/module/export + for _, item := range state.VaultExternalRewards { + k.SetExternalRewardVault(ctx, item) + } - return genesis + for _, item := range state.AppIDs { + k.SetAppByAppID(ctx, item) + } + + for _, item := range state.EpochInfo { + k.SetEpochInfoByDuration(ctx, item) + } + + for _, item := range state.Gauge { + if item.Id > gaugeID { + gaugeID = item.Id + } + k.SetGauge(ctx, item) + } + + for _, item := range state.GaugeByTriggerDuration { + k.SetGaugeIdsByTriggerDuration(ctx, item) + } + + k.SetGaugeID(ctx, gaugeID) +} + +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { + return types.NewGenesisState( + k.GetRewards(ctx), + k.GetAllLockerRewardTracker(ctx), + k.GetAllVaultInterestTracker(ctx), + k.GetExternalRewardsLockers(ctx), + k.GetExternalRewardVaults(ctx), + k.GetAppIDs(ctx), + k.GetAllEpochInfos(ctx), + k.GetAllGauges(ctx), + k.GetAllGaugeIdsByTriggerDuration(ctx), + k.GetParams(ctx), + ) } diff --git a/x/rewards/keeper/interest.go b/x/rewards/keeper/interest.go deleted file mode 100644 index b55569d4a..000000000 --- a/x/rewards/keeper/interest.go +++ /dev/null @@ -1 +0,0 @@ -package keeper diff --git a/x/rewards/keeper/rewards.go b/x/rewards/keeper/rewards.go index 7d4e70782..6a607fffe 100644 --- a/x/rewards/keeper/rewards.go +++ b/x/rewards/keeper/rewards.go @@ -451,6 +451,28 @@ func (k Keeper) GetLockerRewardTracker(ctx sdk.Context, id, appID uint64) (rewar return rewards, true } +func (k Keeper) GetAllLockerRewardTracker(ctx sdk.Context) (Lockrewards []types.LockerRewardsTracker) { + var ( + store = k.Store(ctx) + iter = sdk.KVStorePrefixIterator(store, types.LockerRewardsTrackerKeyPrefix) + ) + + defer func(iter sdk.Iterator) { + err := iter.Close() + if err != nil { + return + } + }(iter) + + for ; iter.Valid(); iter.Next() { + var rewards types.LockerRewardsTracker + k.cdc.MustUnmarshal(iter.Value(), &rewards) + Lockrewards = append(Lockrewards, rewards) + } + + return Lockrewards +} + func (k Keeper) SetVaultInterestTracker(ctx sdk.Context, vault types.VaultInterestTracker) { var ( store = k.Store(ctx) @@ -476,6 +498,28 @@ func (k Keeper) GetVaultInterestTracker(ctx sdk.Context, id, appID uint64) (vaul return vault, true } +func (k Keeper) GetAllVaultInterestTracker(ctx sdk.Context) (Vaultrewards []types.VaultInterestTracker) { + var ( + store = k.Store(ctx) + iter = sdk.KVStorePrefixIterator(store, types.VaultInterestTrackerKeyPrefix) + ) + + defer func(iter sdk.Iterator) { + err := iter.Close() + if err != nil { + return + } + }(iter) + + for ; iter.Valid(); iter.Next() { + var rewards types.VaultInterestTracker + k.cdc.MustUnmarshal(iter.Value(), &rewards) + Vaultrewards = append(Vaultrewards, rewards) + } + + return Vaultrewards +} + func (k Keeper) CalculateLockerRewards(ctx sdk.Context, appID, assetID, lockerID uint64, Depositor string, NetBalance sdk.Int, blockHeight int64, lockerBlockTime int64) error { _, found := k.GetReward(ctx, appID, assetID) diff --git a/x/rewards/keeper/store.go b/x/rewards/keeper/store.go index 8db0375c9..abb0328fc 100644 --- a/x/rewards/keeper/store.go +++ b/x/rewards/keeper/store.go @@ -171,6 +171,25 @@ func (k Keeper) GetGaugeIdsByTriggerDuration(ctx sdk.Context, triggerDuration ti return gaugeIdsByTriggerDuration, true } +func (k Keeper) GetAllGaugeIdsByTriggerDuration(ctx sdk.Context) (gaugeByTriggerDuration []types.GaugeByTriggerDuration) { + var ( + store = k.Store(ctx) + iter = sdk.KVStorePrefixIterator(store, types.GaugeIdsByTriggerDurationKeyPrefix) + ) + defer func(iter sdk.Iterator) { + err := iter.Close() + if err != nil { + return + } + }(iter) + for ; iter.Valid(); iter.Next() { + var gauge types.GaugeByTriggerDuration + k.cdc.MustUnmarshal(iter.Value(), &gauge) + gaugeByTriggerDuration = append(gaugeByTriggerDuration, gauge) + } + return gaugeByTriggerDuration +} + // GetAllGaugesByGaugeTypeID returns all the gauges with given gaugeTypeId. func (k Keeper) GetAllGaugesByGaugeTypeID(ctx sdk.Context, gaugeTypeID uint64) (gauges []types.Gauge) { var ( diff --git a/x/rewards/module.go b/x/rewards/module.go index 1f6e0eaef..6784bbcde 100644 --- a/x/rewards/module.go +++ b/x/rewards/module.go @@ -55,7 +55,7 @@ func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { // DefaultGenesis returns the capability module's default genesis state. func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { - return cdc.MustMarshalJSON(types.DefaultGenesis()) + return cdc.MustMarshalJSON(types.DefaultGenesisState()) } // ValidateGenesis performs genesis state validation for the capability module. @@ -151,7 +151,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.Ra // Initialize global index to index in genesis state cdc.MustUnmarshalJSON(gs, &genState) - InitGenesis(ctx, am.keeper, genState) + InitGenesis(ctx, am.keeper, &genState) return []abci.ValidatorUpdate{} } diff --git a/x/rewards/types/genesis.go b/x/rewards/types/genesis.go index 9019cc0f1..5151cea78 100644 --- a/x/rewards/types/genesis.go +++ b/x/rewards/types/genesis.go @@ -1,17 +1,34 @@ package types -// DefaultIndex is the default capability global index. -const DefaultIndex uint64 = 1 - -// DefaultGenesis returns the default Capability genesis state. -func DefaultGenesis() *GenesisState { +func NewGenesisState(internal_rewards []InternalRewards, locker_rewards_tracker []LockerRewardsTracker, vault_interest_tracker []VaultInterestTracker, locker_external_rewards []LockerExternalRewards, vault_external_rewards []VaultExternalRewards, appIDs []uint64, epochInfo []EpochInfo, gauge []Gauge, gaugeDuration []GaugeByTriggerDuration, params Params) *GenesisState { return &GenesisState{ - Params: DefaultParams(), + InternalRewards: internal_rewards, + LockerRewardsTracker: locker_rewards_tracker, + VaultInterestTracker: vault_interest_tracker, + LockerExternalRewards: locker_external_rewards, + VaultExternalRewards: vault_external_rewards, + AppIDs: appIDs, + EpochInfo: epochInfo, + Gauge: gauge, + GaugeByTriggerDuration: gaugeDuration, + Params: params, } } +func DefaultGenesisState() *GenesisState { + return NewGenesisState( + []InternalRewards{}, + []LockerRewardsTracker{}, + []VaultInterestTracker{}, + []LockerExternalRewards{}, + []VaultExternalRewards{}, + []uint64{}, + []EpochInfo{}, + []Gauge{}, + []GaugeByTriggerDuration{}, + DefaultParams(), + ) +} -// Validate performs basic genesis state validation returning an error upon any -// failure. -func (gs GenesisState) Validate() error { - return gs.Params.Validate() +func (m *GenesisState) Validate() error { + return nil } diff --git a/x/rewards/types/genesis.pb.go b/x/rewards/types/genesis.pb.go index 595f96aec..7e7bdb20f 100644 --- a/x/rewards/types/genesis.pb.go +++ b/x/rewards/types/genesis.pb.go @@ -25,7 +25,16 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the rewards module's genesis state. type GenesisState struct { - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + InternalRewards []InternalRewards `protobuf:"bytes,1,rep,name=internal_rewards,json=internalRewards,proto3" json:"internal_rewards" yaml:"internal_rewards"` + LockerRewardsTracker []LockerRewardsTracker `protobuf:"bytes,2,rep,name=locker_rewards_tracker,json=lockerRewardsTracker,proto3" json:"locker_rewards_tracker" yaml:"locker_rewards_tracker"` + VaultInterestTracker []VaultInterestTracker `protobuf:"bytes,3,rep,name=vault_interest_tracker,json=vaultInterestTracker,proto3" json:"vault_interest_tracker" yaml:"vault_interest_tracker"` + LockerExternalRewards []LockerExternalRewards `protobuf:"bytes,4,rep,name=locker_external_rewards,json=lockerExternalRewards,proto3" json:"locker_external_rewards" yaml:"locker_external_rewards"` + VaultExternalRewards []VaultExternalRewards `protobuf:"bytes,5,rep,name=vault_external_rewards,json=vaultExternalRewards,proto3" json:"vault_external_rewards" yaml:"vault_external_rewards"` + AppIDs []uint64 `protobuf:"varint,6,rep,packed,name=appIDs,proto3" json:"appIDs,omitempty" yaml:"vault_external_rewards"` + EpochInfo []EpochInfo `protobuf:"bytes,7,rep,name=epochInfo,proto3" json:"epochInfo" yaml:"epochInfo"` + Gauge []Gauge `protobuf:"bytes,8,rep,name=gauge,proto3" json:"gauge" yaml:"gauge"` + GaugeByTriggerDuration []GaugeByTriggerDuration `protobuf:"bytes,9,rep,name=gaugeByTriggerDuration,proto3" json:"gaugeByTriggerDuration" yaml:"gaugeByTriggerDuration"` + Params Params `protobuf:"bytes,10,opt,name=params,proto3" json:"params" yaml:"params"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -61,6 +70,69 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo +func (m *GenesisState) GetInternalRewards() []InternalRewards { + if m != nil { + return m.InternalRewards + } + return nil +} + +func (m *GenesisState) GetLockerRewardsTracker() []LockerRewardsTracker { + if m != nil { + return m.LockerRewardsTracker + } + return nil +} + +func (m *GenesisState) GetVaultInterestTracker() []VaultInterestTracker { + if m != nil { + return m.VaultInterestTracker + } + return nil +} + +func (m *GenesisState) GetLockerExternalRewards() []LockerExternalRewards { + if m != nil { + return m.LockerExternalRewards + } + return nil +} + +func (m *GenesisState) GetVaultExternalRewards() []VaultExternalRewards { + if m != nil { + return m.VaultExternalRewards + } + return nil +} + +func (m *GenesisState) GetAppIDs() []uint64 { + if m != nil { + return m.AppIDs + } + return nil +} + +func (m *GenesisState) GetEpochInfo() []EpochInfo { + if m != nil { + return m.EpochInfo + } + return nil +} + +func (m *GenesisState) GetGauge() []Gauge { + if m != nil { + return m.Gauge + } + return nil +} + +func (m *GenesisState) GetGaugeByTriggerDuration() []GaugeByTriggerDuration { + if m != nil { + return m.GaugeByTriggerDuration + } + return nil +} + func (m *GenesisState) GetParams() Params { if m != nil { return m.Params @@ -77,20 +149,41 @@ func init() { } var fileDescriptor_cdfc05d0f3c33bb6 = []byte{ - // 204 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x49, 0xce, 0xcf, 0x4d, - 0x49, 0xad, 0xd0, 0x2f, 0x4a, 0x2d, 0x4f, 0x2c, 0x4a, 0x29, 0xd6, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, - 0x49, 0x34, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, - 0x17, 0x12, 0x83, 0xa8, 0xd2, 0x83, 0xaa, 0xd2, 0x83, 0xaa, 0x92, 0x12, 0x49, 0xcf, 0x4f, 0xcf, - 0x07, 0x2b, 0xd1, 0x07, 0xb1, 0x20, 0xaa, 0xa5, 0x94, 0x71, 0x98, 0x59, 0x90, 0x58, 0x94, 0x98, - 0x0b, 0x35, 0x52, 0xc9, 0x87, 0x8b, 0xc7, 0x1d, 0x62, 0x47, 0x70, 0x49, 0x62, 0x49, 0xaa, 0x90, - 0x0d, 0x17, 0x1b, 0x44, 0x5e, 0x82, 0x51, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x4e, 0x0f, 0xbb, 0x9d, - 0x7a, 0x01, 0x60, 0x55, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0x41, 0xf5, 0x38, 0x79, 0x9f, - 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, - 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x61, 0x7a, 0x66, 0x49, 0x46, 0x69, - 0x12, 0xc8, 0x34, 0x7d, 0x88, 0x89, 0xba, 0xf9, 0x69, 0x69, 0x99, 0xc9, 0x99, 0x89, 0x39, 0x50, - 0xbe, 0x3e, 0xc2, 0xa5, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0x17, 0x1a, 0x03, 0x02, - 0x00, 0x00, 0xff, 0xff, 0x4a, 0xf6, 0xfe, 0x62, 0x1c, 0x01, 0x00, 0x00, + // 541 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0x4d, 0x6f, 0xd3, 0x30, + 0x18, 0xc7, 0x1b, 0xb6, 0x15, 0xea, 0x0d, 0x31, 0x45, 0x5d, 0x17, 0x55, 0x5a, 0xda, 0x99, 0x17, + 0xf5, 0x42, 0xa2, 0x8e, 0x13, 0x1c, 0xa3, 0x4d, 0x55, 0x04, 0x48, 0xc8, 0x4c, 0x48, 0x70, 0xa9, + 0xdc, 0xce, 0xcd, 0x22, 0xd2, 0x38, 0x72, 0xdc, 0xd1, 0xde, 0xb8, 0x23, 0x04, 0x1f, 0x6b, 0xc7, + 0x1d, 0x39, 0x4d, 0xa8, 0xfd, 0x06, 0x7c, 0x02, 0x54, 0x3f, 0xce, 0x26, 0xd2, 0xa4, 0xe3, 0x96, + 0xd8, 0xff, 0x97, 0x9f, 0x9f, 0x28, 0x46, 0x4f, 0x86, 0x7c, 0x7c, 0xc6, 0xa6, 0xae, 0x60, 0x5f, + 0xa8, 0x38, 0x4b, 0xdd, 0x8b, 0xee, 0x80, 0x49, 0xda, 0x75, 0x03, 0x16, 0xb3, 0x34, 0x4c, 0x9d, + 0x44, 0x70, 0xc9, 0xcd, 0x06, 0xa8, 0x1c, 0xad, 0x72, 0xb4, 0xaa, 0x59, 0x0f, 0x78, 0xc0, 0x95, + 0xc4, 0x5d, 0x3e, 0x81, 0xba, 0xf9, 0xb8, 0x24, 0x33, 0xa1, 0x82, 0x8e, 0x75, 0x64, 0xb3, 0xac, + 0x38, 0xab, 0x58, 0x1f, 0xc5, 0x12, 0x3e, 0x3c, 0xcf, 0x44, 0xb8, 0xec, 0x0c, 0x74, 0x12, 0x30, + 0xd0, 0xe0, 0xaf, 0x35, 0xb4, 0xd3, 0x83, 0x33, 0xbd, 0x97, 0x54, 0x32, 0x53, 0xa2, 0xdd, 0x30, + 0x96, 0x4c, 0xc4, 0x34, 0xea, 0x6b, 0xa3, 0x65, 0xb4, 0x37, 0x3a, 0xdb, 0x47, 0x1d, 0xa7, 0xf8, + 0xb4, 0x8e, 0x9f, 0xd3, 0x7b, 0xad, 0xcb, 0xeb, 0x56, 0xe5, 0xcf, 0x75, 0x6b, 0x7f, 0x46, 0xc7, + 0xd1, 0x2b, 0x9c, 0xcf, 0xc3, 0xe4, 0x51, 0xb6, 0x44, 0x60, 0xc5, 0xfc, 0x66, 0xa0, 0x46, 0xc4, + 0x87, 0x9f, 0x99, 0xc8, 0x44, 0x7d, 0x29, 0xe8, 0xf2, 0xdd, 0xba, 0xa7, 0xca, 0x9d, 0xb2, 0xf2, + 0x37, 0x85, 0x2e, 0xef, 0xa9, 0x46, 0x38, 0x00, 0x84, 0xe2, 0x6c, 0x4c, 0xea, 0xb0, 0xa1, 0x31, + 0x4e, 0x61, 0x59, 0xd1, 0x5c, 0xd0, 0x49, 0x24, 0xfb, 0x8a, 0x93, 0xa5, 0xf2, 0x86, 0x66, 0x63, + 0x3d, 0xcd, 0x87, 0x42, 0x57, 0x9e, 0xa6, 0x38, 0x1b, 0x93, 0xba, 0xda, 0xf0, 0xf5, 0x7a, 0x46, + 0xf3, 0xc3, 0x40, 0xfb, 0x9a, 0x9f, 0x4d, 0x73, 0x5f, 0x66, 0x53, 0xe1, 0xb8, 0x77, 0x0c, 0x27, + 0x6f, 0xf3, 0x9e, 0x69, 0x1e, 0xfb, 0x9f, 0xe9, 0xe4, 0x65, 0x98, 0xec, 0xc1, 0xce, 0xc9, 0x74, + 0xf5, 0x6b, 0xc1, 0x19, 0x56, 0x80, 0xb6, 0xfe, 0x67, 0x3e, 0x2b, 0x3c, 0x85, 0xf3, 0x59, 0xc5, + 0x81, 0xf9, 0xe4, 0x69, 0x5e, 0xa2, 0x2a, 0x4d, 0x12, 0xff, 0x38, 0xb5, 0xaa, 0xed, 0x8d, 0xce, + 0xa6, 0x77, 0x78, 0x77, 0x90, 0x36, 0x98, 0x1f, 0x51, 0x4d, 0xfd, 0x31, 0x7e, 0x3c, 0xe2, 0xd6, + 0x7d, 0x85, 0x7e, 0x58, 0x86, 0x7e, 0x92, 0x09, 0x3d, 0x4b, 0xd3, 0xee, 0x42, 0xc9, 0x4d, 0x02, + 0x26, 0xb7, 0x69, 0xa6, 0x8f, 0xb6, 0xd4, 0x7f, 0x66, 0x3d, 0x50, 0xb1, 0x07, 0x65, 0xb1, 0xbd, + 0xa5, 0xc8, 0xab, 0xeb, 0xc8, 0x1d, 0x88, 0x54, 0x4e, 0x4c, 0x20, 0xc1, 0xfc, 0x6e, 0xa0, 0x86, + 0x7a, 0xf2, 0x66, 0xa7, 0x22, 0x0c, 0x02, 0x26, 0x8e, 0x27, 0x82, 0xca, 0x90, 0xc7, 0x56, 0x6d, + 0xfd, 0xb8, 0x7b, 0x85, 0xae, 0xfc, 0xb8, 0x8b, 0xb3, 0x31, 0x29, 0x29, 0x35, 0xdf, 0xa2, 0x2a, + 0x5c, 0x59, 0x16, 0x6a, 0x1b, 0x9d, 0xed, 0x23, 0xbb, 0xac, 0xfe, 0x9d, 0x52, 0x79, 0x7b, 0xba, + 0xee, 0x21, 0xd4, 0x81, 0x17, 0x13, 0x1d, 0xe2, 0xbd, 0xbe, 0x9c, 0xdb, 0xc6, 0xd5, 0xdc, 0x36, + 0x7e, 0xcf, 0x6d, 0xe3, 0xe7, 0xc2, 0xae, 0x5c, 0x2d, 0xec, 0xca, 0xaf, 0x85, 0x5d, 0xf9, 0xd4, + 0x0d, 0x42, 0x79, 0x3e, 0x19, 0x2c, 0xe3, 0x5d, 0xa8, 0x78, 0xce, 0x47, 0xa3, 0x70, 0x18, 0xd2, + 0x48, 0xbf, 0xbb, 0xb7, 0xb7, 0x9b, 0x9c, 0x25, 0x2c, 0x1d, 0x54, 0xd5, 0xb5, 0xf6, 0xe2, 0x6f, + 0x00, 0x00, 0x00, 0xff, 0xff, 0xe4, 0xfb, 0x8a, 0xe0, 0xc0, 0x05, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -122,7 +215,137 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0xa + dAtA[i] = 0x52 + if len(m.GaugeByTriggerDuration) > 0 { + for iNdEx := len(m.GaugeByTriggerDuration) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.GaugeByTriggerDuration[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x4a + } + } + if len(m.Gauge) > 0 { + for iNdEx := len(m.Gauge) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Gauge[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + } + } + if len(m.EpochInfo) > 0 { + for iNdEx := len(m.EpochInfo) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.EpochInfo[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } + } + if len(m.AppIDs) > 0 { + dAtA3 := make([]byte, len(m.AppIDs)*10) + var j2 int + for _, num := range m.AppIDs { + for num >= 1<<7 { + dAtA3[j2] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j2++ + } + dAtA3[j2] = uint8(num) + j2++ + } + i -= j2 + copy(dAtA[i:], dAtA3[:j2]) + i = encodeVarintGenesis(dAtA, i, uint64(j2)) + i-- + dAtA[i] = 0x32 + } + if len(m.VaultExternalRewards) > 0 { + for iNdEx := len(m.VaultExternalRewards) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.VaultExternalRewards[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } + if len(m.LockerExternalRewards) > 0 { + for iNdEx := len(m.LockerExternalRewards) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.LockerExternalRewards[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.VaultInterestTracker) > 0 { + for iNdEx := len(m.VaultInterestTracker) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.VaultInterestTracker[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.LockerRewardsTracker) > 0 { + for iNdEx := len(m.LockerRewardsTracker) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.LockerRewardsTracker[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.InternalRewards) > 0 { + for iNdEx := len(m.InternalRewards) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.InternalRewards[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } return len(dAtA) - i, nil } @@ -143,6 +366,61 @@ func (m *GenesisState) Size() (n int) { } var l int _ = l + if len(m.InternalRewards) > 0 { + for _, e := range m.InternalRewards { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.LockerRewardsTracker) > 0 { + for _, e := range m.LockerRewardsTracker { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.VaultInterestTracker) > 0 { + for _, e := range m.VaultInterestTracker { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.LockerExternalRewards) > 0 { + for _, e := range m.LockerExternalRewards { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.VaultExternalRewards) > 0 { + for _, e := range m.VaultExternalRewards { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.AppIDs) > 0 { + l = 0 + for _, e := range m.AppIDs { + l += sovGenesis(uint64(e)) + } + n += 1 + sovGenesis(uint64(l)) + l + } + if len(m.EpochInfo) > 0 { + for _, e := range m.EpochInfo { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.Gauge) > 0 { + for _, e := range m.Gauge { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.GaugeByTriggerDuration) > 0 { + for _, e := range m.GaugeByTriggerDuration { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } l = m.Params.Size() n += 1 + l + sovGenesis(uint64(l)) return n @@ -184,6 +462,354 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InternalRewards", 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.InternalRewards = append(m.InternalRewards, InternalRewards{}) + if err := m.InternalRewards[len(m.InternalRewards)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LockerRewardsTracker", 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.LockerRewardsTracker = append(m.LockerRewardsTracker, LockerRewardsTracker{}) + if err := m.LockerRewardsTracker[len(m.LockerRewardsTracker)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VaultInterestTracker", 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.VaultInterestTracker = append(m.VaultInterestTracker, VaultInterestTracker{}) + if err := m.VaultInterestTracker[len(m.VaultInterestTracker)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LockerExternalRewards", 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.LockerExternalRewards = append(m.LockerExternalRewards, LockerExternalRewards{}) + if err := m.LockerExternalRewards[len(m.LockerExternalRewards)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VaultExternalRewards", 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.VaultExternalRewards = append(m.VaultExternalRewards, VaultExternalRewards{}) + if err := m.VaultExternalRewards[len(m.VaultExternalRewards)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.AppIDs = append(m.AppIDs, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.AppIDs) == 0 { + m.AppIDs = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.AppIDs = append(m.AppIDs, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field AppIDs", wireType) + } + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EpochInfo", 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.EpochInfo = append(m.EpochInfo, EpochInfo{}) + if err := m.EpochInfo[len(m.EpochInfo)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Gauge", 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.Gauge = append(m.Gauge, Gauge{}) + if err := m.Gauge[len(m.Gauge)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GaugeByTriggerDuration", 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.GaugeByTriggerDuration = append(m.GaugeByTriggerDuration, GaugeByTriggerDuration{}) + if err := m.GaugeByTriggerDuration[len(m.GaugeByTriggerDuration)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 10: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) } diff --git a/x/vault/genesis.go b/x/vault/genesis.go index a1d305259..4a7cf4c01 100644 --- a/x/vault/genesis.go +++ b/x/vault/genesis.go @@ -9,31 +9,44 @@ import ( func InitGenesis(ctx sdk.Context, k keeper.Keeper, state *types.GenesisState) { + var ( + vaultID uint64 = 0 + stableVaultID uint64 = 0 + ) + for _, item := range state.Vaults { + if item.Id > vaultID { + vaultID = item.Id + } k.SetVault(ctx, item) } for _, item := range state.StableMintVault { + if item.Id > stableVaultID { + stableVaultID = item.Id + } k.SetStableMintVault(ctx, item) } - // for _, item := range state.AppExtendedPairVaultMapping { - // err := k.SetAppExtendedPairVaultMappingData(ctx, item) - // if err != nil { - // return - // } - // } + for _, item := range state.AppExtendedPairVaultMapping { + err := k.SetAppExtendedPairVaultMappingData(ctx, item) + if err != nil { + return + } + } - // for _, item := range state.UserVaultAssetMapping { - // k.SetUserVaultExtendedPairMapping(ctx, item) - // } + for _, item := range state.UserVaultAssetMapping { + k.SetUserAppExtendedPairMappingData(ctx, item) + } + k.SetIDForVault(ctx, vaultID) + k.SetIDForStableVault(ctx, stableVaultID) } func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { return types.NewGenesisState( k.GetVaults(ctx), k.GetStableMintVaults(ctx), - // k.GetAllAppExtendedPairVaultMapping(ctx), - // k.GetAllUserVaultExtendedPairMapping(ctx), + k.GetAllAppExtendedPairVaultMapping(ctx), + k.GetAllUserVaultExtendedPairMapping(ctx), ) } diff --git a/x/vault/types/genesis.go b/x/vault/types/genesis.go index 03185b924..7363eafbb 100644 --- a/x/vault/types/genesis.go +++ b/x/vault/types/genesis.go @@ -1,11 +1,11 @@ package types -func NewGenesisState(vaults []Vault, stableMintVault []StableMintVault) *GenesisState { +func NewGenesisState(vaults []Vault, stableMintVault []StableMintVault, appExtendedPairVaultMapping []AppExtendedPairVaultMappingData, userVaultAssetMapping []OwnerAppExtendedPairVaultMappingData) *GenesisState { return &GenesisState{ - Vaults: vaults, - StableMintVault: stableMintVault, - // AppExtendedPairVaultMapping: appExtendedPairVaultMapping, - // UserVaultAssetMapping: userVaultAssetMapping, + Vaults: vaults, + StableMintVault: stableMintVault, + AppExtendedPairVaultMapping: appExtendedPairVaultMapping, + UserVaultAssetMapping: userVaultAssetMapping, } } @@ -13,8 +13,8 @@ func DefaultGenesisState() *GenesisState { return NewGenesisState( []Vault{}, []StableMintVault{}, - // []AppExtendedPairVaultMappingData{}, - // []UserVaultAssetMapping{}, + []AppExtendedPairVaultMappingData{}, + []OwnerAppExtendedPairVaultMappingData{}, ) }