-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #273 from CosmosContracts/dimi/inflation
Update mint module
- Loading branch information
Showing
12 changed files
with
224 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package keeper | ||
|
||
import ( | ||
v2 "github.com/CosmosContracts/juno/v10/x/mint/migrations/v2" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
// Migrator is a struct for handling in-place state migrations. | ||
type Migrator struct { | ||
keeper Keeper | ||
} | ||
|
||
func NewMigrator(k Keeper) Migrator { | ||
return Migrator{ | ||
keeper: k, | ||
} | ||
} | ||
|
||
// Migrate migrates the x/mint module state from the consensus version | ||
// 1 to version 2 | ||
func (m Migrator) Migrate1to2(ctx sdk.Context) error { | ||
return v2.Migrate(ctx, ctx.KVStore(m.keeper.storeKey), m.keeper.cdc) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package v2 | ||
|
||
import ( | ||
"github.com/CosmosContracts/juno/v10/x/mint/types" | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
const ( | ||
ModuleName = "mint" | ||
) | ||
|
||
// Migrate migrates the x/mint module state from the consensus version 1 to | ||
// version 2. Specifically, it take calculate target supply for the current phase | ||
func Migrate( | ||
ctx sdk.Context, | ||
store sdk.KVStore, | ||
cdc codec.BinaryCodec, | ||
) error { | ||
|
||
// Get minter | ||
var minter types.Minter | ||
b := store.Get(types.MinterKey) | ||
if b == nil { | ||
panic("stored minter should not have been nil") | ||
} | ||
|
||
cdc.MustUnmarshal(b, &minter) | ||
|
||
// Calculate target supply | ||
minter.TargetSupply = minter.AnnualProvisions.Add(minter.AnnualProvisions.Quo(minter.Inflation)).TruncateInt() | ||
|
||
// Save new minter | ||
bz := cdc.MustMarshal(&minter) | ||
store.Set(types.MinterKey, bz) | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.