2022-09-15 22:00:32 +00:00
|
|
|
package keeper
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2024-02-06 22:54:10 +00:00
|
|
|
"github.com/cometbft/cometbft/libs/log"
|
2022-09-15 22:00:32 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
|
2024-05-01 03:17:24 +00:00
|
|
|
"github.com/0glabs/0g-chain/x/liquid/types"
|
2022-09-15 22:00:32 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Keeper struct for the liquid module.
|
|
|
|
type Keeper struct {
|
|
|
|
cdc codec.Codec
|
|
|
|
|
2022-09-28 20:20:01 +00:00
|
|
|
accountKeeper types.AccountKeeper
|
|
|
|
bankKeeper types.BankKeeper
|
|
|
|
stakingKeeper types.StakingKeeper
|
|
|
|
distributionKeeper types.DistributionKeeper
|
2022-09-15 22:00:32 +00:00
|
|
|
|
|
|
|
derivativeDenom string
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewKeeper returns a new keeper for the liquid module.
|
|
|
|
func NewKeeper(
|
|
|
|
cdc codec.Codec,
|
2022-09-28 20:20:01 +00:00
|
|
|
ak types.AccountKeeper, bk types.BankKeeper, sk types.StakingKeeper, dk types.DistributionKeeper,
|
2022-09-15 22:00:32 +00:00
|
|
|
derivativeDenom string,
|
|
|
|
) Keeper {
|
|
|
|
|
|
|
|
return Keeper{
|
2022-09-28 20:20:01 +00:00
|
|
|
cdc: cdc,
|
|
|
|
accountKeeper: ak,
|
|
|
|
bankKeeper: bk,
|
|
|
|
stakingKeeper: sk,
|
|
|
|
distributionKeeper: dk,
|
|
|
|
derivativeDenom: derivativeDenom,
|
2022-09-15 22:00:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewDefaultKeeper returns a new keeper for the liquid module with default values.
|
|
|
|
func NewDefaultKeeper(
|
|
|
|
cdc codec.Codec,
|
2022-09-28 20:20:01 +00:00
|
|
|
ak types.AccountKeeper, bk types.BankKeeper, sk types.StakingKeeper, dk types.DistributionKeeper,
|
2022-09-15 22:00:32 +00:00
|
|
|
) Keeper {
|
|
|
|
|
2022-09-28 20:20:01 +00:00
|
|
|
return NewKeeper(cdc, ak, bk, sk, dk, types.DefaultDerivativeDenom)
|
2022-09-15 22:00:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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))
|
|
|
|
}
|