Skip to content

Commit

Permalink
feat: support cosmos-sdk v0.50.x (#746)
Browse files Browse the repository at this point in the history
## 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)
  • Loading branch information
dadamu authored Jun 25, 2024
1 parent 868bbd5 commit ca1ebaa
Show file tree
Hide file tree
Showing 113 changed files with 1,193 additions and 1,905 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Setup Go 🧰
uses: actions/setup-go@v5
with:
go-version: "1.20"
go-version: "1.21"

- name: Compute diff 📜
uses: technote-space/get-diff-action@v6.1.2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Setup Go 🧰
uses: actions/setup-go@v5
with:
go-version: "1.20"
go-version: "1.21"

- name: Compute diff 📜
uses: technote-space/get-diff-action@v6.1.2
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ all: lint build test-unit
### Build flags ###
###############################################################################

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

ifeq ($(LINK_STATICALLY),true)
Expand Down Expand Up @@ -60,7 +60,7 @@ stop-docker-test:

start-docker-test: stop-docker-test
@echo "Starting Docker container..."
@docker run --name callisto-test-db -e POSTGRES_USER=callisto -e POSTGRES_PASSWORD=password -e POSTGRES_DB=callisto -d -p 6433:5432 postgres
@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
.PHONY: start-docker-test

test-unit: start-docker-test
Expand Down
29 changes: 9 additions & 20 deletions cmd/callisto/main.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
package main

import (
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/forbole/juno/v5/cmd"
initcmd "github.com/forbole/juno/v5/cmd/init"
parsetypes "github.com/forbole/juno/v5/cmd/parse/types"
startcmd "github.com/forbole/juno/v5/cmd/start"
"github.com/forbole/juno/v5/modules/messages"
"github.com/forbole/juno/v6/cmd"
initcmd "github.com/forbole/juno/v6/cmd/init"
parsetypes "github.com/forbole/juno/v6/cmd/parse/types"
startcmd "github.com/forbole/juno/v6/cmd/start"
"github.com/forbole/juno/v6/modules/messages"

migratecmd "github.com/forbole/callisto/v4/cmd/migrate"
parsecmd "github.com/forbole/callisto/v4/cmd/parse"
"github.com/forbole/callisto/v4/utils"

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

"cosmossdk.io/simapp"

"github.com/forbole/callisto/v4/database"
"github.com/forbole/callisto/v4/modules"
)
Expand All @@ -23,10 +21,10 @@ func main() {
initCfg := initcmd.NewConfig().
WithConfigCreator(config.Creator)

cdc := utils.GetCodec()
parseCfg := parsetypes.NewConfig().
WithDBBuilder(database.Builder).
WithEncodingConfigBuilder(config.MakeEncodingConfig(getBasicManagers())).
WithRegistrar(modules.NewRegistrar(getAddressesParser()))
WithDBBuilder(database.Builder(cdc)).
WithRegistrar(modules.NewRegistrar(getAddressesParser(), cdc))

cfg := cmd.NewConfig("callisto").
WithInitConfig(initCfg).
Expand All @@ -50,15 +48,6 @@ func main() {
}
}

// getBasicManagers returns the various basic managers that are used to register the encoding to
// support custom messages.
// This should be edited by custom implementations if needed.
func getBasicManagers() []module.BasicManager {
return []module.BasicManager{
simapp.ModuleBasics,
}
}

// getAddressesParser returns the messages parser that should be used to get the users involved in
// a specific message.
// This should be edited by custom implementations if needed.
Expand Down
2 changes: 1 addition & 1 deletion cmd/migrate/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"os"

parsecmdtypes "github.com/forbole/juno/v5/cmd/parse/types"
parsecmdtypes "github.com/forbole/juno/v6/cmd/parse/types"
"github.com/spf13/cobra"

v3 "github.com/forbole/callisto/v4/cmd/migrate/v3"
Expand Down
6 changes: 3 additions & 3 deletions cmd/migrate/v3/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import (

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

parsecmdtypes "github.com/forbole/juno/v5/cmd/parse/types"
parsecmdtypes "github.com/forbole/juno/v6/cmd/parse/types"

"gopkg.in/yaml.v3"

junov4 "github.com/forbole/juno/v5/cmd/migrate/v4"
"github.com/forbole/juno/v5/types/config"
junov4 "github.com/forbole/juno/v6/cmd/migrate/v4"
"github.com/forbole/juno/v6/types/config"
)

// RunMigration runs the migrations from v2 to v3
Expand Down
2 changes: 1 addition & 1 deletion cmd/migrate/v3/types.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package v3

import (
v3 "github.com/forbole/juno/v5/cmd/migrate/v3"
v3 "github.com/forbole/juno/v6/cmd/migrate/v3"

"github.com/forbole/callisto/v4/modules/actions"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/migrate/v3/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"os"
"path"

"github.com/forbole/juno/v5/types/config"
"github.com/forbole/juno/v6/types/config"
"gopkg.in/yaml.v3"
)

Expand Down
14 changes: 6 additions & 8 deletions cmd/migrate/v5/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package v5
import (
"fmt"

parse "github.com/forbole/juno/v6/cmd/parse/types"
"github.com/forbole/juno/v6/database"
"github.com/forbole/juno/v6/database/postgresql"
"github.com/forbole/juno/v6/types/config"

v5db "github.com/forbole/callisto/v4/database/migrate/v5"
parse "github.com/forbole/juno/v5/cmd/parse/types"
"github.com/forbole/juno/v5/database"
"github.com/forbole/juno/v5/database/postgresql"
"github.com/forbole/juno/v5/types/config"
)

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

func migrateDb(cfg config.Config, parseConfig *parse.Config) error {
// Build the codec
encodingConfig := parseConfig.GetEncodingConfigBuilder()()

// Get the db
databaseCtx := database.NewContext(cfg.Database, encodingConfig, parseConfig.GetLogger())
databaseCtx := database.NewContext(cfg.Database, parseConfig.GetLogger())
db, err := postgresql.Builder(databaseCtx)
if err != nil {
return fmt.Errorf("error while building the db: %s", err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/migrate/v5/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"os"
"path"

"github.com/forbole/juno/v5/types/config"
"github.com/forbole/juno/v6/types/config"
"gopkg.in/yaml.v3"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/parse/auth/cmd.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package auth

import (
parsecmdtypes "github.com/forbole/juno/v5/cmd/parse/types"
parsecmdtypes "github.com/forbole/juno/v6/cmd/parse/types"
"github.com/spf13/cobra"
)

Expand Down
6 changes: 3 additions & 3 deletions cmd/parse/auth/vesting.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"encoding/json"
"fmt"

parsecmdtypes "github.com/forbole/juno/v5/cmd/parse/types"
"github.com/forbole/juno/v5/types/config"
parsecmdtypes "github.com/forbole/juno/v6/cmd/parse/types"
"github.com/forbole/juno/v6/types/config"
"github.com/spf13/cobra"

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

vestingAccounts, err := authutils.GetGenesisVestingAccounts(appState, parseCtx.EncodingConfig.Codec)
vestingAccounts, err := authutils.GetGenesisVestingAccounts(appState, utils.GetCodec())
if err != nil {
return fmt.Errorf("error while gestting vesting accounts: %s", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/parse/bank/cmd.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package bank

import (
parsecmdtypes "github.com/forbole/juno/v5/cmd/parse/types"
parsecmdtypes "github.com/forbole/juno/v6/cmd/parse/types"
"github.com/spf13/cobra"
)

Expand Down
9 changes: 5 additions & 4 deletions cmd/parse/bank/supply.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"fmt"

modulestypes "github.com/forbole/callisto/v4/modules/types"
"github.com/forbole/callisto/v4/utils"

parsecmdtypes "github.com/forbole/juno/v5/cmd/parse/types"
"github.com/forbole/juno/v5/types/config"
parsecmdtypes "github.com/forbole/juno/v6/cmd/parse/types"
"github.com/forbole/juno/v6/types/config"
"github.com/spf13/cobra"

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

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

// Build bank module
bankModule := bank.NewModule(nil, sources.BankSource, parseCtx.EncodingConfig.Codec, db)
bankModule := bank.NewModule(nil, sources.BankSource, utils.GetCodec(), db)

err = bankModule.UpdateSupply()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/parse/distribution/cmd.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package distribution

import (
parsecmdtypes "github.com/forbole/juno/v5/cmd/parse/types"
parsecmdtypes "github.com/forbole/juno/v6/cmd/parse/types"
"github.com/spf13/cobra"
)

Expand Down
9 changes: 5 additions & 4 deletions cmd/parse/distribution/communitypool.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package distribution
import (
"fmt"

parsecmdtypes "github.com/forbole/juno/v5/cmd/parse/types"
"github.com/forbole/juno/v5/types/config"
parsecmdtypes "github.com/forbole/juno/v6/cmd/parse/types"
"github.com/forbole/juno/v6/types/config"
"github.com/spf13/cobra"

"github.com/forbole/callisto/v4/database"
"github.com/forbole/callisto/v4/modules/distribution"
modulestypes "github.com/forbole/callisto/v4/modules/types"
"github.com/forbole/callisto/v4/utils"
)

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

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

// Build distribution module
distrModule := distribution.NewModule(sources.DistrSource, parseCtx.EncodingConfig.Codec, db)
distrModule := distribution.NewModule(sources.DistrSource, utils.GetCodec(), db)

err = distrModule.GetLatestCommunityPool()
if err != nil {
Expand Down
16 changes: 8 additions & 8 deletions cmd/parse/feegrant/allowance.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"
"sort"

parsecmdtypes "github.com/forbole/juno/v5/cmd/parse/types"
"github.com/forbole/juno/v5/types/config"
parsecmdtypes "github.com/forbole/juno/v6/cmd/parse/types"
"github.com/forbole/juno/v6/types/config"

"github.com/forbole/callisto/v4/modules/feegrant"
"github.com/forbole/callisto/v4/utils"
Expand All @@ -17,7 +17,7 @@ import (

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

feegranttypes "github.com/cosmos/cosmos-sdk/x/feegrant"
feegranttypes "cosmossdk.io/x/feegrant"
"github.com/rs/zerolog/log"
)

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

// Build feegrant module
feegrantModule := feegrant.NewModule(parseCtx.EncodingConfig.Codec, db)
feegrantModule := feegrant.NewModule(utils.GetCodec(), db)

// Get the accounts
// Collect all the transactions
Expand Down Expand Up @@ -71,15 +71,15 @@ func allowanceCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
}

// Handle only the MsgGrantAllowance and MsgRevokeAllowance instances
for index, msg := range transaction.GetMsgs() {
_, isMsgGrantAllowance := msg.(*feegranttypes.MsgGrantAllowance)
_, isMsgRevokeAllowance := msg.(*feegranttypes.MsgRevokeAllowance)
for index, sdkMsg := range transaction.GetMsgs() {
_, isMsgGrantAllowance := sdkMsg.(*feegranttypes.MsgGrantAllowance)
_, isMsgRevokeAllowance := sdkMsg.(*feegranttypes.MsgRevokeAllowance)

if !isMsgGrantAllowance && !isMsgRevokeAllowance {
continue
}

err = feegrantModule.HandleMsg(index, msg, transaction)
err = feegrantModule.HandleMsg(index, transaction.Body.Messages[index], transaction)
if err != nil {
return fmt.Errorf("error while handling feegrant module message: %s", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/parse/feegrant/cmd.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package feegrant

import (
parsecmdtypes "github.com/forbole/juno/v5/cmd/parse/types"
parsecmdtypes "github.com/forbole/juno/v6/cmd/parse/types"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/parse/gov/cmd.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package gov

import (
parsecmdtypes "github.com/forbole/juno/v5/cmd/parse/types"
parsecmdtypes "github.com/forbole/juno/v6/cmd/parse/types"
"github.com/spf13/cobra"
)

Expand Down
Loading

0 comments on commit ca1ebaa

Please sign in to comment.