Skip to content

Commit d57ceff

Browse files
julienrbrtGNaD13
authored andcommitted
chore: bring in core v0.11.x (v0.50 compatible) to v0.50 (cosmos#21298)
1 parent fbfa3a3 commit d57ceff

16 files changed

Lines changed: 151 additions & 3050 deletions

File tree

core/CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,27 @@ Ref: https://keepachangelog.com/en/1.0.0/
3636

3737
## [Unreleased]
3838

39+
## [v0.11.2](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.11.2)
40+
41+
* [#21298](https://github.com/cosmos/cosmos-sdk/pull/21298) Backport [#19265](https://github.com/cosmos/cosmos-sdk/pull/19265) to core.
42+
* [#21298](https://github.com/cosmos/cosmos-sdk/pull/21298) Clean-up after depinject upgrade.
43+
44+
## [v0.11.1](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.11.1)
45+
46+
* [#21022](https://github.com/cosmos/cosmos-sdk/pull/21022) Upgrade depinject to v1.0.0.
47+
48+
## [v0.11.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.11.0)
49+
50+
* [#17468](https://github.com/cosmos/cosmos-sdk/pull/17468) Add `appmodule.HasPreBlocker` interface.
51+
52+
## [v0.10.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.10.0)
53+
54+
* [#17383](https://github.com/cosmos/cosmos-sdk/pull/17383) Add `appmoduke.UpgradeModule` interface.
55+
56+
## [v0.9.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.9.0)
57+
58+
* [#16739](https://github.com/cosmos/cosmos-sdk/pull/16739) Add `AppHash` to header.Info.
59+
3960
## [v0.8.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.8.0)
4061

4162
* [#15519](https://github.com/cosmos/cosmos-sdk/pull/15519) Update `comet.VoteInfo` for CometBFT v0.38.

core/appconfig/config.go

Lines changed: 5 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,18 @@
11
package appconfig
22

33
import (
4-
"fmt"
5-
"strings"
6-
7-
"github.com/cosmos/cosmos-proto/anyutil"
8-
"google.golang.org/protobuf/encoding/protojson"
9-
"google.golang.org/protobuf/proto"
10-
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
11-
"google.golang.org/protobuf/reflect/protoregistry"
12-
"google.golang.org/protobuf/types/known/anypb"
13-
"sigs.k8s.io/yaml"
14-
15-
appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1"
16-
"cosmossdk.io/core/internal"
17-
"cosmossdk.io/depinject"
4+
depinjectappconfig "cosmossdk.io/depinject/appconfig"
185
)
196

207
// LoadJSON loads an app config in JSON format.
21-
func LoadJSON(bz []byte) depinject.Config {
22-
config := &appv1alpha1.Config{}
23-
err := protojson.Unmarshal(bz, config)
24-
if err != nil {
25-
return depinject.Error(err)
26-
}
27-
28-
return Compose(config)
29-
}
8+
var LoadJSON = depinjectappconfig.LoadJSON
309

3110
// LoadYAML loads an app config in YAML format.
32-
func LoadYAML(bz []byte) depinject.Config {
33-
j, err := yaml.YAMLToJSON(bz)
34-
if err != nil {
35-
return depinject.Error(err)
36-
}
37-
38-
return LoadJSON(j)
39-
}
11+
var LoadYAML = depinjectappconfig.LoadYAML
4012

4113
// WrapAny marshals a proto message into a proto Any instance
42-
func WrapAny(config protoreflect.ProtoMessage) *anypb.Any {
43-
cfg, err := anyutil.New(config)
44-
if err != nil {
45-
panic(err)
46-
}
47-
48-
return cfg
49-
}
14+
var WrapAny = depinjectappconfig.WrapAny
5015

5116
// Compose composes a v1alpha1 app config into a container option by resolving
5217
// the required modules and composing their options.
53-
func Compose(appConfig *appv1alpha1.Config) depinject.Config {
54-
opts := []depinject.Config{
55-
depinject.Supply(appConfig),
56-
}
57-
58-
for _, module := range appConfig.Modules {
59-
if module.Name == "" {
60-
return depinject.Error(fmt.Errorf("module is missing name"))
61-
}
62-
63-
if module.Config == nil {
64-
return depinject.Error(fmt.Errorf("module %q is missing a config object", module.Name))
65-
}
66-
67-
msgType, err := protoregistry.GlobalTypes.FindMessageByURL(module.Config.TypeUrl)
68-
if err != nil {
69-
return depinject.Error(err)
70-
}
71-
72-
modules, err := internal.ModulesByProtoMessageName()
73-
if err != nil {
74-
return depinject.Error(err)
75-
}
76-
77-
init, ok := modules[msgType.Descriptor().FullName()]
78-
if !ok {
79-
modDesc := proto.GetExtension(msgType.Descriptor().Options(), appv1alpha1.E_Module).(*appv1alpha1.ModuleDescriptor)
80-
if modDesc == nil {
81-
return depinject.Error(fmt.Errorf("no module registered for type URL %s and that protobuf type does not have the option %s\n\n%s",
82-
module.Config.TypeUrl, appv1alpha1.E_Module.TypeDescriptor().FullName(), dumpRegisteredModules(modules)))
83-
}
84-
85-
return depinject.Error(fmt.Errorf("no module registered for type URL %s, did you forget to import %s: find more information on how to make a module ready for app wiring: https://docs.cosmos.network/main/building-modules/depinject\n\n%s",
86-
module.Config.TypeUrl, modDesc.GoImport, dumpRegisteredModules(modules)))
87-
}
88-
89-
config := init.ConfigProtoMessage.ProtoReflect().Type().New().Interface()
90-
err = anypb.UnmarshalTo(module.Config, config, proto.UnmarshalOptions{})
91-
if err != nil {
92-
return depinject.Error(err)
93-
}
94-
95-
opts = append(opts, depinject.Supply(config))
96-
97-
for _, provider := range init.Providers {
98-
opts = append(opts, depinject.ProvideInModule(module.Name, provider))
99-
}
100-
101-
for _, invoker := range init.Invokers {
102-
opts = append(opts, depinject.InvokeInModule(module.Name, invoker))
103-
}
104-
105-
for _, binding := range module.GolangBindings {
106-
opts = append(opts, depinject.BindInterfaceInModule(module.Name, binding.InterfaceType, binding.Implementation))
107-
}
108-
}
109-
110-
for _, binding := range appConfig.GolangBindings {
111-
opts = append(opts, depinject.BindInterface(binding.InterfaceType, binding.Implementation))
112-
}
113-
114-
return depinject.Configs(opts...)
115-
}
116-
117-
func dumpRegisteredModules(modules map[protoreflect.FullName]*internal.ModuleInitializer) string {
118-
var mods []string
119-
for name := range modules {
120-
mods = append(mods, " "+string(name))
121-
}
122-
return fmt.Sprintf("registered modules are:\n%s", strings.Join(mods, "\n"))
123-
}
18+
var Compose = depinjectappconfig.Compose

core/appconfig/config_test.go

Lines changed: 0 additions & 223 deletions
This file was deleted.

0 commit comments

Comments
 (0)