Prathamesh Musale
94ba057807
Some checks failed
Integration Tests / test-integration (push) Successful in 2m42s
E2E Tests / test-e2e (push) Successful in 4m23s
Unit Tests / test-unit (push) Successful in 2m39s
SDK Tests / sdk_tests_nameservice_expiry (push) Successful in 10m14s
SDK Tests / sdk_tests (push) Failing after 11m55s
SDK Tests / sdk_tests_auctions (push) Successful in 15m48s
Part of [Add gov module to laconicd](https://www.notion.so/Add-gov-module-to-laconicd-938c9f5f87634b4fbd7896d3907fb89e) - Add methods to update params for `bond`, `registry` and `auction` modules Co-authored-by: IshaVenikar <ishavenikar7@gmail.com> Reviewed-on: #57 Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com> Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
86 lines
2.0 KiB
Go
86 lines
2.0 KiB
Go
package module
|
|
|
|
import (
|
|
"cosmossdk.io/core/appmodule"
|
|
"cosmossdk.io/core/store"
|
|
"cosmossdk.io/depinject"
|
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
|
bank "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
|
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
|
|
|
modulev1 "git.vdb.to/cerc-io/laconicd/api/cerc/bond/module/v1"
|
|
"git.vdb.to/cerc-io/laconicd/x/bond"
|
|
"git.vdb.to/cerc-io/laconicd/x/bond/keeper"
|
|
)
|
|
|
|
var _ appmodule.AppModule = AppModule{}
|
|
|
|
// IsOnePerModuleType implements the depinject.OnePerModuleType interface.
|
|
func (am AppModule) IsOnePerModuleType() {}
|
|
|
|
// IsAppModule implements the appmodule.AppModule interface.
|
|
func (am AppModule) IsAppModule() {}
|
|
|
|
func init() {
|
|
appmodule.Register(
|
|
&modulev1.Module{},
|
|
appmodule.Provide(ProvideModule),
|
|
appmodule.Invoke(InvokeSetBondHooks),
|
|
)
|
|
}
|
|
|
|
type ModuleInputs struct {
|
|
depinject.In
|
|
|
|
Config *modulev1.Module
|
|
Cdc codec.Codec
|
|
StoreService store.KVStoreService
|
|
|
|
AccountKeeper auth.AccountKeeper
|
|
BankKeeper bank.Keeper
|
|
}
|
|
|
|
type ModuleOutputs struct {
|
|
depinject.Out
|
|
|
|
Keeper *keeper.Keeper
|
|
Module appmodule.AppModule
|
|
}
|
|
|
|
func ProvideModule(in ModuleInputs) ModuleOutputs {
|
|
// default to governance authority if not provided
|
|
authority := authtypes.NewModuleAddress(govtypes.ModuleName)
|
|
if in.Config.Authority != "" {
|
|
authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority)
|
|
}
|
|
|
|
k := keeper.NewKeeper(in.Cdc, in.StoreService, in.AccountKeeper, in.BankKeeper, authority.String())
|
|
m := NewAppModule(in.Cdc, k)
|
|
|
|
return ModuleOutputs{Module: m, Keeper: k}
|
|
}
|
|
|
|
func InvokeSetBondHooks(
|
|
config *modulev1.Module,
|
|
keeper *keeper.Keeper,
|
|
bondHooks map[string]bond.BondHooksWrapper,
|
|
) error {
|
|
// All arguments to invokers are optional
|
|
if keeper == nil || config == nil {
|
|
return nil
|
|
}
|
|
|
|
usageKeepers := make([]bond.BondUsageKeeper, 0, len(bondHooks))
|
|
|
|
for _, hook := range bondHooks {
|
|
usageKeepers = append(usageKeepers, hook)
|
|
}
|
|
|
|
keeper.SetUsageKeepers(usageKeepers)
|
|
|
|
return nil
|
|
}
|