-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
avery
committed
Nov 21, 2024
1 parent
2406be9
commit d63ad81
Showing
2 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |