Skip to content

Commit

Permalink
Merge pull request #49
Browse files Browse the repository at this point in the history
Release v0.3.0-rc1
  • Loading branch information
ironman0x7b2 authored Jul 10, 2020
2 parents 29bdc18 + a768649 commit d4d1d25
Show file tree
Hide file tree
Showing 260 changed files with 8,177 additions and 10,926 deletions.
2 changes: 1 addition & 1 deletion .golangci/v1.27.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ linters:
- maligned
- misspell
- nakedret
- nestif
#- nestif
#- nolintlint
- prealloc
- rowserrcheck
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright [2019] [Sentinel]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
38 changes: 15 additions & 23 deletions app/app.go → app.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app
package hub

import (
"encoding/json"
Expand Down Expand Up @@ -28,9 +28,8 @@ import (
"github.com/tendermint/tendermint/libs/log"
db "github.com/tendermint/tm-db"

"github.com/sentinel-official/hub/types"
"github.com/sentinel-official/hub/x/deposit"
"github.com/sentinel-official/hub/x/vpn"
"github.com/sentinel-official/hub/x/dvpn"
"github.com/sentinel-official/hub/x/dvpn/deposit"
)

const (
Expand All @@ -54,8 +53,7 @@ var (
slashing.AppModuleBasic{},
crisis.AppModuleBasic{},
gov.NewAppModuleBasic(client.ProposalHandler, distribution.ProposalHandler),
deposit.AppModuleBasic{},
vpn.AppModuleBasic{},
dvpn.AppModuleBasic{},
)

moduleAccountPermissions = map[string][]string{
Expand All @@ -73,7 +71,6 @@ func MakeCodec() *codec.Codec {
var cdc = codec.New()

sdk.RegisterCodec(cdc)
types.RegisterCodec(cdc)
codec.RegisterCrypto(cdc)
codec.RegisterEvidences(cdc)
ModuleBasics.RegisterCodec(cdc)
Expand All @@ -99,21 +96,21 @@ type App struct {
slashingKeeper slashing.Keeper
crisisKeeper crisis.Keeper
govKeeper gov.Keeper
depositKeeper deposit.Keeper
vpnKeeper vpn.Keeper
dVPNKeeper dvpn.Keeper
}

func NewApp(logger log.Logger, db db.DB, tracer io.Writer, latest bool, invarCheckPeriod uint,
options ...func(*baseapp.BaseApp)) *App {
cdc := MakeCodec()

baseApp := baseapp.NewBaseApp(appName, logger, db, auth.DefaultTxDecoder(cdc), options...)
baseApp.SetCommitMultiStoreTracer(tracer)
baseApp.SetAppVersion(version.Version)

keys := sdk.NewKVStoreKeys(baseapp.MainStoreKey,
params.StoreKey, auth.StoreKey, supply.StoreKey, staking.StoreKey,
mint.StoreKey, distribution.StoreKey, slashing.StoreKey, gov.StoreKey,
deposit.StoreKey, vpn.StoreKeyNode, vpn.StoreKeySubscription, vpn.StoreKeySession,
dvpn.StoreKey,
)
transientKeys := sdk.NewTransientStoreKeys(params.TStoreKey, staking.TStoreKey)

Expand Down Expand Up @@ -196,15 +193,11 @@ func NewApp(logger log.Logger, db db.DB, tracer io.Writer, latest bool, invarChe
govRouter)
app.stakingKeeper = *stakingKeeper.SetHooks(
staking.NewMultiStakingHooks(app.distributionKeeper.Hooks(), app.slashingKeeper.Hooks()))
app.depositKeeper = deposit.NewKeeper(app.cdc,
keys[deposit.StoreKey],
app.dVPNKeeper = dvpn.NewKeeper(app.cdc,
keys[dvpn.StoreKey],
app.paramsKeeper,
app.bankKeeper,
app.supplyKeeper)
app.vpnKeeper = vpn.NewKeeper(app.cdc,
keys[vpn.StoreKeyNode],
keys[vpn.StoreKeySubscription],
keys[vpn.StoreKeySession],
app.paramsKeeper.Subspace(vpn.DefaultParamspace),
app.depositKeeper)

app.manager = module.NewManager(
genaccounts.NewAppModule(app.accountKeeper),
Expand All @@ -218,17 +211,16 @@ func NewApp(logger log.Logger, db db.DB, tracer io.Writer, latest bool, invarChe
slashing.NewAppModule(app.slashingKeeper, app.stakingKeeper),
crisis.NewAppModule(&app.crisisKeeper),
gov.NewAppModule(app.govKeeper, app.supplyKeeper),
deposit.NewAppModule(app.depositKeeper),
vpn.NewAppModule(app.vpnKeeper),
dvpn.NewAppModule(app.dVPNKeeper),
)

// NOTE: order is very important here
app.manager.SetOrderBeginBlockers(mint.ModuleName, distribution.ModuleName, slashing.ModuleName)
app.manager.SetOrderEndBlockers(crisis.ModuleName, gov.ModuleName, staking.ModuleName, vpn.ModuleName)
app.manager.SetOrderBeginBlockers(mint.ModuleName, distribution.ModuleName, slashing.ModuleName, dvpn.ModuleName)
app.manager.SetOrderEndBlockers(crisis.ModuleName, gov.ModuleName, staking.ModuleName)
app.manager.SetOrderInitGenesis(
genaccounts.ModuleName, distribution.ModuleName, staking.ModuleName, auth.ModuleName,
bank.ModuleName, slashing.ModuleName, gov.ModuleName, mint.ModuleName,
supply.ModuleName, crisis.ModuleName, genutil.ModuleName, deposit.ModuleName, vpn.ModuleName,
supply.ModuleName, crisis.ModuleName, genutil.ModuleName, dvpn.ModuleName,
)

app.manager.RegisterInvariants(&app.crisisKeeper)
Expand Down
41 changes: 14 additions & 27 deletions cmd/sentinel-hub-cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,23 @@ import (
"github.com/cosmos/cosmos-sdk/client/keys"
"github.com/cosmos/cosmos-sdk/client/lcd"
"github.com/cosmos/cosmos-sdk/client/rpc"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth"
authCli "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
authRest "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
"github.com/cosmos/cosmos-sdk/x/bank"
bankCli "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/tendermint/go-amino"
"github.com/tendermint/tendermint/libs/cli"

"github.com/sentinel-official/hub"
"github.com/sentinel-official/hub/types"

hub "github.com/sentinel-official/hub/app"
)

func main() {
cdc := hub.MakeCodec()

config := sdk.GetConfig()
config := types.GetConfig()
config.SetBech32PrefixForAccount(types.Bech32PrefixAccAddr, types.Bech32PrefixAccPub)
config.SetBech32PrefixForValidator(types.Bech32PrefixValAddr, types.Bech32PrefixValPub)
config.SetBech32PrefixForConsensusNode(types.Bech32PrefixConsAddr, types.Bech32PrefixConsPub)
Expand All @@ -48,13 +44,12 @@ func main() {
cmd.AddCommand(
rpc.StatusCommand(),
client.ConfigCmd(hub.DefaultCLIHome),
client.LineBreak,
keys.Commands(),
queryCmd(cdc),
txCmd(cdc),
client.LineBreak,
lcd.ServeCommand(cdc, registerRoutes),
client.LineBreak,
keys.Commands(),
client.LineBreak,
version.Cmd,
client.NewCompletionCmd(cmd, true),
)
Expand All @@ -65,52 +60,44 @@ func main() {
}
}

func queryCmd(cdc *amino.Codec) *cobra.Command {
func queryCmd(cdc *codec.Codec) *cobra.Command {
cmd := &cobra.Command{
Use: "query",
Aliases: []string{"q"},
Short: "Query sub-commands",
}

cmd.AddCommand(
authCli.GetAccountCmd(cdc),
client.LineBreak,
rpc.ValidatorCommand(cdc),
rpc.BlockCommand(),
authCli.QueryTxsByEventsCmd(cdc),
rpc.ValidatorCommand(cdc),
client.LineBreak,
authCli.GetAccountCmd(cdc),
authCli.QueryTxCmd(cdc),
authCli.QueryTxsByEventsCmd(cdc),
client.LineBreak,
)

hub.ModuleBasics.AddQueryCommands(cmd, cdc)
return cmd
}

func txCmd(cdc *amino.Codec) *cobra.Command {
func txCmd(cdc *codec.Codec) *cobra.Command {
cmd := &cobra.Command{
Use: "tx",
Short: "Transaction sub-commands",
}

cmd.AddCommand(
bankCli.SendTxCmd(cdc),
client.LineBreak,
authCli.GetSignCommand(cdc),
authCli.GetMultiSignCommand(cdc),
client.LineBreak,
authCli.GetBroadcastCommand(cdc),
authCli.GetEncodeCommand(cdc),
authCli.GetBroadcastCommand(cdc),
client.LineBreak,
bankCli.SendTxCmd(cdc),
client.LineBreak,
)

hub.ModuleBasics.AddTxCommands(cmd, cdc)

for _, cmd := range cmd.Commands() {
if cmd.Use == auth.ModuleName || cmd.Use == bank.ModuleName {
cmd.RemoveCommand(cmd)
}
}

return cmd
}

Expand Down
5 changes: 2 additions & 3 deletions cmd/sentinel-hub-daemon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/store"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/genaccounts"
genaccountsCli "github.com/cosmos/cosmos-sdk/x/genaccounts/client/cli"
genutilCli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
Expand All @@ -21,7 +20,7 @@ import (
tm "github.com/tendermint/tendermint/types"
db "github.com/tendermint/tm-db"

hub "github.com/sentinel-official/hub/app"
"github.com/sentinel-official/hub"
"github.com/sentinel-official/hub/types"
)

Expand All @@ -36,7 +35,7 @@ var (
func main() {
cdc := hub.MakeCodec()

config := sdk.GetConfig()
config := types.GetConfig()
config.SetBech32PrefixForAccount(types.Bech32PrefixAccAddr, types.Bech32PrefixAccPub)
config.SetBech32PrefixForValidator(types.Bech32PrefixValAddr, types.Bech32PrefixValPub)
config.SetBech32PrefixForConsensusNode(types.Bech32PrefixConsAddr, types.Bech32PrefixConsPub)
Expand Down
2 changes: 1 addition & 1 deletion app/export.go → export.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app
package hub

import (
"encoding/json"
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ require (
github.com/gorilla/mux v1.7.4
github.com/spf13/cobra v1.0.0
github.com/spf13/viper v1.7.0
github.com/stretchr/testify v1.6.1
github.com/tendermint/go-amino v0.15.1
github.com/tendermint/tendermint v0.32.12
github.com/tendermint/tm-db v0.2.0
gopkg.in/yaml.v2 v2.2.7
)
9 changes: 3 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stumble/gorocksdb v0.0.3/go.mod h1:v6IHdFBXk5DJ1K4FZ0xi+eY737quiiBxYtSWXadLybY=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
Expand All @@ -282,9 +281,8 @@ github.com/tendermint/btcd v0.1.1/go.mod h1:DC6/m53jtQzr/NFmMNEu0rxf18/ktVoVtMrn
github.com/tendermint/crypto v0.0.0-20180820045704-3764759f34a5 h1:u8i49c+BxloX3XQ55cvzFNXplizZP/q00i+IlttUjAU=
github.com/tendermint/crypto v0.0.0-20180820045704-3764759f34a5/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk=
github.com/tendermint/go-amino v0.14.1/go.mod h1:i/UKE5Uocn+argJJBb12qTZsCDBcAYMbR92AaJVmKso=
github.com/tendermint/go-amino v0.15.0 h1:TC4e66P59W7ML9+bxio17CPKnxW3nKIRAYskntMAoRk=
github.com/tendermint/go-amino v0.15.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME=
github.com/tendermint/go-amino v0.15.1 h1:D2uk35eT4iTsvJd9jWIetzthE5C0/k2QmMFkCN+4JgQ=
github.com/tendermint/go-amino v0.15.1/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME=
github.com/tendermint/iavl v0.12.4 h1:hd1woxUGISKkfUWBA4mmmTwOua6PQZTJM/F0FDrmMV8=
github.com/tendermint/iavl v0.12.4/go.mod h1:8LHakzt8/0G3/I8FUU0ReNx98S/EP6eyPJkAUvEXT/o=
github.com/tendermint/tendermint v0.32.1/go.mod h1:jmPDAKuNkev9793/ivn/fTBnfpA9mGBww8MPRNPNxnU=
Expand All @@ -298,6 +296,7 @@ github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGr
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
github.com/zondax/hid v0.9.0 h1:eiT3P6vNxAEVxXMw66eZUAAnU2zD33JBkfG/EnfAKl8=
github.com/zondax/hid v0.9.0/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
Expand Down Expand Up @@ -449,8 +448,6 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo=
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Expand Down
Loading

0 comments on commit d4d1d25

Please sign in to comment.