Skip to content

Commit

Permalink
tokens module refactoring and token minting in other modules to use t…
Browse files Browse the repository at this point in the history
…okens module
  • Loading branch information
kiragpg committed May 29, 2024
1 parent 42f2c3f commit 22ab369
Show file tree
Hide file tree
Showing 36 changed files with 439 additions and 327 deletions.
11 changes: 10 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ func NewInitApp(
app.CustomStakingKeeper,
app.CustomGovKeeper,
app.SpendingKeeper,
app.TokensKeeper,
)

app.UpgradeKeeper = upgradekeeper.NewKeeper(keys[upgradetypes.StoreKey], appCodec, app.CustomStakingKeeper)
Expand Down Expand Up @@ -346,6 +347,7 @@ func NewInitApp(
app.CollectivesKeeper,
app.SpendingKeeper,
app.CustodyKeeper,
app.TokensKeeper,
)

app.DistrKeeper = distributorkeeper.NewKeeper(
Expand All @@ -354,7 +356,14 @@ func NewInitApp(
app.CustomStakingKeeper, app.CustomGovKeeper,
app.MultiStakingKeeper, app.RecoveryKeeper)
app.MultiStakingKeeper.SetDistrKeeper(app.DistrKeeper)
app.UbiKeeper = ubikeeper.NewKeeper(keys[ubitypes.ModuleName], appCodec, app.BankKeeper, app.SpendingKeeper, app.DistrKeeper)
app.UbiKeeper = ubikeeper.NewKeeper(
keys[ubitypes.ModuleName],
appCodec,
app.BankKeeper,
app.SpendingKeeper,
app.DistrKeeper,
app.TokensKeeper,
)

proposalRouter := govtypes.NewProposalRouter(
[]govtypes.ProposalHandler{
Expand Down
5 changes: 3 additions & 2 deletions proto/kira/tokens/genesis.proto
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
syntax = "proto3";
package kira.tokens;

import "gogoproto/gogo.proto";
import "kira/tokens/token.proto";
import "kira/tokens/freeze.proto";

option go_package = "github.com/KiraCore/sekai/x/tokens/types";

message GenesisState {
repeated kira.tokens.TokenInfo tokenInfos = 1;
TokensWhiteBlack tokenBlackWhites = 2;
repeated kira.tokens.TokenInfo tokenInfos = 1 [ (gogoproto.nullable) = false ];
TokensWhiteBlack tokenBlackWhites = 2 [ (gogoproto.nullable) = false ];
}
8 changes: 5 additions & 3 deletions proto/kira/tokens/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "kira/tokens/token.proto";
import "kira/tokens/freeze.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "cosmos/base/v1beta1/coin.proto";

option go_package = "github.com/KiraCore/sekai/x/tokens/types";

Expand Down Expand Up @@ -32,23 +33,24 @@ message TokenInfoRequest {

message TokenInfoResponse {
kira.tokens.TokenInfo data = 1;
cosmos.base.v1beta1.Coin supply = 2 [(gogoproto.nullable) = false];
}

message AllTokenInfosRequest {}

message AllTokenInfosResponse {
repeated kira.tokens.TokenInfo data = 1;
repeated TokenInfoResponse data = 1 [ (gogoproto.nullable) = false ];
}

message TokenInfosByDenomRequest {
repeated string denoms = 1;
}

message TokenInfosByDenomResponse {
map<string, kira.tokens.TokenInfo> data = 1;
map<string, TokenInfoResponse> data = 1 [ (gogoproto.nullable) = false ];
}

message TokenBlackWhitesRequest {}
message TokenBlackWhitesResponse {
TokensWhiteBlack data = 1;
TokensWhiteBlack data = 1 [ (gogoproto.nullable) = false ];
}
5 changes: 2 additions & 3 deletions x/basket/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"github.com/KiraCore/sekai/x/basket/types"
govkeeper "github.com/KiraCore/sekai/x/gov/keeper"
govtypes "github.com/KiraCore/sekai/x/gov/types"
tokenskeeper "github.com/KiraCore/sekai/x/tokens/keeper"
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -17,12 +16,12 @@ type Keeper struct {
ak types.AccountKeeper
bk types.BankKeeper
gk govkeeper.Keeper
tk tokenskeeper.Keeper
tk types.TokensKeeper
mk types.MultiStakingKeeper
}

// NewKeeper returns instance of a keeper
func NewKeeper(storeKey storetypes.StoreKey, cdc codec.BinaryCodec, ak types.AccountKeeper, bk types.BankKeeper, gk govkeeper.Keeper, tk tokenskeeper.Keeper, mk types.MultiStakingKeeper) Keeper {
func NewKeeper(storeKey storetypes.StoreKey, cdc codec.BinaryCodec, ak types.AccountKeeper, bk types.BankKeeper, gk govkeeper.Keeper, tk types.TokensKeeper, mk types.MultiStakingKeeper) Keeper {
return Keeper{
cdc: cdc,
storeKey: storeKey,
Expand Down
2 changes: 1 addition & 1 deletion x/basket/keeper/mint_burn_swap.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (k Keeper) MintBasketToken(ctx sdk.Context, msg *types.MsgBasketTokenMint)
}

basketCoins := sdk.Coins{basketCoin}
err = k.bk.MintCoins(ctx, types.ModuleName, basketCoins)
err = k.tk.MintCoins(ctx, types.ModuleName, basketCoins)
if err != nil {
return err
}
Expand Down
8 changes: 8 additions & 0 deletions x/basket/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package types
import (
govtypes "github.com/KiraCore/sekai/x/gov/types"
multistakingtypes "github.com/KiraCore/sekai/x/multistaking/types"
tokenstypes "github.com/KiraCore/sekai/x/tokens/types"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
)
Expand Down Expand Up @@ -35,3 +36,10 @@ type MultistakingHooks interface {
AfterUpsertStakingPool(ctx sdk.Context, valAddr sdk.ValAddress, pool multistakingtypes.StakingPool) // Must be called when a upsert staking pool
AfterSlashStakingPool(ctx sdk.Context, valAddr sdk.ValAddress, pool multistakingtypes.StakingPool, slash sdk.Dec)
}

// TokensKeeper defines expected interface needed from tokens keeper
type TokensKeeper interface {
MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error
GetTokenInfo(ctx sdk.Context, denom string) *tokenstypes.TokenInfo
GetAllTokenInfos(ctx sdk.Context) []tokenstypes.TokenInfo
}
2 changes: 1 addition & 1 deletion x/genutil/client/cli/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command {
}

tokenGenState := tokenstypes.GetGenesisStateFromAppState(clientCtx.Codec, genesis)
tokenGenState.TokenInfos = []*tokenstypes.TokenInfo{
tokenGenState.TokenInfos = []tokenstypes.TokenInfo{
{
Denom: defaultDenom,
FeeRate: sdk.OneDec(),
Expand Down
Loading

0 comments on commit 22ab369

Please sign in to comment.