Skip to content

Commit 748352e

Browse files
authored
chore: prepare depinject 1.0.0 (#21001)
1 parent b551384 commit 748352e

8 files changed

Lines changed: 380 additions & 9 deletions

File tree

depinject/CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ Each entry must include the Github issue reference in the following format:
2222

2323
## [Unreleased]
2424

25-
### Features
25+
## 1.0.0
2626

27-
- [#20540](https://github.com/cosmos/cosmos-sdk/pull/20540) add support for defining `appconfig` module configuration types using `github.com/cosmos/gogoproto/proto` in addition to `google.golang.org/protobuf` so that users can use gogo proto across their stack.
27+
* [#20540](https://github.com/cosmos/cosmos-sdk/pull/20540) Add support for defining `appconfig` module configuration types using `github.com/cosmos/gogoproto/proto` in addition to `google.golang.org/protobuf` so that users can use gogo proto across their stack.
28+
* Move `cosmossdk.io/core/appconfig` to `cosmossdk.io/depinject/appconfig`.
2829

2930
## 1.0.0-alpha.x
3031

depinject/appconfig/config.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"reflect"
66
"strings"
77

8-
"github.com/cosmos/cosmos-proto/anyutil"
98
gogoproto "github.com/cosmos/gogoproto/proto"
109
"google.golang.org/protobuf/encoding/protojson"
1110
protov2 "google.golang.org/protobuf/proto"
@@ -52,13 +51,16 @@ func LoadYAML(bz []byte) depinject.Config {
5251
}
5352

5453
// WrapAny marshals a proto message into a proto Any instance
55-
func WrapAny(config protoreflect.ProtoMessage) *anypb.Any {
56-
cfg, err := anyutil.New(config)
54+
func WrapAny(config gogoproto.Message) *anypb.Any {
55+
pbz, err := gogoproto.Marshal(config)
5756
if err != nil {
5857
panic(err)
5958
}
6059

61-
return cfg
60+
return &anypb.Any{
61+
TypeUrl: "/" + gogoproto.MessageName(config),
62+
Value: pbz,
63+
}
6264
}
6365

6466
// Compose composes an app config into a container option by resolving

simapp/app_config.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ import (
6969
upgradetypes "cosmossdk.io/x/upgrade/types"
7070

7171
"github.com/cosmos/cosmos-sdk/runtime"
72+
_ "github.com/cosmos/cosmos-sdk/testutil/x/counter" // import for side-effects
73+
countertypes "github.com/cosmos/cosmos-sdk/testutil/x/counter/types"
7274
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
7375
)
7476

@@ -279,6 +281,11 @@ var (
279281
Name: epochstypes.ModuleName,
280282
Config: appconfig.WrapAny(&epochsmodulev1.Module{}),
281283
},
284+
// This module is used for testing the depinject gogo x pulsar module registration.
285+
{
286+
Name: countertypes.ModuleName,
287+
Config: appconfig.WrapAny(&countertypes.Module{}),
288+
},
282289
},
283290
})
284291
)

simapp/upgrades.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
epochstypes "cosmossdk.io/x/epochs/types"
1111
protocolpooltypes "cosmossdk.io/x/protocolpool/types"
1212
upgradetypes "cosmossdk.io/x/upgrade/types"
13+
14+
countertypes "github.com/cosmos/cosmos-sdk/testutil/x/counter/types"
1315
)
1416

1517
// UpgradeName defines the on-chain upgrade name for the sample SimApp upgrade
@@ -45,6 +47,7 @@ func (app SimApp) RegisterUpgradeHandlers() {
4547
accounts.StoreKey,
4648
protocolpooltypes.StoreKey,
4749
epochstypes.StoreKey,
50+
countertypes.StoreKey, // This module is used for testing purposes only.
4851
},
4952
Deleted: []string{"crisis"}, // The SDK discontinued the crisis module in v0.52.0
5053
}

testutil/x/counter/autocli.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package counter
2+
3+
import (
4+
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
5+
counterv1 "cosmossdk.io/api/cosmos/counter/v1"
6+
)
7+
8+
// AutoCLIOptions implements the autocli.HasAutoCLIConfig interface.
9+
func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
10+
return &autocliv1.ModuleOptions{
11+
Query: &autocliv1.ServiceCommandDescriptor{
12+
Service: counterv1.Query_ServiceDesc.ServiceName,
13+
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
14+
{
15+
RpcMethod: "GetCount",
16+
Use: "count",
17+
Short: "Query the current counter value",
18+
},
19+
},
20+
},
21+
Tx: &autocliv1.ServiceCommandDescriptor{
22+
Service: counterv1.Msg_ServiceDesc.ServiceName,
23+
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
24+
{
25+
RpcMethod: "IncreaseCount",
26+
Use: "increase-count [count]",
27+
Alias: []string{"increase-counter", "increase", "inc", "bump"},
28+
Short: "Increase the counter by the specified amount",
29+
PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "count"}},
30+
},
31+
},
32+
},
33+
}
34+
}

testutil/x/counter/depinject.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package counter
22

33
import (
4-
modulev1 "cosmossdk.io/api/cosmos/counter/module/v1"
54
"cosmossdk.io/core/appmodule"
65
"cosmossdk.io/depinject"
76
"cosmossdk.io/depinject/appconfig"
87

98
"github.com/cosmos/cosmos-sdk/testutil/x/counter/keeper"
9+
"github.com/cosmos/cosmos-sdk/testutil/x/counter/types"
1010
)
1111

1212
var _ depinject.OnePerModuleType = AppModule{}
@@ -16,15 +16,15 @@ func (am AppModule) IsOnePerModuleType() {}
1616

1717
func init() {
1818
appconfig.RegisterModule(
19-
&modulev1.Module{},
19+
&types.Module{},
2020
appconfig.Provide(ProvideModule),
2121
)
2222
}
2323

2424
type ModuleInputs struct {
2525
depinject.In
2626

27-
Config *modulev1.Module
27+
Config *types.Module
2828
Environment appmodule.Environment
2929
}
3030

testutil/x/counter/proto/cosmos/counter/module/v1/module.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ package cosmos.counter.module.v1;
44

55
import "cosmos/app/v1alpha1/module.proto";
66

7+
option go_package = "github.com/cosmos/cosmos-sdk/testutil/x/counter/types";
8+
79
// Module is the config object of the counter module.
810
message Module {
911
option (cosmos.app.v1alpha1.module) = {

0 commit comments

Comments
 (0)