Skip to content

Commit

Permalink
feat: auctions, minimum validator commission decorator (#24)
Browse files Browse the repository at this point in the history
- bump [email protected]
- minimum validator commission decorator
- bump [email protected]
- bump [email protected]
- v2 upgrade handler
  • Loading branch information
harish551 authored Aug 30, 2022
2 parents 31adcc5 + b939f72 commit 8644508
Show file tree
Hide file tree
Showing 12 changed files with 483 additions and 136 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Setup go
uses: actions/setup-go@v1
with:
go-version: 1.17
go-version: 1.18
env:
GOOS: ${{ matrix.targetos }}
GOARCH: ${{ matrix.arch }}
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
.idea
secret.yml
.build/*
._build/*
.envrc
/build
/_build
.vscode
54 changes: 54 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
project_name: omniflixhub

env:
- GO111MODULE=on

before:
hooks:
- go mod tidy -compat=1.18

builds:
- main: ./cmd/omniflixhubd
id: "omniflixhubd"
binary: omniflixhubd
mod_timestamp: "{{ .CommitTimestamp }}"
flags:
- -tags=netgo ledger
- -trimpath
env:
- CGO_ENABLED=0
ldflags:
- -s -w -X main.commit={{.Commit}} -X main.date={{ .CommitDate }} -X github.com/cosmos/cosmos-sdk/version.Name=gaia -X github.com/cosmos/cosmos-sdk/version.AppName=gaiad -X github.com/cosmos/cosmos-sdk/version.Version={{ .Version }} -X github.com/cosmos/cosmos-sdk/version.Commit={{ .Commit }} -X github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger -X github.com/tendermint/tendermint/version.TMCoreSemVer={{ .Env.TM_VERSION }}
goos:
- linux
goarch:
- amd64
- arm64

archives:
- format: tar.gz
wrap_in_directory: "true"
format_overrides:
- goos: windows
format: zip
name_template: "{{ .Binary }}-v{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
files:
- LICENSE
- README.md

release:
github:
owner: OmniFlix
name: omniflixhub
name_template: "v{{.Version}}"

checksum:
name_template: SHA256SUMS-v{{.Version}}.txt
algorithm: sha256

snapshot:
name_template: SNAPSHOT-{{ .Commit }}

changelog:
skip: true
14 changes: 10 additions & 4 deletions app/ante_handler.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
package app

import (
"github.com/OmniFlix/omniflixhub/app/decorators"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
channelkeeper "github.com/cosmos/ibc-go/v2/modules/core/04-channel/keeper"
ibcante "github.com/cosmos/ibc-go/v2/modules/core/ante"
ibcante "github.com/cosmos/ibc-go/v3/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper"
)

// HandlerOptions extend the SDK's AnteHandler options by requiring the IBC
// channel keeper.
type HandlerOptions struct {
ante.HandlerOptions

IBCChannelkeeper channelkeeper.Keeper
IBCKeeper *ibckeeper.Keeper
TxCounterStoreKey sdk.StoreKey
Codec codec.BinaryCodec
}

func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
Expand All @@ -33,6 +37,8 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
}

anteDecorators := []sdk.AnteDecorator{
ante.NewSetUpContextDecorator(), // Outermost AnteDecorator, SetUpContext must be called first
decorators.NewMinCommissionDecorator(options.Codec),
ante.NewRejectExtensionOptionsDecorator(),
ante.NewMempoolFeeDecorator(),
ante.NewValidateBasicDecorator(),
Expand All @@ -46,7 +52,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
ante.NewSigGasConsumeDecorator(options.AccountKeeper, sigGasConsumer),
ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
ibcante.NewAnteDecorator(options.IBCChannelkeeper),
ibcante.NewAnteDecorator(options.IBCKeeper),
}

return sdk.ChainAnteDecorators(anteDecorators...), nil
Expand Down
80 changes: 54 additions & 26 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package app

import (
"fmt"
appparams "github.com/OmniFlix/omniflixhub/app/params"
"io"
"net/http"
"os"
"path/filepath"

appparams "github.com/OmniFlix/omniflixhub/app/params"
customAuthRest "github.com/OmniFlix/omniflixhub/custom/auth/client/rest"
"github.com/OmniFlix/omniflixhub/docs"
"github.com/cosmos/cosmos-sdk/baseapp"
Expand Down Expand Up @@ -77,15 +77,16 @@ import (
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/cosmos/ibc-go/v2/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v2/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v2/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v2/modules/core"
ibcclient "github.com/cosmos/ibc-go/v2/modules/core/02-client"
ibcclientclient "github.com/cosmos/ibc-go/v2/modules/core/02-client/client"
porttypes "github.com/cosmos/ibc-go/v2/modules/core/05-port/types"
ibchost "github.com/cosmos/ibc-go/v2/modules/core/24-host"
ibckeeper "github.com/cosmos/ibc-go/v2/modules/core/keeper"
transfer "github.com/cosmos/ibc-go/v3/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v3/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v3/modules/core"
ibcclient "github.com/cosmos/ibc-go/v3/modules/core/02-client"
ibcclientclient "github.com/cosmos/ibc-go/v3/modules/core/02-client/client"
ibcclienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types"
porttypes "github.com/cosmos/ibc-go/v3/modules/core/05-port/types"
ibchost "github.com/cosmos/ibc-go/v3/modules/core/24-host"
ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper"
"github.com/spf13/cast"
"github.com/tendermint/spm/openapiconsole"
abci "github.com/tendermint/tendermint/abci/types"
Expand All @@ -108,12 +109,9 @@ import (

const Name = "omniflixhub"

// this line is used by starport scaffolding # stargate/wasm/app/enabledProposals

func getGovProposalHandlers() []govclient.ProposalHandler {
var govProposalHandlers []govclient.ProposalHandler
// this line is used by starport scaffolding # stargate/app/govProposalHandlers

govProposalHandlers = append(govProposalHandlers,
paramsclient.ProposalHandler,
distrclient.ProposalHandler,
Expand Down Expand Up @@ -153,6 +151,7 @@ var (
evidence.AppModuleBasic{},
transfer.AppModuleBasic{},
vesting.AppModuleBasic{},
//ica.AppModuleBasic{},

alloc.AppModuleBasic{},
onft.AppModuleBasic{},
Expand Down Expand Up @@ -225,8 +224,11 @@ type App struct {
FeeGrantKeeper feegrantkeeper.Keeper
AuthzKeeper authzkeeper.Keeper

//ICAHostKeeper icahostkeeper.Keeper

// make scoped keepers public for test purposes
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
//ScopedICAHostKeeper capabilitykeeper.ScopedKeeper
ScopedTransferKeeper capabilitykeeper.ScopedKeeper

AllocKeeper allockeeper.Keeper
Expand All @@ -247,10 +249,17 @@ type App struct {
// New returns a reference to an initialized app.

func NewOmniFlixApp(
logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, skipUpgradeHeights map[int64]bool,
homePath string, invCheckPeriod uint, encodingConfig appparams.EncodingConfig,
logger log.Logger,
db dbm.DB,
traceStore io.Writer,
loadLatest bool,
skipUpgradeHeights map[int64]bool,
homePath string,
invCheckPeriod uint,
encodingConfig appparams.EncodingConfig,
// this line is used by starport scaffolding # stargate/app/newArgument
appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp),
appOpts servertypes.AppOptions,
baseAppOptions ...func(*baseapp.BaseApp),
) *App {

appCodec := encodingConfig.Marshaler
Expand Down Expand Up @@ -394,20 +403,35 @@ func NewOmniFlixApp(
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)).
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)).
AddRoute(ibchost.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper))
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper))

// Create Transfer Keepers
app.TransferKeeper = ibctransferkeeper.NewKeeper(
appCodec,
keys[ibctransfertypes.StoreKey],
app.GetSubspace(ibctransfertypes.ModuleName),
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
app.AccountKeeper,
app.BankKeeper,
scopedTransferKeeper,
)
transferModule := transfer.NewAppModule(app.TransferKeeper)
transferIBCModule := transfer.NewIBCModule(app.TransferKeeper)

/* app.ICAHostKeeper = icahostkeeper.NewKeeper(
appCodec,
keys[icahosttypes.StoreKey],
app.GetSubspace(icahosttypes.SubModuleName),
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
app.AccountKeeper,
scopedICAHostKeeper,
app.MsgServiceRouter(),
)
icaModule := ica.NewAppModule(nil, &app.ICAHostKeeper)
icaHostIBCModule := icahost.NewIBCModule(app.ICAHostKeeper) */

// Create evidence Keeper for to register the IBC light client misbehaviour evidence route
evidenceKeeper := evidencekeeper.NewKeeper(
Expand Down Expand Up @@ -462,7 +486,7 @@ func NewOmniFlixApp(

// Create static IBC router, add transfer route, then set and seal it
ibcRouter := porttypes.NewRouter()
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferModule)
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferIBCModule)
// this line is used by starport scaffolding # ibc/app/router
app.IBCKeeper.SetRouter(ibcRouter)

Expand Down Expand Up @@ -497,11 +521,11 @@ func NewOmniFlixApp(
ibc.NewAppModule(app.IBCKeeper),
params.NewAppModule(app.ParamsKeeper),
transferModule,
//icaModule,
allocModule,
onftModule,
marketplaceModule,
// this line is used by starport scaffolding # stargate/app/appModule

)

// During begin block slashing happens after distr.BeginBlocker so that
Expand Down Expand Up @@ -571,19 +595,19 @@ func NewOmniFlixApp(
govtypes.ModuleName,
minttypes.ModuleName,
crisistypes.ModuleName,
ibchost.ModuleName,
genutiltypes.ModuleName,
evidencetypes.ModuleName,
ibctransfertypes.ModuleName,
feegrant.ModuleName,
authz.ModuleName,
paramstypes.ModuleName,
vestingtypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
feegrant.ModuleName,
alloctypes.ModuleName,
onfttypes.ModuleName,
marketplacetypes.ModuleName,
// this line is used by starport scaffolding # stargate/app/initGenesis
ibchost.ModuleName,
ibctransfertypes.ModuleName,
)

app.mm.RegisterInvariants(&app.CrisisKeeper)
Expand Down Expand Up @@ -630,14 +654,16 @@ func NewOmniFlixApp(
SignModeHandler: encodingConfig.TxConfig.SignModeHandler(),
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
},
IBCChannelkeeper: app.IBCKeeper.ChannelKeeper,
IBCKeeper: app.IBCKeeper,
Codec: appCodec,
},
)
if err != nil {
panic(fmt.Errorf("failed to create AnteHandler: %s", err))
}
app.SetAnteHandler(anteHandler)
app.SetEndBlocker(app.EndBlocker)
app.RegisterUpgradeHandlers(app.configurator)

if loadLatest {
if err := app.LoadLatestVersion(); err != nil {
Expand All @@ -648,7 +674,6 @@ func NewOmniFlixApp(
app.ScopedIBCKeeper = scopedIBCKeeper
app.ScopedTransferKeeper = scopedTransferKeeper
// this line is used by starport scaffolding # stargate/app/beforeInitReturn

return app
}

Expand All @@ -671,6 +696,8 @@ func (app *App) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.Res
if err := tmjson.Unmarshal(req.AppStateBytes, &genesisState); err != nil {
panic(err)
}

app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap())
return app.mm.InitGenesis(ctx, app.appCodec, genesisState)
}

Expand Down Expand Up @@ -802,6 +829,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(alloctypes.ModuleName)
paramsKeeper.Subspace(onfttypes.ModuleName)
paramsKeeper.Subspace(marketplacetypes.ModuleName)

// this line is used by starport scaffolding # stargate/app/paramSubspace

return paramsKeeper
Expand Down
Loading

0 comments on commit 8644508

Please sign in to comment.