Skip to content

Commit

Permalink
feat(epochs): add wrapper of epoch getter (#22068)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xHansLee authored Oct 4, 2024
1 parent eec7392 commit dc14960
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 18 deletions.
4 changes: 3 additions & 1 deletion tests/integration/tx/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ package tx
import (
"testing"

"github.com/stretchr/testify/require"

"cosmossdk.io/depinject"
"cosmossdk.io/log"
_ "cosmossdk.io/x/accounts"
"cosmossdk.io/x/tx/signing"

codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/tests/integration/tx/internal"
"github.com/cosmos/cosmos-sdk/tests/integration/tx/internal/pulsar/testpb"
"github.com/cosmos/cosmos-sdk/testutil/configurator"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
"github.com/stretchr/testify/require"
)

func ProvideCustomGetSigner() signing.CustomGetSigner {
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/tx/internal/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/json"
"testing"

gogoproto "github.com/cosmos/gogoproto/proto"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/reflect/protoreflect"
Expand All @@ -26,7 +27,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
"github.com/cosmos/cosmos-sdk/x/auth/tx"
gogoproto "github.com/cosmos/gogoproto/proto"
)

var TestRepeatedFieldsSigner = signing.CustomGetSigner{
Expand Down
16 changes: 0 additions & 16 deletions x/epochs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,6 @@ The `epochs` module emits the following events:

Epochs keeper module provides utility functions to manage epochs.

``` go
// Keeper is the interface for epochs module keeper
type Keeper interface {
// GetEpochInfo returns epoch info by identifier
GetEpochInfo(ctx sdk.Context, identifier string) types.EpochInfo
// SetEpochInfo set epoch info
SetEpochInfo(ctx sdk.Context, epoch types.EpochInfo)
// DeleteEpochInfo delete epoch info
DeleteEpochInfo(ctx sdk.Context, identifier string)
// IterateEpochInfo iterate through epochs
IterateEpochInfo(ctx sdk.Context, fn func(index int64, epochInfo types.EpochInfo) (stop bool))
// Get all epoch infos
AllEpochInfos(ctx sdk.Context) []types.EpochInfo
}
```

## Hooks

```go
Expand Down
7 changes: 7 additions & 0 deletions x/epochs/keeper/epoch.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@ import (
"fmt"

"cosmossdk.io/x/epochs/types"

sdk "github.com/cosmos/cosmos-sdk/types"
)

// GetEpochInfo returns epoch info by identifier.
func (k Keeper) GetEpochInfo(ctx sdk.Context, identifier string) (types.EpochInfo, error) {
return k.EpochInfo.Get(ctx, identifier)
}

// AddEpochInfo adds a new epoch info. Will return an error if the epoch fails validation,
// or re-uses an existing identifier.
// This method also sets the start time if left unset, and sets the epoch start height.
Expand Down

0 comments on commit dc14960

Please sign in to comment.