diff --git a/RELEASE.md b/RELEASE.md index 0254b4790..3a51b948a 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,9 +1,3 @@ Features: -- Give PermCreatePollProposal when claiming councilor seat -- Remove fees collected query -- Add filter for derivative only basket query -- Support multiple swaps at once -- Add validation for commission range -- Update CLI command for upsert-staking-pool (error logs, and commissio… -- Add filters on multistaking undelegations query +- Configurable bond denom and address prefix diff --git a/app/ante/ante.go b/app/ante/ante.go index 1f9e127ee..a4f63e928 100644 --- a/app/ante/ante.go +++ b/app/ante/ante.go @@ -4,6 +4,8 @@ import ( "crypto/sha256" "encoding/hex" "fmt" + "time" + kiratypes "github.com/KiraCore/sekai/types" custodykeeper "github.com/KiraCore/sekai/x/custody/keeper" custodytypes "github.com/KiraCore/sekai/x/custody/types" @@ -19,7 +21,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/signing" "github.com/cosmos/cosmos-sdk/x/auth/types" bank "github.com/cosmos/cosmos-sdk/x/bank/types" - "time" ) // NewAnteHandler returns an AnteHandler that checks and increments sequence @@ -226,7 +227,7 @@ func (cd CustodyDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, return ctx, sdkerrors.Wrap(custodytypes.ErrNotEnoughReward, "to small reward") } - if msg.Reward[0].Denom != cd.ck.BondDenom(ctx) { + if msg.Reward[0].Denom != cd.ck.DefaultDenom(ctx) { return ctx, sdkerrors.Wrap(custodytypes.ErrNotEnoughReward, "wrong reward denom") } } @@ -317,20 +318,20 @@ func (svd ValidateFeeRangeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu } properties := svd.cgk.GetNetworkProperties(ctx) - bondDenom := svd.sk.BondDenom(ctx) + defaultDenom := svd.sk.DefaultDenom(ctx) feeAmount := sdk.NewDec(0) feeCoins := feeTx.GetFee() tokensBlackWhite := svd.tk.GetTokenBlackWhites(ctx) for _, feeCoin := range feeCoins { rate := svd.tk.GetTokenRate(ctx, feeCoin.Denom) - if !properties.EnableForeignFeePayments && feeCoin.Denom != bondDenom { + if !properties.EnableForeignFeePayments && feeCoin.Denom != defaultDenom { return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, fmt.Sprintf("foreign fee payments is disabled by governance")) } if rate == nil || !rate.FeePayments { return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, fmt.Sprintf("currency you are trying to use was not whitelisted as fee payment")) } - if tokensBlackWhite.IsFrozen(feeCoin.Denom, bondDenom, properties.EnableTokenBlacklist, properties.EnableTokenWhitelist) { + if tokensBlackWhite.IsFrozen(feeCoin.Denom, defaultDenom, properties.EnableTokenBlacklist, properties.EnableTokenWhitelist) { return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, fmt.Sprintf("currency you are trying to use as fee is frozen")) } feeAmount = feeAmount.Add(feeCoin.Amount.ToDec().Mul(rate.FeeRate)) @@ -350,11 +351,11 @@ func (svd ValidateFeeRangeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu } if feeAmount.LT(sdk.NewDec(int64(properties.MinTxFee))) || feeAmount.GT(sdk.NewDec(int64(properties.MaxTxFee))) { - return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, fmt.Sprintf("fee %+v(%d) is out of range [%d, %d]%s", feeTx.GetFee(), feeAmount.RoundInt().Int64(), properties.MinTxFee, properties.MaxTxFee, bondDenom)) + return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, fmt.Sprintf("fee %+v(%d) is out of range [%d, %d]%s", feeTx.GetFee(), feeAmount.RoundInt().Int64(), properties.MinTxFee, properties.MaxTxFee, defaultDenom)) } if feeAmount.LT(sdk.NewDec(int64(executionMaxFee))) { - return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, fmt.Sprintf("fee %+v(%d) is less than max execution fee %d%s", feeTx.GetFee(), feeAmount.RoundInt().Int64(), executionMaxFee, bondDenom)) + return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, fmt.Sprintf("fee %+v(%d) is less than max execution fee %d%s", feeTx.GetFee(), feeAmount.RoundInt().Int64(), executionMaxFee, defaultDenom)) } return next(ctx, tx, simulate) @@ -436,7 +437,7 @@ func (pnmd PoorNetworkManagementDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx if kiratypes.MsgType(msg) == bank.TypeMsgSend { // on poor network, we introduce POOR_NETWORK_MAX_BANK_TX_SEND network property to limit transaction send amount msg := msg.(*bank.MsgSend) - if len(msg.Amount) > 1 || msg.Amount[0].Denom != pnmd.csk.BondDenom(ctx) { + if len(msg.Amount) > 1 || msg.Amount[0].Denom != pnmd.csk.DefaultDenom(ctx) { return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "only bond denom is allowed on poor network") } if msg.Amount[0].Amount.Uint64() > pnmd.cgk.GetNetworkProperties(ctx).PoorNetworkMaxBankSend { @@ -477,14 +478,14 @@ func (pnmd BlackWhiteTokensCheckDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "invalid transaction type") } - bondDenom := pnmd.csk.BondDenom(ctx) + defaultDenom := pnmd.csk.DefaultDenom(ctx) tokensBlackWhite := pnmd.tk.GetTokenBlackWhites(ctx) properties := pnmd.cgk.GetNetworkProperties(ctx) for _, msg := range sigTx.GetMsgs() { if kiratypes.MsgType(msg) == bank.TypeMsgSend { msg := msg.(*bank.MsgSend) for _, amt := range msg.Amount { - if tokensBlackWhite.IsFrozen(amt.Denom, bondDenom, properties.EnableTokenBlacklist, properties.EnableTokenWhitelist) { + if tokensBlackWhite.IsFrozen(amt.Denom, defaultDenom, properties.EnableTokenBlacklist, properties.EnableTokenWhitelist) { return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "token is frozen") } } diff --git a/app/prefix.go b/app/params/params.go similarity index 95% rename from app/prefix.go rename to app/params/params.go index 6119d8cb4..13d3ab068 100644 --- a/app/prefix.go +++ b/app/params/params.go @@ -11,6 +11,10 @@ var ( ConsNodePubKeyPrefix = "kiravalconspub" ) +var ( + DefaultDenom = "ukex" +) + func SetConfig() { config := sdk.GetConfig() config.SetBech32PrefixForAccount(AccountAddressPrefix, AccountPubKeyPrefix) diff --git a/app/test_helpers.go b/app/test_helpers.go index 38ca0be17..d941d0243 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -9,6 +9,7 @@ import ( "testing" "time" + appparams "github.com/KiraCore/sekai/app/params" bam "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -30,9 +31,6 @@ import ( dbm "github.com/tendermint/tm-db" ) -// DefaultBondDenom defines default denom for fee -var DefaultBondDenom = "ukex" - // DefaultConsensusParams defines the default Tendermint consensus params used in // SimApp testing. var DefaultConsensusParams = &abci.ConsensusParams{ @@ -129,7 +127,7 @@ func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs totalSupply := sdk.NewCoins() for _, b := range balances { // add genesis acc tokens and delegated tokens to total supply - totalSupply = totalSupply.Add(b.Coins.Add(sdk.NewCoin(DefaultBondDenom, bondAmt))...) + totalSupply = totalSupply.Add(b.Coins.Add(sdk.NewCoin(appparams.DefaultDenom, bondAmt))...) } // update total supply @@ -231,7 +229,7 @@ func createIncrementalAccounts(accNum int) []sdk.AccAddress { // AddTestAddrsFromPubKeys adds the addresses into the SimApp providing only the public keys. func AddTestAddrsFromPubKeys(app *SekaiApp, ctx sdk.Context, pubKeys []cryptotypes.PubKey, accAmt sdk.Int) { - initCoins := sdk.NewCoins(sdk.NewCoin(app.CustomStakingKeeper.BondDenom(ctx), accAmt)) + initCoins := sdk.NewCoins(sdk.NewCoin(app.CustomStakingKeeper.DefaultDenom(ctx), accAmt)) // fill all the addresses with some coins, set the loose pool tokens simultaneously for _, pubKey := range pubKeys { @@ -254,7 +252,7 @@ func AddTestAddrsIncremental(app *SekaiApp, ctx sdk.Context, accNum int, accAmt func addTestAddrs(app *SekaiApp, ctx sdk.Context, accNum int, accAmt sdk.Int, strategy GenerateAccountStrategy) []sdk.AccAddress { testAddrs := strategy(accNum) - initCoins := sdk.NewCoins(sdk.NewCoin(app.CustomStakingKeeper.BondDenom(ctx), accAmt)) + initCoins := sdk.NewCoins(sdk.NewCoin(app.CustomStakingKeeper.DefaultDenom(ctx), accAmt)) // fill all the addresses with some coins, set the loose pool tokens simultaneously for _, addr := range testAddrs { diff --git a/cmd/sekaid/main.go b/cmd/sekaid/main.go index 21cedeb3e..e08bd5c80 100644 --- a/cmd/sekaid/main.go +++ b/cmd/sekaid/main.go @@ -8,8 +8,10 @@ import ( "path/filepath" "github.com/KiraCore/sekai/app" + appparams "github.com/KiraCore/sekai/app/params" functionmeta "github.com/KiraCore/sekai/function_meta" genutilcli "github.com/KiraCore/sekai/x/genutil/client/cli" + genutiltypes "github.com/KiraCore/sekai/x/genutil/types" govtypes "github.com/KiraCore/sekai/x/gov/types" customstaking "github.com/KiraCore/sekai/x/staking/client/cli" "github.com/cosmos/cosmos-sdk/baseapp" @@ -77,7 +79,32 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) { customAppTemplate, customAppConfig := initAppConfig() - return server.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig) + err = server.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig) + { + serverCtx := server.GetServerContextFromCmd(cmd) + config := serverCtx.Config + + clientCtx := client.GetClientContextFromCmd(cmd) + + config.SetRoot(clientCtx.HomeDir) + + appState, _, err := genutiltypes.GenesisStateFromGenFile(config.GenesisFile()) + if err == nil { + bech32Prefix, defaultDenom := govtypes.GetBech32PrefixAndDefaultDenomFromAppState(appState) + appparams.DefaultDenom = defaultDenom + appparams.AccountAddressPrefix = bech32Prefix + appparams.AccountPubKeyPrefix = bech32Prefix + "pub" + appparams.ValidatorAddressPrefix = bech32Prefix + "valoper" + appparams.ValidatorPubKeyPrefix = bech32Prefix + "valoperpub" + appparams.ConsNodeAddressPrefix = bech32Prefix + "valcons" + appparams.ConsNodePubKeyPrefix = bech32Prefix + "valconspub" + } + + appparams.SetConfig() + cfg := sdk.GetConfig() + cfg.Seal() + } + return err }, } @@ -143,8 +170,6 @@ lru_size = 0` } func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { - cfg := sdk.GetConfig() - cfg.Seal() rootCmd.AddCommand( genutilcli.InitCmd(app.ModuleBasics, app.DefaultNodeHome), @@ -179,7 +204,6 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { } func main() { - app.SetConfig() rootCmd, _ := NewRootCmd() if err := svrcmd.Execute(rootCmd, app.DefaultNodeHome); err != nil { diff --git a/cmd/sekaid/testnet.go b/cmd/sekaid/testnet.go index e4419f92d..c7e6d93cb 100644 --- a/cmd/sekaid/testnet.go +++ b/cmd/sekaid/testnet.go @@ -17,6 +17,7 @@ import ( "github.com/tendermint/tendermint/types" tmtime "github.com/tendermint/tendermint/types/time" + appparams "github.com/KiraCore/sekai/app/params" "github.com/KiraCore/sekai/x/genutil" genutiltypes "github.com/KiraCore/sekai/x/genutil/types" stakingtypes "github.com/KiraCore/sekai/x/staking/types" @@ -43,9 +44,6 @@ var ( flagStartingIPAddress = "starting-ip-address" ) -// DefaultBondDenom defines default denom for fee -var DefaultBondDenom = "ukex" - // get cmd to initialize all files for tendermint testnet and application func testnetCmd(mbm module.BasicManager, genBalIterator banktypes.GenesisBalancesIterator) *cobra.Command { cmd := &cobra.Command{ @@ -86,7 +84,7 @@ Example: cmd.Flags().String(flagNodeDaemonHome, "simd", "Home directory of the node's daemon configuration") cmd.Flags().String(flagStartingIPAddress, "192.168.0.1", "Starting IP address (192.168.0.1 results in persistent peers list ID0@192.168.0.1:46656, ID1@192.168.0.2:46656, ...)") cmd.Flags().String(flags.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created") - cmd.Flags().String(server.FlagMinGasPrices, fmt.Sprintf("0.000006%s", DefaultBondDenom), "Minimum gas prices to accept for transactions; All fees in a tx must meet this minimum (e.g. 0.01photino,0.001stake)") + cmd.Flags().String(server.FlagMinGasPrices, fmt.Sprintf("0.000006%s", appparams.DefaultDenom), "Minimum gas prices to accept for transactions; All fees in a tx must meet this minimum (e.g. 0.01photino,0.001stake)") cmd.Flags().String(flags.FlagKeyringBackend, flags.DefaultKeyringBackend, "Select keyring's backend (os|file|test)") cmd.Flags().String(flags.FlagKeyAlgorithm, string(hd.Secp256k1Type), "Key signing algorithm to generate keys for") @@ -199,7 +197,7 @@ func InitTestnet( accStakingTokens := sdk.TokensFromConsensusPower(500, sdk.DefaultPowerReduction) coins := sdk.Coins{ sdk.NewCoin(fmt.Sprintf("%stoken", nodeDirName), accTokens), - sdk.NewCoin(DefaultBondDenom, accStakingTokens), + sdk.NewCoin(appparams.DefaultDenom, accStakingTokens), } genBalances = append(genBalances, banktypes.Balance{Address: addr.String(), Coins: coins.Sort()}) diff --git a/middleware/middleware_test.go b/middleware/middleware_test.go index b66942030..5b8a12fbd 100644 --- a/middleware/middleware_test.go +++ b/middleware/middleware_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" - "github.com/KiraCore/sekai/app" simapp "github.com/KiraCore/sekai/app" + appparams "github.com/KiraCore/sekai/app/params" "github.com/KiraCore/sekai/middleware" "github.com/KiraCore/sekai/types" kiratypes "github.com/KiraCore/sekai/types" @@ -19,7 +19,7 @@ import ( ) func TestMain(m *testing.M) { - app.SetConfig() + appparams.SetConfig() os.Exit(m.Run()) } diff --git a/proto/kira/gov/genesis.proto b/proto/kira/gov/genesis.proto index 53171464e..c337d7dc3 100644 --- a/proto/kira/gov/genesis.proto +++ b/proto/kira/gov/genesis.proto @@ -14,28 +14,30 @@ import "kira/gov/identity_registrar.proto"; option go_package = "github.com/KiraCore/sekai/x/gov/types"; message GenesisState { + string default_denom = 1; + string bech32_prefix = 2; // starting_proposal_id is the ID of the starting proposal. - uint64 starting_proposal_id = 1; - uint64 next_role_id = 2; - repeated Role roles = 3 [ (gogoproto.nullable) = false ]; + uint64 starting_proposal_id = 3; + uint64 next_role_id = 4; + repeated Role roles = 5 [ (gogoproto.nullable) = false ]; // role_permissions is the roles that are active from genesis. - map role_permissions = 4; + map role_permissions = 6; // NetworkActors are the actors that are saved from genesis. - repeated NetworkActor network_actors = 5; + repeated NetworkActor network_actors = 7; - NetworkProperties network_properties = 6; - repeated ExecutionFee execution_fees = 7 [ (gogoproto.nullable) = false ]; - AllowedMessages poor_network_messages = 8; + NetworkProperties network_properties = 8; + repeated ExecutionFee execution_fees = 9 [ (gogoproto.nullable) = false ]; + AllowedMessages poor_network_messages = 10; - repeated Proposal proposals = 9 [ (gogoproto.nullable) = false ]; - repeated Vote votes = 10 [ (gogoproto.nullable) = false ]; - map data_registry = 11; + repeated Proposal proposals = 11 [ (gogoproto.nullable) = false ]; + repeated Vote votes = 12 [ (gogoproto.nullable) = false ]; + map data_registry = 13; - repeated kira.gov.IdentityRecord identity_records = 12 [ (gogoproto.nullable) = false ]; - uint64 last_identity_record_id = 13; + repeated kira.gov.IdentityRecord identity_records = 14 [ (gogoproto.nullable) = false ]; + uint64 last_identity_record_id = 15; - repeated kira.gov.IdentityRecordsVerify id_records_verify_requests = 14 [ (gogoproto.nullable) = false ]; - uint64 last_id_record_verify_request_id = 15; + repeated kira.gov.IdentityRecordsVerify id_records_verify_requests = 16 [ (gogoproto.nullable) = false ]; + uint64 last_id_record_verify_request_id = 17; - map proposal_durations = 16; + map proposal_durations = 18; } diff --git a/scripts/sekaidtestsetup.sh b/scripts/sekaidtestsetup.sh index 0baee799d..1af683e5c 100755 --- a/scripts/sekaidtestsetup.sh +++ b/scripts/sekaidtestsetup.sh @@ -4,7 +4,7 @@ rm -rf $HOME/.sekaid/ cd $HOME -sekaid init --chain-id=testing testing --home=$HOME/.sekaid +sekaid init --default-denom="ukex" --bech32-prefix="kira" --chain-id=testing testing --home=$HOME/.sekaid sekaid keys add validator --keyring-backend=test --home=$HOME/.sekaid sekaid add-genesis-account $(sekaid keys show validator -a --keyring-backend=test --home=$HOME/.sekaid) 1000000000000000ukex,1000000000ubtc,1000000000ueth,1000000000validatortoken,1000000000stake,10000000frozen,10000000samolean --home=$HOME/.sekaid sekaid gentx-claim validator --keyring-backend=test --moniker="hello" --home=$HOME/.sekaid diff --git a/testutil/network/network.go b/testutil/network/network.go index e5f5e3e1b..08184b0b7 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -15,6 +15,7 @@ import ( "time" "github.com/KiraCore/sekai/app" + appparams "github.com/KiraCore/sekai/app/params" "github.com/KiraCore/sekai/x/genutil" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" @@ -44,9 +45,6 @@ import ( "google.golang.org/grpc" ) -// DefaultBondDenom defines default denom for fee -var DefaultBondDenom = "ukex" - // package-wide network lock to only allow one test network at a time var lock = new(sync.Mutex) @@ -80,7 +78,7 @@ type Config struct { TimeoutCommit time.Duration // the consensus commitment timeout ChainID string // the network chain-id NumValidators int // the total number of validators to create and bond - BondDenom string // the staking bond denomination + DefaultDenom string // the staking bond denomination MinGasPrices string // the minimum gas prices each validator will accept AccountTokens sdk.Int // the amount of unique validator tokens (e.g. 1000node0) StakingTokens sdk.Int // the amount of tokens each validator has available to stake @@ -108,8 +106,8 @@ func DefaultConfig() Config { TimeoutCommit: 2 * time.Second, ChainID: "chain-" + tmrand.NewRand().Str(6), NumValidators: 4, - BondDenom: DefaultBondDenom, - MinGasPrices: fmt.Sprintf("0.000006%s", DefaultBondDenom), + DefaultDenom: appparams.DefaultDenom, + MinGasPrices: fmt.Sprintf("0.000006%s", appparams.DefaultDenom), AccountTokens: sdk.TokensFromConsensusPower(1000, sdk.DefaultPowerReduction), StakingTokens: sdk.TokensFromConsensusPower(500, sdk.DefaultPowerReduction), BondedTokens: sdk.TokensFromConsensusPower(100, sdk.DefaultPowerReduction), @@ -283,7 +281,7 @@ func New(t *testing.T, cfg Config) *Network { balances := sdk.NewCoins( sdk.NewCoin(fmt.Sprintf("%stoken", nodeDirName), cfg.AccountTokens), - sdk.NewCoin(cfg.BondDenom, cfg.StakingTokens), + sdk.NewCoin(cfg.DefaultDenom, cfg.StakingTokens), ) genFiles = append(genFiles, tmCfg.GenesisFile()) diff --git a/types/constants.go b/types/constants.go index 0166da04d..6995e6cdb 100644 --- a/types/constants.go +++ b/types/constants.go @@ -3,6 +3,6 @@ package types const ( // we set page iteration limit for safety PageIterationLimit = 512 - SekaiVersion = "v0.3.18" + SekaiVersion = "v0.3.20" CosmosVersion = "v0.45.10" ) diff --git a/x/basket/keeper/keeper.go b/x/basket/keeper/keeper.go index 03cf5d811..bf3c527db 100644 --- a/x/basket/keeper/keeper.go +++ b/x/basket/keeper/keeper.go @@ -30,11 +30,6 @@ func NewKeeper(storeKey sdk.StoreKey, cdc codec.BinaryCodec, ak types.AccountKee } } -// BondDenom returns the denom that is basically used for fee payment -func (k Keeper) BondDenom(ctx sdk.Context) string { - return "ukex" -} - func (k Keeper) CheckIfAllowedPermission(ctx sdk.Context, addr sdk.AccAddress, permValue govtypes.PermValue) bool { return govkeeper.CheckIfAllowedPermission(ctx, k.gk, addr, govtypes.PermHandleBasketEmergency) } diff --git a/x/collectives/keeper/keeper.go b/x/collectives/keeper/keeper.go index cfff34eb1..585dbe2c7 100644 --- a/x/collectives/keeper/keeper.go +++ b/x/collectives/keeper/keeper.go @@ -32,11 +32,6 @@ func NewKeeper(storeKey sdk.StoreKey, cdc codec.BinaryCodec, bk types.BankKeeper } } -// BondDenom returns the denom that is basically used for fee payment -func (k Keeper) BondDenom(ctx sdk.Context) string { - return "ukex" -} - func (k Keeper) CheckIfAllowedPermission(ctx sdk.Context, addr sdk.AccAddress, permValue govtypes.PermValue) bool { return govkeeper.CheckIfAllowedPermission(ctx, k.gk, addr, govtypes.PermHandleBasketEmergency) } diff --git a/x/custody/keeper/keeper.go b/x/custody/keeper/keeper.go index 4bd90c434..68dfa485d 100644 --- a/x/custody/keeper/keeper.go +++ b/x/custody/keeper/keeper.go @@ -1,6 +1,7 @@ package keeper import ( + appparams "github.com/KiraCore/sekai/app/params" "github.com/KiraCore/sekai/x/custody/types" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -25,9 +26,9 @@ func NewKeeper(storeKey sdk.StoreKey, cdc codec.BinaryCodec, gk types.CustomGovK } } -// BondDenom returns the denom that is basically used for fee payment -func (k Keeper) BondDenom(ctx sdk.Context) string { - return "ukex" +// DefaultDenom returns the denom that is basically used for fee payment +func (k Keeper) DefaultDenom(ctx sdk.Context) string { + return appparams.DefaultDenom } func (k Keeper) Logger(ctx sdk.Context) log.Logger { diff --git a/x/distributor/keeper/abci.go b/x/distributor/keeper/abci.go index c9f7fda4e..35817deb9 100644 --- a/x/distributor/keeper/abci.go +++ b/x/distributor/keeper/abci.go @@ -71,7 +71,7 @@ func (k Keeper) EndBlocker(ctx sdk.Context) { month := int64(86400 * 30) year := month * 12 if yearSnapshot.SnapshotTime == 0 || yearSnapshot.SnapshotTime+year < ctx.BlockTime().Unix() { - supply := k.bk.GetSupply(ctx, k.BondDenom(ctx)) + supply := k.bk.GetSupply(ctx, k.DefaultDenom(ctx)) yearSnapshot = types.YearStartSnapshot{ SnapshotTime: ctx.BlockTime().Unix(), SnapshotAmount: supply.Amount, diff --git a/x/distributor/keeper/annual_inflation.go b/x/distributor/keeper/annual_inflation.go index fdbed9cae..423a8208f 100644 --- a/x/distributor/keeper/annual_inflation.go +++ b/x/distributor/keeper/annual_inflation.go @@ -31,7 +31,7 @@ func (k Keeper) InflationPossible(ctx sdk.Context) bool { return true } yearlyInflation := k.gk.GetNetworkProperties(ctx).MaxAnnualInflation - currSupply := k.bk.GetSupply(ctx, k.BondDenom(ctx)) + currSupply := k.bk.GetSupply(ctx, k.DefaultDenom(ctx)) month := int64(86400 * 30) currTimeGone := ctx.BlockTime().Unix() - snapshot.SnapshotTime diff --git a/x/distributor/keeper/distributor.go b/x/distributor/keeper/distributor.go index 6c80c92bf..f5be20b7b 100644 --- a/x/distributor/keeper/distributor.go +++ b/x/distributor/keeper/distributor.go @@ -30,7 +30,7 @@ func (k Keeper) AllocateTokens( feesTreasury := k.GetFeesTreasury(ctx) // mint inflated tokens - totalSupply := k.bk.GetSupply(ctx, k.BondDenom(ctx)) + totalSupply := k.bk.GetSupply(ctx, k.DefaultDenom(ctx)) properties := k.gk.GetNetworkProperties(ctx) inflationRewards := totalSupply.Amount.ToDec().Mul(properties.InflationRate).Quo(sdk.NewDec(int64(properties.InflationPeriod))).TruncateInt() inflationCoin := sdk.NewCoin(totalSupply.Denom, inflationRewards) diff --git a/x/distributor/keeper/keeper.go b/x/distributor/keeper/keeper.go index cbdbbda75..ffb487b1f 100644 --- a/x/distributor/keeper/keeper.go +++ b/x/distributor/keeper/keeper.go @@ -1,6 +1,7 @@ package keeper import ( + appparams "github.com/KiraCore/sekai/app/params" "github.com/KiraCore/sekai/x/distributor/types" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -32,7 +33,7 @@ func NewKeeper(storeKey sdk.StoreKey, cdc codec.BinaryCodec, ak types.AccountKee } } -// BondDenom returns the denom that is basically used for fee payment -func (k Keeper) BondDenom(ctx sdk.Context) string { - return "ukex" +// DefaultDenom returns the denom that is basically used for fee payment +func (k Keeper) DefaultDenom(ctx sdk.Context) string { + return appparams.DefaultDenom } diff --git a/x/distributor/types/errors.go b/x/distributor/types/errors.go index 16ba37edd..ab1254f4c 100644 --- a/x/distributor/types/errors.go +++ b/x/distributor/types/errors.go @@ -1,12 +1 @@ package types - -import "github.com/cosmos/cosmos-sdk/types/errors" - -// distributor module errors -var ( - ErrdistributorRecordNotFound = errors.Register(ModuleName, 1, "distributor record not found") - ErrdistributorSumOverflowsHardcap = errors.Register(ModuleName, 2, "distributor sum overflows hardcap") - ErrdistributorRecordDoesNotExists = errors.Register(ModuleName, 3, "distributor record does not exist") - ErrdistributorOnlyAllowedOnBondDenomPools = errors.Register(ModuleName, 4, "distributor is only allowed for bond denom pools") - ErrSpendingPoolDoesNotExist = errors.Register(ModuleName, 5, "spending pool does not exist") -) diff --git a/x/evidence/client/cli/cli_test.go b/x/evidence/client/cli/cli_test.go index 037020888..64a2b2373 100644 --- a/x/evidence/client/cli/cli_test.go +++ b/x/evidence/client/cli/cli_test.go @@ -8,6 +8,7 @@ import ( "github.com/KiraCore/sekai/app" simapp "github.com/KiraCore/sekai/app" + appparams "github.com/KiraCore/sekai/app/params" "github.com/KiraCore/sekai/testutil/network" "github.com/KiraCore/sekai/x/evidence/client/cli" "github.com/cosmos/cosmos-sdk/baseapp" @@ -25,7 +26,7 @@ type IntegrationTestSuite struct { } func (s *IntegrationTestSuite) SetupSuite() { - app.SetConfig() + appparams.SetConfig() s.T().Log("setting up integration test suite") cfg := network.DefaultConfig() diff --git a/x/feeprocessing/keeper/keeper.go b/x/feeprocessing/keeper/keeper.go index c40d54795..f1a0e71f5 100644 --- a/x/feeprocessing/keeper/keeper.go +++ b/x/feeprocessing/keeper/keeper.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/json" + appparams "github.com/KiraCore/sekai/app/params" kiratypes "github.com/KiraCore/sekai/types" "github.com/KiraCore/sekai/x/feeprocessing/types" "github.com/cosmos/cosmos-sdk/codec" @@ -32,9 +33,9 @@ func NewKeeper(storeKey sdk.StoreKey, cdc codec.BinaryCodec, bk types.BankKeeper } } -// BondDenom returns the denom that is basically used for fee payment -func (k Keeper) BondDenom(ctx sdk.Context) string { - return "ukex" +// DefaultDenom returns the denom that is basically used for fee payment +func (k Keeper) DefaultDenom(ctx sdk.Context) string { + return appparams.DefaultDenom } // GetSenderCoinsHistory returns fee payment history of an address @@ -155,8 +156,8 @@ func (k Keeper) ProcessExecutionFeeReturn(ctx sdk.Context) { } if amount > 0 { // handle extra fee based on handler result - bondDenom := k.BondDenom(ctx) - fees := sdk.Coins{sdk.NewInt64Coin(bondDenom, amount)} + defaultDenom := k.DefaultDenom(ctx) + fees := sdk.Coins{sdk.NewInt64Coin(defaultDenom, amount)} if fees.IsAllPositive() { err := k.SendCoinsFromModuleToAccount(ctx, authtypes.FeeCollectorName, exec.FeePayer, fees) if err != nil { diff --git a/x/genutil/client/cli/init.go b/x/genutil/client/cli/init.go index 611805c65..aa4832514 100644 --- a/x/genutil/client/cli/init.go +++ b/x/genutil/client/cli/init.go @@ -7,6 +7,14 @@ import ( "os" "path/filepath" + "github.com/KiraCore/sekai/x/genutil" + govtypes "github.com/KiraCore/sekai/x/gov/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/input" + "github.com/cosmos/cosmos-sdk/server" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/go-bip39" "github.com/pkg/errors" "github.com/spf13/cobra" @@ -15,14 +23,6 @@ import ( tmos "github.com/tendermint/tendermint/libs/os" tmrand "github.com/tendermint/tendermint/libs/rand" "github.com/tendermint/tendermint/types" - - "github.com/KiraCore/sekai/x/genutil" - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/client/input" - "github.com/cosmos/cosmos-sdk/server" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" ) const ( @@ -31,6 +31,9 @@ const ( // FlagSeed defines a flag to initialize the private validator key from a specific seed. FlagRecover = "recover" + + FlagDefaultDenom = "default-denom" + FlagBech32Prefix = "bech32-prefix" ) type printInfo struct { @@ -109,10 +112,23 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command { genFile := config.GenesisFile() overwrite, _ := cmd.Flags().GetBool(FlagOverwrite) + defaultDenom, _ := cmd.Flags().GetString(FlagDefaultDenom) + bech32Prefix, _ := cmd.Flags().GetString(FlagBech32Prefix) + if !overwrite && tmos.FileExists(genFile) { return fmt.Errorf("genesis.json file already exists: %v", genFile) } - appState, err := json.MarshalIndent(mbm.DefaultGenesis(cdc), "", " ") + + genesis := mbm.DefaultGenesis(cdc) + govGenState := govtypes.GetGenesisStateFromAppState(clientCtx.Codec, genesis) + govGenState.Bech32Prefix = bech32Prefix + govGenState.DefaultDenom = defaultDenom + genesis[govtypes.ModuleName], err = cdc.MarshalJSON(&govGenState) + if err != nil { + return err + } + + appState, err := json.MarshalIndent(genesis, "", " ") if err != nil { return errors.Wrap(err, "Failed to marshall default genesis state") } @@ -145,6 +161,8 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command { cmd.Flags().String(cli.HomeFlag, defaultNodeHome, "node's home directory") cmd.Flags().BoolP(FlagOverwrite, "o", false, "overwrite the genesis.json file") + cmd.Flags().String(FlagDefaultDenom, "ukex", "bond denom - default denom of the chain") + cmd.Flags().String(FlagBech32Prefix, "kira", "bech32 prefix of the chain addresses") cmd.Flags().Bool(FlagRecover, false, "provide seed phrase to recover existing key instead of creating") cmd.Flags().String(flags.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created") diff --git a/x/genutil/gentx.go b/x/genutil/gentx.go index e4a63a776..1ff62a3f6 100644 --- a/x/genutil/gentx.go +++ b/x/genutil/gentx.go @@ -7,11 +7,11 @@ import ( abci "github.com/tendermint/tendermint/abci/types" "github.com/KiraCore/sekai/x/genutil/types" + govtypes "github.com/KiraCore/sekai/x/gov/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" bankexported "github.com/cosmos/cosmos-sdk/x/bank/exported" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) // SetGenTxsInAppGenesisState - sets the genesis transactions in the app genesis state @@ -41,15 +41,10 @@ func ValidateAccountInGenesis( appGenesisState map[string]json.RawMessage, genBalIterator types.GenesisBalancesIterator, addr sdk.Address, coins sdk.Coins, cdc codec.JSONCodec, ) error { - - var stakingData stakingtypes.GenesisState - cdc.MustUnmarshalJSON(appGenesisState[stakingtypes.ModuleName], &stakingData) - bondDenom := stakingData.Params.BondDenom - var err error + _, defaultDenom := govtypes.GetBech32PrefixAndDefaultDenomFromAppState(appGenesisState) accountIsInGenesis := false - genBalIterator.IterateGenesisBalances(cdc, appGenesisState, func(bal bankexported.GenesisBalance) (stop bool) { accAddress := bal.GetAddress() @@ -58,10 +53,10 @@ func ValidateAccountInGenesis( // ensure that account is in genesis if accAddress.Equals(addr) { // ensure account contains enough funds of default bond denom - if coins.AmountOf(bondDenom).GT(accCoins.AmountOf(bondDenom)) { + if coins.AmountOf(defaultDenom).GT(accCoins.AmountOf(defaultDenom)) { err = fmt.Errorf( "account %s has a balance in genesis, but it only has %v%s available to stake, not %v%s", - addr, accCoins.AmountOf(bondDenom), bondDenom, coins.AmountOf(bondDenom), bondDenom, + addr, accCoins.AmountOf(defaultDenom), defaultDenom, coins.AmountOf(defaultDenom), defaultDenom, ) return true diff --git a/x/gov/client/cli/cli_identity_registrar_test.go b/x/gov/client/cli/cli_identity_registrar_test.go index 4baa62df0..5ae0dcaf5 100644 --- a/x/gov/client/cli/cli_identity_registrar_test.go +++ b/x/gov/client/cli/cli_identity_registrar_test.go @@ -30,7 +30,7 @@ func (s IntegrationTestSuite) TestTxRegisterIdentityRecords() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }, ) s.Require().NoError(err) @@ -53,7 +53,7 @@ func (s IntegrationTestSuite) TestTxEditIdentityRecord() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }, ) s.Require().NoError(err) @@ -78,7 +78,7 @@ func (s IntegrationTestSuite) TestTxRequestIdentityRecordsVerify() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }, ) s.Require().NoError(err) @@ -102,7 +102,7 @@ func (s IntegrationTestSuite) TestTxHandleIdentityRecordsVerifyRequest() { fmt.Sprintf("--%s=true", cli.FlagApprove), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }, ) s.Require().NoError(err) @@ -125,7 +125,7 @@ func (s IntegrationTestSuite) TestTxCancelIdentityRecordsVerifyRequest() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }, ) s.Require().NoError(err) diff --git a/x/gov/client/cli/cli_permission_test.go b/x/gov/client/cli/cli_permission_test.go index 9f2bff38d..4072ff546 100644 --- a/x/gov/client/cli/cli_permission_test.go +++ b/x/gov/client/cli/cli_permission_test.go @@ -32,7 +32,7 @@ func (s IntegrationTestSuite) TestGetTxSetWhitelistPermissions() { fmt.Sprintf("--%s=%s", cli.FlagPermission, "1"), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }, ) s.Require().NoError(err) @@ -78,7 +78,7 @@ func (s IntegrationTestSuite) TestGetTxSetBlacklistPermissions() { fmt.Sprintf("--%s=%s", cli.FlagPermission, "1"), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }, ) s.Require().NoError(err) @@ -112,7 +112,7 @@ func (s IntegrationTestSuite) TestGetTxSetWhitelistPermissions_WithUserThatDoesN // We create some random address where we will give perms. newAccount, _, err := val.ClientCtx.Keyring.NewMnemonic("test", keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1) s.Require().NoError(err) - s.SendValue(val.ClientCtx, val.Address, newAccount.GetAddress(), sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))) + s.SendValue(val.ClientCtx, val.Address, newAccount.GetAddress(), sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))) // Now we try to set permissions with a user that does not have. cmd := cli.GetTxSetWhitelistPermissions() @@ -123,7 +123,7 @@ func (s IntegrationTestSuite) TestGetTxSetWhitelistPermissions_WithUserThatDoesN fmt.Sprintf("--%s=%s", cli.FlagPermission, "1"), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }) s.Require().NoError(err) strings.Contains(out.String(), "SetPermissions: not enough permissions") diff --git a/x/gov/client/cli/cli_proposal_test.go b/x/gov/client/cli/cli_proposal_test.go index e88425f9d..3b4fc8c74 100644 --- a/x/gov/client/cli/cli_proposal_test.go +++ b/x/gov/client/cli/cli_proposal_test.go @@ -29,7 +29,7 @@ func (s IntegrationTestSuite) TestCreateProposalAssignPermission() { fmt.Sprintf("--%s=%s", cli.FlagDescription, "some desc"), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }) s.Require().NoError(err) @@ -40,7 +40,7 @@ func (s IntegrationTestSuite) TestCreateProposalAssignPermission() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }) s.Require().NoError(err) } @@ -62,7 +62,7 @@ func (s IntegrationTestSuite) TestCreateProposalUpsertDataRegistry() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }) s.Require().NoError(err) fmt.Printf("%s", out.String()) @@ -75,7 +75,7 @@ func (s IntegrationTestSuite) TestCreateProposalUpsertDataRegistry() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }) s.Require().NoError(err) fmt.Printf("%s", out.String()) @@ -95,7 +95,7 @@ func (s IntegrationTestSuite) TestCreateProposalSetNetworkProperty() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }) s.Require().NoError(err) fmt.Printf("%s", out.String()) @@ -108,7 +108,7 @@ func (s IntegrationTestSuite) TestCreateProposalSetNetworkProperty() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }) s.Require().NoError(err) fmt.Printf("%s", out.String()) @@ -129,7 +129,7 @@ func (s IntegrationTestSuite) TestCreateProposalCreateRole() { fmt.Sprintf("--%s=%s", cli.FlagWhitelistPerms, "1,2,3"), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }) s.Require().NoError(err) fmt.Printf("%s", out.String()) @@ -142,7 +142,7 @@ func (s IntegrationTestSuite) TestCreateProposalCreateRole() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }) s.Require().NoError(err) fmt.Printf("%s", out.String()) diff --git a/x/gov/client/cli/cli_role_test.go b/x/gov/client/cli/cli_role_test.go index ee0f1c5e6..bd891161f 100644 --- a/x/gov/client/cli/cli_role_test.go +++ b/x/gov/client/cli/cli_role_test.go @@ -35,7 +35,7 @@ func (s IntegrationTestSuite) TestWhitelistRolePermission() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }) s.Require().NoError(err) @@ -75,7 +75,7 @@ func (s IntegrationTestSuite) TestBlacklistRolePermission() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }) s.Require().NoError(err) @@ -118,7 +118,7 @@ func (s IntegrationTestSuite) TestRemoveWhitelistRolePermission() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }) s.Require().NoError(err) @@ -156,7 +156,7 @@ func (s IntegrationTestSuite) TestRemoveBlacklistRolePermission() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }) s.Require().NoError(err) @@ -184,7 +184,7 @@ func (s IntegrationTestSuite) TestCreateRole() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }) s.Require().NoError(err) @@ -213,7 +213,7 @@ func (s IntegrationTestSuite) TestAssignRoles_AndUnassignRoles() { fmt.Sprintf("--%s=%s", stakingcli.FlagAddr, addr), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }) s.Require().NoError(err) @@ -230,7 +230,7 @@ func (s IntegrationTestSuite) TestAssignRoles_AndUnassignRoles() { fmt.Sprintf("--%s=%s", stakingcli.FlagAddr, addr), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }) s.Require().NoError(err) diff --git a/x/gov/client/cli/cli_test.go b/x/gov/client/cli/cli_test.go index 4ca487135..7faad474a 100644 --- a/x/gov/client/cli/cli_test.go +++ b/x/gov/client/cli/cli_test.go @@ -5,6 +5,7 @@ import ( "github.com/KiraCore/sekai/app" simapp "github.com/KiraCore/sekai/app" + appparams "github.com/KiraCore/sekai/app/params" "github.com/KiraCore/sekai/testutil/network" "github.com/KiraCore/sekai/x/gov/types" "github.com/cosmos/cosmos-sdk/baseapp" @@ -22,7 +23,7 @@ type IntegrationTestSuite struct { } func (s *IntegrationTestSuite) SetupSuite() { - app.SetConfig() + appparams.SetConfig() s.T().Log("setting up integration test suite") cfg := network.DefaultConfig() @@ -150,7 +151,7 @@ func (s *IntegrationTestSuite) SetupSuite() { // s.network.WaitForNextBlock() // // try sending after modification of poor network bank send param -// s.SendValue(val.ClientCtx, val.Address, val.Address, sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100000000))) +// s.SendValue(val.ClientCtx, val.Address, val.Address, sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100000000))) // } // func (s IntegrationTestSuite) TestPoorNetworkRestrictions_HappyPath() { @@ -170,7 +171,7 @@ func (s *IntegrationTestSuite) SetupSuite() { // s.Require().Contains(result.RawLog, "invalid transaction type on poor network") // // try sending more than allowed amount via bank send -// s.SendValue(val.ClientCtx, val.Address, val.Address, sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100000000))) +// s.SendValue(val.ClientCtx, val.Address, val.Address, sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100000000))) // } func TestIntegrationTestSuite(t *testing.T) { diff --git a/x/gov/client/cli/util_test.go b/x/gov/client/cli/util_test.go index a06d6be62..6cde7c009 100644 --- a/x/gov/client/cli/util_test.go +++ b/x/gov/client/cli/util_test.go @@ -45,7 +45,7 @@ func (s IntegrationTestSuite) SetCouncilor(address sdk.Address) { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), fmt.Sprintf("--%s=%s", cli.FlagAddr, address.String()), fmt.Sprintf("--%s=%s", cli.FlagMoniker, val.Moniker), }) @@ -64,7 +64,7 @@ func (s IntegrationTestSuite) SendValue(cCtx client.Context, from sdk.AccAddress coin.String(), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }) s.Require().NoError(err) @@ -82,7 +82,7 @@ func (s IntegrationTestSuite) WhitelistPermission(address sdk.AccAddress, perm s fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }) s.Require().NoError(err) fmt.Println("IntegrationTestSuite::WhitelistPermission", out.String()) @@ -98,7 +98,7 @@ func (s IntegrationTestSuite) VoteWithValidator0(proposalID uint64, voteOption t fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }) s.Require().NoError(err) var result sdk.TxResponse @@ -143,7 +143,7 @@ func (s IntegrationTestSuite) SetPoorNetworkMessages(messages string) sdk.TxResp fmt.Sprintf("--%s=%s", cli.FlagTitle, "title"), fmt.Sprintf("--%s=%s", cli.FlagDescription, "some desc"), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }) s.Require().NoError(err) @@ -167,7 +167,7 @@ func (s IntegrationTestSuite) SetNetworkProperties(minTxFee, maxTxFee, minValida fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }) s.Require().NoError(err) @@ -192,7 +192,7 @@ func (s IntegrationTestSuite) SetNetworkPropertyProposal(property string, value fmt.Sprintf("--%s=%s", cli.FlagDescription, "some desc"), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }) s.Require().NoError(err) @@ -216,7 +216,7 @@ func (s IntegrationTestSuite) UpsertRate(denom string, rate string, flagFeePayme fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }) s.Require().NoError(err) diff --git a/x/gov/genesis.go b/x/gov/genesis.go index 4c662867c..cb3bb157e 100644 --- a/x/gov/genesis.go +++ b/x/gov/genesis.go @@ -3,6 +3,7 @@ package gov import ( "bytes" + appparams "github.com/KiraCore/sekai/app/params" "github.com/KiraCore/sekai/x/gov/keeper" "github.com/KiraCore/sekai/x/gov/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -117,6 +118,8 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) (data *types.GenesisState) proposals, _ := k.GetProposals(ctx) return &types.GenesisState{ + DefaultDenom: appparams.DefaultDenom, + Bech32Prefix: appparams.AccountAddressPrefix, StartingProposalId: k.GetNextProposalID(ctx), NextRoleId: k.GetNextRoleId(ctx), Roles: k.GetAllRoles(ctx), diff --git a/x/gov/genesis_test.go b/x/gov/genesis_test.go index c891b4cbe..ade0a3bc8 100644 --- a/x/gov/genesis_test.go +++ b/x/gov/genesis_test.go @@ -28,7 +28,9 @@ func TestSimappExportGenesis(t *testing.T) { bz, err := app.AppCodec().MarshalJSON(genesis) require.NoError(t, err) buffer := new(bytes.Buffer) - err = json.Compact(buffer, []byte(`{ + err = json.Compact(buffer, []byte(`{ + "default_denom": "ukex", + "bech32_prefix": "kira", "starting_proposal_id": "1", "next_role_id": "3", "roles": [ @@ -312,7 +314,9 @@ func TestExportInitGenesis(t *testing.T) { k := keeper.NewKeeper(keyGovernance, simapp.MakeEncodingConfig().Marshaler, nil) genState := types.GenesisState{ - NextRoleId: 3, + DefaultDenom: "ukex", + Bech32Prefix: "kira", + NextRoleId: 3, Roles: []types.Role{ { Id: uint32(types.RoleSudo), @@ -411,7 +415,9 @@ func TestExportInitGenesis(t *testing.T) { bz, err := simapp.MakeEncodingConfig().Marshaler.MarshalJSON(genesis) require.NoError(t, err) buffer := new(bytes.Buffer) - err = json.Compact(buffer, []byte(` { + err = json.Compact(buffer, []byte(` { + "default_denom": "ukex", + "bech32_prefix": "kira", "starting_proposal_id": "1", "next_role_id": "3", "roles": [ diff --git a/x/gov/handler_test.go b/x/gov/handler_test.go index 5de9be1ff..a7c452d62 100644 --- a/x/gov/handler_test.go +++ b/x/gov/handler_test.go @@ -6,8 +6,8 @@ import ( "testing" "time" - "github.com/KiraCore/sekai/app" simapp "github.com/KiraCore/sekai/app" + appparams "github.com/KiraCore/sekai/app/params" kiratypes "github.com/KiraCore/sekai/types" "github.com/KiraCore/sekai/x/gov" "github.com/KiraCore/sekai/x/gov/types" @@ -20,7 +20,7 @@ import ( ) func TestMain(m *testing.M) { - app.SetConfig() + appparams.SetConfig() os.Exit(m.Run()) } diff --git a/x/gov/keeper/keeper.go b/x/gov/keeper/keeper.go index 31893b5b5..91979a554 100644 --- a/x/gov/keeper/keeper.go +++ b/x/gov/keeper/keeper.go @@ -25,11 +25,6 @@ func NewKeeper(storeKey sdk.StoreKey, cdc codec.BinaryCodec, bk types.BankKeeper } } -// BondDenom returns the denom that is basically used for fee payment -func (k Keeper) BondDenom(ctx sdk.Context) string { - return "ukex" -} - func (k *Keeper) SetProposalRouter(proposalRouter types.ProposalRouter) { k.proposalRouter = proposalRouter } diff --git a/x/gov/keeper/util_test.go b/x/gov/keeper/util_test.go index 8656bbd0d..776ef078e 100644 --- a/x/gov/keeper/util_test.go +++ b/x/gov/keeper/util_test.go @@ -8,14 +8,14 @@ import ( "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/KiraCore/sekai/app" simapp "github.com/KiraCore/sekai/app" + appparams "github.com/KiraCore/sekai/app/params" "github.com/KiraCore/sekai/x/gov/keeper" "github.com/KiraCore/sekai/x/gov/types" ) func TestMain(m *testing.M) { - app.SetConfig() + appparams.SetConfig() os.Exit(m.Run()) } diff --git a/x/gov/types/genesis.go b/x/gov/types/genesis.go index 6e3f1a3d8..8d2a0fe68 100644 --- a/x/gov/types/genesis.go +++ b/x/gov/types/genesis.go @@ -1,14 +1,20 @@ package types import ( + "encoding/json" + + appparams "github.com/KiraCore/sekai/app/params" kiratypes "github.com/KiraCore/sekai/types" + "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" ) // DefaultGenesis returns the default CustomGo genesis state func DefaultGenesis() *GenesisState { return &GenesisState{ - NextRoleId: 3, + DefaultDenom: appparams.DefaultDenom, + Bech32Prefix: appparams.AccountAddressPrefix, + NextRoleId: 3, Roles: []Role{ { Id: uint32(RoleSudo), @@ -254,3 +260,24 @@ func DefaultGenesis() *GenesisState { LastIdRecordVerifyRequestId: 0, } } + +// GetGenesisStateFromAppState returns x/auth GenesisState given raw application +// genesis state. +func GetGenesisStateFromAppState(cdc codec.Codec, appState map[string]json.RawMessage) GenesisState { + var genesisState GenesisState + + if appState[ModuleName] != nil { + cdc.MustUnmarshalJSON(appState[ModuleName], &genesisState) + } + + return genesisState +} + +func GetBech32PrefixAndDefaultDenomFromAppState(appState map[string]json.RawMessage) (string, string) { + var genesisState map[string]interface{} + err := json.Unmarshal(appState[ModuleName], &genesisState) + if err != nil { + panic(err) + } + return genesisState["bech32_prefix"].(string), genesisState["default_denom"].(string) +} diff --git a/x/gov/types/genesis.pb.go b/x/gov/types/genesis.pb.go index 2a2634c10..592bf15f0 100644 --- a/x/gov/types/genesis.pb.go +++ b/x/gov/types/genesis.pb.go @@ -24,25 +24,27 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type GenesisState struct { + DefaultDenom string `protobuf:"bytes,1,opt,name=default_denom,json=defaultDenom,proto3" json:"default_denom,omitempty"` + Bech32Prefix string `protobuf:"bytes,2,opt,name=bech32_prefix,json=bech32Prefix,proto3" json:"bech32_prefix,omitempty"` // starting_proposal_id is the ID of the starting proposal. - StartingProposalId uint64 `protobuf:"varint,1,opt,name=starting_proposal_id,json=startingProposalId,proto3" json:"starting_proposal_id,omitempty"` - NextRoleId uint64 `protobuf:"varint,2,opt,name=next_role_id,json=nextRoleId,proto3" json:"next_role_id,omitempty"` - Roles []Role `protobuf:"bytes,3,rep,name=roles,proto3" json:"roles"` + StartingProposalId uint64 `protobuf:"varint,3,opt,name=starting_proposal_id,json=startingProposalId,proto3" json:"starting_proposal_id,omitempty"` + NextRoleId uint64 `protobuf:"varint,4,opt,name=next_role_id,json=nextRoleId,proto3" json:"next_role_id,omitempty"` + Roles []Role `protobuf:"bytes,5,rep,name=roles,proto3" json:"roles"` // role_permissions is the roles that are active from genesis. - RolePermissions map[uint64]*Permissions `protobuf:"bytes,4,rep,name=role_permissions,json=rolePermissions,proto3" json:"role_permissions,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + RolePermissions map[uint64]*Permissions `protobuf:"bytes,6,rep,name=role_permissions,json=rolePermissions,proto3" json:"role_permissions,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // NetworkActors are the actors that are saved from genesis. - NetworkActors []*NetworkActor `protobuf:"bytes,5,rep,name=network_actors,json=networkActors,proto3" json:"network_actors,omitempty"` - NetworkProperties *NetworkProperties `protobuf:"bytes,6,opt,name=network_properties,json=networkProperties,proto3" json:"network_properties,omitempty"` - ExecutionFees []ExecutionFee `protobuf:"bytes,7,rep,name=execution_fees,json=executionFees,proto3" json:"execution_fees"` - PoorNetworkMessages *AllowedMessages `protobuf:"bytes,8,opt,name=poor_network_messages,json=poorNetworkMessages,proto3" json:"poor_network_messages,omitempty"` - Proposals []Proposal `protobuf:"bytes,9,rep,name=proposals,proto3" json:"proposals"` - Votes []Vote `protobuf:"bytes,10,rep,name=votes,proto3" json:"votes"` - DataRegistry map[string]*DataRegistryEntry `protobuf:"bytes,11,rep,name=data_registry,json=dataRegistry,proto3" json:"data_registry,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - IdentityRecords []IdentityRecord `protobuf:"bytes,12,rep,name=identity_records,json=identityRecords,proto3" json:"identity_records"` - LastIdentityRecordId uint64 `protobuf:"varint,13,opt,name=last_identity_record_id,json=lastIdentityRecordId,proto3" json:"last_identity_record_id,omitempty"` - IdRecordsVerifyRequests []IdentityRecordsVerify `protobuf:"bytes,14,rep,name=id_records_verify_requests,json=idRecordsVerifyRequests,proto3" json:"id_records_verify_requests"` - LastIdRecordVerifyRequestId uint64 `protobuf:"varint,15,opt,name=last_id_record_verify_request_id,json=lastIdRecordVerifyRequestId,proto3" json:"last_id_record_verify_request_id,omitempty"` - ProposalDurations map[string]uint64 `protobuf:"bytes,16,rep,name=proposal_durations,json=proposalDurations,proto3" json:"proposal_durations,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` + NetworkActors []*NetworkActor `protobuf:"bytes,7,rep,name=network_actors,json=networkActors,proto3" json:"network_actors,omitempty"` + NetworkProperties *NetworkProperties `protobuf:"bytes,8,opt,name=network_properties,json=networkProperties,proto3" json:"network_properties,omitempty"` + ExecutionFees []ExecutionFee `protobuf:"bytes,9,rep,name=execution_fees,json=executionFees,proto3" json:"execution_fees"` + PoorNetworkMessages *AllowedMessages `protobuf:"bytes,10,opt,name=poor_network_messages,json=poorNetworkMessages,proto3" json:"poor_network_messages,omitempty"` + Proposals []Proposal `protobuf:"bytes,11,rep,name=proposals,proto3" json:"proposals"` + Votes []Vote `protobuf:"bytes,12,rep,name=votes,proto3" json:"votes"` + DataRegistry map[string]*DataRegistryEntry `protobuf:"bytes,13,rep,name=data_registry,json=dataRegistry,proto3" json:"data_registry,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + IdentityRecords []IdentityRecord `protobuf:"bytes,14,rep,name=identity_records,json=identityRecords,proto3" json:"identity_records"` + LastIdentityRecordId uint64 `protobuf:"varint,15,opt,name=last_identity_record_id,json=lastIdentityRecordId,proto3" json:"last_identity_record_id,omitempty"` + IdRecordsVerifyRequests []IdentityRecordsVerify `protobuf:"bytes,16,rep,name=id_records_verify_requests,json=idRecordsVerifyRequests,proto3" json:"id_records_verify_requests"` + LastIdRecordVerifyRequestId uint64 `protobuf:"varint,17,opt,name=last_id_record_verify_request_id,json=lastIdRecordVerifyRequestId,proto3" json:"last_id_record_verify_request_id,omitempty"` + ProposalDurations map[string]uint64 `protobuf:"bytes,18,rep,name=proposal_durations,json=proposalDurations,proto3" json:"proposal_durations,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -78,6 +80,20 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo +func (m *GenesisState) GetDefaultDenom() string { + if m != nil { + return m.DefaultDenom + } + return "" +} + +func (m *GenesisState) GetBech32Prefix() string { + if m != nil { + return m.Bech32Prefix + } + return "" +} + func (m *GenesisState) GetStartingProposalId() uint64 { if m != nil { return m.StartingProposalId @@ -200,54 +216,57 @@ func init() { func init() { proto.RegisterFile("kira/gov/genesis.proto", fileDescriptor_042721fb65a4ea2d) } var fileDescriptor_042721fb65a4ea2d = []byte{ - // 748 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x54, 0x5d, 0x4f, 0x13, 0x4d, - 0x18, 0xed, 0x42, 0xe1, 0x85, 0xe9, 0x07, 0x65, 0x28, 0xb0, 0x6f, 0x31, 0xa5, 0x9a, 0x98, 0x34, - 0x12, 0x5b, 0xc5, 0x68, 0x8c, 0x89, 0x31, 0x7c, 0x69, 0xaa, 0xc1, 0x90, 0x35, 0x21, 0xd1, 0x90, - 0x6c, 0x86, 0xee, 0xb0, 0x4e, 0xba, 0xec, 0xac, 0x33, 0xd3, 0x42, 0xff, 0x85, 0xbf, 0xc9, 0x2b, - 0x2e, 0xb9, 0xf4, 0xca, 0x18, 0xf8, 0x23, 0x66, 0x66, 0x67, 0xf6, 0xa3, 0x85, 0xbb, 0xdd, 0xf3, - 0x9c, 0xe7, 0xcc, 0x99, 0x39, 0xcf, 0x0c, 0x58, 0x1b, 0x10, 0x86, 0xba, 0x3e, 0x1d, 0x75, 0x7d, - 0x1c, 0x62, 0x4e, 0x78, 0x27, 0x62, 0x54, 0x50, 0xb8, 0x20, 0xf1, 0x8e, 0x4f, 0x47, 0x8d, 0xba, - 0x4f, 0x7d, 0xaa, 0xc0, 0xae, 0xfc, 0x8a, 0xeb, 0x8d, 0x7a, 0xd2, 0x87, 0xfa, 0x82, 0x32, 0x8d, - 0xae, 0x24, 0x28, 0xa3, 0x01, 0xd6, 0xe0, 0x7a, 0x02, 0x46, 0x8c, 0x46, 0x94, 0xa3, 0x40, 0x17, - 0x1e, 0x24, 0x05, 0x0f, 0x09, 0xe4, 0x32, 0xec, 0x13, 0x2e, 0xd8, 0x78, 0xaa, 0x8a, 0x2f, 0x71, - 0x7f, 0x28, 0x08, 0x0d, 0xdd, 0x33, 0x6c, 0x44, 0x1f, 0x26, 0xd5, 0x10, 0x8b, 0x0b, 0xca, 0x06, - 0xae, 0x14, 0xc7, 0x4c, 0x10, 0xac, 0xb7, 0xd0, 0xd8, 0x4c, 0x2d, 0x06, 0x01, 0xbd, 0xc0, 0x9e, - 0x7b, 0x8e, 0x39, 0x47, 0x7e, 0x42, 0x48, 0x35, 0x88, 0x87, 0x43, 0x41, 0xc4, 0xd8, 0x78, 0x40, - 0x7a, 0x43, 0x8f, 0x7e, 0x01, 0x50, 0xfe, 0x10, 0x1f, 0xcc, 0x17, 0x81, 0x04, 0x86, 0xcf, 0x40, - 0x9d, 0x0b, 0xc4, 0x04, 0x09, 0x7d, 0xd7, 0x6c, 0xc7, 0x25, 0x9e, 0x6d, 0xb5, 0xac, 0x76, 0xd1, - 0x81, 0xa6, 0x76, 0xa4, 0x4b, 0x3d, 0x0f, 0xb6, 0x40, 0x39, 0xc4, 0x97, 0xc2, 0x95, 0x27, 0x22, - 0x99, 0x33, 0x8a, 0x09, 0x24, 0xe6, 0xd0, 0x00, 0xf7, 0x3c, 0xf8, 0x04, 0xcc, 0xc9, 0x22, 0xb7, - 0x67, 0x5b, 0xb3, 0xed, 0xd2, 0x76, 0xb5, 0x63, 0xce, 0xbe, 0x23, 0x09, 0xbb, 0xc5, 0xab, 0x3f, - 0x9b, 0x05, 0x27, 0xa6, 0xc0, 0x63, 0x50, 0x53, 0x42, 0x11, 0x66, 0xe7, 0x84, 0x73, 0x42, 0x43, - 0x6e, 0x17, 0x55, 0xdb, 0x56, 0xda, 0x96, 0x75, 0xac, 0x34, 0x8e, 0x52, 0xf6, 0x41, 0x28, 0xd8, - 0xd8, 0x59, 0x62, 0x79, 0x14, 0xbe, 0x05, 0x55, 0x73, 0x90, 0x2a, 0x50, 0x6e, 0xcf, 0x29, 0xd5, - 0xb5, 0x54, 0xf5, 0x73, 0x5c, 0xdf, 0x91, 0x65, 0xa7, 0x12, 0x66, 0xfe, 0x38, 0xfc, 0x08, 0xe0, - 0x74, 0x0e, 0xf6, 0x7c, 0xcb, 0x6a, 0x97, 0xb6, 0x37, 0xa6, 0x24, 0x8e, 0x12, 0x8a, 0xb3, 0x1c, - 0x4e, 0x42, 0x70, 0x0f, 0x54, 0x73, 0x89, 0x73, 0xfb, 0xbf, 0x49, 0x2b, 0x07, 0xa6, 0xfe, 0x1e, - 0x9b, 0xf3, 0xa9, 0xe0, 0x0c, 0xc6, 0xe1, 0x21, 0x58, 0x8d, 0x28, 0x65, 0xae, 0x71, 0x65, 0xa2, - 0xb7, 0x17, 0x94, 0xa7, 0xff, 0x53, 0xad, 0x9d, 0x78, 0x38, 0x0e, 0x35, 0xc1, 0x59, 0x91, 0x7d, - 0xda, 0xa8, 0x01, 0xe1, 0x2b, 0xb0, 0x68, 0xd2, 0xe6, 0xf6, 0xa2, 0xb2, 0x03, 0x53, 0x09, 0x93, - 0xb6, 0xb6, 0x92, 0x52, 0x65, 0xb4, 0x23, 0x2a, 0x30, 0xb7, 0xc1, 0x64, 0xb4, 0xc7, 0x54, 0x24, - 0xd1, 0x2a, 0x0a, 0x3c, 0x04, 0x95, 0xdc, 0x3d, 0xb0, 0x4b, 0xaa, 0xa7, 0x7d, 0x4f, 0xae, 0xfb, - 0x48, 0x20, 0x47, 0x53, 0xe3, 0x50, 0xcb, 0x5e, 0x06, 0x82, 0x3d, 0x50, 0xcb, 0x8c, 0x75, 0x9f, - 0x32, 0x8f, 0xdb, 0x65, 0xa5, 0x68, 0xa7, 0x8a, 0x3d, 0xcd, 0x70, 0x14, 0x41, 0xfb, 0x59, 0x22, - 0x39, 0x94, 0xc3, 0x97, 0x60, 0x3d, 0x40, 0x5c, 0xb8, 0x13, 0x7a, 0x72, 0x9a, 0x2b, 0x6a, 0x9a, - 0xeb, 0xb2, 0x9c, 0xd7, 0xea, 0x79, 0xf0, 0x14, 0x34, 0x88, 0x67, 0xd6, 0x76, 0x47, 0x98, 0x91, - 0x33, 0xd9, 0xfa, 0x63, 0x88, 0xb9, 0xe0, 0x76, 0x55, 0x79, 0xd9, 0xbc, 0xcf, 0x0b, 0x3f, 0x56, - 0x7c, 0x6d, 0x69, 0x9d, 0x78, 0x39, 0xd8, 0xd1, 0x2a, 0xf0, 0x00, 0xb4, 0xb4, 0x35, 0x63, 0x2a, - 0xbf, 0x8e, 0xf4, 0xb8, 0xa4, 0x3c, 0x6e, 0xc4, 0x1e, 0x63, 0x99, 0x9c, 0x4a, 0xcf, 0x83, 0x27, - 0x00, 0x26, 0xb7, 0xd9, 0x1b, 0x32, 0x24, 0xd4, 0xc5, 0xaa, 0x29, 0x8b, 0x4f, 0xef, 0x09, 0xc0, - 0xa4, 0xbe, 0x6f, 0xf8, 0x71, 0x0a, 0xcb, 0xd1, 0x24, 0xde, 0xf8, 0x0a, 0xea, 0x77, 0xdd, 0x42, - 0x58, 0x03, 0xb3, 0x03, 0x3c, 0xd6, 0x6f, 0x87, 0xfc, 0x84, 0x5b, 0x60, 0x6e, 0x84, 0x82, 0x21, - 0x56, 0xaf, 0x44, 0x69, 0x7b, 0x35, 0x33, 0x63, 0x69, 0xb3, 0x13, 0x73, 0xde, 0xcc, 0xbc, 0xb6, - 0x1a, 0x27, 0x60, 0x79, 0x6a, 0x10, 0xb2, 0xba, 0x8b, 0xb1, 0xee, 0xf3, 0xbc, 0x6e, 0xe6, 0x4a, - 0x4e, 0x8f, 0x51, 0x46, 0x7d, 0x1f, 0xac, 0xdd, 0xbd, 0xcb, 0x3b, 0x96, 0xa8, 0x67, 0x97, 0x28, - 0x66, 0x54, 0x76, 0xdf, 0x5d, 0xdd, 0x34, 0xad, 0xeb, 0x9b, 0xa6, 0xf5, 0xf7, 0xa6, 0x69, 0xfd, - 0xbc, 0x6d, 0x16, 0xae, 0x6f, 0x9b, 0x85, 0xdf, 0xb7, 0xcd, 0xc2, 0xb7, 0xc7, 0x3e, 0x11, 0xdf, - 0x87, 0xa7, 0x9d, 0x3e, 0x3d, 0xef, 0x7e, 0x22, 0x0c, 0xed, 0x51, 0x86, 0xbb, 0x1c, 0x0f, 0x10, - 0xe9, 0x5e, 0xaa, 0x87, 0x59, 0x8c, 0x23, 0xcc, 0x4f, 0xe7, 0xd5, 0x63, 0xfc, 0xe2, 0x5f, 0x00, - 0x00, 0x00, 0xff, 0xff, 0x24, 0xdf, 0x5f, 0xf3, 0xad, 0x06, 0x00, 0x00, + // 795 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x54, 0xdd, 0x6e, 0x23, 0x35, + 0x18, 0xcd, 0x6c, 0xd3, 0x65, 0xe3, 0xfc, 0x34, 0xf1, 0x66, 0xdb, 0x21, 0x8b, 0xd2, 0x00, 0x42, + 0x8a, 0xa8, 0x48, 0x20, 0x15, 0x08, 0x21, 0x21, 0xd4, 0x36, 0x05, 0x05, 0x54, 0x14, 0x0d, 0x52, + 0x25, 0x50, 0xa5, 0x91, 0x93, 0x71, 0xa6, 0x56, 0x26, 0xe3, 0xc1, 0x76, 0xd2, 0xe4, 0x1d, 0xb8, + 0xe0, 0xb1, 0x7a, 0xd9, 0x4b, 0xae, 0x10, 0x6a, 0x5f, 0x04, 0xd9, 0x63, 0xcf, 0x4f, 0xd2, 0xde, + 0xcd, 0x9c, 0xef, 0x7c, 0xc7, 0xc7, 0x3e, 0x9f, 0x0d, 0x0e, 0xe7, 0x84, 0xa1, 0xbe, 0x4f, 0x57, + 0x7d, 0x1f, 0x87, 0x98, 0x13, 0xde, 0x8b, 0x18, 0x15, 0x14, 0xbe, 0x91, 0x78, 0xcf, 0xa7, 0xab, + 0x56, 0xd3, 0xa7, 0x3e, 0x55, 0x60, 0x5f, 0x7e, 0xc5, 0xf5, 0x56, 0x33, 0xe9, 0x43, 0x53, 0x41, + 0x99, 0x46, 0xdf, 0x26, 0x28, 0xa3, 0x01, 0xd6, 0xe0, 0x51, 0x02, 0x46, 0x8c, 0x46, 0x94, 0xa3, + 0x40, 0x17, 0x3e, 0x4a, 0x0a, 0x1e, 0x12, 0xc8, 0x65, 0xd8, 0x27, 0x5c, 0xb0, 0xcd, 0x4e, 0x15, + 0xaf, 0xf1, 0x74, 0x29, 0x08, 0x0d, 0xdd, 0x19, 0x36, 0xa2, 0x1f, 0x27, 0xd5, 0x10, 0x8b, 0x3b, + 0xca, 0xe6, 0xae, 0x14, 0xc7, 0x4c, 0x10, 0xac, 0xb7, 0xd0, 0x3a, 0x4e, 0x2d, 0x06, 0x01, 0xbd, + 0xc3, 0x9e, 0xbb, 0xc0, 0x9c, 0x23, 0x3f, 0x21, 0xa4, 0x1a, 0xc4, 0xc3, 0xa1, 0x20, 0x62, 0x63, + 0x3c, 0x20, 0xbd, 0xa1, 0x4f, 0xfe, 0x2a, 0x83, 0xca, 0x4f, 0xf1, 0xc1, 0xfc, 0x26, 0x90, 0xc0, + 0xf0, 0x53, 0x50, 0xf5, 0xf0, 0x0c, 0x2d, 0x03, 0xe1, 0x7a, 0x38, 0xa4, 0x0b, 0xdb, 0xea, 0x58, + 0xdd, 0x92, 0x53, 0xd1, 0xe0, 0x50, 0x62, 0x92, 0x34, 0xc1, 0xd3, 0xdb, 0xd3, 0x81, 0x1b, 0x31, + 0x3c, 0x23, 0x6b, 0xfb, 0x55, 0x4c, 0x8a, 0xc1, 0xb1, 0xc2, 0xe0, 0x97, 0xa0, 0xc9, 0x05, 0x62, + 0x82, 0x84, 0xbe, 0x6b, 0x0e, 0xc6, 0x25, 0x9e, 0xbd, 0xd7, 0xb1, 0xba, 0x45, 0x07, 0x9a, 0xda, + 0x58, 0x97, 0x46, 0x1e, 0xec, 0x80, 0x4a, 0x88, 0xd7, 0xc2, 0x95, 0x67, 0x2b, 0x99, 0x45, 0xc5, + 0x04, 0x12, 0x73, 0x68, 0x80, 0x47, 0x1e, 0xfc, 0x1c, 0xec, 0xcb, 0x22, 0xb7, 0xf7, 0x3b, 0x7b, + 0xdd, 0xf2, 0xa0, 0xd6, 0x33, 0x29, 0xf6, 0x24, 0xe1, 0xbc, 0x78, 0xff, 0xef, 0x71, 0xc1, 0x89, + 0x29, 0xf0, 0x1a, 0xd4, 0x95, 0x50, 0x84, 0xd9, 0x82, 0x70, 0x4e, 0x68, 0xc8, 0xed, 0xd7, 0xaa, + 0xed, 0x24, 0x6d, 0xcb, 0xee, 0x5d, 0x69, 0x8c, 0x53, 0xf6, 0x65, 0x28, 0xd8, 0xc6, 0x39, 0x60, + 0x79, 0x14, 0x7e, 0x0f, 0x6a, 0x26, 0x12, 0x35, 0x1a, 0xdc, 0xfe, 0x40, 0xa9, 0x1e, 0xa6, 0xaa, + 0xbf, 0xc6, 0xf5, 0x33, 0x59, 0x76, 0xaa, 0x61, 0xe6, 0x8f, 0xc3, 0x9f, 0x01, 0xdc, 0x4d, 0xd4, + 0x7e, 0xd3, 0xb1, 0xba, 0xe5, 0xc1, 0xfb, 0x1d, 0x89, 0x71, 0x42, 0x71, 0x1a, 0xe1, 0x36, 0x04, + 0x2f, 0x40, 0x2d, 0x37, 0x3b, 0xdc, 0x2e, 0x6d, 0x5b, 0xb9, 0x34, 0xf5, 0x1f, 0xb1, 0x39, 0x9f, + 0x2a, 0xce, 0x60, 0x1c, 0x5e, 0x81, 0x77, 0x11, 0xa5, 0xcc, 0x35, 0xae, 0xcc, 0x10, 0xd9, 0x40, + 0x79, 0xfa, 0x30, 0xd5, 0x3a, 0x8b, 0xc7, 0xec, 0x4a, 0x13, 0x9c, 0xb7, 0xb2, 0x4f, 0x1b, 0x35, + 0x20, 0xfc, 0x06, 0x94, 0x4c, 0xda, 0xdc, 0x2e, 0x2b, 0x3b, 0x30, 0x95, 0x30, 0x69, 0x6b, 0x2b, + 0x29, 0x55, 0x46, 0xbb, 0xa2, 0x02, 0x73, 0xbb, 0xb2, 0x1d, 0xed, 0x35, 0x15, 0x49, 0xb4, 0x8a, + 0x02, 0xaf, 0x40, 0x35, 0x77, 0xa3, 0xec, 0xaa, 0xea, 0xe9, 0xbe, 0x90, 0xeb, 0x10, 0x09, 0xe4, + 0x68, 0x6a, 0x1c, 0x6a, 0xc5, 0xcb, 0x40, 0x70, 0x04, 0xea, 0x99, 0x0b, 0x32, 0xa5, 0xcc, 0xe3, + 0x76, 0x4d, 0x29, 0xda, 0xa9, 0xe2, 0x48, 0x33, 0x1c, 0x45, 0xd0, 0x7e, 0x0e, 0x48, 0x0e, 0xe5, + 0xf0, 0x6b, 0x70, 0x14, 0x20, 0x2e, 0xdc, 0x2d, 0x3d, 0x39, 0xcd, 0x07, 0x6a, 0x9a, 0x9b, 0xb2, + 0x9c, 0xd7, 0x1a, 0x79, 0x70, 0x02, 0x5a, 0xc4, 0x33, 0x6b, 0xbb, 0x2b, 0xcc, 0xc8, 0x4c, 0xb6, + 0xfe, 0xb9, 0xc4, 0x5c, 0x70, 0xbb, 0xae, 0xbc, 0x1c, 0xbf, 0xe4, 0x85, 0x5f, 0x2b, 0xbe, 0xb6, + 0x74, 0x44, 0xbc, 0x1c, 0xec, 0x68, 0x15, 0x78, 0x09, 0x3a, 0xda, 0x9a, 0x31, 0x95, 0x5f, 0x47, + 0x7a, 0x6c, 0x28, 0x8f, 0xef, 0x63, 0x8f, 0xb1, 0x4c, 0x4e, 0x65, 0xe4, 0xc1, 0x1b, 0x00, 0x93, + 0xdb, 0xec, 0x2d, 0x19, 0x12, 0xea, 0x62, 0x41, 0x65, 0xf1, 0x8b, 0x17, 0x02, 0x30, 0xa9, 0x0f, + 0x0d, 0x3f, 0x4e, 0xa1, 0x11, 0x6d, 0xe3, 0xad, 0xdf, 0x41, 0xf3, 0xb9, 0x5b, 0x08, 0xeb, 0x60, + 0x6f, 0x8e, 0x37, 0xea, 0x31, 0x2a, 0x3a, 0xf2, 0x13, 0x9e, 0x80, 0xfd, 0x15, 0x0a, 0x96, 0x58, + 0xbd, 0x3d, 0xe5, 0xc1, 0xbb, 0xcc, 0x8c, 0xa5, 0xcd, 0x4e, 0xcc, 0xf9, 0xee, 0xd5, 0xb7, 0x56, + 0xeb, 0x06, 0x34, 0x76, 0x06, 0x21, 0xab, 0x5b, 0x8a, 0x75, 0xbf, 0xca, 0xeb, 0x66, 0xae, 0xe4, + 0xee, 0x18, 0x65, 0xd4, 0x87, 0xe0, 0xf0, 0xf9, 0x5d, 0x3e, 0xb3, 0x44, 0x33, 0xbb, 0x44, 0x31, + 0xa3, 0x72, 0xfe, 0xc3, 0xfd, 0x63, 0xdb, 0x7a, 0x78, 0x6c, 0x5b, 0xff, 0x3d, 0xb6, 0xad, 0xbf, + 0x9f, 0xda, 0x85, 0x87, 0xa7, 0x76, 0xe1, 0x9f, 0xa7, 0x76, 0xe1, 0x8f, 0xcf, 0x7c, 0x22, 0x6e, + 0x97, 0x93, 0xde, 0x94, 0x2e, 0xfa, 0xbf, 0x10, 0x86, 0x2e, 0x28, 0xc3, 0x7d, 0x8e, 0xe7, 0x88, + 0xf4, 0xd7, 0xea, 0x89, 0x17, 0x9b, 0x08, 0xf3, 0xc9, 0x6b, 0xf5, 0xac, 0x9f, 0xfe, 0x1f, 0x00, + 0x00, 0xff, 0xff, 0x3b, 0x5d, 0x08, 0x8d, 0xf7, 0x06, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -286,13 +305,15 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1 i-- - dAtA[i] = 0x82 + dAtA[i] = 0x92 } } if m.LastIdRecordVerifyRequestId != 0 { i = encodeVarintGenesis(dAtA, i, uint64(m.LastIdRecordVerifyRequestId)) i-- - dAtA[i] = 0x78 + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x88 } if len(m.IdRecordsVerifyRequests) > 0 { for iNdEx := len(m.IdRecordsVerifyRequests) - 1; iNdEx >= 0; iNdEx-- { @@ -305,13 +326,15 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x72 + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x82 } } if m.LastIdentityRecordId != 0 { i = encodeVarintGenesis(dAtA, i, uint64(m.LastIdentityRecordId)) i-- - dAtA[i] = 0x68 + dAtA[i] = 0x78 } if len(m.IdentityRecords) > 0 { for iNdEx := len(m.IdentityRecords) - 1; iNdEx >= 0; iNdEx-- { @@ -324,7 +347,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x62 + dAtA[i] = 0x72 } } if len(m.DataRegistry) > 0 { @@ -350,7 +373,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0xa i = encodeVarintGenesis(dAtA, i, uint64(baseI-i)) i-- - dAtA[i] = 0x5a + dAtA[i] = 0x6a } } if len(m.Votes) > 0 { @@ -364,7 +387,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x52 + dAtA[i] = 0x62 } } if len(m.Proposals) > 0 { @@ -378,7 +401,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x4a + dAtA[i] = 0x5a } } if m.PoorNetworkMessages != nil { @@ -391,7 +414,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x42 + dAtA[i] = 0x52 } if len(m.ExecutionFees) > 0 { for iNdEx := len(m.ExecutionFees) - 1; iNdEx >= 0; iNdEx-- { @@ -404,7 +427,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x3a + dAtA[i] = 0x4a } } if m.NetworkProperties != nil { @@ -417,7 +440,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x32 + dAtA[i] = 0x42 } if len(m.NetworkActors) > 0 { for iNdEx := len(m.NetworkActors) - 1; iNdEx >= 0; iNdEx-- { @@ -430,7 +453,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x2a + dAtA[i] = 0x3a } } if len(m.RolePermissions) > 0 { @@ -454,7 +477,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x8 i = encodeVarintGenesis(dAtA, i, uint64(baseI-i)) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x32 } } if len(m.Roles) > 0 { @@ -468,18 +491,32 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a + dAtA[i] = 0x2a } } if m.NextRoleId != 0 { i = encodeVarintGenesis(dAtA, i, uint64(m.NextRoleId)) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x20 } if m.StartingProposalId != 0 { i = encodeVarintGenesis(dAtA, i, uint64(m.StartingProposalId)) i-- - dAtA[i] = 0x8 + dAtA[i] = 0x18 + } + if len(m.Bech32Prefix) > 0 { + i -= len(m.Bech32Prefix) + copy(dAtA[i:], m.Bech32Prefix) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Bech32Prefix))) + i-- + dAtA[i] = 0x12 + } + if len(m.DefaultDenom) > 0 { + i -= len(m.DefaultDenom) + copy(dAtA[i:], m.DefaultDenom) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.DefaultDenom))) + i-- + dAtA[i] = 0xa } return len(dAtA) - i, nil } @@ -501,6 +538,14 @@ func (m *GenesisState) Size() (n int) { } var l int _ = l + l = len(m.DefaultDenom) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = len(m.Bech32Prefix) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } if m.StartingProposalId != 0 { n += 1 + sovGenesis(uint64(m.StartingProposalId)) } @@ -583,11 +628,11 @@ func (m *GenesisState) Size() (n int) { if len(m.IdRecordsVerifyRequests) > 0 { for _, e := range m.IdRecordsVerifyRequests { l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) + n += 2 + l + sovGenesis(uint64(l)) } } if m.LastIdRecordVerifyRequestId != 0 { - n += 1 + sovGenesis(uint64(m.LastIdRecordVerifyRequestId)) + n += 2 + sovGenesis(uint64(m.LastIdRecordVerifyRequestId)) } if len(m.ProposalDurations) > 0 { for k, v := range m.ProposalDurations { @@ -636,6 +681,70 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DefaultDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DefaultDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Bech32Prefix", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Bech32Prefix = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field StartingProposalId", wireType) } @@ -654,7 +763,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { break } } - case 2: + case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field NextRoleId", wireType) } @@ -673,7 +782,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { break } } - case 3: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Roles", wireType) } @@ -707,7 +816,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field RolePermissions", wireType) } @@ -822,7 +931,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } m.RolePermissions[mapkey] = mapvalue iNdEx = postIndex - case 5: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field NetworkActors", wireType) } @@ -856,7 +965,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 6: + case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field NetworkProperties", wireType) } @@ -892,7 +1001,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 7: + case 9: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ExecutionFees", wireType) } @@ -926,7 +1035,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 8: + case 10: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PoorNetworkMessages", wireType) } @@ -962,7 +1071,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 9: + case 11: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Proposals", wireType) } @@ -996,7 +1105,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 10: + case 12: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Votes", wireType) } @@ -1030,7 +1139,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 11: + case 13: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field DataRegistry", wireType) } @@ -1159,7 +1268,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } m.DataRegistry[mapkey] = mapvalue iNdEx = postIndex - case 12: + case 14: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field IdentityRecords", wireType) } @@ -1193,7 +1302,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 13: + case 15: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field LastIdentityRecordId", wireType) } @@ -1212,7 +1321,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { break } } - case 14: + case 16: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field IdRecordsVerifyRequests", wireType) } @@ -1246,7 +1355,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 15: + case 17: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field LastIdRecordVerifyRequestId", wireType) } @@ -1265,7 +1374,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { break } } - case 16: + case 18: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProposalDurations", wireType) } diff --git a/x/gov/types/types_test.go b/x/gov/types/types_test.go index 8980c2bb6..cece5c70c 100644 --- a/x/gov/types/types_test.go +++ b/x/gov/types/types_test.go @@ -4,13 +4,13 @@ import ( "os" "testing" - "github.com/KiraCore/sekai/app" + appparams "github.com/KiraCore/sekai/app/params" "github.com/KiraCore/sekai/x/gov/types" "github.com/stretchr/testify/require" ) func TestMain(m *testing.M) { - app.SetConfig() + appparams.SetConfig() os.Exit(m.Run()) } diff --git a/x/layer2/keeper/keeper.go b/x/layer2/keeper/keeper.go index 40a52549d..b8851cdaa 100644 --- a/x/layer2/keeper/keeper.go +++ b/x/layer2/keeper/keeper.go @@ -1,6 +1,7 @@ package keeper import ( + appparams "github.com/KiraCore/sekai/app/params" govkeeper "github.com/KiraCore/sekai/x/gov/keeper" govtypes "github.com/KiraCore/sekai/x/gov/types" "github.com/KiraCore/sekai/x/layer2/types" @@ -28,9 +29,9 @@ func NewKeeper(storeKey sdk.StoreKey, cdc codec.BinaryCodec, bk types.BankKeeper } } -// BondDenom returns the denom that is basically used for fee payment -func (k Keeper) BondDenom(ctx sdk.Context) string { - return "ukex" +// DefaultDenom returns the denom that is basically used for fee payment +func (k Keeper) DefaultDenom(ctx sdk.Context) string { + return appparams.DefaultDenom } func (k Keeper) CheckIfAllowedPermission(ctx sdk.Context, addr sdk.AccAddress, permValue govtypes.PermValue) bool { diff --git a/x/layer2/keeper/lp_swap_redeem_convert.go b/x/layer2/keeper/lp_swap_redeem_convert.go index f88b896af..bd06b3e7c 100644 --- a/x/layer2/keeper/lp_swap_redeem_convert.go +++ b/x/layer2/keeper/lp_swap_redeem_convert.go @@ -79,7 +79,7 @@ func (k Keeper) RedeemDappPoolTx(ctx sdk.Context, addr sdk.AccAddress, dapp type func (k Keeper) SwapDappPoolTx(ctx sdk.Context, addr sdk.AccAddress, dapp types.Dapp, poolFee sdk.Dec, swapBond sdk.Coin) (sdk.Coin, error) { // totalBond * lpSupply = (totalBond + swapBond) * (lpSupply - swapLpAmount) lpToken := dapp.LpToken() - if swapBond.Denom != k.BondDenom(ctx) { + if swapBond.Denom != k.DefaultDenom(ctx) { return sdk.Coin{}, types.ErrInvalidLpToken } lpSupply := k.bk.GetSupply(ctx, lpToken).Amount diff --git a/x/layer2/keeper/msg_server.go b/x/layer2/keeper/msg_server.go index 0f8c734d6..03657bd4a 100644 --- a/x/layer2/keeper/msg_server.go +++ b/x/layer2/keeper/msg_server.go @@ -32,7 +32,7 @@ func (k msgServer) CreateDappProposal(goCtx context.Context, msg *types.MsgCreat isAllowed := k.keeper.CheckIfAllowedPermission(ctx, addr, govtypes.PermCreateDappProposalWithoutBond) if !isAllowed { minDappBond := properties.MinDappBond - if msg.Bond.Denom != k.keeper.BondDenom(ctx) { + if msg.Bond.Denom != k.keeper.DefaultDenom(ctx) { return nil, types.ErrInvalidDappBondDenom } // check 1% of properties.MinDappBond @@ -76,7 +76,7 @@ func (k msgServer) BondDappProposal(goCtx context.Context, msg *types.MsgBondDap return nil, types.ErrDappDoesNotExist } - if k.keeper.BondDenom(ctx) != msg.Bond.Denom { + if k.keeper.DefaultDenom(ctx) != msg.Bond.Denom { return nil, types.ErrInvalidDappBondDenom } @@ -681,7 +681,7 @@ func (k msgServer) ConvertDappPoolTx(goCtx context.Context, msg *types.MsgConver func (k msgServer) MintCreateFtTx(goCtx context.Context, msg *types.MsgMintCreateFtTx) (*types.MsgMintCreateFtTxResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) properties := k.keeper.gk.GetNetworkProperties(ctx) - fee := sdk.NewInt64Coin(k.keeper.BondDenom(ctx), int64(properties.MintingFtFee)) + fee := sdk.NewInt64Coin(k.keeper.DefaultDenom(ctx), int64(properties.MintingFtFee)) sender := sdk.MustAccAddressFromBech32(msg.Sender) err := k.keeper.bk.SendCoinsFromAccountToModule(ctx, sender, types.ModuleName, sdk.Coins{fee}) if err != nil { @@ -725,7 +725,7 @@ func (k msgServer) MintCreateFtTx(goCtx context.Context, msg *types.MsgMintCreat func (k msgServer) MintCreateNftTx(goCtx context.Context, msg *types.MsgMintCreateNftTx) (*types.MsgMintCreateNftTxResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) properties := k.keeper.gk.GetNetworkProperties(ctx) - fee := sdk.NewInt64Coin(k.keeper.BondDenom(ctx), int64(properties.MintingFtFee)) + fee := sdk.NewInt64Coin(k.keeper.DefaultDenom(ctx), int64(properties.MintingFtFee)) sender := sdk.MustAccAddressFromBech32(msg.Sender) err := k.keeper.bk.SendCoinsFromAccountToModule(ctx, sender, types.ModuleName, sdk.Coins{fee}) if err != nil { @@ -775,7 +775,7 @@ func (k msgServer) MintIssueTx(goCtx context.Context, msg *types.MsgMintIssueTx) if msg.Sender != tokenInfo.Owner { fee := msg.Amount.Mul(tokenInfo.Fee).Quo(Pow10(tokenInfo.Decimals)) - feeCoins := sdk.Coins{sdk.NewCoin(k.keeper.BondDenom(ctx), fee)} + feeCoins := sdk.Coins{sdk.NewCoin(k.keeper.DefaultDenom(ctx), fee)} if fee.IsPositive() { if tokenInfo.Owner == "" { err := k.keeper.bk.SendCoinsFromAccountToModule(ctx, sender, types.ModuleName, feeCoins) diff --git a/x/multistaking/keeper/slash.go b/x/multistaking/keeper/slash.go index 7e151c734..d3274b8b1 100644 --- a/x/multistaking/keeper/slash.go +++ b/x/multistaking/keeper/slash.go @@ -21,9 +21,9 @@ func (k Keeper) SlashStakingPool(ctx sdk.Context, validator string, slash sdk.De totalSlashedTokens := sdk.Coins(pool.TotalStakingTokens).Sub(totalStakingTokens) pool.TotalStakingTokens = totalStakingTokens - bondDenom := k.govKeeper.BondDenom(ctx) - bondDenomAmount := totalSlashedTokens.AmountOf(bondDenom) - burnAmount := sdk.Coins{sdk.NewCoin(bondDenom, bondDenomAmount)} + defaultDenom := k.sk.DefaultDenom(ctx) + defaultDenomAmount := totalSlashedTokens.AmountOf(defaultDenom) + burnAmount := sdk.Coins{sdk.NewCoin(defaultDenom, defaultDenomAmount)} err := k.bankKeeper.BurnCoins(ctx, types.ModuleName, burnAmount) if err != nil { panic(err) diff --git a/x/multistaking/types/expected_keepers.go b/x/multistaking/types/expected_keepers.go index 8de67836f..d666a898d 100644 --- a/x/multistaking/types/expected_keepers.go +++ b/x/multistaking/types/expected_keepers.go @@ -8,6 +8,7 @@ import ( // StakingKeeper expected staking keeper type StakingKeeper interface { + DefaultDenom(sdk.Context) string GetValidator(sdk.Context, sdk.ValAddress) (stakingtypes.Validator, error) } diff --git a/x/recovery/keeper/msg_server.go b/x/recovery/keeper/msg_server.go index 17f927331..64e09d78c 100644 --- a/x/recovery/keeper/msg_server.go +++ b/x/recovery/keeper/msg_server.go @@ -7,6 +7,7 @@ import ( "fmt" "strings" + appparams "github.com/KiraCore/sekai/app/params" custodytypes "github.com/KiraCore/sekai/x/custody/types" govtypes "github.com/KiraCore/sekai/x/gov/types" "github.com/KiraCore/sekai/x/recovery/types" @@ -27,7 +28,7 @@ func NewMsgServerImpl(keeper Keeper) types.MsgServer { var _ types.MsgServer = msgServer{} -var RecoveryFee = sdk.Coins{sdk.NewInt64Coin("ukex", 1000_000_000)} +var RecoveryFee = sdk.Coins{sdk.NewInt64Coin(appparams.DefaultDenom, 1000_000_000)} // allow ANY user to register or modify existing recovery secret & verify if the nonce is correct func (k msgServer) RegisterRecoverySecret(goCtx context.Context, msg *types.MsgRegisterRecoverySecret) (*types.MsgRegisterRecoverySecretResponse, error) { @@ -530,7 +531,7 @@ func (k msgServer) IssueRecoveryTokens(goCtx context.Context, msg *types.MsgIssu // KEX token spend properties := k.gk.GetNetworkProperties(ctx) amount := sdk.NewInt(int64(properties.ValidatorRecoveryBond)).Mul(sdk.NewInt(1000_000)) - coins := sdk.NewCoins(sdk.NewCoin("ukex", amount)) + coins := sdk.NewCoins(sdk.NewCoin(appparams.DefaultDenom, amount)) err = k.bk.SendCoinsFromAccountToModule(ctx, addr, types.ModuleName, coins) if err != nil { return nil, err diff --git a/x/recovery/keeper/msg_server_test.go b/x/recovery/keeper/msg_server_test.go index d171b7156..b2ef0db24 100644 --- a/x/recovery/keeper/msg_server_test.go +++ b/x/recovery/keeper/msg_server_test.go @@ -5,7 +5,7 @@ import ( "encoding/hex" "time" - "github.com/KiraCore/sekai/app" + appparams "github.com/KiraCore/sekai/app/params" collectivestypes "github.com/KiraCore/sekai/x/collectives/types" custodytypes "github.com/KiraCore/sekai/x/custody/types" govtypes "github.com/KiraCore/sekai/x/gov/types" @@ -21,7 +21,7 @@ import ( ) func init() { - app.SetConfig() + appparams.SetConfig() } func (suite *KeeperTestSuite) TestRegisterRecoverySecret() { diff --git a/x/slashing/client/cli/cli_test.go b/x/slashing/client/cli/cli_test.go index 5c86fd947..e18b7d3b1 100644 --- a/x/slashing/client/cli/cli_test.go +++ b/x/slashing/client/cli/cli_test.go @@ -92,7 +92,7 @@ func (s *IntegrationTestSuite) TestNewActivateTxCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), // sync mode as there are no funds yet - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(1000))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(1000))).String()), }, false, &sdk.TxResponse{}, 0, }, @@ -137,7 +137,7 @@ func (s *IntegrationTestSuite) TestTxProposalResetWholeValidatorRankCmd() { fmt.Sprintf("--%s=%s", cli.FlagDescription, "resetvalidators"), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), // sync mode as there are no funds yet - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(1000))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(1000))).String()), }, false, &sdk.TxResponse{}, 0, }, @@ -189,7 +189,7 @@ func (s *IntegrationTestSuite) TestTxProposalSlashValidatorCmd() { fmt.Sprintf("--%s=%s", cli.FlagDescription, "slash validators"), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), // sync mode as there are no funds yet - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(1000))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(1000))).String()), }, false, &sdk.TxResponse{}, 0, }, diff --git a/x/slashing/handler_test.go b/x/slashing/handler_test.go index 6a05a8952..97aa207ba 100644 --- a/x/slashing/handler_test.go +++ b/x/slashing/handler_test.go @@ -5,8 +5,8 @@ import ( "strings" "testing" - "github.com/KiraCore/sekai/app" simapp "github.com/KiraCore/sekai/app" + appparams "github.com/KiraCore/sekai/app/params" "github.com/KiraCore/sekai/x/gov" govtypes "github.com/KiraCore/sekai/x/gov/types" "github.com/KiraCore/sekai/x/slashing" @@ -20,7 +20,7 @@ import ( ) func TestMain(m *testing.M) { - app.SetConfig() + appparams.SetConfig() os.Exit(m.Run()) } diff --git a/x/slashing/keeper/keeper_test.go b/x/slashing/keeper/keeper_test.go index 93a32599f..61db4def9 100644 --- a/x/slashing/keeper/keeper_test.go +++ b/x/slashing/keeper/keeper_test.go @@ -8,8 +8,8 @@ import ( "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/KiraCore/sekai/app" simapp "github.com/KiraCore/sekai/app" + appparams "github.com/KiraCore/sekai/app/params" "github.com/KiraCore/sekai/x/slashing/testslashing" "github.com/KiraCore/sekai/x/staking" "github.com/KiraCore/sekai/x/staking/teststaking" @@ -18,7 +18,7 @@ import ( ) func TestMain(m *testing.M) { - app.SetConfig() + appparams.SetConfig() os.Exit(m.Run()) } diff --git a/x/slashing/keeper/rank_test.go b/x/slashing/keeper/rank_test.go index 900f9ddd3..16a43e172 100644 --- a/x/slashing/keeper/rank_test.go +++ b/x/slashing/keeper/rank_test.go @@ -113,7 +113,7 @@ func TestResetWholeValidatorRank(t *testing.T) { func createValidators(t *testing.T, app *simapp.SekaiApp, ctx sdk.Context, accNum int) (validators []stakingtypes.Validator) { pubkeys := simapp.CreateTestPubKeys(accNum) accAmt := sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction) - initCoins := sdk.NewCoins(sdk.NewCoin(app.CustomStakingKeeper.BondDenom(ctx), accAmt)) + initCoins := sdk.NewCoins(sdk.NewCoin(app.CustomStakingKeeper.DefaultDenom(ctx), accAmt)) for _, pubkey := range pubkeys { addr := sdk.AccAddress(pubkey.Address()) acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr) diff --git a/x/staking/client/cli/cli_test.go b/x/staking/client/cli/cli_test.go index 6974b872a..77dcc9e7b 100644 --- a/x/staking/client/cli/cli_test.go +++ b/x/staking/client/cli/cli_test.go @@ -20,6 +20,7 @@ import ( "github.com/KiraCore/sekai/app" simapp "github.com/KiraCore/sekai/app" + appparams "github.com/KiraCore/sekai/app/params" "github.com/KiraCore/sekai/testutil/network" "github.com/KiraCore/sekai/x/staking/client/cli" customtypes "github.com/KiraCore/sekai/x/staking/types" @@ -34,7 +35,7 @@ type IntegrationTestSuite struct { } func (s *IntegrationTestSuite) SetupSuite() { - app.SetConfig() + appparams.SetConfig() s.T().Log("setting up integration test suite") cfg := network.DefaultConfig() @@ -159,7 +160,7 @@ func (s IntegrationTestSuite) TestCreateProposalUnjailValidator() { fmt.Sprintf("--%s=%s", cli.FlagDescription, "some desc"), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), val.ValAddress.String(), "theReference", }, @@ -177,7 +178,7 @@ func (s IntegrationTestSuite) TestCreateProposalUnjailValidator() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }, ) s.Require().NoError(err) diff --git a/x/staking/handler_test.go b/x/staking/handler_test.go index 1b93ead2c..4095504e0 100644 --- a/x/staking/handler_test.go +++ b/x/staking/handler_test.go @@ -7,8 +7,8 @@ import ( "testing" "time" - "github.com/KiraCore/sekai/app" simapp "github.com/KiraCore/sekai/app" + appparams "github.com/KiraCore/sekai/app/params" "github.com/KiraCore/sekai/x/gov" govtypes "github.com/KiraCore/sekai/x/gov/types" "github.com/KiraCore/sekai/x/staking" @@ -21,7 +21,7 @@ import ( ) func TestMain(m *testing.M) { - app.SetConfig() + appparams.SetConfig() os.Exit(m.Run()) } diff --git a/x/staking/keeper/keeper.go b/x/staking/keeper/keeper.go index 3f117712e..d4d48afd5 100644 --- a/x/staking/keeper/keeper.go +++ b/x/staking/keeper/keeper.go @@ -3,6 +3,7 @@ package keeper import ( "fmt" + appparams "github.com/KiraCore/sekai/app/params" govtypes "github.com/KiraCore/sekai/x/gov/types" "github.com/KiraCore/sekai/x/staking/types" "github.com/cosmos/cosmos-sdk/codec" @@ -22,9 +23,9 @@ func NewKeeper(storeKey sdk.StoreKey, cdc *codec.LegacyAmino, govkeeper types.Go return Keeper{storeKey: storeKey, cdc: cdc, govkeeper: govkeeper} } -// BondDenom returns the denom that is basically used for fee payment -func (k Keeper) BondDenom(ctx sdk.Context) string { - return "ukex" +// DefaultDenom returns the denom that is basically used for fee payment +func (k Keeper) DefaultDenom(ctx sdk.Context) string { + return appparams.DefaultDenom } // Set the validator hooks diff --git a/x/staking/keeper/keeper_test.go b/x/staking/keeper/keeper_test.go index 3da89d51f..0b4956faf 100644 --- a/x/staking/keeper/keeper_test.go +++ b/x/staking/keeper/keeper_test.go @@ -4,8 +4,8 @@ import ( "os" "testing" - "github.com/KiraCore/sekai/app" simapp "github.com/KiraCore/sekai/app" + appparams "github.com/KiraCore/sekai/app/params" govtypes "github.com/KiraCore/sekai/x/gov/types" "github.com/KiraCore/sekai/x/staking/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -14,7 +14,7 @@ import ( ) func TestMain(m *testing.M) { - app.SetConfig() + appparams.SetConfig() os.Exit(m.Run()) } diff --git a/x/staking/types/msg_test.go b/x/staking/types/msg_test.go index 7190ed331..5e24ba1a4 100644 --- a/x/staking/types/msg_test.go +++ b/x/staking/types/msg_test.go @@ -3,7 +3,7 @@ package types_test import ( "testing" - "github.com/KiraCore/sekai/app" + appparams "github.com/KiraCore/sekai/app/params" stakingtypes "github.com/KiraCore/sekai/x/staking/types" "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/types" @@ -11,7 +11,7 @@ import ( ) func TestMsgClaimValidator_ValidateBasic(t *testing.T) { - app.SetConfig() + appparams.SetConfig() valAddr1, err := types.ValAddressFromBech32("kiravaloper15ky9du8a2wlstz6fpx3p4mqpjyrm5cgq38f2fp") require.NoError(t, err) diff --git a/x/tokens/client/cli/cli_test.go b/x/tokens/client/cli/cli_test.go index 76c0d0d0b..fe188b7b0 100644 --- a/x/tokens/client/cli/cli_test.go +++ b/x/tokens/client/cli/cli_test.go @@ -17,6 +17,7 @@ import ( "github.com/KiraCore/sekai/app" simapp "github.com/KiraCore/sekai/app" + appparams "github.com/KiraCore/sekai/app/params" "github.com/KiraCore/sekai/testutil/network" "github.com/KiraCore/sekai/x/tokens/client/cli" tokenstypes "github.com/KiraCore/sekai/x/tokens/types" @@ -32,7 +33,7 @@ type IntegrationTestSuite struct { } func (s *IntegrationTestSuite) SetupSuite() { - app.SetConfig() + appparams.SetConfig() s.T().Log("setting up integration test suite") cfg := network.DefaultConfig() @@ -80,7 +81,7 @@ func (s *IntegrationTestSuite) TestUpsertTokenAliasAndQuery() { fmt.Sprintf("--%s=%s", cli.FlagDenoms, "finney"), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }) s.Require().NoError(err) @@ -116,7 +117,7 @@ func (s *IntegrationTestSuite) TestUpsertTokenRateAndQuery() { fmt.Sprintf("--%s=%s", cli.FlagFeePayments, "true"), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }) s.Require().NoError(err) @@ -168,7 +169,7 @@ func (s IntegrationTestSuite) TestCreateProposalUpsertTokenRates() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }) s.Require().NoError(err) fmt.Printf("%s", out.String()) @@ -181,7 +182,7 @@ func (s IntegrationTestSuite) TestCreateProposalUpsertTokenRates() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }) s.Require().NoError(err) fmt.Printf("%s", out.String()) @@ -204,7 +205,7 @@ func (s IntegrationTestSuite) TestCreateProposalUpsertTokenAlias() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }) s.Require().NoError(err) fmt.Printf("%s", out.String()) @@ -218,7 +219,7 @@ func (s IntegrationTestSuite) TestCreateProposalUpsertTokenAlias() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }) s.Require().NoError(err) fmt.Printf("%s", out.String()) @@ -240,7 +241,7 @@ func (s IntegrationTestSuite) TestTxProposalTokensBlackWhiteChangeCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }) s.Require().NoError(err) @@ -255,7 +256,7 @@ func (s IntegrationTestSuite) TestTxProposalTokensBlackWhiteChangeCmd() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }) s.Require().NoError(err) fmt.Printf("%s", out.String()) diff --git a/x/tokens/client/cli/tx.go b/x/tokens/client/cli/tx.go index 491db913d..dd0787e0b 100644 --- a/x/tokens/client/cli/tx.go +++ b/x/tokens/client/cli/tx.go @@ -4,6 +4,7 @@ import ( "fmt" "strings" + appparams "github.com/KiraCore/sekai/app/params" govtypes "github.com/KiraCore/sekai/x/gov/types" "github.com/KiraCore/sekai/x/tokens/types" "github.com/cosmos/cosmos-sdk/client" @@ -236,7 +237,7 @@ func GetTxProposalUpsertTokenRatesCmd() *cobra.Command { if err != nil { return fmt.Errorf("invalid denom") } - if denom == "ukex" { + if denom == appparams.DefaultDenom { return fmt.Errorf("bond denom rate is read-only") } @@ -355,7 +356,7 @@ func GetTxUpsertTokenRateCmd() *cobra.Command { if err != nil { return fmt.Errorf("invalid denom") } - if denom == "ukex" { + if denom == appparams.DefaultDenom { return fmt.Errorf("bond denom rate is read-only") } diff --git a/x/tokens/client/cli/utils_test.go b/x/tokens/client/cli/utils_test.go index d5127489d..cef3274c7 100644 --- a/x/tokens/client/cli/utils_test.go +++ b/x/tokens/client/cli/utils_test.go @@ -22,7 +22,7 @@ func (s IntegrationTestSuite) WhitelistPermissions(addr sdk.AccAddress, perm gov fmt.Sprintf("--%s=%d", cli.FlagPermission, perm), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.DefaultDenom, sdk.NewInt(100))).String()), }) s.Require().NoError(err) diff --git a/x/tokens/handler_test.go b/x/tokens/handler_test.go index b6e637b4c..a1033129c 100644 --- a/x/tokens/handler_test.go +++ b/x/tokens/handler_test.go @@ -8,8 +8,8 @@ import ( "testing" "time" - "github.com/KiraCore/sekai/app" simapp "github.com/KiraCore/sekai/app" + appparams "github.com/KiraCore/sekai/app/params" "github.com/KiraCore/sekai/x/gov" "github.com/KiraCore/sekai/x/gov/types" govtypes "github.com/KiraCore/sekai/x/gov/types" @@ -23,7 +23,7 @@ import ( ) func TestMain(m *testing.M) { - app.SetConfig() + appparams.SetConfig() os.Exit(m.Run()) } diff --git a/x/tokens/keeper/keeper.go b/x/tokens/keeper/keeper.go index f602acc47..0e54665d4 100644 --- a/x/tokens/keeper/keeper.go +++ b/x/tokens/keeper/keeper.go @@ -1,6 +1,7 @@ package keeper import ( + appparams "github.com/KiraCore/sekai/app/params" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -24,7 +25,7 @@ func NewKeeper(storeKey sdk.StoreKey, cdc codec.BinaryCodec) Keeper { return Keeper{cdc: cdc, storeKey: storeKey} } -// BondDenom returns the denom that is basically used for fee payment -func (k Keeper) BondDenom(ctx sdk.Context) string { - return "ukex" +// DefaultDenom returns the denom that is basically used for fee payment +func (k Keeper) DefaultDenom(ctx sdk.Context) string { + return appparams.DefaultDenom } diff --git a/x/tokens/keeper/rate.go b/x/tokens/keeper/rate.go index 466d9ca71..29f883565 100644 --- a/x/tokens/keeper/rate.go +++ b/x/tokens/keeper/rate.go @@ -66,7 +66,7 @@ func (k Keeper) UpsertTokenRate(ctx sdk.Context, rate types.TokenRate) error { store := ctx.KVStore(k.storeKey) // we use denom of TokenRate as an ID inside KVStore storage tokenRateStoreID := append([]byte(PrefixKeyTokenRate), []byte(rate.Denom)...) - if rate.Denom == k.BondDenom(ctx) && store.Has(tokenRateStoreID) { + if rate.Denom == k.DefaultDenom(ctx) && store.Has(tokenRateStoreID) { return errors.New("bond denom rate is read-only") } diff --git a/x/tokens/types/freeze.go b/x/tokens/types/freeze.go index 0df42e345..05d1d8422 100644 --- a/x/tokens/types/freeze.go +++ b/x/tokens/types/freeze.go @@ -11,8 +11,8 @@ func FindTokenIndex(tokens []string, token string) int { } // IsFrozen returns is frozen -func (t TokensWhiteBlack) IsFrozen(denom string, bondDenom string, enableTokenBlacklist, enableTokenWhitelist bool) bool { - if denom == bondDenom { +func (t TokensWhiteBlack) IsFrozen(denom string, defaultDenom string, enableTokenBlacklist, enableTokenWhitelist bool) bool { + if denom == defaultDenom { return false } if enableTokenBlacklist { diff --git a/x/tokens/types/msg_rate.go b/x/tokens/types/msg_rate.go index cb43103c4..689ab4c10 100644 --- a/x/tokens/types/msg_rate.go +++ b/x/tokens/types/msg_rate.go @@ -3,6 +3,7 @@ package types import ( "errors" + appparams "github.com/KiraCore/sekai/app/params" "github.com/KiraCore/sekai/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -46,7 +47,7 @@ func (m *MsgUpsertTokenRate) Type() string { // ValidateBasic returns basic validation result func (m *MsgUpsertTokenRate) ValidateBasic() error { - if m.Denom == "ukex" { + if m.Denom == appparams.DefaultDenom { return errors.New("bond denom rate is read-only") } diff --git a/x/ubi/keeper/keeper.go b/x/ubi/keeper/keeper.go index 4f9954d32..4b607ac02 100644 --- a/x/ubi/keeper/keeper.go +++ b/x/ubi/keeper/keeper.go @@ -1,6 +1,7 @@ package keeper import ( + appparams "github.com/KiraCore/sekai/app/params" "github.com/KiraCore/sekai/x/ubi/types" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -26,7 +27,7 @@ func NewKeeper(storeKey sdk.StoreKey, cdc codec.BinaryCodec, bk types.BankKeeper } } -// BondDenom returns the denom that is basically used for fee payment -func (k Keeper) BondDenom(ctx sdk.Context) string { - return "ukex" +// DefaultDenom returns the denom that is basically used for fee payment +func (k Keeper) DefaultDenom(ctx sdk.Context) string { + return appparams.DefaultDenom } diff --git a/x/ubi/keeper/ubi.go b/x/ubi/keeper/ubi.go index 5a1d62d4d..e3041aea6 100644 --- a/x/ubi/keeper/ubi.go +++ b/x/ubi/keeper/ubi.go @@ -70,7 +70,7 @@ func (k Keeper) ProcessUBIRecord(ctx sdk.Context, record types.UBIRecord) error amount := sdk.NewInt(int64(record.Amount)).Mul(sdk.NewInt(1000_000)) - bondDenom := k.BondDenom(ctx) + defaultDenom := k.DefaultDenom(ctx) // if dynamic ubi record, mint only missing amount if record.Dynamic { spendingPool := k.sk.GetSpendingPool(ctx, record.Pool) @@ -78,15 +78,15 @@ func (k Keeper) ProcessUBIRecord(ctx sdk.Context, record types.UBIRecord) error return types.ErrSpendingPoolDoesNotExist } - bondDenomBalance := sdk.Coins(spendingPool.Balances).AmountOf(bondDenom) + defaultDenomBalance := sdk.Coins(spendingPool.Balances).AmountOf(defaultDenom) - if amount.LTE(bondDenomBalance) { + if amount.LTE(defaultDenomBalance) { return nil } - amount = amount.Sub(bondDenomBalance) + amount = amount.Sub(defaultDenomBalance) } - coin := sdk.NewCoin(bondDenom, amount) + coin := sdk.NewCoin(defaultDenom, amount) err := k.bk.MintCoins(ctx, minttypes.ModuleName, sdk.NewCoins(coin)) if err != nil { return err