-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into alex/21429_build_systemtest
* main: docs: amend docs for 52 changes (#21992) test: migrate e2e/authz to system tests (#21819) refactor(runtime/v2): use StoreBuilder (#21989) feat(schema): add API descriptors, struct, oneof & list types, and wire encoding spec (#21482) docs: add instructions to change DefaultGenesis (#21680) feat(x/staking)!: Add metadata field to validator info (#21315) chore(x/authz)!: Remove account keeper dependency (#21632)
- Loading branch information
Showing
65 changed files
with
4,275 additions
and
3,079 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
sidebar_position: 1 | ||
--- | ||
|
||
### Modifying the `DefaultGenesis` | ||
|
||
It is possible to modify the DefaultGenesis parameters for modules by wrapping the module, providing it to the `*module.Manager` and injecting it with `depinject`. | ||
|
||
Example ( staking ) : | ||
|
||
```go | ||
type CustomStakingModule struct { | ||
staking.AppModule | ||
cdc codec.Codec | ||
} | ||
|
||
// DefaultGenesis will override the Staking module DefaultGenesis AppModuleBasic method. | ||
func (cm CustomStakingModule) DefaultGenesis() json.RawMessage { | ||
params := stakingtypes.DefaultParams() | ||
params.BondDenom = "mydenom" | ||
|
||
return cm.cdc.MustMarshalJSON(&stakingtypes.GenesisState{ | ||
Params: params, | ||
}) | ||
} | ||
|
||
// option 1 ( for depinject users ): override previous module manager | ||
depinject.Inject( | ||
// ... provider/invoker/supplier | ||
&moduleManager, | ||
) | ||
|
||
oldStakingModule,_ := moduleManager.Modules()[stakingtypes.ModuleName].(staking.AppModule) | ||
moduleManager.Modules()[stakingtypes.ModuleName] = CustomStakingModule{ | ||
AppModule: oldStakingModule, | ||
cdc: appCodec, | ||
} | ||
|
||
// option 2 ( for non depinject users ): use new module manager | ||
moduleManager := module.NewManagerFromMap(map[string]appmodule.AppModule{ | ||
stakingtypes.ModuleName: CustomStakingModule{cdc: appCodec, AppModule: staking.NewAppModule(...)}, | ||
// other modules ... | ||
}) | ||
|
||
// set the module manager | ||
app.ModuleManager = moduleManager | ||
``` |
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
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.