-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update mint module #273
Merged
Merged
Update mint module #273
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d3fc4be
Update mint module
dimiandre f734102
lints
faddat 3bd7929
total supply....
faddat f450ecc
more tests
faddat 4db15ef
fix tests
dimiandre 8e0d3e7
fix genesis test and decoder test
dimiandre 514eb52
superlinter settings
faddat f238b07
lint proto
dimiandre 98b7e89
ignore generated files with superlinter
dimiandre 6afbd2a
Merge branch 'main' into dimi/inflation
faddat 39e4895
add migration for mint module
dimiandre e5c5f17
change upgrade name, calculate target supply
dimiandre 886b8c8
Remove extra logging, add extra test case and a couple of comments
the-frey 78d3b6a
Hopefully shut the linter up
the-frey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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. Specifically, it take calculate target supply for the current phase | ||
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods