/
keeper.go
74 lines (63 loc) · 1.88 KB
/
keeper.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package keeper
import (
"fmt"
"github.com/ethereum/go-ethereum/common"
ethermint "github.com/FiboChain/fbc/app/types"
"github.com/FiboChain/fbc/libs/cosmos-sdk/codec"
sdk "github.com/FiboChain/fbc/libs/cosmos-sdk/types"
"github.com/FiboChain/fbc/libs/tendermint/libs/log"
"github.com/FiboChain/fbc/x/feesplit/types"
"github.com/FiboChain/fbc/x/params"
)
// Keeper of this module maintains collections of fee splits for contracts
// registered to receive transaction fees.
type Keeper struct {
storeKey sdk.StoreKey
cdc *codec.Codec
paramSpace types.Subspace
evmKeeper types.EvmKeeper
govKeeper types.GovKeeper
supplyKeeper types.SupplyKeeper
accountKeeper types.AccountKeeper
updateFeeSplitHandler sdk.UpdateFeeSplitHandler
}
// NewKeeper creates new instances of the fees Keeper
func NewKeeper(
storeKey sdk.StoreKey,
cdc *codec.Codec,
ps params.Subspace,
ek types.EvmKeeper,
sk types.SupplyKeeper,
ak types.AccountKeeper,
) Keeper {
// set KeyTable if it has not already been set
if !ps.HasKeyTable() {
ps = ps.WithKeyTable(types.ParamKeyTable())
}
return Keeper{
storeKey: storeKey,
cdc: cdc,
paramSpace: ps,
evmKeeper: ek,
supplyKeeper: sk,
accountKeeper: ak,
}
}
// Logger returns a module-specific logger.
func (k Keeper) Logger(ctx sdk.Context) log.Logger {
return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName))
}
// GetEthAccount returns an eth account.
func (k Keeper) GetEthAccount(ctx sdk.Context, addr common.Address) (*ethermint.EthAccount, bool) {
cosmosAddr := sdk.AccAddress(addr.Bytes())
acct := k.accountKeeper.GetAccount(ctx, cosmosAddr)
if acct == nil {
return nil, false
}
ethAcct, _ := acct.(*ethermint.EthAccount)
return ethAcct, true
}
// SetGovKeeper sets keeper of gov
func (k *Keeper) SetGovKeeper(gk types.GovKeeper) {
k.govKeeper = gk
}