docs: sync module interfaces with actual code (#25656)
Co-authored-by: Alex | Cosmos Labs <alex@cosmoslabs.io>
This commit is contained in:
parent
0a65efd5c4
commit
9d8d03dc4a
@ -190,34 +190,40 @@ all fields of all accounts, and to iterate over all stored accounts.
|
||||
// AccountKeeperI is the interface contract that x/auth's keeper implements.
|
||||
type AccountKeeperI interface {
|
||||
// Return a new account with the next account number and the specified address. Does not save the new account to the store.
|
||||
NewAccountWithAddress(sdk.Context, sdk.AccAddress) types.AccountI
|
||||
NewAccountWithAddress(context.Context, sdk.AccAddress) sdk.AccountI
|
||||
|
||||
// Return a new account with the next account number. Does not save the new account to the store.
|
||||
NewAccount(sdk.Context, types.AccountI) types.AccountI
|
||||
NewAccount(context.Context, sdk.AccountI) sdk.AccountI
|
||||
|
||||
// Check if an account exists in the store.
|
||||
HasAccount(sdk.Context, sdk.AccAddress) bool
|
||||
HasAccount(context.Context, sdk.AccAddress) bool
|
||||
|
||||
// Retrieve an account from the store.
|
||||
GetAccount(sdk.Context, sdk.AccAddress) types.AccountI
|
||||
GetAccount(context.Context, sdk.AccAddress) sdk.AccountI
|
||||
|
||||
// Set an account in the store.
|
||||
SetAccount(sdk.Context, types.AccountI)
|
||||
SetAccount(context.Context, sdk.AccountI)
|
||||
|
||||
// Remove an account from the store.
|
||||
RemoveAccount(sdk.Context, types.AccountI)
|
||||
RemoveAccount(context.Context, sdk.AccountI)
|
||||
|
||||
// Iterate over all accounts, calling the provided function. Stop iteration when it returns true.
|
||||
IterateAccounts(sdk.Context, func(types.AccountI) bool)
|
||||
IterateAccounts(context.Context, func(sdk.AccountI) bool)
|
||||
|
||||
// Fetch the public key of an account at a specified address
|
||||
GetPubKey(sdk.Context, sdk.AccAddress) (crypto.PubKey, error)
|
||||
GetPubKey(context.Context, sdk.AccAddress) (cryptotypes.PubKey, error)
|
||||
|
||||
// Fetch the sequence of an account at a specified address.
|
||||
GetSequence(sdk.Context, sdk.AccAddress) (uint64, error)
|
||||
GetSequence(context.Context, sdk.AccAddress) (uint64, error)
|
||||
|
||||
// Fetch the next account number, and increment the internal counter.
|
||||
NextAccountNumber(sdk.Context) uint64
|
||||
NextAccountNumber(context.Context) uint64
|
||||
|
||||
// GetModulePermissions fetches per-module account permissions
|
||||
GetModulePermissions() map[string]types.PermissionsForAddress
|
||||
|
||||
// AddressCodec returns the account address codec.
|
||||
AddressCodec() address.Codec
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@ -193,7 +193,8 @@ Restricted permission to mint per module could be achieved by using baseKeeper w
|
||||
// between accounts.
|
||||
type Keeper interface {
|
||||
SendKeeper
|
||||
WithMintCoinsRestriction(MintingRestrictionFn) BaseKeeper
|
||||
WithMintCoinsRestriction(types.MintingRestrictionFn) BaseKeeper
|
||||
WithObjStoreKey(storetypes.StoreKey) BaseKeeper
|
||||
|
||||
InitGenesis(context.Context, *types.GenesisState)
|
||||
ExportGenesis(context.Context) *types.GenesisState
|
||||
@ -205,6 +206,7 @@ type Keeper interface {
|
||||
GetDenomMetaData(ctx context.Context, denom string) (types.Metadata, bool)
|
||||
HasDenomMetaData(ctx context.Context, denom string) bool
|
||||
SetDenomMetaData(ctx context.Context, denomMetaData types.Metadata)
|
||||
GetAllDenomMetaData(ctx context.Context) []types.Metadata
|
||||
IterateAllDenomMetaData(ctx context.Context, cb func(types.Metadata) bool)
|
||||
|
||||
SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
|
||||
@ -215,12 +217,15 @@ type Keeper interface {
|
||||
MintCoins(ctx context.Context, moduleName string, amt sdk.Coins) error
|
||||
BurnCoins(ctx context.Context, moduleName string, amt sdk.Coins) error
|
||||
|
||||
SendCoinsFromAccountToModuleVirtual(ctx context.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
|
||||
SendCoinsFromModuleToAccountVirtual(ctx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
|
||||
CreditVirtualAccounts(ctx context.Context) error
|
||||
SendCoinsFromVirtual(ctx context.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error
|
||||
SendCoinsToVirtual(ctx context.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error
|
||||
|
||||
DelegateCoins(ctx context.Context, delegatorAddr, moduleAccAddr sdk.AccAddress, amt sdk.Coins) error
|
||||
UndelegateCoins(ctx context.Context, moduleAccAddr, delegatorAddr sdk.AccAddress, amt sdk.Coins) error
|
||||
|
||||
// GetAuthority gets the address capable of executing governance proposal messages. Usually the gov module account.
|
||||
GetAuthority() string
|
||||
|
||||
types.QueryServer
|
||||
}
|
||||
```
|
||||
@ -236,8 +241,8 @@ accounts. The send keeper does not alter the total supply (mint or burn coins).
|
||||
type SendKeeper interface {
|
||||
ViewKeeper
|
||||
|
||||
AppendSendRestriction(restriction SendRestrictionFn)
|
||||
PrependSendRestriction(restriction SendRestrictionFn)
|
||||
AppendSendRestriction(restriction types.SendRestrictionFn)
|
||||
PrependSendRestriction(restriction types.SendRestrictionFn)
|
||||
ClearSendRestriction()
|
||||
|
||||
InputOutputCoins(ctx context.Context, input types.Input, outputs []types.Output) error
|
||||
@ -247,9 +252,10 @@ type SendKeeper interface {
|
||||
SetParams(ctx context.Context, params types.Params) error
|
||||
|
||||
IsSendEnabledDenom(ctx context.Context, denom string) bool
|
||||
GetSendEnabledEntry(ctx context.Context, denom string) (types.SendEnabled, bool)
|
||||
SetSendEnabled(ctx context.Context, denom string, value bool)
|
||||
SetAllSendEnabled(ctx context.Context, sendEnableds []*types.SendEnabled)
|
||||
DeleteSendEnabled(ctx context.Context, denom string)
|
||||
DeleteSendEnabled(ctx context.Context, denoms ...string)
|
||||
IterateSendEnabledEntries(ctx context.Context, cb func(denom string, sendEnabled bool) (stop bool))
|
||||
GetAllSendEnabledEntries(ctx context.Context) []types.SendEnabled
|
||||
|
||||
@ -257,6 +263,9 @@ type SendKeeper interface {
|
||||
IsSendEnabledCoins(ctx context.Context, coins ...sdk.Coin) error
|
||||
|
||||
BlockedAddr(addr sdk.AccAddress) bool
|
||||
GetBlockedAddresses() map[string]bool
|
||||
|
||||
GetAuthority() string
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@ -72,9 +72,9 @@ Epochs keeper module provides utility functions to manage epochs.
|
||||
|
||||
```go
|
||||
// the first block whose timestamp is after the duration is counted as the end of the epoch
|
||||
AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber int64)
|
||||
AfterEpochEnd(ctx context.Context, epochIdentifier string, epochNumber int64) error
|
||||
// new epoch is next block of epoch end block
|
||||
BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber int64)
|
||||
BeforeEpochStart(ctx context.Context, epochIdentifier string, epochNumber int64) error
|
||||
```
|
||||
|
||||
### How modules receive hooks
|
||||
@ -87,11 +87,12 @@ modules so that they can be modified by governance.
|
||||
This is the standard dev UX of this:
|
||||
|
||||
```golang
|
||||
func (k MyModuleKeeper) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber int64) {
|
||||
func (k MyModuleKeeper) AfterEpochEnd(ctx context.Context, epochIdentifier string, epochNumber int64) error {
|
||||
params := k.GetParams(ctx)
|
||||
if epochIdentifier == params.DistrEpochIdentifier {
|
||||
// my logic
|
||||
}
|
||||
return nil
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@ -160,7 +160,7 @@ inflation calculation logic is needed, this can be achieved by defining and
|
||||
passing a function that matches `InflationCalculationFn`'s signature.
|
||||
|
||||
```go
|
||||
type InflationCalculationFn func(ctx sdk.Context, minter Minter, params Params, bondedRatio math.LegacyDec) math.LegacyDec
|
||||
type InflationCalculationFn func(ctx context.Context, minter Minter, params Params, bondedRatio math.LegacyDec) math.LegacyDec
|
||||
```
|
||||
|
||||
#### NextInflationRate
|
||||
|
||||
@ -837,11 +837,13 @@ following hooks can registered with staking:
|
||||
* called when a delegation is created
|
||||
* `BeforeDelegationSharesModified(Context, AccAddress, ValAddress) error`
|
||||
* called when a delegation's shares are modified
|
||||
* `AfterDelegationModified(Context, AccAddress, ValAddress) error`
|
||||
* called when a delegation is created or modified
|
||||
* `BeforeDelegationRemoved(Context, AccAddress, ValAddress) error`
|
||||
* called when a delegation is removed
|
||||
* `AfterUnbondingInitiated(Context, UnbondingID)`
|
||||
* `AfterDelegationModified(Context, AccAddress, ValAddress) error`
|
||||
* called when a delegation is created or modified
|
||||
* `BeforeValidatorSlashed(Context, ValAddress, math.LegacyDec) error`
|
||||
* called when a validator is about to be slashed
|
||||
* `AfterUnbondingInitiated(Context, UnbondingID) error`
|
||||
* called when an unbonding operation (validator unbonding, unbonding delegation, redelegation) was initiated
|
||||
|
||||
|
||||
|
||||
@ -67,7 +67,7 @@ and not defined on a per-module basis. Registering a `Handler` is done via
|
||||
`Keeper#SetUpgradeHandler` in the application.
|
||||
|
||||
```go
|
||||
type UpgradeHandler func(Context, Plan, VersionMap) (VersionMap, error)
|
||||
type UpgradeHandler func(ctx context.Context, plan Plan, fromVM module.VersionMap) (module.VersionMap, error)
|
||||
```
|
||||
|
||||
During each `EndBlock` execution, the `x/upgrade` module checks if there exists a
|
||||
|
||||
Loading…
Reference in New Issue
Block a user