Skip to content

Commit 9d8d03d

Browse files
docs: sync module interfaces with actual code (#25656)
Co-authored-by: Alex | Cosmos Labs <[email protected]>
1 parent 0a65efd commit 9d8d03d

File tree

6 files changed

+43
-25
lines changed

6 files changed

+43
-25
lines changed

x/auth/README.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -190,34 +190,40 @@ all fields of all accounts, and to iterate over all stored accounts.
190190
// AccountKeeperI is the interface contract that x/auth's keeper implements.
191191
type AccountKeeperI interface {
192192
// Return a new account with the next account number and the specified address. Does not save the new account to the store.
193-
NewAccountWithAddress(sdk.Context, sdk.AccAddress) types.AccountI
193+
NewAccountWithAddress(context.Context, sdk.AccAddress) sdk.AccountI
194194

195195
// Return a new account with the next account number. Does not save the new account to the store.
196-
NewAccount(sdk.Context, types.AccountI) types.AccountI
196+
NewAccount(context.Context, sdk.AccountI) sdk.AccountI
197197

198198
// Check if an account exists in the store.
199-
HasAccount(sdk.Context, sdk.AccAddress) bool
199+
HasAccount(context.Context, sdk.AccAddress) bool
200200

201201
// Retrieve an account from the store.
202-
GetAccount(sdk.Context, sdk.AccAddress) types.AccountI
202+
GetAccount(context.Context, sdk.AccAddress) sdk.AccountI
203203

204204
// Set an account in the store.
205-
SetAccount(sdk.Context, types.AccountI)
205+
SetAccount(context.Context, sdk.AccountI)
206206

207207
// Remove an account from the store.
208-
RemoveAccount(sdk.Context, types.AccountI)
208+
RemoveAccount(context.Context, sdk.AccountI)
209209

210210
// Iterate over all accounts, calling the provided function. Stop iteration when it returns true.
211-
IterateAccounts(sdk.Context, func(types.AccountI) bool)
211+
IterateAccounts(context.Context, func(sdk.AccountI) bool)
212212

213213
// Fetch the public key of an account at a specified address
214-
GetPubKey(sdk.Context, sdk.AccAddress) (crypto.PubKey, error)
214+
GetPubKey(context.Context, sdk.AccAddress) (cryptotypes.PubKey, error)
215215

216216
// Fetch the sequence of an account at a specified address.
217-
GetSequence(sdk.Context, sdk.AccAddress) (uint64, error)
217+
GetSequence(context.Context, sdk.AccAddress) (uint64, error)
218218

219219
// Fetch the next account number, and increment the internal counter.
220-
NextAccountNumber(sdk.Context) uint64
220+
NextAccountNumber(context.Context) uint64
221+
222+
// GetModulePermissions fetches per-module account permissions
223+
GetModulePermissions() map[string]types.PermissionsForAddress
224+
225+
// AddressCodec returns the account address codec.
226+
AddressCodec() address.Codec
221227
}
222228
```
223229

x/bank/README.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ Restricted permission to mint per module could be achieved by using baseKeeper w
193193
// between accounts.
194194
type Keeper interface {
195195
SendKeeper
196-
WithMintCoinsRestriction(MintingRestrictionFn) BaseKeeper
196+
WithMintCoinsRestriction(types.MintingRestrictionFn) BaseKeeper
197+
WithObjStoreKey(storetypes.StoreKey) BaseKeeper
197198

198199
InitGenesis(context.Context, *types.GenesisState)
199200
ExportGenesis(context.Context) *types.GenesisState
@@ -205,6 +206,7 @@ type Keeper interface {
205206
GetDenomMetaData(ctx context.Context, denom string) (types.Metadata, bool)
206207
HasDenomMetaData(ctx context.Context, denom string) bool
207208
SetDenomMetaData(ctx context.Context, denomMetaData types.Metadata)
209+
GetAllDenomMetaData(ctx context.Context) []types.Metadata
208210
IterateAllDenomMetaData(ctx context.Context, cb func(types.Metadata) bool)
209211

210212
SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
@@ -215,12 +217,15 @@ type Keeper interface {
215217
MintCoins(ctx context.Context, moduleName string, amt sdk.Coins) error
216218
BurnCoins(ctx context.Context, moduleName string, amt sdk.Coins) error
217219

220+
SendCoinsFromAccountToModuleVirtual(ctx context.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
221+
SendCoinsFromModuleToAccountVirtual(ctx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
222+
CreditVirtualAccounts(ctx context.Context) error
223+
SendCoinsFromVirtual(ctx context.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error
224+
SendCoinsToVirtual(ctx context.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error
225+
218226
DelegateCoins(ctx context.Context, delegatorAddr, moduleAccAddr sdk.AccAddress, amt sdk.Coins) error
219227
UndelegateCoins(ctx context.Context, moduleAccAddr, delegatorAddr sdk.AccAddress, amt sdk.Coins) error
220228

221-
// GetAuthority gets the address capable of executing governance proposal messages. Usually the gov module account.
222-
GetAuthority() string
223-
224229
types.QueryServer
225230
}
226231
```
@@ -236,8 +241,8 @@ accounts. The send keeper does not alter the total supply (mint or burn coins).
236241
type SendKeeper interface {
237242
ViewKeeper
238243

239-
AppendSendRestriction(restriction SendRestrictionFn)
240-
PrependSendRestriction(restriction SendRestrictionFn)
244+
AppendSendRestriction(restriction types.SendRestrictionFn)
245+
PrependSendRestriction(restriction types.SendRestrictionFn)
241246
ClearSendRestriction()
242247

243248
InputOutputCoins(ctx context.Context, input types.Input, outputs []types.Output) error
@@ -247,16 +252,20 @@ type SendKeeper interface {
247252
SetParams(ctx context.Context, params types.Params) error
248253

249254
IsSendEnabledDenom(ctx context.Context, denom string) bool
255+
GetSendEnabledEntry(ctx context.Context, denom string) (types.SendEnabled, bool)
250256
SetSendEnabled(ctx context.Context, denom string, value bool)
251257
SetAllSendEnabled(ctx context.Context, sendEnableds []*types.SendEnabled)
252-
DeleteSendEnabled(ctx context.Context, denom string)
258+
DeleteSendEnabled(ctx context.Context, denoms ...string)
253259
IterateSendEnabledEntries(ctx context.Context, cb func(denom string, sendEnabled bool) (stop bool))
254260
GetAllSendEnabledEntries(ctx context.Context) []types.SendEnabled
255261

256262
IsSendEnabledCoin(ctx context.Context, coin sdk.Coin) bool
257263
IsSendEnabledCoins(ctx context.Context, coins ...sdk.Coin) error
258264

259265
BlockedAddr(addr sdk.AccAddress) bool
266+
GetBlockedAddresses() map[string]bool
267+
268+
GetAuthority() string
260269
}
261270
```
262271

x/epochs/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ Epochs keeper module provides utility functions to manage epochs.
7272

7373
```go
7474
// the first block whose timestamp is after the duration is counted as the end of the epoch
75-
AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber int64)
75+
AfterEpochEnd(ctx context.Context, epochIdentifier string, epochNumber int64) error
7676
// new epoch is next block of epoch end block
77-
BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber int64)
77+
BeforeEpochStart(ctx context.Context, epochIdentifier string, epochNumber int64) error
7878
```
7979

8080
### How modules receive hooks
@@ -87,11 +87,12 @@ modules so that they can be modified by governance.
8787
This is the standard dev UX of this:
8888

8989
```golang
90-
func (k MyModuleKeeper) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber int64) {
90+
func (k MyModuleKeeper) AfterEpochEnd(ctx context.Context, epochIdentifier string, epochNumber int64) error {
9191
params := k.GetParams(ctx)
9292
if epochIdentifier == params.DistrEpochIdentifier {
9393
// my logic
9494
}
95+
return nil
9596
}
9697
```
9798

x/mint/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ inflation calculation logic is needed, this can be achieved by defining and
160160
passing a function that matches `InflationCalculationFn`'s signature.
161161

162162
```go
163-
type InflationCalculationFn func(ctx sdk.Context, minter Minter, params Params, bondedRatio math.LegacyDec) math.LegacyDec
163+
type InflationCalculationFn func(ctx context.Context, minter Minter, params Params, bondedRatio math.LegacyDec) math.LegacyDec
164164
```
165165

166166
#### NextInflationRate

x/staking/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -837,11 +837,13 @@ following hooks can registered with staking:
837837
* called when a delegation is created
838838
* `BeforeDelegationSharesModified(Context, AccAddress, ValAddress) error`
839839
* called when a delegation's shares are modified
840-
* `AfterDelegationModified(Context, AccAddress, ValAddress) error`
841-
* called when a delegation is created or modified
842840
* `BeforeDelegationRemoved(Context, AccAddress, ValAddress) error`
843841
* called when a delegation is removed
844-
* `AfterUnbondingInitiated(Context, UnbondingID)`
842+
* `AfterDelegationModified(Context, AccAddress, ValAddress) error`
843+
* called when a delegation is created or modified
844+
* `BeforeValidatorSlashed(Context, ValAddress, math.LegacyDec) error`
845+
* called when a validator is about to be slashed
846+
* `AfterUnbondingInitiated(Context, UnbondingID) error`
845847
* called when an unbonding operation (validator unbonding, unbonding delegation, redelegation) was initiated
846848

847849

x/upgrade/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ and not defined on a per-module basis. Registering a `Handler` is done via
6767
`Keeper#SetUpgradeHandler` in the application.
6868

6969
```go
70-
type UpgradeHandler func(Context, Plan, VersionMap) (VersionMap, error)
70+
type UpgradeHandler func(ctx context.Context, plan Plan, fromVM module.VersionMap) (module.VersionMap, error)
7171
```
7272

7373
During each `EndBlock` execution, the `x/upgrade` module checks if there exists a

0 commit comments

Comments
 (0)