-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
migrator.go
48 lines (39 loc) · 1.11 KB
/
migrator.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package keeper
import (
"context"
"cosmossdk.io/x/mint/types"
)
// Migrator is a struct for handling in-place state migrations.
type Migrator struct {
keeper *Keeper
}
// NewMigrator returns Migrator instance for the state migration.
func NewMigrator(k *Keeper) Migrator {
return Migrator{
keeper: k,
}
}
// Migrate1to2 migrates the x/mint module state from the consensus version 1 to
// version 2. Specifically, it takes the parameters that are currently stored
// and managed by the x/params modules and stores them directly into the x/mint
// module state.
func (m Migrator) Migrate1to2(_ context.Context) error {
return nil
}
// Migrate2to3 migrates the x/mint module state from the consensus version 2 to
// version 3.
func (m Migrator) Migrate2to3(ctx context.Context) error {
params, err := m.keeper.Params.Get(ctx)
if err != nil {
return err
}
// Initialize the new MaxSupply parameter with the default value
defaultParams := types.DefaultParams()
params.MaxSupply = defaultParams.MaxSupply
// Set the updated params
err = m.keeper.Params.Set(ctx, params)
if err != nil {
return err
}
return nil
}