-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
ADR 11: Generalize Gen Accounts implementation #5017
Merged
Merged
Changes from 7 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
40ed336
ADR 11: Generalize Gen Accounts implementation
fedekunze 90a3882
move CLI cmd to auth
fedekunze 8e92e02
delete genaccount module
fedekunze e1e4993
add some tests
fedekunze 84f92dd
more fixes
fedekunze 19fd7c8
register codec
fedekunze 7085b9c
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into fe…
fedekunze 0b6bbb5
Apply suggestions from code review
fedekunze e6bf7c4
address comments from review
fedekunze ac7aaef
Merge branch 'fedekunze/ADR-11-generalize-gen-accs' of https://github…
fedekunze e9d215a
remove genaccounts command
fedekunze 5a69363
keep legacy genaccount migrations
fedekunze 6c4b702
update genutil migration
fedekunze 4e5e1a2
format
fedekunze 6288793
migrate
fedekunze fe125bf
iterator
fedekunze 1198733
Update godoc
alexanderbez f07fabc
Update godoc
alexanderbez 2979564
Remove RegisterAccountTypeCodec call from supply
alexanderbez 3636574
Merge branch 'master' into fedekunze/ADR-11-generalize-gen-accs
alexanderbez da91323
re-add RegisterAccountTypeCodec
alexanderbez 42b04ee
Update godoc
alexanderbez 7cef4d1
Add sim genesis concrete type
alexanderbez ae1569f
Fix migration
alexanderbez 3d924db
Add ref for https://github.com/cosmos/cosmos-sdk/issues/5041
alexanderbez 1d16d34
Add changelog entries
alexanderbez 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ import ( | |
"github.com/cosmos/cosmos-sdk/codec" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/x/auth" | ||
"github.com/cosmos/cosmos-sdk/x/genaccounts" | ||
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported" | ||
"github.com/cosmos/cosmos-sdk/x/supply" | ||
) | ||
|
||
|
@@ -45,13 +45,17 @@ func Setup(isCheckTx bool) *SimApp { | |
|
||
// SetupWithGenesisAccounts initializes a new SimApp with the passed in | ||
// genesis accounts. | ||
func SetupWithGenesisAccounts(genAccs genaccounts.GenesisAccounts) *SimApp { | ||
func SetupWithGenesisAccounts(genAccs []authexported.GenesisAccount) *SimApp { | ||
db := dbm.NewMemDB() | ||
app := NewSimApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0) | ||
|
||
// initialize the chain with the passed in genesis accounts | ||
genesisState := NewDefaultGenesisState() | ||
genesisState = genaccounts.SetGenesisStateInAppState(app.Codec(), genesisState, genaccounts.GenesisState(genAccs)) | ||
|
||
authGenesis := auth.NewGenesisState(auth.DefaultParams(), genAccs) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what are the default params here btw? |
||
genesisStateBz := app.cdc.MustMarshalJSON(authGenesis) | ||
genesisState[auth.ModuleName] = genesisStateBz | ||
|
||
stateBytes, err := codec.MarshalJSONIndent(app.cdc, genesisState) | ||
if err != nil { | ||
panic(err) | ||
|
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 |
---|---|---|
|
@@ -57,3 +57,9 @@ type VestingAccount interface { | |
GetDelegatedFree() sdk.Coins | ||
GetDelegatedVesting() sdk.Coins | ||
} | ||
|
||
// GenesisAccount defines an Account with a validation function. | ||
fedekunze marked this conversation as resolved.
Show resolved
Hide resolved
|
||
type GenesisAccount interface { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice! I'm a fan of this pattern |
||
Account | ||
Validate() error | ||
} |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally we should provided a function:
SealAccountTypeCodec
to be used after all auth types have been registeredThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this function is necessary. The application will call
{module}.ModuleCdc.Seal()
somewhere near the end in the app constructor (e.g.gov.ModuleCdc.Seal()
).