From 89c3b6a04da3b8238e6e910b48a89e2e7426ab07 Mon Sep 17 00:00:00 2001 From: Brandon Weng <18161326+BrandonWeng@users.noreply.github.com> Date: Wed, 26 Apr 2023 13:22:15 -0400 Subject: [PATCH] lint --- proto/mint/v1beta1/mint.proto | 38 ++ x/mint/keeper/keeper.go | 19 +- x/mint/keeper/migrations.go | 66 ++ x/mint/keeper/migrations_test.go | 152 +++++ x/mint/module.go | 3 +- x/mint/types/keys.go | 2 + x/mint/types/mint.pb.go | 1036 ++++++++++++++++++++++++++---- x/mint/types/params.go | 13 + 8 files changed, 1185 insertions(+), 144 deletions(-) create mode 100644 x/mint/keeper/migrations_test.go diff --git a/proto/mint/v1beta1/mint.proto b/proto/mint/v1beta1/mint.proto index a4a14dedab..22c3e6a819 100644 --- a/proto/mint/v1beta1/mint.proto +++ b/proto/mint/v1beta1/mint.proto @@ -36,3 +36,41 @@ message Params { ]; } + +// Legacy Protobufs used for migration purposes + +// Minter represents the most recent +message Version2Minter { + string last_mint_amount = 1 [ + (gogoproto.moretags) = "yaml:\"last_mint_amount\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string last_mint_date = 2 [ + (gogoproto.moretags) = "yaml:\"last_mint_date\"" + ]; + int64 last_mint_height = 3 [ + (gogoproto.moretags) = "yaml:\"last_mint_height\"" + ]; + string denom = 4 [ + (gogoproto.moretags) = "yaml:\"denom\"" + ]; +} + +message Version2ScheduledTokenRelease { + string date = 1; // yyyy-mm-dd + int64 token_release_amount = 2; +} + +// Params holds parameters for the mint module. +message Version2Params { + option (gogoproto.goproto_stringer) = false; + + // type of coin to mint + string mint_denom = 1; + // List of token release schedules + repeated Version2ScheduledTokenRelease token_release_schedule = 2 [ + (gogoproto.moretags) = "yaml:\"token_release_schedule\"", + (gogoproto.nullable) = false + ]; +} diff --git a/x/mint/keeper/keeper.go b/x/mint/keeper/keeper.go index f1bec00b9e..90c9d5bf4c 100644 --- a/x/mint/keeper/keeper.go +++ b/x/mint/keeper/keeper.go @@ -4,13 +4,12 @@ import ( "fmt" "time" - "github.com/tendermint/tendermint/libs/log" - "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" epochTypes "github.com/sei-protocol/sei-chain/x/epoch/types" "github.com/sei-protocol/sei-chain/x/mint/types" + "github.com/tendermint/tendermint/libs/log" ) // Keeper of the mint store @@ -149,6 +148,22 @@ func (k Keeper) GetOrUpdateLatestMinter( ) } +func (k Keeper) GetCdc() codec.BinaryCodec { + return k.cdc +} + +func (k Keeper) GetStoreKey() sdk.StoreKey { + return k.storeKey +} + +func (k Keeper) GetParamSpace() paramtypes.Subspace { + return k.paramSpace +} + +func (k *Keeper) SetParamSpace(subspace paramtypes.Subspace) { + k.paramSpace = subspace +} + func GetNextScheduledTokenRelease( epoch epochTypes.Epoch, tokenReleaseSchedule []types.ScheduledTokenRelease, diff --git a/x/mint/keeper/migrations.go b/x/mint/keeper/migrations.go index d1b92b2d80..fd3048f23a 100644 --- a/x/mint/keeper/migrations.go +++ b/x/mint/keeper/migrations.go @@ -1,6 +1,9 @@ package keeper import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/sei-protocol/sei-chain/x/mint/types" ) @@ -21,3 +24,66 @@ func (m Migrator) Migrate1to2(ctx sdk.Context) error { m.keeper.paramSpace.SetParamSet(ctx, &defaultParams) return nil } + +// Migrate1to2 migrates from version 1 to 2 +func (m Migrator) Migrate2to3(ctx sdk.Context) error { + ctx.Logger().Info("Migrating mint module from v2 to v3") + store := ctx.KVStore(m.keeper.storeKey) + // Migrate Minter First + minterBytes := store.Get(types.MinterKey) + if minterBytes == nil { + panic("stored minter should not have been nil") + } + + var oldMinter types.Version2Minter + m.keeper.cdc.MustUnmarshal(minterBytes, &oldMinter) + + newMinter := types.Minter{ + StartDate: oldMinter.GetLastMintDate(), + EndDate: oldMinter.GetLastMintDate(), + Denom: sdk.DefaultBondDenom, + TotalMintAmount: oldMinter.LastMintAmount.RoundInt().Uint64(), + RemainingMintAmount: 0, + LastMintDate: oldMinter.GetLastMintDate(), + LastMintHeight: uint64(oldMinter.GetLastMintHeight()), + LastMintAmount: oldMinter.LastMintAmount.RoundInt().Uint64(), + } + ctx.Logger().Info("Migrating mint module from v2 to v3", "oldMinter", oldMinter.String(), "newMinter", newMinter.String()) + m.keeper.SetMinter(ctx, newMinter) + + // Migrate TokenReleaseSchedule + + var oldTokenReleaseSchedules []types.Version2ScheduledTokenRelease + oldTokenReleaseSchedulesBytes := m.keeper.GetParamSpace().GetRaw(ctx, types.KeyTokenReleaseSchedule) + err := codec.NewLegacyAmino().UnmarshalJSON(oldTokenReleaseSchedulesBytes, &oldTokenReleaseSchedules) + if err != nil { + panic(fmt.Sprintf("Key not found or error: %s", err)) + } + + var oldMintDenom string + oldMintDenomBytes := m.keeper.GetParamSpace().GetRaw(ctx, types.KeyMintDenom) + err = codec.NewLegacyAmino().UnmarshalJSON(oldMintDenomBytes, &oldMintDenom) + if err != nil { + panic(fmt.Sprintf("Key not found or error: %s", err)) + } + ctx.Logger().Info("Migrating mint module from v2 to v3", "oldTokenReleaseSchedules", oldTokenReleaseSchedules, "oldMintDenom", oldMintDenom) + fmt.Println("Migrating mint module from v2 to v3", "oldTokenReleaseSchedules", oldTokenReleaseSchedules, "oldMintDenom", oldMintDenom) + + newTokenReleaseSchedule := []types.ScheduledTokenRelease{} + for _, oldTokenReleaseSchedule := range oldTokenReleaseSchedules { + newSchedule := types.ScheduledTokenRelease{ + TokenReleaseAmount: uint64(oldTokenReleaseSchedule.GetTokenReleaseAmount()), + StartDate: oldTokenReleaseSchedule.GetDate(), + EndDate: oldTokenReleaseSchedule.GetDate(), + } + newTokenReleaseSchedule = append(newTokenReleaseSchedule, newSchedule) + } + newParams := types.Params{ + MintDenom: oldMintDenom, + TokenReleaseSchedule: newTokenReleaseSchedule, + } + m.keeper.SetParams(ctx, newParams) + ctx.Logger().Info("Migrating mint module from v2 to v3", "newParams", newParams.String()) + + return nil +} diff --git a/x/mint/keeper/migrations_test.go b/x/mint/keeper/migrations_test.go new file mode 100644 index 0000000000..b3c151ffce --- /dev/null +++ b/x/mint/keeper/migrations_test.go @@ -0,0 +1,152 @@ +package keeper_test + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/store" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + typesparams "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/sei-protocol/sei-chain/x/mint/keeper" + "github.com/sei-protocol/sei-chain/x/mint/types" + "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/libs/log" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + tmdb "github.com/tendermint/tm-db" +) + +type MockAccountKeeper struct { + ModuleAddress sdk.AccAddress + ModuleAccount authtypes.ModuleAccountI +} + +func (m MockAccountKeeper) GetModuleAddress(name string) sdk.AccAddress { + address, _ := sdk.AccAddressFromBech32("sei1t4xhq2pnhnf223zr4z5lw02vsrxwf74z604kja") + return address +} + +func (m MockAccountKeeper) SetModuleAccount(ctx sdk.Context, account authtypes.ModuleAccountI) { + m.ModuleAccount = account +} + +func (m MockAccountKeeper) GetModuleAccount(ctx sdk.Context, moduleName string) authtypes.ModuleAccountI { + return m.ModuleAccount +} + +func TestMigrate2to3(t *testing.T) { + + storeKey := sdk.NewKVStoreKey(types.StoreKey) + memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) + + db := tmdb.NewMemDB() + stateStore := store.NewCommitMultiStore(db) + stateStore.MountStoreWithDB(storeKey, sdk.StoreTypeIAVL, db) + stateStore.MountStoreWithDB(memStoreKey, sdk.StoreTypeMemory, nil) + require.NoError(t, stateStore.LoadLatestVersion()) + + registry := codectypes.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(registry) + + paramsSubspace := typesparams.NewSubspace(cdc, + codec.NewLegacyAmino(), + storeKey, + memStoreKey, + "MintParams", + ) + ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) + if !paramsSubspace.HasKeyTable() { + paramsSubspace = paramsSubspace.WithKeyTable(paramtypes.NewKeyTable().RegisterParamSet(&types.Version2Params{})) + } + store := ctx.KVStore(storeKey) + + // Set up the old Minter and Params + oldMinter := types.Version2Minter{ + LastMintAmount: sdk.NewDec(1000), + LastMintDate: "2021-01-01", + LastMintHeight: 100, + Denom: sdk.DefaultBondDenom, + } + + oldTokenReleaseSchedule := []types.Version2ScheduledTokenRelease{ + { + Date: "2021-02-01", + TokenReleaseAmount: 500, + }, + { + Date: "2021-03-01", + TokenReleaseAmount: 1000, + }, + } + + // Start up post upgrade with new Param Space + newParamsSubspace := typesparams.NewSubspace(cdc, + codec.NewLegacyAmino(), + storeKey, + memStoreKey, + "MintParams", + ) + mintKeeper := keeper.NewKeeper( + cdc, + storeKey, + newParamsSubspace, + nil, + MockAccountKeeper{}, + nil, + nil, + "fee_collector", + ) + + oldParams := types.Version2Params{ + MintDenom: sdk.DefaultBondDenom, + TokenReleaseSchedule: oldTokenReleaseSchedule, + } + + // Store the old Minter and Params + b := cdc.MustMarshal(&oldMinter) + store.Set(types.MinterKey, b) + paramsSubspace.SetParamSet(ctx, &oldParams) + + // Perform the migration + + // Use new keeper or param space here + migrator := keeper.NewMigrator(mintKeeper) + err := migrator.Migrate2to3(ctx) + require.NoError(t, err) + + // Check if the new Minter was stored correctly + minterBytes := store.Get(types.MinterKey) + if minterBytes == nil { + panic("stored minter should not have been nil") + } + var newMinter types.Minter + cdc.MustUnmarshal(minterBytes, &newMinter) + + require.Equal(t, oldMinter.LastMintDate, newMinter.StartDate) + require.Equal(t, oldMinter.LastMintDate, newMinter.EndDate) + require.Equal(t, oldMinter.LastMintDate, newMinter.LastMintDate) + require.Equal(t, oldMinter.LastMintHeight, int64(newMinter.LastMintHeight)) + require.Equal(t, oldMinter.LastMintAmount.RoundInt().Uint64(), newMinter.TotalMintAmount) + require.Equal(t, oldMinter.LastMintAmount.RoundInt().Uint64(), newMinter.LastMintAmount) + + // Check if the new Params were stored correctly + var newTokenReleaseSchedules []types.ScheduledTokenRelease + mintKeeper.GetParamSpace().Get(ctx, types.KeyTokenReleaseSchedule, &newTokenReleaseSchedules) + + var newMintDenom string + mintKeeper.GetParamSpace().Get(ctx, types.KeyMintDenom, &newMintDenom) + + require.Equal(t, oldParams.MintDenom, newMintDenom) + require.Len(t, newTokenReleaseSchedules, len(oldParams.TokenReleaseSchedule)) + + for i, oldSchedule := range oldParams.TokenReleaseSchedule { + newSchedule := newTokenReleaseSchedules[i] + + require.Equal(t, oldSchedule.Date, newSchedule.StartDate) + require.Equal(t, oldSchedule.Date, newSchedule.EndDate) + require.Equal(t, uint64(oldSchedule.TokenReleaseAmount), newSchedule.TokenReleaseAmount) + } +} diff --git a/x/mint/module.go b/x/mint/module.go index 054c85fa17..fbdacd5873 100644 --- a/x/mint/module.go +++ b/x/mint/module.go @@ -128,6 +128,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQuerier(am.keeper)) m := keeper.NewMigrator(am.keeper) _ = cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2) + _ = cfg.RegisterMigration(types.ModuleName, 2, m.Migrate2to3) } // InitGenesis performs genesis initialization for the mint module. It returns @@ -148,7 +149,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion implements AppModule/ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 2 } +func (AppModule) ConsensusVersion() uint64 { return 3 } // BeginBlock returns the begin blocker for the mint module. func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) {} diff --git a/x/mint/types/keys.go b/x/mint/types/keys.go index 833a4fc57e..f8e7c5ec88 100644 --- a/x/mint/types/keys.go +++ b/x/mint/types/keys.go @@ -10,6 +10,8 @@ const ( // StoreKey is the default store key for mint StoreKey = ModuleName + MemStoreKey = "mem_mint" + // QuerierRoute is the querier route for the minting store. QuerierRoute = StoreKey diff --git a/x/mint/types/mint.pb.go b/x/mint/types/mint.pb.go index 231e356730..26e0f995a3 100644 --- a/x/mint/types/mint.pb.go +++ b/x/mint/types/mint.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" @@ -238,44 +239,225 @@ func (m *Params) GetTokenReleaseSchedule() []ScheduledTokenRelease { return nil } +// Minter represents the most recent +type Version2Minter struct { + LastMintAmount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=last_mint_amount,json=lastMintAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"last_mint_amount" yaml:"last_mint_amount"` + LastMintDate string `protobuf:"bytes,2,opt,name=last_mint_date,json=lastMintDate,proto3" json:"last_mint_date,omitempty" yaml:"last_mint_date"` + LastMintHeight int64 `protobuf:"varint,3,opt,name=last_mint_height,json=lastMintHeight,proto3" json:"last_mint_height,omitempty" yaml:"last_mint_height"` + Denom string `protobuf:"bytes,4,opt,name=denom,proto3" json:"denom,omitempty" yaml:"denom"` +} + +func (m *Version2Minter) Reset() { *m = Version2Minter{} } +func (m *Version2Minter) String() string { return proto.CompactTextString(m) } +func (*Version2Minter) ProtoMessage() {} +func (*Version2Minter) Descriptor() ([]byte, []int) { + return fileDescriptor_06339c129491fd39, []int{3} +} +func (m *Version2Minter) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Version2Minter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Version2Minter.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 *Version2Minter) XXX_Merge(src proto.Message) { + xxx_messageInfo_Version2Minter.Merge(m, src) +} +func (m *Version2Minter) XXX_Size() int { + return m.Size() +} +func (m *Version2Minter) XXX_DiscardUnknown() { + xxx_messageInfo_Version2Minter.DiscardUnknown(m) +} + +var xxx_messageInfo_Version2Minter proto.InternalMessageInfo + +func (m *Version2Minter) GetLastMintDate() string { + if m != nil { + return m.LastMintDate + } + return "" +} + +func (m *Version2Minter) GetLastMintHeight() int64 { + if m != nil { + return m.LastMintHeight + } + return 0 +} + +func (m *Version2Minter) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +type Version2ScheduledTokenRelease struct { + Date string `protobuf:"bytes,1,opt,name=date,proto3" json:"date,omitempty"` + TokenReleaseAmount int64 `protobuf:"varint,2,opt,name=token_release_amount,json=tokenReleaseAmount,proto3" json:"token_release_amount,omitempty"` +} + +func (m *Version2ScheduledTokenRelease) Reset() { *m = Version2ScheduledTokenRelease{} } +func (m *Version2ScheduledTokenRelease) String() string { return proto.CompactTextString(m) } +func (*Version2ScheduledTokenRelease) ProtoMessage() {} +func (*Version2ScheduledTokenRelease) Descriptor() ([]byte, []int) { + return fileDescriptor_06339c129491fd39, []int{4} +} +func (m *Version2ScheduledTokenRelease) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Version2ScheduledTokenRelease) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Version2ScheduledTokenRelease.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 *Version2ScheduledTokenRelease) XXX_Merge(src proto.Message) { + xxx_messageInfo_Version2ScheduledTokenRelease.Merge(m, src) +} +func (m *Version2ScheduledTokenRelease) XXX_Size() int { + return m.Size() +} +func (m *Version2ScheduledTokenRelease) XXX_DiscardUnknown() { + xxx_messageInfo_Version2ScheduledTokenRelease.DiscardUnknown(m) +} + +var xxx_messageInfo_Version2ScheduledTokenRelease proto.InternalMessageInfo + +func (m *Version2ScheduledTokenRelease) GetDate() string { + if m != nil { + return m.Date + } + return "" +} + +func (m *Version2ScheduledTokenRelease) GetTokenReleaseAmount() int64 { + if m != nil { + return m.TokenReleaseAmount + } + return 0 +} + +// Params holds parameters for the mint module. +type Version2Params struct { + // type of coin to mint + MintDenom string `protobuf:"bytes,1,opt,name=mint_denom,json=mintDenom,proto3" json:"mint_denom,omitempty"` + // List of token release schedules + TokenReleaseSchedule []Version2ScheduledTokenRelease `protobuf:"bytes,2,rep,name=token_release_schedule,json=tokenReleaseSchedule,proto3" json:"token_release_schedule" yaml:"token_release_schedule"` +} + +func (m *Version2Params) Reset() { *m = Version2Params{} } +func (*Version2Params) ProtoMessage() {} +func (*Version2Params) Descriptor() ([]byte, []int) { + return fileDescriptor_06339c129491fd39, []int{5} +} +func (m *Version2Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Version2Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Version2Params.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 *Version2Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Version2Params.Merge(m, src) +} +func (m *Version2Params) XXX_Size() int { + return m.Size() +} +func (m *Version2Params) XXX_DiscardUnknown() { + xxx_messageInfo_Version2Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Version2Params proto.InternalMessageInfo + +func (m *Version2Params) GetMintDenom() string { + if m != nil { + return m.MintDenom + } + return "" +} + +func (m *Version2Params) GetTokenReleaseSchedule() []Version2ScheduledTokenRelease { + if m != nil { + return m.TokenReleaseSchedule + } + return nil +} + func init() { proto.RegisterType((*Minter)(nil), "seiprotocol.seichain.mint.Minter") proto.RegisterType((*ScheduledTokenRelease)(nil), "seiprotocol.seichain.mint.ScheduledTokenRelease") proto.RegisterType((*Params)(nil), "seiprotocol.seichain.mint.Params") + proto.RegisterType((*Version2Minter)(nil), "seiprotocol.seichain.mint.Version2Minter") + proto.RegisterType((*Version2ScheduledTokenRelease)(nil), "seiprotocol.seichain.mint.Version2ScheduledTokenRelease") + proto.RegisterType((*Version2Params)(nil), "seiprotocol.seichain.mint.Version2Params") } func init() { proto.RegisterFile("mint/v1beta1/mint.proto", fileDescriptor_06339c129491fd39) } var fileDescriptor_06339c129491fd39 = []byte{ - // 442 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x52, 0x31, 0x6f, 0xd3, 0x40, - 0x18, 0xf5, 0x25, 0x69, 0xda, 0x1e, 0xa8, 0x80, 0x49, 0xc1, 0x45, 0xaa, 0x13, 0x59, 0x20, 0x45, - 0x48, 0xd8, 0x6d, 0xd9, 0xba, 0x51, 0x75, 0xe8, 0x82, 0x84, 0x02, 0x13, 0x8b, 0x75, 0xb1, 0x3f, - 0xd9, 0x27, 0xec, 0xbb, 0xca, 0xf7, 0x05, 0xd1, 0x99, 0x19, 0x89, 0x91, 0x91, 0xdf, 0xc0, 0xce, - 0xde, 0xb1, 0x23, 0x53, 0x85, 0x92, 0x7f, 0xc0, 0x2f, 0x40, 0xf7, 0xb9, 0x06, 0x5b, 0x0a, 0x13, - 0x9b, 0xbf, 0xf7, 0xde, 0xbd, 0xef, 0x3d, 0xdf, 0xf1, 0x87, 0xa5, 0x54, 0x18, 0xbd, 0x3f, 0x9c, - 0x03, 0x8a, 0xc3, 0xc8, 0x0e, 0xe1, 0x79, 0xa5, 0x51, 0xbb, 0x7b, 0x06, 0x24, 0x7d, 0x25, 0xba, - 0x08, 0x0d, 0xc8, 0x24, 0x17, 0x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xda, 0x52, 0xb7, - 0x0a, 0xbe, 0x33, 0x3e, 0x7c, 0x25, 0x2a, 0x51, 0x1a, 0xbb, 0xb6, 0xee, 0x46, 0xb7, 0x70, 0xb3, - 0xd6, 0x22, 0xa7, 0x74, 0x13, 0x9f, 0x18, 0x7f, 0xd0, 0x35, 0x37, 0x37, 0xe9, 0xbd, 0xde, 0xa4, - 0x3f, 0xbd, 0x75, 0x74, 0x10, 0xfe, 0xf3, 0xdd, 0x84, 0x6b, 0x8b, 0x9e, 0x3c, 0xb9, 0xbc, 0x1e, - 0x3b, 0xbf, 0xae, 0xc7, 0xfb, 0x17, 0xa2, 0x2c, 0x8e, 0x83, 0xf5, 0xee, 0xc1, 0x6c, 0xd4, 0xce, - 0xdd, 0x38, 0x1d, 0x0f, 0xbe, 0x7c, 0x1d, 0x3b, 0x27, 0x67, 0x97, 0x4b, 0x9f, 0x5d, 0x2d, 0x7d, - 0xf6, 0x73, 0xe9, 0xb3, 0xcf, 0x2b, 0xdf, 0xb9, 0x5a, 0xf9, 0xce, 0x8f, 0x95, 0xef, 0xbc, 0x0d, - 0x33, 0x89, 0xf9, 0x62, 0x1e, 0x26, 0xba, 0x8c, 0x0c, 0xc8, 0x67, 0x4d, 0x32, 0x1a, 0x28, 0x5a, - 0xf4, 0x81, 0x5e, 0x7d, 0x84, 0x17, 0xe7, 0x60, 0xe6, 0x43, 0x12, 0x3c, 0xff, 0x1d, 0x00, 0x00, - 0xff, 0xff, 0x9f, 0x5b, 0x5a, 0x63, 0x17, 0x03, 0x00, 0x00, + // 601 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x41, 0x6b, 0x13, 0x41, + 0x14, 0xce, 0x26, 0x69, 0xda, 0x8e, 0x25, 0xd6, 0x35, 0xb1, 0x89, 0x92, 0xdd, 0xb0, 0x68, 0x09, + 0x42, 0x77, 0xdb, 0x78, 0x91, 0x5e, 0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, 0x80, 0x07, 0xbf, 0x03, 0x00, 0x00, 0xff, + 0xff, 0xec, 0x81, 0x8e, 0x2d, 0x86, 0x05, 0x00, 0x00, } func (m *Minter) Marshal() (dAtA []byte, err error) { @@ -435,6 +617,137 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *Version2Minter) 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 *Version2Minter) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Version2Minter) 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 = encodeVarintMint(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0x22 + } + if m.LastMintHeight != 0 { + i = encodeVarintMint(dAtA, i, uint64(m.LastMintHeight)) + i-- + dAtA[i] = 0x18 + } + if len(m.LastMintDate) > 0 { + i -= len(m.LastMintDate) + copy(dAtA[i:], m.LastMintDate) + i = encodeVarintMint(dAtA, i, uint64(len(m.LastMintDate))) + i-- + dAtA[i] = 0x12 + } + { + size := m.LastMintAmount.Size() + i -= size + if _, err := m.LastMintAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintMint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *Version2ScheduledTokenRelease) 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 *Version2ScheduledTokenRelease) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Version2ScheduledTokenRelease) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.TokenReleaseAmount != 0 { + i = encodeVarintMint(dAtA, i, uint64(m.TokenReleaseAmount)) + i-- + dAtA[i] = 0x10 + } + if len(m.Date) > 0 { + i -= len(m.Date) + copy(dAtA[i:], m.Date) + i = encodeVarintMint(dAtA, i, uint64(len(m.Date))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Version2Params) 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 *Version2Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Version2Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.TokenReleaseSchedule) > 0 { + for iNdEx := len(m.TokenReleaseSchedule) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.TokenReleaseSchedule[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintMint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.MintDenom) > 0 { + i -= len(m.MintDenom) + copy(dAtA[i:], m.MintDenom) + i = encodeVarintMint(dAtA, i, uint64(len(m.MintDenom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintMint(dAtA []byte, offset int, v uint64) int { offset -= sovMint(v) base := offset @@ -519,16 +832,460 @@ func (m *Params) Size() (n int) { n += 1 + l + sovMint(uint64(l)) } } - return n -} + return n +} + +func (m *Version2Minter) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.LastMintAmount.Size() + n += 1 + l + sovMint(uint64(l)) + l = len(m.LastMintDate) + if l > 0 { + n += 1 + l + sovMint(uint64(l)) + } + if m.LastMintHeight != 0 { + n += 1 + sovMint(uint64(m.LastMintHeight)) + } + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovMint(uint64(l)) + } + return n +} + +func (m *Version2ScheduledTokenRelease) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Date) + if l > 0 { + n += 1 + l + sovMint(uint64(l)) + } + if m.TokenReleaseAmount != 0 { + n += 1 + sovMint(uint64(m.TokenReleaseAmount)) + } + return n +} + +func (m *Version2Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.MintDenom) + if l > 0 { + n += 1 + l + sovMint(uint64(l)) + } + if len(m.TokenReleaseSchedule) > 0 { + for _, e := range m.TokenReleaseSchedule { + l = e.Size() + n += 1 + l + sovMint(uint64(l)) + } + } + return n +} + +func sovMint(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozMint(x uint64) (n int) { + return sovMint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Minter) 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 ErrIntOverflowMint + } + 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: Minter: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Minter: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StartDate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + 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 ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StartDate = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EndDate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + 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 ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EndDate = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + 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 ErrIntOverflowMint + } + 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 ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalMintAmount", wireType) + } + m.TotalMintAmount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TotalMintAmount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RemainingMintAmount", wireType) + } + m.RemainingMintAmount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RemainingMintAmount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LastMintAmount", wireType) + } + m.LastMintAmount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LastMintAmount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LastMintDate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + 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 ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.LastMintDate = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LastMintHeight", wireType) + } + m.LastMintHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LastMintHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipMint(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMint + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ScheduledTokenRelease) 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 ErrIntOverflowMint + } + 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: ScheduledTokenRelease: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ScheduledTokenRelease: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StartDate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + 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 ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StartDate = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EndDate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + 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 ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EndDate = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenReleaseAmount", wireType) + } + m.TokenReleaseAmount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TokenReleaseAmount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipMint(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMint + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } -func sovMint(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozMint(x uint64) (n int) { - return sovMint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil } -func (m *Minter) Unmarshal(dAtA []byte) error { +func (m *Params) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -551,15 +1308,15 @@ func (m *Minter) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Minter: wiretype end group for non-group") + return fmt.Errorf("proto: Params: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Minter: illegal tag %d (wire type %d)", fieldNum, wire) + 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 StartDate", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field MintDenom", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -587,13 +1344,13 @@ func (m *Minter) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.StartDate = string(dAtA[iNdEx:postIndex]) + m.MintDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EndDate", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TokenReleaseSchedule", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowMint @@ -603,27 +1360,79 @@ func (m *Minter) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthMint } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthMint } if postIndex > l { return io.ErrUnexpectedEOF } - m.EndDate = string(dAtA[iNdEx:postIndex]) + m.TokenReleaseSchedule = append(m.TokenReleaseSchedule, ScheduledTokenRelease{}) + if err := m.TokenReleaseSchedule[len(m.TokenReleaseSchedule)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex - case 3: + default: + iNdEx = preIndex + skippy, err := skipMint(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMint + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Version2Minter) 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 ErrIntOverflowMint + } + 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: Version2Minter: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Version2Minter: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field LastMintAmount", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -651,13 +1460,15 @@ func (m *Minter) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Denom = string(dAtA[iNdEx:postIndex]) + if err := m.LastMintAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field TotalMintAmount", wireType) + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LastMintDate", wireType) } - m.TotalMintAmount = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowMint @@ -667,35 +1478,29 @@ func (m *Minter) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.TotalMintAmount |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field RemainingMintAmount", wireType) + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMint } - m.RemainingMintAmount = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.RemainingMintAmount |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint } - case 6: + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.LastMintDate = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field LastMintAmount", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field LastMintHeight", wireType) } - m.LastMintAmount = 0 + m.LastMintHeight = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowMint @@ -705,14 +1510,14 @@ func (m *Minter) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.LastMintAmount |= uint64(b&0x7F) << shift + m.LastMintHeight |= int64(b&0x7F) << shift if b < 0x80 { break } } - case 7: + case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LastMintDate", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -740,27 +1545,8 @@ func (m *Minter) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.LastMintDate = string(dAtA[iNdEx:postIndex]) + m.Denom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 8: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field LastMintHeight", wireType) - } - m.LastMintHeight = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.LastMintHeight |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipMint(dAtA[iNdEx:]) @@ -782,7 +1568,7 @@ func (m *Minter) Unmarshal(dAtA []byte) error { } return nil } -func (m *ScheduledTokenRelease) Unmarshal(dAtA []byte) error { +func (m *Version2ScheduledTokenRelease) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -805,15 +1591,15 @@ func (m *ScheduledTokenRelease) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: ScheduledTokenRelease: wiretype end group for non-group") + return fmt.Errorf("proto: Version2ScheduledTokenRelease: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: ScheduledTokenRelease: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Version2ScheduledTokenRelease: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StartDate", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Date", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -841,41 +1627,9 @@ func (m *ScheduledTokenRelease) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.StartDate = string(dAtA[iNdEx:postIndex]) + m.Date = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EndDate", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMint - } - 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 ErrInvalidLengthMint - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMint - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EndDate = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field TokenReleaseAmount", wireType) } @@ -889,7 +1643,7 @@ func (m *ScheduledTokenRelease) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.TokenReleaseAmount |= uint64(b&0x7F) << shift + m.TokenReleaseAmount |= int64(b&0x7F) << shift if b < 0x80 { break } @@ -915,7 +1669,7 @@ func (m *ScheduledTokenRelease) Unmarshal(dAtA []byte) error { } return nil } -func (m *Params) Unmarshal(dAtA []byte) error { +func (m *Version2Params) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -938,10 +1692,10 @@ func (m *Params) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Params: wiretype end group for non-group") + return fmt.Errorf("proto: Version2Params: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Version2Params: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1005,7 +1759,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.TokenReleaseSchedule = append(m.TokenReleaseSchedule, ScheduledTokenRelease{}) + m.TokenReleaseSchedule = append(m.TokenReleaseSchedule, Version2ScheduledTokenRelease{}) if err := m.TokenReleaseSchedule[len(m.TokenReleaseSchedule)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/mint/types/params.go b/x/mint/types/params.go index 58763dc544..0a269686a9 100644 --- a/x/mint/types/params.go +++ b/x/mint/types/params.go @@ -58,6 +58,11 @@ func (p Params) String() string { return string(out) } +func (p Version2Params) String() string { + out, _ := yaml.Marshal(p) + return string(out) +} + // Implements params.ParamSet func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ @@ -66,6 +71,14 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { } } +// Used for v2 -> v3 migration +func (p *Version2Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair(KeyMintDenom, &p.MintDenom, func(i interface{}) error { return nil }), + paramtypes.NewParamSetPair(KeyTokenReleaseSchedule, &p.TokenReleaseSchedule, func(i interface{}) error { return nil }), + } +} + func validateMintDenom(i interface{}) error { denomString, ok := i.(string) denomTrimed := strings.TrimSpace(denomString)