diff --git a/modules/light-clients/08-wasm/client/cli/tx.go b/modules/light-clients/08-wasm/client/cli/tx.go index 222418c4924..f00f000eabb 100644 --- a/modules/light-clients/08-wasm/client/cli/tx.go +++ b/modules/light-clients/08-wasm/client/cli/tx.go @@ -4,7 +4,9 @@ import ( "encoding/hex" "fmt" "os" + "sync" + "github.com/hashicorp/golang-lru/simplelru" "github.com/spf13/cobra" govcli "cosmossdk.io/x/gov/client/cli" @@ -13,6 +15,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" + addresscodec "github.com/cosmos/cosmos-sdk/codec/address" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" "github.com/cosmos/cosmos-sdk/version" @@ -42,13 +45,29 @@ func newSubmitStoreCodeProposalCmd() *cobra.Command { return err } + bech32PrefixAccAddr := sdk.GetConfig().GetBech32AccountAddrPrefix() + lru, err := simplelru.NewLRU(60000, nil) + if err != nil { + panic(err) + } + addrCdc, err := addresscodec.NewCachedBech32Codec( + bech32PrefixAccAddr, + addresscodec.CachedCodecOptions{ + Mu: &sync.Mutex{}, + Lru: lru}) + if err != nil { + panic(err) + } authority, _ := cmd.Flags().GetString(FlagAuthority) if authority != "" { - if _, err = sdk.AccAddressFromBech32(authority); err != nil { + if _, err = addrCdc.StringToBytes(authority); err != nil { return fmt.Errorf("invalid authority address: %w", err) } } else { - authority = sdk.AccAddress(address.Module(govtypes.ModuleName)).String() + authority, err = addrCdc.BytesToString(address.Module(govtypes.ModuleName)) + if err != nil { + return fmt.Errorf("invalid authority address: %w", err) + } } code, err := os.ReadFile(args[0]) diff --git a/modules/light-clients/08-wasm/go.mod b/modules/light-clients/08-wasm/go.mod index 4a77559c96a..448e18208b9 100644 --- a/modules/light-clients/08-wasm/go.mod +++ b/modules/light-clients/08-wasm/go.mod @@ -43,6 +43,7 @@ require ( github.com/cosmos/ibc-go/v9 v9.0.0 github.com/golang/protobuf v1.5.4 github.com/grpc-ecosystem/grpc-gateway v1.16.0 + github.com/hashicorp/golang-lru v1.0.2 github.com/spf13/cast v1.7.1 github.com/spf13/cobra v1.8.1 github.com/spf13/viper v1.19.0 @@ -143,7 +144,6 @@ require ( github.com/hashicorp/go-plugin v1.6.2 // indirect github.com/hashicorp/go-safetemp v1.0.0 // indirect github.com/hashicorp/go-version v1.7.0 // indirect - github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/yamux v0.1.2 // indirect