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

Add Council #55

Merged
merged 47 commits into from
Mar 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
70c3002
Added Pools to genesis
lxgr-linux Feb 17, 2022
f878731
inited and made adding and subtracting from Pools able
lxgr-linux Feb 17, 2022
451ae35
removed big comment
lxgr-linux Feb 17, 2022
bc0be4e
Removed old fns
lxgr-linux Feb 17, 2022
aad343a
Added Collection creation Fee
lxgr-linux Feb 17, 2022
2c55994
Added Collection Contribution Fee
lxgr-linux Feb 17, 2022
4aa4f3a
added fee at collection finalysation
lxgr-linux Feb 17, 2022
ca892a2
added CollateralDeposit
lxgr-linux Feb 17, 2022
8a8fa1d
added WinnerReward
lxgr-linux Feb 17, 2022
9b575d9
Added voters reward
lxgr-linux Feb 17, 2022
db80721
Merge branch 'double_bug_fix' into pools
lxgr-linux Feb 17, 2022
fba9ef0
Merge branch 'double_bug_fix' into pools
lxgr-linux Feb 17, 2022
0dab43d
Merge branch 'double_bug_fix' into pools
lxgr-linux Feb 17, 2022
06e86e0
changed income splitting back
lxgr-linux Feb 17, 2022
20d3bd3
Merge branch 'new-features' into pools
lxgr-linux Feb 18, 2022
b8c380c
Added HourlyFaucet
lxgr-linux Feb 18, 2022
ebd616e
Added hourly faucet
lxgr-linux Feb 18, 2022
24fa10d
made votes and games 24 savable
lxgr-linux Feb 18, 2022
316d4b9
removed some deprected code
lxgr-linux Feb 19, 2022
c4e9396
fixed cardauctionprice
lxgr-linux Feb 19, 2022
7a7d085
added incentives
lxgr-linux Feb 19, 2022
8e496f7
added some logging
lxgr-linux Feb 20, 2022
d5a53d2
Added income splitting for collections
lxgr-linux Feb 20, 2022
947d03c
added inflationrate
lxgr-linux Feb 20, 2022
4824e39
added checking of right card amounts in collections
lxgr-linux Feb 22, 2022
0066bc7
added *PerPack params
lxgr-linux Feb 22, 2022
cc5ac7c
added checks for raritiies when buying boosterpacks
lxgr-linux Feb 22, 2022
a6c14fc
added message SetCardRarity
lxgr-linux Feb 22, 2022
2f23385
added council
lxgr-linux Feb 23, 2022
0b76b59
added keeper for councils
lxgr-linux Feb 23, 2022
4d0dcda
Reworked some queries
lxgr-linux Feb 24, 2022
8b12d2a
added message create Council
lxgr-linux Feb 24, 2022
699a700
Registering and creating coucil works properly
lxgr-linux Feb 25, 2022
deda9e2
Added CommitCouncilResponse
lxgr-linux Feb 25, 2022
06ec4dc
added revealCouncilResponse
lxgr-linux Feb 25, 2022
020119c
finished reveal
lxgr-linux Feb 26, 2022
d362b15
added card trial
lxgr-linux Feb 26, 2022
5b51912
fixed vote resetting
lxgr-linux Feb 26, 2022
ec67576
added checking for Status enum
lxgr-linux Feb 28, 2022
89f47f9
polishing
lxgr-linux Feb 28, 2022
744aebf
Added MulCoinFloat
lxgr-linux Feb 28, 2022
887b9b4
Added mint/burn from/to string
lxgr-linux Feb 28, 2022
c6624ff
made use of AddPoolCredits
lxgr-linux Feb 28, 2022
34a573a
Added TODOs
lxgr-linux Feb 28, 2022
5423f5b
Added Todos
lxgr-linux Feb 28, 2022
b3710bc
added another todo
lxgr-linux Mar 1, 2022
d04a4ac
Merge branch 'pools' into council
lxgr-linux Mar 1, 2022
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
52 changes: 44 additions & 8 deletions app/app.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package app

import (
"fmt"
"io"
"math"
"net/http"
"os"
"path/filepath"
Expand Down Expand Up @@ -100,7 +102,7 @@ import (
const (
AccountAddressPrefix = "cc"
Name = "Cardchain"
BondDenom = "bpf"
BondDenom = "bpf"
// epochBlockTime defines how many blocks are one buffnerf epoch
epochBlockTime = 86000 // this is 1 week with 7s block time
// epochBlockTime = 5 // this is great for debugging
Expand Down Expand Up @@ -256,7 +258,7 @@ func New(
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey,
cardchainmoduletypes.UsersStoreKey, cardchainmoduletypes.CardsStoreKey, cardchainmoduletypes.MatchesStoreKey, cardchainmoduletypes.CollectionsStoreKey, cardchainmoduletypes.SellOffersStoreKey, cardchainmoduletypes.InternalStoreKey,
cardchainmoduletypes.GeneralStoreKey, cardchainmoduletypes.UsersStoreKey, cardchainmoduletypes.CardsStoreKey, cardchainmoduletypes.MatchesStoreKey, cardchainmoduletypes.CollectionsStoreKey, cardchainmoduletypes.SellOffersStoreKey, cardchainmoduletypes.PoolsStoreKey, cardchainmoduletypes.CouncilsStoreKey, cardchainmoduletypes.InternalStoreKey,
// this line is used by starport scaffolding # stargate/app/storeKey
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
Expand Down Expand Up @@ -344,11 +346,14 @@ func New(

app.CardchainKeeper = *cardchainmodulekeeper.NewKeeper(
appCodec,
keys[cardchainmoduletypes.GeneralStoreKey],
keys[cardchainmoduletypes.UsersStoreKey],
keys[cardchainmoduletypes.CardsStoreKey],
keys[cardchainmoduletypes.MatchesStoreKey],
keys[cardchainmoduletypes.CollectionsStoreKey],
keys[cardchainmoduletypes.SellOffersStoreKey],
keys[cardchainmoduletypes.PoolsStoreKey],
keys[cardchainmoduletypes.CouncilsStoreKey],
keys[cardchainmoduletypes.InternalStoreKey],
app.GetSubspace(cardchainmoduletypes.ModuleName),

Expand Down Expand Up @@ -526,30 +531,61 @@ func (app *App) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.R
// EndBlocker application updates every end block
func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
// update the price of card auction (currently 1% decay per block)
price := app.CardchainKeeper.GetCardAuctionPrice(ctx)
newprice := price.Sub(sdk.NewCoin("ucredits", price.Amount.Quo(sdk.NewInt(100000000)))) // Somehow this line is evil
app.CardchainKeeper.SetCardAuctionPrice(ctx, newprice)
price := app.CardchainKeeper.GetCardAuctionPrice(ctx) // TODO intervall
newprice := price.Sub(cardchainmodulekeeper.QuoCoin(price, 100))
if !newprice.IsLT(sdk.NewInt64Coin("ucredits", 1000000)) { // stop at 1 credit
app.CardchainKeeper.SetCardAuctionPrice(ctx, newprice)
}
app.CardchainKeeper.Logger(ctx).Info(fmt.Sprintf(":: CardAuctionPrice: %s", app.CardchainKeeper.GetCardAuctionPrice(ctx)))

// automated nerf/buff happens here
if app.LastBlockHeight()%epochBlockTime == 0 {
cardchainmodule.UpdateNerfLevels(ctx, app.CardchainKeeper)
app.CardchainKeeper.AddVoteRightsToAllUsers(ctx, ctx.BlockHeight()+app.CardchainKeeper.GetParams(ctx).VotingRightsExpirationTime)
}

if app.LastBlockHeight()%500 == 0 { //HourlyFaucet
app.CardchainKeeper.AddPoolCredits(ctx, cardchainmodulekeeper.PublicPoolKey, app.CardchainKeeper.GetParams(ctx).HourlyFaucet)

incentives := cardchainmodulekeeper.QuoCoin(app.CardchainKeeper.GetPool(ctx, cardchainmodulekeeper.PublicPoolKey), 10)
app.CardchainKeeper.SubPoolCredits(ctx, cardchainmodulekeeper.PublicPoolKey, incentives)
winnersIncentives := cardchainmodulekeeper.MulCoinFloat(incentives, float64(app.CardchainKeeper.GetWinnerIncentives(ctx)))
balancersIncentives := cardchainmodulekeeper.MulCoinFloat(incentives, float64(app.CardchainKeeper.GetBalancerIncentives(ctx)))
app.CardchainKeeper.AddPoolCredits(ctx, cardchainmodulekeeper.WinnersPoolKey, winnersIncentives)
app.CardchainKeeper.AddPoolCredits(ctx, cardchainmodulekeeper.BalancersPoolKey, balancersIncentives)
app.CardchainKeeper.Logger(ctx).Info(fmt.Sprintf(":: PublicPool: %s", app.CardchainKeeper.GetPool(ctx, cardchainmodulekeeper.PublicPoolKey)))
}

if app.LastBlockHeight()%(24*500) == 0 { //Dayly game/vote reset
app.CardchainKeeper.SetGeneralValue(ctx, cardchainmodulekeeper.Votes24ValueKey, 0)
app.CardchainKeeper.SetGeneralValue(ctx, cardchainmodulekeeper.Games24ValueKey, 0)
}

err := app.CardchainKeeper.CheckTrial(ctx)
if err != nil {
app.CardchainKeeper.Logger(ctx).Error(fmt.Sprintf("%s", err))
}

return app.mm.EndBlock(ctx, req)
}

// InitChainer application update at chain initialization
func (app *App) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain {
var genesisState GenesisState
if err := tmjson.Unmarshal(req.AppStateBytes, &genesisState); err != nil {
panic(err)
//panic(err)
}

// initialize CardScheme Id, Auction price and public pool
app.CardchainKeeper.SetLastCardSchemeId(ctx, uint64(0))
app.CardchainKeeper.SetCardAuctionPrice(ctx, sdk.NewInt64Coin("ucredits", 10000000))
app.CardchainKeeper.SetPublicPoolCredits(ctx, sdk.NewInt64Coin("ucredits", 1000000000))

for _, key := range app.CardchainKeeper.PoolKeys {
app.CardchainKeeper.SetPool(ctx, key, sdk.NewInt64Coin("ucredits", int64(1000*math.Pow(10, 6))))
}

for _, key := range app.CardchainKeeper.GeneralValueKeys {
app.CardchainKeeper.SetGeneralValue(ctx, key, uint64(0))
}

app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap())
return app.mm.InitGenesis(ctx, app.appCodec, genesisState)
Expand Down
41 changes: 20 additions & 21 deletions app/modules.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package app

import (
"encoding/json"
"encoding/json"

"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/bank"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/bank"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/crisis"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
"github.com/cosmos/cosmos-sdk/x/gov"
"github.com/cosmos/cosmos-sdk/x/crisis"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
"github.com/cosmos/cosmos-sdk/x/gov"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/mint"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
"github.com/cosmos/cosmos-sdk/x/staking"
"github.com/cosmos/cosmos-sdk/x/mint"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)

Expand All @@ -26,16 +26,16 @@ type BankModule struct {
// DefaultGenesis returns custom x/bank module genesis state.
func (BankModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
Metadata := banktypes.Metadata{
Name: "Burning Pitchfork",
Symbol: "BPF",
Description: "The native staking token of the CrowdControlNetwork.",
DenomUnits: []*banktypes.DenomUnit{
{"ubpf", uint32(0), []string{"microbpf"}},
{"mbpf", uint32(3), []string{"millibpf"}},
{BondDenom, uint32(6), nil},
},
Base: "ubpf",
Display: BondDenom,
Name: "Burning Pitchfork",
Symbol: "BPF",
Description: "The native staking token of the CrowdControlNetwork.",
DenomUnits: []*banktypes.DenomUnit{
{"ubpf", uint32(0), []string{"microbpf"}},
{"mbpf", uint32(3), []string{"millibpf"}},
{BondDenom, uint32(6), nil},
},
Base: "ubpf",
Display: BondDenom,
}

genState := banktypes.DefaultGenesisState()
Expand Down Expand Up @@ -74,7 +74,6 @@ func (MintModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
return cdc.MustMarshalJSON(genState)
}


// GovModule defines a custom wrapper around the x/gov module's
// AppModuleBasic implementation to provide custom default genesis state.
type GovModule struct {
Expand Down
Loading