Skip to content
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

update simapp #463

Merged
merged 3 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions simapp/app_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ func NewSimApp(
// mocks.ProvideEVMKeeper(),
// mocks.ProvideICS20Keeper(),
),
depinject.Provide(NewDistrKeeperAdapter, NewGovKeeperAdapter),
)
)

Expand Down
51 changes: 50 additions & 1 deletion simapp/types.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,59 @@
package simapp

import "cosmossdk.io/depinject"
import (
"context"

"cosmossdk.io/depinject"
sdk "github.com/cosmos/cosmos-sdk/types"
distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
)

// DepinjectOptions are passed to the app on creation
type DepinjectOptions struct {
Config depinject.Config
Providers []interface{}
Consumers []interface{}
}

type DistrKeeperAdapter struct {
keeper distrkeeper.Keeper
}

func NewDistrKeeperAdapter(keeper distrkeeper.Keeper) DistrKeeperAdapter {
return DistrKeeperAdapter{keeper: keeper}
}

func (a DistrKeeperAdapter) GetFeePool(ctx sdk.Context) (distrtypes.FeePool, error) {
return a.keeper.FeePool.Get(ctx)
}

func (a DistrKeeperAdapter) SetFeePool(ctx sdk.Context, feePool distrtypes.FeePool) error {
return a.keeper.FeePool.Set(ctx, feePool)
}

type GovKeeperAdapter struct {
keeper *govkeeper.Keeper
}

func NewGovKeeperAdapter(keeper *govkeeper.Keeper) GovKeeperAdapter {
return GovKeeperAdapter{keeper: keeper}
}

func (a GovKeeperAdapter) SubmitProposal(ctx context.Context, messages []sdk.Msg, metadata, title, summary string, proposer sdk.AccAddress, expedited bool) (v1.Proposal, error) {
return a.keeper.SubmitProposal(ctx, messages, metadata, title, summary, proposer, expedited)
}

func (a GovKeeperAdapter) AddDeposit(ctx context.Context, proposalID uint64, depositorAddr sdk.AccAddress, depositAmount sdk.Coins) (bool, error) {
return a.keeper.AddDeposit(ctx, proposalID, depositorAddr, depositAmount)
}

func (a GovKeeperAdapter) GetProposal(ctx context.Context, proposalID uint64) (v1.Proposal, error) {
return a.keeper.Proposals.Get(ctx, proposalID)
}

func (a GovKeeperAdapter) GetGovernanceAccount(ctx context.Context) sdk.ModuleAccountI {
return a.keeper.GetGovernanceAccount(ctx)
}
Loading