Skip to content

Commit

Permalink
Merge pull request #190 from aljo242/chore/remove-ignite-dependency
Browse files Browse the repository at this point in the history
refactor: remove ignite dependency
  • Loading branch information
jaybxyz authored Aug 8, 2022
2 parents ddeb651 + a204829 commit 833b580
Show file tree
Hide file tree
Showing 13 changed files with 790 additions and 826 deletions.
17 changes: 4 additions & 13 deletions app/app.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package app

import (
"github.com/tendermint/fundraising/cmd"
"io"
"net/http"
"os"
"path/filepath"

Expand Down Expand Up @@ -72,15 +72,12 @@ import (
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/spf13/cast"
"github.com/tendermint/starport/starport/pkg/cosmoscmd"
"github.com/tendermint/starport/starport/pkg/openapiconsole"
abci "github.com/tendermint/tendermint/abci/types"
tmjson "github.com/tendermint/tendermint/libs/json"
"github.com/tendermint/tendermint/libs/log"
tmos "github.com/tendermint/tendermint/libs/os"
dbm "github.com/tendermint/tm-db"

fundraisingdocs "github.com/tendermint/fundraising/client/docs"
"github.com/tendermint/fundraising/x/fundraising"
fundraisingkeeper "github.com/tendermint/fundraising/x/fundraising/keeper"
fundraisingtypes "github.com/tendermint/fundraising/x/fundraising/types"
Expand Down Expand Up @@ -145,7 +142,7 @@ var (
)

var (
_ cosmoscmd.App = (*App)(nil)
_ cmd.App = (*App)(nil)
_ servertypes.Application = (*App)(nil)
)

Expand Down Expand Up @@ -211,10 +208,10 @@ func New(
skipUpgradeHeights map[int64]bool,
homePath string,
invCheckPeriod uint,
encodingConfig cosmoscmd.EncodingConfig,
encodingConfig cmd.EncodingConfig,
appOpts servertypes.AppOptions,
baseAppOptions ...func(*baseapp.BaseApp),
) cosmoscmd.App {
) cmd.App {

appCodec := encodingConfig.Marshaler
legacyAmino := encodingConfig.Amino
Expand Down Expand Up @@ -652,12 +649,6 @@ func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig

// Register grpc-gateway routes for all modules.
ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)

// Register app's OpenAPI routes.
if apiConfig.Swagger {
apiSvr.Router.Handle("/static/openapi.yml", http.FileServer(fundraisingdocs.Docs))
apiSvr.Router.HandleFunc("/", openapiconsole.Handler(Name, "/static/openapi.yml"))
}
}

// RegisterTxService implements the Application.RegisterTxService method.
Expand Down
17 changes: 9 additions & 8 deletions app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"os"
"testing"

"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/simapp/helpers"
Expand All @@ -26,8 +28,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/simulation"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/stretchr/testify/require"
"github.com/tendermint/starport/starport/pkg/cosmoscmd"
"github.com/tendermint/fundraising/cmd"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
Expand Down Expand Up @@ -66,7 +67,7 @@ func BenchmarkSimulation(b *testing.B) {
require.NoError(b, err)
})

encoding := cosmoscmd.MakeEncodingConfig(ModuleBasics)
encoding := cmd.MakeEncodingConfig(ModuleBasics)
cosmoscmdApp := New(
logger, db, nil, true, map[int64]bool{},
DefaultNodeHome, simapp.FlagPeriodValue, encoding,
Expand Down Expand Up @@ -113,7 +114,7 @@ func TestAppImportExport(t *testing.T) {

cosmoscmdApp := New(
logger, db, nil, true, map[int64]bool{},
DefaultNodeHome, simapp.FlagPeriodValue, cosmoscmd.MakeEncodingConfig(ModuleBasics),
DefaultNodeHome, simapp.FlagPeriodValue, cmd.MakeEncodingConfig(ModuleBasics),
simapp.EmptyAppOptions{}, fauxMerkleModeOpt,
)

Expand Down Expand Up @@ -160,7 +161,7 @@ func TestAppImportExport(t *testing.T) {

cosmoscmdNewApp := New(
log.NewNopLogger(), newDB, nil, true, map[int64]bool{},
DefaultNodeHome, simapp.FlagPeriodValue, cosmoscmd.MakeEncodingConfig(ModuleBasics),
DefaultNodeHome, simapp.FlagPeriodValue, cmd.MakeEncodingConfig(ModuleBasics),
simapp.EmptyAppOptions{}, fauxMerkleModeOpt,
)

Expand Down Expand Up @@ -223,7 +224,7 @@ func TestAppSimulationAfterImport(t *testing.T) {

cosmoscmdApp := New(
logger, db, nil, true, map[int64]bool{},
DefaultNodeHome, simapp.FlagPeriodValue, cosmoscmd.MakeEncodingConfig(ModuleBasics),
DefaultNodeHome, simapp.FlagPeriodValue, cmd.MakeEncodingConfig(ModuleBasics),
simapp.EmptyAppOptions{}, fauxMerkleModeOpt,
)

Expand Down Expand Up @@ -274,7 +275,7 @@ func TestAppSimulationAfterImport(t *testing.T) {

cosmoscmdNewApp := New(
logger, newDB, nil, true, map[int64]bool{},
DefaultNodeHome, simapp.FlagPeriodValue, cosmoscmd.MakeEncodingConfig(ModuleBasics),
DefaultNodeHome, simapp.FlagPeriodValue, cmd.MakeEncodingConfig(ModuleBasics),
simapp.EmptyAppOptions{}, fauxMerkleModeOpt,
)

Expand Down Expand Up @@ -327,7 +328,7 @@ func TestAppStateDeterminism(t *testing.T) {
}

db := dbm.NewMemDB()
encoding := cosmoscmd.MakeEncodingConfig(ModuleBasics)
encoding := cmd.MakeEncodingConfig(ModuleBasics)
cosmoscmdApp := New(
logger, db, nil, true, map[int64]bool{},
DefaultNodeHome, simapp.FlagPeriodValue, encoding,
Expand Down
40 changes: 40 additions & 0 deletions cmd/cosmosapp.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package cmd

import (
abci "github.com/tendermint/tendermint/abci/types"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)

// CosmosApp implements the common methods for a Cosmos SDK-based application
// specific blockchain.
type CosmosApp interface {
// Name is the assigned name of the app.
Name() string

// The application types codec.
// NOTE: This should be sealed before being returned.
LegacyAmino() *codec.LegacyAmino

// BeginBlocker updates every begin block.
BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock

// EndBlocker updates every end block.
EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock

// InitChainer updates at chain (i.e app) initialization.
InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain

// LoadHeight loads the app at a given height.
LoadHeight(height int64) error

// ExportAppStateAndValidators exports the state of the application for a genesis file.
ExportAppStateAndValidators(
forZeroHeight bool, jailAllowedAddrs []string,
) (types.ExportedApp, error)

// ModuleAccountAddrs are registered module account addreses.
ModuleAccountAddrs() map[string]bool
}
44 changes: 44 additions & 0 deletions cmd/encoding.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package cmd

import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/std"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/auth/tx"
)

// EncodingConfig specifies the concrete encoding types to use for a given app.
// This is provided for compatibility between protobuf and amino implementations.
type EncodingConfig struct {
InterfaceRegistry types.InterfaceRegistry
Marshaler codec.Codec
TxConfig client.TxConfig
Amino *codec.LegacyAmino
}

// makeEncodingConfig creates an EncodingConfig for an amino based test configuration.
func makeEncodingConfig() EncodingConfig {
amino := codec.NewLegacyAmino()
interfaceRegistry := types.NewInterfaceRegistry()
marshaler := codec.NewProtoCodec(interfaceRegistry)
txCfg := tx.NewTxConfig(marshaler, tx.DefaultSignModes)

return EncodingConfig{
InterfaceRegistry: interfaceRegistry,
Marshaler: marshaler,
TxConfig: txCfg,
Amino: amino,
}
}

// MakeEncodingConfig creates an EncodingConfig for testing
func MakeEncodingConfig(moduleBasics module.BasicManager) EncodingConfig {
encodingConfig := makeEncodingConfig()
std.RegisterLegacyAminoCodec(encodingConfig.Amino)
std.RegisterInterfaces(encodingConfig.InterfaceRegistry)
moduleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino)
moduleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry)
return encodingConfig
}
4 changes: 2 additions & 2 deletions cmd/fundraisingd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import (
"os"

svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
"github.com/tendermint/starport/starport/pkg/cosmoscmd"

"github.com/tendermint/fundraising/app"
"github.com/tendermint/fundraising/cmd"
)

func main() {
rootCmd, _ := cosmoscmd.NewRootCmd(
rootCmd, _ := cmd.NewRootCmd(
app.Name,
app.AccountAddressPrefix,
app.DefaultNodeHome,
Expand Down
Loading

0 comments on commit 833b580

Please sign in to comment.