Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CM-339 Add Faucet Module #60

Merged
merged 5 commits into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=BluzelleService \
-X github.com/cosmos/cosmos-sdk/version.ClientName=blzcli \
-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=$(build_tags_comma_sep),cosmos-sdk $(COSMOS_SDK)"
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep),faucet,cosmos-sdk $(COSMOS_SDK)"

BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'
BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)' -tags faucet
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this update the version info as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now it does.


all:
go build $(BUILD_FLAGS) ./cmd/blzd
Expand Down
21 changes: 20 additions & 1 deletion app.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package app

import (
"encoding/json"
"time"
bluzellechain "github.com/bluzelle/curium/types"
"github.com/bluzelle/curium/x/crud"
bam "github.com/cosmos/cosmos-sdk/baseapp"
Expand All @@ -31,6 +32,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/slashing"
"github.com/cosmos/cosmos-sdk/x/staking"
"github.com/cosmos/cosmos-sdk/x/supply"
"github.com/cosmos/modules/incubator/faucet"
"github.com/spf13/viper"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
Expand Down Expand Up @@ -60,6 +62,7 @@ var (
distr.ModuleName: nil,
staking.BondedPoolName: {supply.Burner, supply.Staking},
staking.NotBondedPoolName: {supply.Burner, supply.Staking},
faucet.ModuleName: {supply.Minter}, // add permissions for faucet
}
)

Expand Down Expand Up @@ -91,6 +94,7 @@ func newBasicManager(nodeHome string) module.BasicManager {
slashing.AppModuleBasic{},
supply.AppModuleBasic{},
crud.AppModule{},
faucet.AppModule{},
)
} else {
return module.NewBasicManager(
Expand All @@ -102,6 +106,7 @@ func newBasicManager(nodeHome string) module.BasicManager {
params.AppModuleBasic{},
slashing.AppModuleBasic{},
supply.AppModuleBasic{},
faucet.AppModule{},
)
}
}
Expand Down Expand Up @@ -131,6 +136,7 @@ type CRUDApp struct {
supplyKeeper supply.Keeper
paramsKeeper params.Keeper
crudKeeper crud.Keeper
faucetKeeper faucet.Keeper

// Module Manager
mm *module.Manager
Expand All @@ -149,7 +155,7 @@ func NewCRUDApp(
bApp.SetAppVersion(version.Version)

keys := sdk.NewKVStoreKeys(bam.MainStoreKey, auth.StoreKey, staking.StoreKey,
supply.StoreKey, distr.StoreKey, slashing.StoreKey, params.StoreKey, crud.StoreKey)
supply.StoreKey, distr.StoreKey, slashing.StoreKey, params.StoreKey, crud.StoreKey, faucet.StoreKey)

tkeys := sdk.NewTransientStoreKeys(staking.TStoreKey, params.TStoreKey)

Expand Down Expand Up @@ -236,11 +242,24 @@ func NewCRUDApp(
crud.MaxKeeperSizes{MaxKeysSize: maxKeysSize, MaxKeyValuesSize: maxKeyValuesSize},
)

// Example use of the faucet:
//
// blzcli tx faucet mintfor $(blzcli keys show neeraj -a) --from vuser --gas-prices 0.01bnt

app.faucetKeeper = faucet.NewKeeper(
app.supplyKeeper,
app.stakingKeeper,
2000000000, // How many tokens to mint out for every successful request
5*time.Minute, // Time you have to wait before you can use the faucet again for a given beneficiary address
keys[faucet.StoreKey],
app.cdc)

app.mm = module.NewManager(
genutil.NewAppModule(app.accountKeeper, app.stakingKeeper, app.BaseApp.DeliverTx),
auth.NewAppModule(app.accountKeeper),
bank.NewAppModule(app.bankKeeper, app.accountKeeper),
crud.NewAppModule(app.crudKeeper, app.bankKeeper),
faucet.NewAppModule(app.faucetKeeper), // faucet module
supply.NewAppModule(app.supplyKeeper, app.accountKeeper),
distr.NewAppModule(app.distrKeeper, app.accountKeeper, app.supplyKeeper, app.stakingKeeper),
slashing.NewAppModule(app.slashingKeeper, app.accountKeeper, app.stakingKeeper),
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ go 1.13

require (
github.com/cosmos/cosmos-sdk v0.38.1
github.com/cosmos/modules/incubator/faucet v0.0.0-20200305101902-47c39933dbb5
github.com/golang/mock v1.4.0
github.com/gorilla/mux v1.7.3
github.com/gorilla/mux v1.7.4
github.com/magiconair/properties v1.8.1
github.com/spf13/cobra v0.0.5
github.com/spf13/viper v1.6.2
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8Nz
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cosmos/cosmos-sdk v0.38.0/go.mod h1:9ZZex0GKpyNCvilvVAPBoB+0n3A/aO1+/UhPVEaiCy4=
github.com/cosmos/cosmos-sdk v0.38.1 h1:DTuxIJeMpB//ydq+ObAjQgsaiwYBZ8T7NDzXjyiL1Kg=
github.com/cosmos/cosmos-sdk v0.38.1/go.mod h1:9ZZex0GKpyNCvilvVAPBoB+0n3A/aO1+/UhPVEaiCy4=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d h1:49RLWk1j44Xu4fjHb6JFYmeUnDORVwHNkDxaQ0ctCVU=
Expand All @@ -48,6 +49,9 @@ github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6
github.com/cosmos/ledger-cosmos-go v0.11.1/go.mod h1:J8//BsAGTo3OC/vDLjMRFLW6q0WAaXvHnVc7ZmE8iUY=
github.com/cosmos/ledger-go v0.9.2 h1:Nnao/dLwaVTk1Q5U9THldpUMMXU94BOTWPddSmVB6pI=
github.com/cosmos/ledger-go v0.9.2/go.mod h1:oZJ2hHAZROdlHiwTg4t7kP+GKIIkBT+o6c9QWFanOyI=
github.com/cosmos/modules v0.0.0-20200305101902-47c39933dbb5 h1:IJZk1RB618iFgOaqeWc93OZK7CVL0VYTsYC3fg+CZC4=
github.com/cosmos/modules/incubator/faucet v0.0.0-20200305101902-47c39933dbb5 h1:L8cdyH39UuctB75OMsJTg8s8lZNBzOQM07t7XfTbhRI=
github.com/cosmos/modules/incubator/faucet v0.0.0-20200305101902-47c39933dbb5/go.mod h1:d3YXBZuK1RTAJhXS85CIg0sNrjlkQS+9bjIr02I9Mjk=
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
github.com/danieljoos/wincred v1.0.2 h1:zf4bhty2iLuwgjgpraD2E9UbvO+fe54XXGJbOwe23fU=
github.com/danieljoos/wincred v1.0.2/go.mod h1:SnuYRW9lp1oJrZX/dXJqr0cPK5gYXqx3EJbmjhLdK9U=
Expand Down Expand Up @@ -121,6 +125,8 @@ github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGa
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw=
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gorilla/mux v1.7.4 h1:VuZ8uybHlWmqV03+zRzdwKL4tUnIp1MAQtp1mIFE1bc=
github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM=
Expand Down