mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-07-08 13:42:29 +00:00
add denoms to config
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
parent
05a484c8b9
commit
c58dda2034
@ -14,6 +14,9 @@ const DefaultConfigTemplate = `
|
|||||||
osc-service-port = {{ .PlmntConfig.OSCServicePort }}
|
osc-service-port = {{ .PlmntConfig.OSCServicePort }}
|
||||||
watchmen-endpoint = "{{ .PlmntConfig.WatchmenEndpoint }}"
|
watchmen-endpoint = "{{ .PlmntConfig.WatchmenEndpoint }}"
|
||||||
watchmen-port = {{ .PlmntConfig.WatchmenPort }}
|
watchmen-port = {{ .PlmntConfig.WatchmenPort }}
|
||||||
|
token-denom = {{ .PlmntConfig.TokenDenom }}
|
||||||
|
stake-denom = {{ .PlmntConfig.StakeDenom }}
|
||||||
|
fee-denom = {{ .PlmntConfig.FeeDenom }}
|
||||||
`
|
`
|
||||||
|
|
||||||
// Config defines Planetmint's top level configuration
|
// Config defines Planetmint's top level configuration
|
||||||
@ -21,6 +24,9 @@ type Config struct {
|
|||||||
OSCServicePort int `mapstructure:"osc-service-port" json:"osc-service-port"`
|
OSCServicePort int `mapstructure:"osc-service-port" json:"osc-service-port"`
|
||||||
WatchmenEndpoint string `mapstructure:"watchmen-endpoint" json:"watchmen-endpoint"`
|
WatchmenEndpoint string `mapstructure:"watchmen-endpoint" json:"watchmen-endpoint"`
|
||||||
WatchmenPort int `mapstructure:"watchmen-port" json:"watchmen-port"`
|
WatchmenPort int `mapstructure:"watchmen-port" json:"watchmen-port"`
|
||||||
|
TokenDenom string `mapstructure:"token-denom" json:"token-denom"`
|
||||||
|
StakeDenom string `mapstructure:"stake-denom" json:"stake-denom"`
|
||||||
|
FeeDenom string `mapstructure:"fee-denom" json:"fee-denom"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// cosmos-sdk wide global singleton
|
// cosmos-sdk wide global singleton
|
||||||
@ -35,6 +41,9 @@ func DefaultConfig() *Config {
|
|||||||
OSCServicePort: 8766,
|
OSCServicePort: 8766,
|
||||||
WatchmenEndpoint: "lab.r3c.network",
|
WatchmenEndpoint: "lab.r3c.network",
|
||||||
WatchmenPort: 7401,
|
WatchmenPort: 7401,
|
||||||
|
TokenDenom: "plmnt",
|
||||||
|
StakeDenom: "plmntstake",
|
||||||
|
FeeDenom: "plmnt",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package dao
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"planetmint-go/config"
|
||||||
"planetmint-go/testutil/network"
|
"planetmint-go/testutil/network"
|
||||||
"planetmint-go/testutil/sample"
|
"planetmint-go/testutil/sample"
|
||||||
|
|
||||||
@ -37,6 +38,10 @@ func NewE2ETestSuite(cfg network.Config) *E2ETestSuite {
|
|||||||
|
|
||||||
// SetupSuite initializes dao E2ETestSuite
|
// SetupSuite initializes dao E2ETestSuite
|
||||||
func (s *E2ETestSuite) SetupSuite() {
|
func (s *E2ETestSuite) SetupSuite() {
|
||||||
|
conf := config.GetConfig()
|
||||||
|
conf.FeeDenom = "node0token"
|
||||||
|
conf.SetPlanetmintConfig(conf)
|
||||||
|
|
||||||
s.T().Log("setting up e2e test suite")
|
s.T().Log("setting up e2e test suite")
|
||||||
|
|
||||||
// set accounts for alice and bob in genesis state
|
// set accounts for alice and bob in genesis state
|
||||||
@ -60,11 +65,13 @@ func (s *E2ETestSuite) SetupSuite() {
|
|||||||
s.cfg.Codec.MustUnmarshalJSON(s.cfg.GenesisState[banktypes.ModuleName], &bankGenState)
|
s.cfg.Codec.MustUnmarshalJSON(s.cfg.GenesisState[banktypes.ModuleName], &bankGenState)
|
||||||
|
|
||||||
bbalances := sdk.NewCoins(
|
bbalances := sdk.NewCoins(
|
||||||
sdk.NewCoin("rddl", math.NewInt(10000)),
|
sdk.NewCoin(conf.TokenDenom, math.NewInt(10000)),
|
||||||
|
sdk.NewCoin(conf.StakeDenom, math.NewInt(10000)),
|
||||||
)
|
)
|
||||||
|
|
||||||
abalances := sdk.NewCoins(
|
abalances := sdk.NewCoins(
|
||||||
sdk.NewCoin("rddl", math.NewInt(5000)),
|
sdk.NewCoin(conf.TokenDenom, math.NewInt(10000)),
|
||||||
|
sdk.NewCoin(conf.StakeDenom, math.NewInt(5000)),
|
||||||
)
|
)
|
||||||
|
|
||||||
accountBalances := []banktypes.Balance{
|
accountBalances := []banktypes.Balance{
|
||||||
@ -74,7 +81,7 @@ func (s *E2ETestSuite) SetupSuite() {
|
|||||||
bankGenState.Balances = append(bankGenState.Balances, accountBalances...)
|
bankGenState.Balances = append(bankGenState.Balances, accountBalances...)
|
||||||
s.cfg.GenesisState[banktypes.ModuleName] = s.cfg.Codec.MustMarshalJSON(&bankGenState)
|
s.cfg.GenesisState[banktypes.ModuleName] = s.cfg.Codec.MustMarshalJSON(&bankGenState)
|
||||||
|
|
||||||
s.cfg.MinGasPrices = fmt.Sprintf("0.000006%s", "node0token")
|
s.cfg.MinGasPrices = fmt.Sprintf("0.000006%s", conf.FeeDenom)
|
||||||
s.network = network.New(s.T(), s.cfg)
|
s.network = network.New(s.T(), s.cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
disttypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
|
disttypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||||
|
|
||||||
|
"planetmint-go/config"
|
||||||
"planetmint-go/x/dao/types"
|
"planetmint-go/x/dao/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -58,13 +59,14 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger {
|
|||||||
|
|
||||||
func (k Keeper) DistributeCollectedFees(ctx sdk.Context) {
|
func (k Keeper) DistributeCollectedFees(ctx sdk.Context) {
|
||||||
ctx = sdk.UnwrapSDKContext(ctx)
|
ctx = sdk.UnwrapSDKContext(ctx)
|
||||||
|
conf := config.GetConfig()
|
||||||
|
|
||||||
balances := make(map[string]math.Int)
|
balances := make(map[string]math.Int)
|
||||||
totalStake := math.ZeroInt()
|
totalStake := math.ZeroInt()
|
||||||
k.accountKeeper.IterateAccounts(ctx, func(acc authtypes.AccountI) bool {
|
k.accountKeeper.IterateAccounts(ctx, func(acc authtypes.AccountI) bool {
|
||||||
addr := acc.GetAddress()
|
addr := acc.GetAddress()
|
||||||
balance := k.bankKeeper.SpendableCoins(ctx, addr)
|
balance := k.bankKeeper.SpendableCoins(ctx, addr)
|
||||||
found, stake := balance.Find("rddl")
|
found, stake := balance.Find(conf.StakeDenom)
|
||||||
if found {
|
if found {
|
||||||
totalStake = totalStake.Add(stake.Amount)
|
totalStake = totalStake.Add(stake.Amount)
|
||||||
balances[addr.String()] = stake.Amount
|
balances[addr.String()] = stake.Amount
|
||||||
@ -74,8 +76,7 @@ func (k Keeper) DistributeCollectedFees(ctx sdk.Context) {
|
|||||||
|
|
||||||
distAddr := k.accountKeeper.GetModuleAddress(disttypes.ModuleName)
|
distAddr := k.accountKeeper.GetModuleAddress(disttypes.ModuleName)
|
||||||
distSpendableCoins := k.bankKeeper.SpendableCoins(ctx, distAddr)
|
distSpendableCoins := k.bankKeeper.SpendableCoins(ctx, distAddr)
|
||||||
// found, coinToDistribute := distSpendableCoins.Find("stake")
|
found, coinToDistribute := distSpendableCoins.Find(conf.FeeDenom)
|
||||||
found, coinToDistribute := distSpendableCoins.Find("node0token")
|
|
||||||
|
|
||||||
if found {
|
if found {
|
||||||
decTotalAmountToDistribute := sdk.NewDecFromInt(coinToDistribute.Amount)
|
decTotalAmountToDistribute := sdk.NewDecFromInt(coinToDistribute.Amount)
|
||||||
@ -86,7 +87,7 @@ func (k Keeper) DistributeCollectedFees(ctx sdk.Context) {
|
|||||||
claim := decTotalAmountToDistribute.Mul(share)
|
claim := decTotalAmountToDistribute.Mul(share)
|
||||||
if claim.GTE(sdk.OneDec()) {
|
if claim.GTE(sdk.OneDec()) {
|
||||||
intClaim := claim.TruncateInt()
|
intClaim := claim.TruncateInt()
|
||||||
coinClaim := sdk.NewCoin("node0token", intClaim)
|
coinClaim := sdk.NewCoin(conf.FeeDenom, intClaim)
|
||||||
accAddress, err := sdk.AccAddressFromBech32(addr)
|
accAddress, err := sdk.AccAddressFromBech32(addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user