Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(runtime): define address codec providers in runtime #17037

Merged
merged 11 commits into from
Jul 18, 2023
Merged
Prev Previous commit
Next Next commit
inject address codecs
  • Loading branch information
julienrbrt committed Jul 18, 2023
commit 4e3a861de706174649039cbd864a2c42648072ba
22 changes: 10 additions & 12 deletions x/auth/tx/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

bankv1beta1 "cosmossdk.io/api/cosmos/bank/v1beta1"
txconfigv1 "cosmossdk.io/api/cosmos/tx/config/v1"
"cosmossdk.io/core/address"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/depinject"
txsigning "cosmossdk.io/x/tx/signing"
Expand All @@ -23,7 +24,6 @@ import (
"github.com/cosmos/cosmos-sdk/types/registry"
signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec"
"github.com/cosmos/cosmos-sdk/x/auth/posthandler"
"github.com/cosmos/cosmos-sdk/x/auth/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
Expand All @@ -38,9 +38,12 @@ func init() {

type ModuleInputs struct {
depinject.In
Config *txconfigv1.Config
ProtoCodecMarshaler codec.ProtoCodecMarshaler
ProtoFileResolver txsigning.ProtoFileResolver

Config *txconfigv1.Config
AddressCodec address.Codec
ValidatorAddressCodec runtime.ValidatorAddressCodec
tac0turtle marked this conversation as resolved.
Show resolved Hide resolved
ProtoCodecMarshaler codec.ProtoCodecMarshaler
ProtoFileResolver txsigning.ProtoFileResolver
// BankKeeper is the expected bank keeper to be passed to AnteHandlers
BankKeeper authtypes.BankKeeper `optional:"true"`
MetadataBankKeeper BankKeeper `optional:"true"`
Expand All @@ -65,18 +68,13 @@ func ProvideModule(in ModuleInputs) ModuleOutputs {
if in.CustomSignModeHandlers != nil {
customSignModeHandlers = in.CustomSignModeHandlers()
}
sdkConfig := sdk.GetConfig()

txConfigOptions := tx.ConfigOptions{
EnabledSignModes: tx.DefaultSignModes,
SigningOptions: &txsigning.Options{
FileResolver: in.ProtoFileResolver,
// From static config? But this is already in auth config.
// - Provide codecs there as types?
// - Provide static prefix there exported from config?
// - Just do as below?
AddressCodec: authcodec.NewBech32Codec(sdkConfig.GetBech32AccountAddrPrefix()),
ValidatorAddressCodec: authcodec.NewBech32Codec(sdkConfig.GetBech32ValidatorAddrPrefix()),
FileResolver: in.ProtoFileResolver,
AddressCodec: in.AddressCodec,
ValidatorAddressCodec: in.ValidatorAddressCodec,
},
CustomSignModes: customSignModeHandlers,
}
Expand Down