Skip to content

Commit

Permalink
constant refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuang committed Oct 31, 2023
1 parent 3a4335c commit b65f2b1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion x/cronos/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ func (k Keeper) onPacketResult(
return err
}

if stateDB, ok := ctx.Value("statedb").(vm.StateDB); ok {
if stateDB, ok := ctx.Value(types.StateDBContextKey).(vm.StateDB); ok {
for _, l := range rsp.Logs {
stateDB.AddLog(l.ToEthereum())
}
Expand Down
3 changes: 2 additions & 1 deletion x/cronos/keeper/precompiles/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/crypto-org-chain/cronos/v2/x/cronos/types"
"github.com/ethereum/go-ethereum/common"
"github.com/evmos/ethermint/x/evm/statedb"
)
Expand Down Expand Up @@ -45,7 +46,7 @@ func exec[Req any, PReq interface {
var res Resp
if err := stateDB.ExecuteNativeAction(contract, converter, func(ctx sdk.Context) error {
var err error
ctx = ctx.WithValue("statedb", stateDB)
ctx = ctx.WithValue(types.StateDBContextKey, stateDB)
res, err = action(ctx, msg)
return err
}); err != nil {
Expand Down
2 changes: 2 additions & 0 deletions x/cronos/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const (
prefixContractToDenom
paramsKey
prefixAdminToPermissions

StateDBContextKey = "statedb"
)

// KVStore key prefixes
Expand Down

0 comments on commit b65f2b1

Please sign in to comment.