Skip to content

Commit

Permalink
Merge pull request #215 from DecentralCardGame/fix/int64_conversion
Browse files Browse the repository at this point in the history
Fix/int64 conversion
  • Loading branch information
lxgr-linux committed Feb 29, 2024
2 parents 5cf6a3d + f9b6647 commit dbf348a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/app.go
Expand Up @@ -803,7 +803,7 @@ func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.Respo
}

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

incentives := cardchainmodulekeeper.QuoCoin(*app.CardchainKeeper.Pools.Get(ctx, cardchainmodulekeeper.PublicPoolKey), 10)
app.CardchainKeeper.SubPoolCredits(ctx, cardchainmodulekeeper.PublicPoolKey, incentives)
Expand Down
8 changes: 3 additions & 5 deletions config.yml
Expand Up @@ -40,12 +40,10 @@ genesis:
denom_metadata:
- base: ubpf
denom_units:
- aliases:
- microbpf
- aliases: [microbpf]
denom: ubpf
exponent: 0
- aliases:
- millibpf
- aliases: [millibpf]
denom: mbpf
exponent: 3
- aliases: []
Expand Down Expand Up @@ -88,7 +86,7 @@ genesis:
staking:
params:
bond_denom: ubpf
chain_id: cardtestnet-9
chain_id: cardtestnet-10
validators:
- name: alice
bonded: 5000000ubpf
Expand Down
8 changes: 8 additions & 0 deletions x/cardchain/keeper/pools.go
Expand Up @@ -24,3 +24,11 @@ func (k Keeper) SubPoolCredits(ctx sdk.Context, poolName string, amount sdk.Coin
newPool := pool.Sub(amount)
k.Pools.Set(ctx, poolName, &newPool)
}

// DistributeHourlyFaucet distributes hourly faucet
func (k Keeper) DistributeHourlyFaucet(ctx sdk.Context) {
pool := k.Pools.Get(ctx, PublicPoolKey)
if pool.Amount.LT(sdk.NewInt(1_000_000_000_000_000)) {
k.AddPoolCredits(ctx, PublicPoolKey, k.GetParams(ctx).HourlyFaucet)
}
}
2 changes: 1 addition & 1 deletion x/cardchain/keeper/vote_right.go
Expand Up @@ -14,7 +14,7 @@ func (k Keeper) GetVoteReward(ctx sdk.Context) sdk.Coin {

pool := k.Pools.Get(ctx, BalancersPoolKey)
reward := QuoCoin(*pool, params.VotePoolFraction)
if reward.Amount.Int64() > params.VotingRewardCap {
if reward.Amount.GTE(sdk.NewInt(params.VotingRewardCap)) {
return sdk.NewInt64Coin(reward.Denom, params.VotingRewardCap)
}
return reward
Expand Down

0 comments on commit dbf348a

Please sign in to comment.