Skip to content

Commit

Permalink
remove mint module and commitment module disable liquid tokens commit…
Browse files Browse the repository at this point in the history
…ment through msg server
  • Loading branch information
jelysn committed Apr 29, 2024
1 parent 2c170e8 commit 60e15a3
Show file tree
Hide file tree
Showing 25 changed files with 156 additions and 952 deletions.
21 changes: 1 addition & 20 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/group"
groupkeeper "github.com/cosmos/cosmos-sdk/x/group/keeper"
groupmodule "github.com/cosmos/cosmos-sdk/x/group/module"
"github.com/cosmos/cosmos-sdk/x/mint"
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
"github.com/cosmos/cosmos-sdk/x/params"
paramsclient "github.com/cosmos/cosmos-sdk/x/params/client"
Expand Down Expand Up @@ -260,7 +258,6 @@ var (
bank.AppModuleBasic{},
capability.AppModuleBasic{},
staking.AppModuleBasic{},
mint.AppModuleBasic{},
distr.AppModuleBasic{},
gov.NewAppModuleBasic(getGovProposalHandlers()),
params.AppModuleBasic{},
Expand Down Expand Up @@ -358,7 +355,6 @@ type ElysApp struct {
CapabilityKeeper *capabilitykeeper.Keeper
StakingKeeper *stakingkeeper.Keeper
SlashingKeeper slashingkeeper.Keeper
MintKeeper mintkeeper.Keeper
DistrKeeper distrkeeper.Keeper
GovKeeper govkeeper.Keeper
CrisisKeeper *crisiskeeper.Keeper
Expand Down Expand Up @@ -464,7 +460,7 @@ func NewElysApp(

keys := sdk.NewKVStoreKeys(
authtypes.StoreKey, authz.ModuleName, banktypes.StoreKey, stakingtypes.StoreKey, crisistypes.StoreKey,
minttypes.StoreKey, slashingtypes.StoreKey, govtypes.StoreKey,
slashingtypes.StoreKey, govtypes.StoreKey,
paramstypes.StoreKey, ibcexported.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, evidencetypes.StoreKey,
ibctransfertypes.StoreKey, icahosttypes.StoreKey, capabilitytypes.StoreKey, group.StoreKey,
ibcfeetypes.StoreKey,
Expand Down Expand Up @@ -626,16 +622,6 @@ func NewElysApp(

estakingModule := estakingmodule.NewAppModule(appCodec, app.EstakingKeeper, app.AccountKeeper, app.BankKeeper)

app.MintKeeper = mintkeeper.NewKeeper(
appCodec,
keys[minttypes.StoreKey],
app.StakingKeeper,
app.AccountKeeper,
app.BankKeeper,
authtypes.FeeCollectorName,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

app.SlashingKeeper = slashingkeeper.NewKeeper(
appCodec,
cdc,
Expand Down Expand Up @@ -1117,7 +1103,6 @@ func NewElysApp(
groupmodule.NewAppModule(appCodec, app.GroupKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), // always be last to make sure that it checks for all invariants and not only part of them
gov.NewAppModule(appCodec, &app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil, app.GetSubspace(minttypes.ModuleName)),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName)),
exdistr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.CommitmentKeeper, &app.EstakingKeeper, authtypes.FeeCollectorName, app.GetSubspace(distrtypes.ModuleName)),
exstaking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)),
Expand Down Expand Up @@ -1159,7 +1144,6 @@ func NewElysApp(
capabilitytypes.ModuleName,
// Note: epochs' begin should be "real" start of epochs, we keep epochs beginblock at the beginning
epochsmoduletypes.ModuleName,
minttypes.ModuleName,
distrtypes.ModuleName,
stablestaketypes.ModuleName,
incentivemoduletypes.ModuleName,
Expand Down Expand Up @@ -1215,7 +1199,6 @@ func NewElysApp(
stablestaketypes.ModuleName,
incentivemoduletypes.ModuleName,
slashingtypes.ModuleName,
minttypes.ModuleName,
genutiltypes.ModuleName,
evidencetypes.ModuleName,
authz.ModuleName,
Expand Down Expand Up @@ -1260,7 +1243,6 @@ func NewElysApp(
stakingtypes.ModuleName,
slashingtypes.ModuleName,
govtypes.ModuleName,
minttypes.ModuleName,
crisistypes.ModuleName,
genutiltypes.ModuleName,
ibctransfertypes.ModuleName,
Expand Down Expand Up @@ -1564,7 +1546,6 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(authtypes.ModuleName)
paramsKeeper.Subspace(banktypes.ModuleName)
paramsKeeper.Subspace(stakingtypes.ModuleName)
paramsKeeper.Subspace(minttypes.ModuleName)
paramsKeeper.Subspace(distrtypes.ModuleName)
paramsKeeper.Subspace(slashingtypes.ModuleName)
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable())
Expand Down
2 changes: 0 additions & 2 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85656,8 +85656,6 @@ definitions:
type: object
elys.commitment.MsgCommitClaimedRewardsResponse:
type: object
elys.commitment.MsgCommitLiquidTokensResponse:
type: object
elys.commitment.MsgStakeResponse:
type: object
properties:
Expand Down
12 changes: 0 additions & 12 deletions proto/elys/commitment/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ option go_package = "github.com/elys-network/elys/x/commitment/types";

// Msg defines the Msg service.
service Msg {
// CommitLiquidTokens commit the tokens from user's balance
rpc CommitLiquidTokens (MsgCommitLiquidTokens) returns (MsgCommitLiquidTokensResponse);

// CommitClaimedRewards commit the tokens on claimed store to committed
rpc CommitClaimedRewards (MsgCommitClaimedRewards) returns (MsgCommitClaimedRewardsResponse);

Expand Down Expand Up @@ -65,15 +62,6 @@ message MsgClaimReward {

message MsgClaimRewardResponse {}

message MsgCommitLiquidTokens {
string creator = 1;
string amount = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
string denom = 3;
uint64 lock_until = 4; // timestamp to lock until the time
}

message MsgCommitLiquidTokensResponse {}

message MsgVest {
string creator = 1;
string amount = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
Expand Down
1 change: 0 additions & 1 deletion wasmbindings/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ type ElysMsg struct {
// clock messages

// commitment messages
CommitmentCommitLiquidTokens *commitmenttypes.MsgCommitLiquidTokens `json:"commitment_commit_liquid_tokens,omitempty"`
CommitmentCommitUnclaimedRewards *commitmenttypes.MsgCommitClaimedRewards `json:"commitment_commit_unclaimed_rewards,omitempty"`
CommitmentUncommitTokens *commitmenttypes.MsgUncommitTokens `json:"commitment_uncommit_tokens,omitempty"`
CommitmentClaimVesting *commitmenttypes.MsgClaimVesting `json:"commitment_claim_vesting,omitempty"`
Expand Down
10 changes: 1 addition & 9 deletions x/amm/keeper/apply_exit_pool_state_change.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,14 @@ import (
"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/elys-network/elys/x/amm/types"
commitmentkeeper "github.com/elys-network/elys/x/commitment/keeper"
ctypes "github.com/elys-network/elys/x/commitment/types"
)

func (k Keeper) ApplyExitPoolStateChange(ctx sdk.Context, pool types.Pool, exiter sdk.AccAddress, numShares math.Int, exitCoins sdk.Coins) error {
// Withdraw exit amount of token from commitment module to exiter's wallet.
msgServer := commitmentkeeper.NewMsgServerImpl(*k.commitmentKeeper)

poolShareDenom := types.GetPoolShareDenom(pool.GetPoolId())

// Withdraw committed LP tokens
_, err := msgServer.UncommitTokens(sdk.WrapSDKContext(ctx), &ctypes.MsgUncommitTokens{
Creator: exiter.String(),
Amount: numShares,
Denom: poolShareDenom,
})
err := k.commitmentKeeper.UncommitTokens(ctx, exiter, poolShareDenom, numShares)
if err != nil {
return err
}
Expand Down
19 changes: 3 additions & 16 deletions x/amm/keeper/pool_share.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/elys-network/elys/x/amm/types"
atypes "github.com/elys-network/elys/x/assetprofile/types"
commitmentkeeper "github.com/elys-network/elys/x/commitment/keeper"
ctypes "github.com/elys-network/elys/x/commitment/types"
ptypes "github.com/elys-network/elys/x/parameter/types"
)

Expand All @@ -35,10 +33,10 @@ func (k Keeper) MintPoolShareToAccount(ctx sdk.Context, pool types.Pool, addr sd
// Before commit LP token to commitment module, we should first register the new denom
// to assetProfile module.

entry, found := k.assetProfileKeeper.GetEntry(ctx, poolShareDenom)
_, found := k.assetProfileKeeper.GetEntry(ctx, poolShareDenom)
if !found {
// Set an entity to assetprofile
entry = atypes.Entry{
entry := atypes.Entry{
Authority: pool.Address,
BaseDenom: poolShareDenom,
Decimals: ptypes.BASE_DECIMAL,
Expand All @@ -64,23 +62,12 @@ func (k Keeper) MintPoolShareToAccount(ctx sdk.Context, pool types.Pool, addr sd
}

// Commit LP token minted
msgServer := commitmentkeeper.NewMsgServerImpl(*k.commitmentKeeper)

lockUntil := uint64(ctx.BlockTime().Unix())
if pool.PoolParams.UseOracle {
lockUntil += uint64(time.Hour.Seconds())
}

// Create a commit LP token message
msgLiquidCommitLPToken := &ctypes.MsgCommitLiquidTokens{
Creator: addr.String(),
Denom: poolShareDenom,
Amount: amount,
LockUntil: lockUntil,
}

// Commit LP token
_, err = msgServer.CommitLiquidTokens(sdk.WrapSDKContext(ctx), msgLiquidCommitLPToken)
err = k.commitmentKeeper.CommitLiquidTokens(ctx, addr, poolShareDenom, amount, lockUntil)
if err != nil {
return err
}
Expand Down
1 change: 0 additions & 1 deletion x/commitment/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ func GetTxCmd() *cobra.Command {
}

cmd.AddCommand(CmdCommitClaimedRewards())
cmd.AddCommand(CmdCommitLiquidTokens())
cmd.AddCommand(CmdUncommitTokens())
cmd.AddCommand(CmdVest())
cmd.AddCommand(CmdCancelVest())
Expand Down
47 changes: 0 additions & 47 deletions x/commitment/client/cli/tx_commit_liquid_tokens.go

This file was deleted.

2 changes: 0 additions & 2 deletions x/commitment/client/wasm/messenger.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ func NewMessenger(keeper *keeper.Keeper, stakingKeeper *stakingkeeper.Keeper, as

func (m *Messenger) HandleMsg(ctx sdk.Context, contractAddr sdk.AccAddress, contractIBCPortID string, msg wasmbindingstypes.ElysMsg) ([]sdk.Event, [][]byte, error) {
switch {
case msg.CommitmentCommitLiquidTokens != nil:
return m.msgCommitLiquidTokens(ctx, contractAddr, msg.CommitmentCommitLiquidTokens)
case msg.CommitmentCommitUnclaimedRewards != nil:
return m.msgCommitClaimedRewards(ctx, contractAddr, msg.CommitmentCommitUnclaimedRewards)
case msg.CommitmentUncommitTokens != nil:
Expand Down
45 changes: 0 additions & 45 deletions x/commitment/client/wasm/msg_commit_liquid_tokens.go

This file was deleted.

Loading

0 comments on commit 60e15a3

Please sign in to comment.