Skip to content

Commit

Permalink
fix: fixed depinject issue
Browse files Browse the repository at this point in the history
  • Loading branch information
dumbeng committed Aug 16, 2024
1 parent 9c1ccc9 commit 94f989e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 71 deletions.
75 changes: 10 additions & 65 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,19 @@ func New(
logger,

// Supply block height getter, required by evm keeper
types.BlockGetter(app.LastBlockHeight),
types.BlockGetter(func() int64 {
return app.LastBlockHeight()
}),

// Supply subspace params getter, required by fee and evm keeper
app.GetSubspace,
types.ChainIDGetter(app.ChainID),

types.ChainIDGetter(func() string {
return app.ChainID()
}),

// Supply eth account
artela.ProtoAccount,

// ADVANCED CONFIGURATION
//
Expand Down Expand Up @@ -309,69 +317,6 @@ func New(
panic(err)
}

// Below we could construct and set an application specific mempool and
// ABCI 1.0 PrepareProposal and ProcessProposal handlers. These defaults are
// already set in the SDK's BaseApp, this shows an example of how to override
// them.
//
// Example:
//
// app.App = appBuilder.Build(...)
// nonceMempool := mempool.NewSenderNonceMempool()
// abciPropHandler := NewDefaultProposalHandler(nonceMempool, app.App.BaseApp)
//
// app.App.BaseApp.SetMempool(nonceMempool)
// app.App.BaseApp.SetPrepareProposal(abciPropHandler.PrepareProposalHandler())
// app.App.BaseApp.SetProcessProposal(abciPropHandler.ProcessProposalHandler())
//
// Alternatively, you can construct BaseApp options, append those to
// baseAppOptions and pass them to the appBuilder.
//
// Example:
//
// prepareOpt = func(app *baseapp.BaseApp) {
// abciPropHandler := baseapp.NewDefaultProposalHandler(nonceMempool, app)
// app.SetPrepareProposal(abciPropHandler.PrepareProposalHandler())
// }
// baseAppOptions = append(baseAppOptions, prepareOpt)
//
// create and set vote extension handler
// voteExtOp := func(bApp *baseapp.BaseApp) {
// voteExtHandler := NewVoteExtensionHandler()
// voteExtHandler.SetHandlers(bApp)
// }

//kvStores := storetypes.NewKVStoreKeys(
// authtypes.StoreKey, authz.ModuleName, banktypes.StoreKey, stakingmodule.StoreKey,
// crisistypes.StoreKey, minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
// govtypes.StoreKey, paramstypes.StoreKey, ibcexported.StoreKey, upgradetypes.StoreKey,
// feegrant.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey, icahosttypes.StoreKey,
// capabilitytypes.StoreKey, group.StoreKey, icacontrollertypes.StoreKey, consensustypes.StoreKey,
// evmmoduletypes.StoreKey,
// feemoduletypes.StoreKey,
// // this line is used by starport scaffolding # stargate/app/storeKey
//)
//
//for _, key := range kvStores {
// if err := app.RegisterStores(key); err != nil {
// panic(err)
// }
//}
//
//tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey, evmmoduletypes.TransientKey, feemoduletypes.TransientStoreKey)
//for _, key := range tkeys {
// if err := app.RegisterStores(key); err != nil {
// panic(err)
// }
//}
//
//memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
//for _, key := range memKeys {
// if err := app.RegisterStores(key); err != nil {
// panic(err)
// }
//}

app.App = appBuilder.Build(db, traceStore, baseAppOptions...)

// Register legacy modules
Expand Down
1 change: 1 addition & 0 deletions app/app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ var (
{Account: ibcfeetypes.ModuleName},
{Account: icatypes.ModuleName},
// this line is used by starport scaffolding # stargate/app/maccPerms
{Account: evmmoduletypes.ModuleName, Permissions: []string{authtypes.Minter, authtypes.Burner}},
}

// blocked account addresses
Expand Down
5 changes: 3 additions & 2 deletions ethereum/types/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"bytes"

codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
)

var (
_ authtypes.AccountI = (*EthAccount)(nil)
_ sdk.AccountI = (*EthAccount)(nil)
_ EthAccountI = (*EthAccount)(nil)
_ authtypes.GenesisAccount = (*EthAccount)(nil)
_ codectypes.UnpackInterfacesMessage = (*EthAccount)(nil)
Expand Down Expand Up @@ -44,7 +45,7 @@ type EthAccountI interface {

// ProtoAccount defines the prototype function for BaseAccount used for an
// AccountKeeper.
func ProtoAccount() authtypes.AccountI {
func ProtoAccount() sdk.AccountI {
return &EthAccount{
BaseAccount: &authtypes.BaseAccount{},
CodeHash: common.BytesToHash(emptyCodeHash).String(),
Expand Down
11 changes: 8 additions & 3 deletions x/evm/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type (
subSpace types.ParamSubspace
blockGetter types.BlockGetter
logger log.Logger
ChainIDGetter types.ChainIDGetter

// the address capable of executing a MsgUpdateParams message. Typically, this
// should be the x/gov module account.
Expand Down Expand Up @@ -117,8 +118,8 @@ func NewKeeper(
aspectRuntimeContext: aspectRuntimeContext,
aspect: aspect,
VerifySigCache: new(sync.Map),
ChainIDGetter: chainIDGetter,
}
k.WithChainID(chainIDGetter())

djpm.NewAspect(aspect, common.WrapLogger(k.logger.With("module", "aspect")))
api.InitAspectGlobals(&k)
Expand Down Expand Up @@ -158,8 +159,9 @@ func (k Keeper) GetClientContext() client.Context {
return k.clientContext
}

// WithChainID sets the chain id to the local variable in the keeper
func (k *Keeper) WithChainID(chainId string) {
// InitChainID sets the chain id to the local variable in the keeper
func (k *Keeper) InitChainID() {
chainId := k.ChainIDGetter()
if k.eip155ChainID != nil {
return
}
Expand All @@ -178,6 +180,9 @@ func (k *Keeper) WithChainID(chainId string) {

// ChainID returns the EIP155 chain ID for the EVM context
func (k Keeper) ChainID() *big.Int {
if k.eip155ChainID == nil {
k.InitChainID()
}
return k.eip155ChainID
}

Expand Down
1 change: 0 additions & 1 deletion x/evm/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/grpc-ecosystem/grpc-gateway/runtime"

// this line is used by starport scaffolding # 1

modulev1 "github.com/artela-network/artela-rollkit/api/artela/evm/module"
Expand Down

0 comments on commit 94f989e

Please sign in to comment.