-
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
feat: allow custom authority and inflation function when using app-wiring #12660
Changes from 5 commits
7aa3be0
a2ce0b9
58d2e8b
3c9dce0
7d8f14f
7ca8844
d623377
d0d947c
b034038
fdbd8be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package types | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
type CrisisAuthority sdk.AccAddress | ||
|
||
func (a CrisisAuthority) String() string { | ||
return sdk.AccAddress(a).String() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package types | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
type DistrAuthority sdk.AccAddress | ||
|
||
func (a DistrAuthority) String() string { | ||
return sdk.AccAddress(a).String() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -236,9 +236,11 @@ func provideModuleBasic() runtime.AppModuleBasicWrapper { | |
type mintInputs struct { | ||
depinject.In | ||
|
||
Config *modulev1.Module | ||
Key *store.KVStoreKey | ||
Cdc codec.Codec | ||
Config *modulev1.Module | ||
Key *store.KVStoreKey | ||
Cdc codec.Codec | ||
Authority types.MintAuthority `optional:"true"` | ||
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. slightly lost where this gets set? I thought you would need to modify protobuf config of each module? (https://github.com/cosmos/cosmos-sdk/blob/main/proto/cosmos/mint/module/v1/module.proto#L13) 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. We set it in the app.go in 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. makes sense. still trying to wrap my head around some of DI |
||
InflationCalculationFn types.InflationCalculationFn `optional:"true"` | ||
|
||
// LegacySubspace is used solely for migration of x/params managed parameters | ||
LegacySubspace exported.Subspace | ||
|
@@ -261,18 +263,24 @@ func provideModule(in mintInputs) mintOutputs { | |
feeCollectorName = authtypes.FeeCollectorName | ||
} | ||
|
||
authority := in.Authority | ||
if authority == nil || len(authority) == 0 { | ||
// default to governance authority if not provided | ||
authority = types.MintAuthority(authtypes.NewModuleAddress(govtypes.ModuleName)) | ||
} | ||
|
||
k := keeper.NewKeeper( | ||
in.Cdc, | ||
in.Key, | ||
in.StakingKeeper, | ||
in.AccountKeeper, | ||
in.BankKeeper, | ||
feeCollectorName, | ||
authtypes.NewModuleAddress(govtypes.ModuleName).String(), | ||
authority.String(), | ||
) | ||
|
||
// TODO: allow to set inflation calculation function | ||
m := NewAppModule(in.Cdc, k, in.AccountKeeper, nil, in.LegacySubspace) | ||
// when no inflation calculation function is provided it will use the default types.DefaultInflationCalculationFn | ||
m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.InflationCalculationFn, in.LegacySubspace) | ||
|
||
return mintOutputs{MintKeeper: k, Module: runtime.WrapAppModule(m)} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package types | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
type MintAuthority sdk.AccAddress | ||
|
||
func (a MintAuthority) String() string { | ||
return sdk.AccAddress(a).String() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package types | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
type SlashingAuthority sdk.AccAddress | ||
|
||
func (a SlashingAuthority) String() string { | ||
return sdk.AccAddress(a).String() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package types | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
type UpgradeAuthority sdk.AccAddress | ||
|
||
func (a UpgradeAuthority) String() string { | ||
return sdk.AccAddress(a).String() | ||
} |
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.
Why is there a need for a dedicated type (alias)?
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.
If we named them all
Authority
, there would be a name collision.Let me try another implementation to see which one you prefer
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.
I've simplified it in d623377. What do you think?