Skip to content

Commit

Permalink
update simapp
Browse files Browse the repository at this point in the history
  • Loading branch information
avery committed Nov 21, 2024
1 parent 2406be9 commit d63ad81
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
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
50 changes: 49 additions & 1 deletion simapp/types.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,58 @@
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)
}

0 comments on commit d63ad81

Please sign in to comment.