Skip to content

Commit ca1ebaa

Browse files
authored
feat: support cosmos-sdk v0.50.x (#746)
## Description Closes: #745 <!-- Add a description of the changes that this PR introduces and the files that are the most critical to review. --> --- This PR upgrade juno to v6 then supports cosmos-sdk v0.50.x. ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch - [ ] provided a link to the relevant issue or specification - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
1 parent 868bbd5 commit ca1ebaa

File tree

113 files changed

+1193
-1905
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+1193
-1905
lines changed

.github/workflows/lint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Setup Go 🧰
2222
uses: actions/setup-go@v5
2323
with:
24-
go-version: "1.20"
24+
go-version: "1.21"
2525

2626
- name: Compute diff 📜
2727
uses: technote-space/[email protected]

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Setup Go 🧰
2828
uses: actions/setup-go@v5
2929
with:
30-
go-version: "1.20"
30+
go-version: "1.21"
3131

3232
- name: Compute diff 📜
3333
uses: technote-space/[email protected]

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ all: lint build test-unit
1313
### Build flags ###
1414
###############################################################################
1515

16-
LD_FLAGS = -X github.com/forbole/juno/v5/cmd.Version=$(VERSION) \
17-
-X github.com/forbole/juno/v5/cmd.Commit=$(COMMIT)
16+
LD_FLAGS = -X github.com/forbole/juno/v6/cmd.Version=$(VERSION) \
17+
-X github.com/forbole/juno/v6/cmd.Commit=$(COMMIT)
1818
BUILD_FLAGS := -ldflags '$(LD_FLAGS)'
1919

2020
ifeq ($(LINK_STATICALLY),true)
@@ -60,7 +60,7 @@ stop-docker-test:
6060

6161
start-docker-test: stop-docker-test
6262
@echo "Starting Docker container..."
63-
@docker run --name callisto-test-db -e POSTGRES_USER=callisto -e POSTGRES_PASSWORD=password -e POSTGRES_DB=callisto -d -p 6433:5432 postgres
63+
@docker run --name callisto-test-db -e POSTGRES_USER=callisto -e POSTGRES_PASSWORD=password -e POSTGRES_DB=callisto -d -p 6433:5432 -v ./database/schema:/docker-entrypoint-initdb.d postgres
6464
.PHONY: start-docker-test
6565

6666
test-unit: start-docker-test

cmd/callisto/main.go

+9-20
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
package main
22

33
import (
4-
"github.com/cosmos/cosmos-sdk/types/module"
5-
"github.com/forbole/juno/v5/cmd"
6-
initcmd "github.com/forbole/juno/v5/cmd/init"
7-
parsetypes "github.com/forbole/juno/v5/cmd/parse/types"
8-
startcmd "github.com/forbole/juno/v5/cmd/start"
9-
"github.com/forbole/juno/v5/modules/messages"
4+
"github.com/forbole/juno/v6/cmd"
5+
initcmd "github.com/forbole/juno/v6/cmd/init"
6+
parsetypes "github.com/forbole/juno/v6/cmd/parse/types"
7+
startcmd "github.com/forbole/juno/v6/cmd/start"
8+
"github.com/forbole/juno/v6/modules/messages"
109

1110
migratecmd "github.com/forbole/callisto/v4/cmd/migrate"
1211
parsecmd "github.com/forbole/callisto/v4/cmd/parse"
12+
"github.com/forbole/callisto/v4/utils"
1313

1414
"github.com/forbole/callisto/v4/types/config"
1515

16-
"cosmossdk.io/simapp"
17-
1816
"github.com/forbole/callisto/v4/database"
1917
"github.com/forbole/callisto/v4/modules"
2018
)
@@ -23,10 +21,10 @@ func main() {
2321
initCfg := initcmd.NewConfig().
2422
WithConfigCreator(config.Creator)
2523

24+
cdc := utils.GetCodec()
2625
parseCfg := parsetypes.NewConfig().
27-
WithDBBuilder(database.Builder).
28-
WithEncodingConfigBuilder(config.MakeEncodingConfig(getBasicManagers())).
29-
WithRegistrar(modules.NewRegistrar(getAddressesParser()))
26+
WithDBBuilder(database.Builder(cdc)).
27+
WithRegistrar(modules.NewRegistrar(getAddressesParser(), cdc))
3028

3129
cfg := cmd.NewConfig("callisto").
3230
WithInitConfig(initCfg).
@@ -50,15 +48,6 @@ func main() {
5048
}
5149
}
5250

53-
// getBasicManagers returns the various basic managers that are used to register the encoding to
54-
// support custom messages.
55-
// This should be edited by custom implementations if needed.
56-
func getBasicManagers() []module.BasicManager {
57-
return []module.BasicManager{
58-
simapp.ModuleBasics,
59-
}
60-
}
61-
6251
// getAddressesParser returns the messages parser that should be used to get the users involved in
6352
// a specific message.
6453
// This should be edited by custom implementations if needed.

cmd/migrate/cmd.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"os"
66

7-
parsecmdtypes "github.com/forbole/juno/v5/cmd/parse/types"
7+
parsecmdtypes "github.com/forbole/juno/v6/cmd/parse/types"
88
"github.com/spf13/cobra"
99

1010
v3 "github.com/forbole/callisto/v4/cmd/migrate/v3"

cmd/migrate/v3/migrate.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import (
66

77
"github.com/forbole/callisto/v4/modules/actions"
88

9-
parsecmdtypes "github.com/forbole/juno/v5/cmd/parse/types"
9+
parsecmdtypes "github.com/forbole/juno/v6/cmd/parse/types"
1010

1111
"gopkg.in/yaml.v3"
1212

13-
junov4 "github.com/forbole/juno/v5/cmd/migrate/v4"
14-
"github.com/forbole/juno/v5/types/config"
13+
junov4 "github.com/forbole/juno/v6/cmd/migrate/v4"
14+
"github.com/forbole/juno/v6/types/config"
1515
)
1616

1717
// RunMigration runs the migrations from v2 to v3

cmd/migrate/v3/types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package v3
22

33
import (
4-
v3 "github.com/forbole/juno/v5/cmd/migrate/v3"
4+
v3 "github.com/forbole/juno/v6/cmd/migrate/v3"
55

66
"github.com/forbole/callisto/v4/modules/actions"
77
)

cmd/migrate/v3/utils.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"os"
66
"path"
77

8-
"github.com/forbole/juno/v5/types/config"
8+
"github.com/forbole/juno/v6/types/config"
99
"gopkg.in/yaml.v3"
1010
)
1111

cmd/migrate/v5/migrate.go

+6-8
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ package v5
33
import (
44
"fmt"
55

6+
parse "github.com/forbole/juno/v6/cmd/parse/types"
7+
"github.com/forbole/juno/v6/database"
8+
"github.com/forbole/juno/v6/database/postgresql"
9+
"github.com/forbole/juno/v6/types/config"
10+
611
v5db "github.com/forbole/callisto/v4/database/migrate/v5"
7-
parse "github.com/forbole/juno/v5/cmd/parse/types"
8-
"github.com/forbole/juno/v5/database"
9-
"github.com/forbole/juno/v5/database/postgresql"
10-
"github.com/forbole/juno/v5/types/config"
1112
)
1213

1314
// RunMigration runs the migrations to v5
@@ -27,11 +28,8 @@ func RunMigration(parseConfig *parse.Config) error {
2728
}
2829

2930
func migrateDb(cfg config.Config, parseConfig *parse.Config) error {
30-
// Build the codec
31-
encodingConfig := parseConfig.GetEncodingConfigBuilder()()
32-
3331
// Get the db
34-
databaseCtx := database.NewContext(cfg.Database, encodingConfig, parseConfig.GetLogger())
32+
databaseCtx := database.NewContext(cfg.Database, parseConfig.GetLogger())
3533
db, err := postgresql.Builder(databaseCtx)
3634
if err != nil {
3735
return fmt.Errorf("error while building the db: %s", err)

cmd/migrate/v5/utils.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"os"
66
"path"
77

8-
"github.com/forbole/juno/v5/types/config"
8+
"github.com/forbole/juno/v6/types/config"
99
"gopkg.in/yaml.v3"
1010
)
1111

cmd/parse/auth/cmd.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package auth
22

33
import (
4-
parsecmdtypes "github.com/forbole/juno/v5/cmd/parse/types"
4+
parsecmdtypes "github.com/forbole/juno/v6/cmd/parse/types"
55
"github.com/spf13/cobra"
66
)
77

cmd/parse/auth/vesting.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"encoding/json"
55
"fmt"
66

7-
parsecmdtypes "github.com/forbole/juno/v5/cmd/parse/types"
8-
"github.com/forbole/juno/v5/types/config"
7+
parsecmdtypes "github.com/forbole/juno/v6/cmd/parse/types"
8+
"github.com/forbole/juno/v6/types/config"
99
"github.com/spf13/cobra"
1010

1111
"github.com/forbole/callisto/v4/database"
@@ -38,7 +38,7 @@ func vestingCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
3838
return fmt.Errorf("error unmarshalling genesis doc: %s", err)
3939
}
4040

41-
vestingAccounts, err := authutils.GetGenesisVestingAccounts(appState, parseCtx.EncodingConfig.Codec)
41+
vestingAccounts, err := authutils.GetGenesisVestingAccounts(appState, utils.GetCodec())
4242
if err != nil {
4343
return fmt.Errorf("error while gestting vesting accounts: %s", err)
4444
}

cmd/parse/bank/cmd.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package bank
22

33
import (
4-
parsecmdtypes "github.com/forbole/juno/v5/cmd/parse/types"
4+
parsecmdtypes "github.com/forbole/juno/v6/cmd/parse/types"
55
"github.com/spf13/cobra"
66
)
77

cmd/parse/bank/supply.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import (
44
"fmt"
55

66
modulestypes "github.com/forbole/callisto/v4/modules/types"
7+
"github.com/forbole/callisto/v4/utils"
78

8-
parsecmdtypes "github.com/forbole/juno/v5/cmd/parse/types"
9-
"github.com/forbole/juno/v5/types/config"
9+
parsecmdtypes "github.com/forbole/juno/v6/cmd/parse/types"
10+
"github.com/forbole/juno/v6/types/config"
1011
"github.com/spf13/cobra"
1112

1213
"github.com/forbole/callisto/v4/database"
@@ -24,7 +25,7 @@ func supplyCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
2425
return err
2526
}
2627

27-
sources, err := modulestypes.BuildSources(config.Cfg.Node, parseCtx.EncodingConfig)
28+
sources, err := modulestypes.BuildSources(config.Cfg.Node, utils.GetCodec())
2829
if err != nil {
2930
return err
3031
}
@@ -33,7 +34,7 @@ func supplyCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
3334
db := database.Cast(parseCtx.Database)
3435

3536
// Build bank module
36-
bankModule := bank.NewModule(nil, sources.BankSource, parseCtx.EncodingConfig.Codec, db)
37+
bankModule := bank.NewModule(nil, sources.BankSource, utils.GetCodec(), db)
3738

3839
err = bankModule.UpdateSupply()
3940
if err != nil {

cmd/parse/distribution/cmd.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package distribution
22

33
import (
4-
parsecmdtypes "github.com/forbole/juno/v5/cmd/parse/types"
4+
parsecmdtypes "github.com/forbole/juno/v6/cmd/parse/types"
55
"github.com/spf13/cobra"
66
)
77

cmd/parse/distribution/communitypool.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ package distribution
33
import (
44
"fmt"
55

6-
parsecmdtypes "github.com/forbole/juno/v5/cmd/parse/types"
7-
"github.com/forbole/juno/v5/types/config"
6+
parsecmdtypes "github.com/forbole/juno/v6/cmd/parse/types"
7+
"github.com/forbole/juno/v6/types/config"
88
"github.com/spf13/cobra"
99

1010
"github.com/forbole/callisto/v4/database"
1111
"github.com/forbole/callisto/v4/modules/distribution"
1212
modulestypes "github.com/forbole/callisto/v4/modules/types"
13+
"github.com/forbole/callisto/v4/utils"
1314
)
1415

1516
// communityPoolCmd returns the Cobra command allowing to refresh community pool
@@ -23,7 +24,7 @@ func communityPoolCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
2324
return err
2425
}
2526

26-
sources, err := modulestypes.BuildSources(config.Cfg.Node, parseCtx.EncodingConfig)
27+
sources, err := modulestypes.BuildSources(config.Cfg.Node, utils.GetCodec())
2728
if err != nil {
2829
return err
2930
}
@@ -32,7 +33,7 @@ func communityPoolCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
3233
db := database.Cast(parseCtx.Database)
3334

3435
// Build distribution module
35-
distrModule := distribution.NewModule(sources.DistrSource, parseCtx.EncodingConfig.Codec, db)
36+
distrModule := distribution.NewModule(sources.DistrSource, utils.GetCodec(), db)
3637

3738
err = distrModule.GetLatestCommunityPool()
3839
if err != nil {

cmd/parse/feegrant/allowance.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"fmt"
66
"sort"
77

8-
parsecmdtypes "github.com/forbole/juno/v5/cmd/parse/types"
9-
"github.com/forbole/juno/v5/types/config"
8+
parsecmdtypes "github.com/forbole/juno/v6/cmd/parse/types"
9+
"github.com/forbole/juno/v6/types/config"
1010

1111
"github.com/forbole/callisto/v4/modules/feegrant"
1212
"github.com/forbole/callisto/v4/utils"
@@ -17,7 +17,7 @@ import (
1717

1818
tmctypes "github.com/cometbft/cometbft/rpc/core/types"
1919

20-
feegranttypes "github.com/cosmos/cosmos-sdk/x/feegrant"
20+
feegranttypes "cosmossdk.io/x/feegrant"
2121
"github.com/rs/zerolog/log"
2222
)
2323

@@ -36,7 +36,7 @@ func allowanceCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
3636
db := database.Cast(parseCtx.Database)
3737

3838
// Build feegrant module
39-
feegrantModule := feegrant.NewModule(parseCtx.EncodingConfig.Codec, db)
39+
feegrantModule := feegrant.NewModule(utils.GetCodec(), db)
4040

4141
// Get the accounts
4242
// Collect all the transactions
@@ -71,15 +71,15 @@ func allowanceCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
7171
}
7272

7373
// Handle only the MsgGrantAllowance and MsgRevokeAllowance instances
74-
for index, msg := range transaction.GetMsgs() {
75-
_, isMsgGrantAllowance := msg.(*feegranttypes.MsgGrantAllowance)
76-
_, isMsgRevokeAllowance := msg.(*feegranttypes.MsgRevokeAllowance)
74+
for index, sdkMsg := range transaction.GetMsgs() {
75+
_, isMsgGrantAllowance := sdkMsg.(*feegranttypes.MsgGrantAllowance)
76+
_, isMsgRevokeAllowance := sdkMsg.(*feegranttypes.MsgRevokeAllowance)
7777

7878
if !isMsgGrantAllowance && !isMsgRevokeAllowance {
7979
continue
8080
}
8181

82-
err = feegrantModule.HandleMsg(index, msg, transaction)
82+
err = feegrantModule.HandleMsg(index, transaction.Body.Messages[index], transaction)
8383
if err != nil {
8484
return fmt.Errorf("error while handling feegrant module message: %s", err)
8585
}

cmd/parse/feegrant/cmd.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package feegrant
22

33
import (
4-
parsecmdtypes "github.com/forbole/juno/v5/cmd/parse/types"
4+
parsecmdtypes "github.com/forbole/juno/v6/cmd/parse/types"
55
"github.com/spf13/cobra"
66
)
77

cmd/parse/gov/cmd.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package gov
22

33
import (
4-
parsecmdtypes "github.com/forbole/juno/v5/cmd/parse/types"
4+
parsecmdtypes "github.com/forbole/juno/v6/cmd/parse/types"
55
"github.com/spf13/cobra"
66
)
77

0 commit comments

Comments
 (0)