diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 5e561725b..4404a52be 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -82479,14 +82479,16 @@ definitions: type: string elys.commitment.MsgCancelVestResponse: type: object - elys.commitment.MsgCommitTokensResponse: + elys.commitment.MsgCommitLiquidTokensResponse: type: object - elys.commitment.MsgDepositTokensResponse: + elys.commitment.MsgCommitTokensResponse: type: object elys.commitment.MsgUncommitTokensResponse: type: object elys.commitment.MsgUpdateVestingInfoResponse: type: object + elys.commitment.MsgVestLiquidResponse: + type: object elys.commitment.MsgVestNowResponse: type: object elys.commitment.MsgVestResponse: diff --git a/proto/elys/commitment/tx.proto b/proto/elys/commitment/tx.proto index 59bf4431c..003680457 100644 --- a/proto/elys/commitment/tx.proto +++ b/proto/elys/commitment/tx.proto @@ -8,14 +8,15 @@ option go_package = "github.com/elys-network/elys/x/commitment/types"; // Msg defines the Msg service. service Msg { - rpc CommitTokens (MsgCommitTokens ) returns (MsgCommitTokensResponse ); - rpc UncommitTokens (MsgUncommitTokens ) returns (MsgUncommitTokensResponse ); - rpc WithdrawTokens (MsgWithdrawTokens ) returns (MsgWithdrawTokensResponse ); - rpc DepositTokens (MsgDepositTokens ) returns (MsgDepositTokensResponse ); - rpc Vest (MsgVest ) returns (MsgVestResponse ); - rpc CancelVest (MsgCancelVest ) returns (MsgCancelVestResponse ); - rpc VestNow (MsgVestNow ) returns (MsgVestNowResponse ); - rpc UpdateVestingInfo (MsgUpdateVestingInfo) returns (MsgUpdateVestingInfoResponse); + rpc CommitTokens (MsgCommitTokens ) returns (MsgCommitTokensResponse ); + rpc UncommitTokens (MsgUncommitTokens ) returns (MsgUncommitTokensResponse ); + rpc WithdrawTokens (MsgWithdrawTokens ) returns (MsgWithdrawTokensResponse ); + rpc CommitLiquidTokens (MsgCommitLiquidTokens) returns (MsgCommitLiquidTokensResponse); + rpc Vest (MsgVest ) returns (MsgVestResponse ); + rpc CancelVest (MsgCancelVest ) returns (MsgCancelVestResponse ); + rpc VestNow (MsgVestNow ) returns (MsgVestNowResponse ); + rpc UpdateVestingInfo (MsgUpdateVestingInfo ) returns (MsgUpdateVestingInfoResponse ); + rpc VestLiquid (MsgVestLiquid ) returns (MsgVestLiquidResponse ); } message MsgCommitTokens { string creator = 1; @@ -41,13 +42,13 @@ message MsgWithdrawTokens { message MsgWithdrawTokensResponse {} -message MsgDepositTokens { +message MsgCommitLiquidTokens { string creator = 1; string amount = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; string denom = 3; } -message MsgDepositTokensResponse {} +message MsgCommitLiquidTokensResponse {} message MsgVest { string creator = 1; @@ -74,14 +75,22 @@ message MsgVestNow { message MsgVestNowResponse {} message MsgUpdateVestingInfo { - string authority = 1; + string authority = 1; string baseDenom = 2; string vestingDenom = 3; string epochIdentifier = 4; - int64 numEpochs = 5; - int64 vestNowFactor = 6; - int64 numMaxVestings = 7; + int64 numEpochs = 5; + int64 vestNowFactor = 6; + int64 numMaxVestings = 7; } message MsgUpdateVestingInfoResponse {} +message MsgVestLiquid { + string creator = 1; + string amount = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; + string denom = 3; +} + +message MsgVestLiquidResponse {} + diff --git a/x/amm/keeper/mint_pool_share_to_account.go b/x/amm/keeper/mint_pool_share_to_account.go index c3287cbfd..f8721df1d 100644 --- a/x/amm/keeper/mint_pool_share_to_account.go +++ b/x/amm/keeper/mint_pool_share_to_account.go @@ -61,31 +61,18 @@ func (k Keeper) MintPoolShareToAccount(ctx sdk.Context, pool types.Pool, addr sd k.apKeeper.SetEntry(ctx, entry) } - // Deposit and commit LP token minted + // Commit LP token minted msgServer := commitmentkeeper.NewMsgServerImpl(*k.commitmentKeeper) - // Create a deposit token message - msgDepositToken := &ctypes.MsgDepositTokens{ + // Create a commit LP token liquidated message + msgLiquidCommitLPToken := &ctypes.MsgCommitLiquidTokens{ Creator: addr.String(), Denom: poolShareDenom, Amount: amount, } - // Deposit LP token - _, err = msgServer.DepositTokens(sdk.WrapSDKContext(ctx), msgDepositToken) - if err != nil { - return err - } - - // Create a commit token message - msgCommitToken := &ctypes.MsgCommitTokens{ - Creator: addr.String(), - Denom: poolShareDenom, - Amount: amount, - } - - // Commit LP token - _, err = msgServer.CommitTokens(sdk.WrapSDKContext(ctx), msgCommitToken) + // Commit LP token liquidated + _, err = msgServer.CommitLiquidTokens(sdk.WrapSDKContext(ctx), msgLiquidCommitLPToken) if err != nil { return err } diff --git a/x/amm/types/query.pb.gw.go b/x/amm/types/query.pb.gw.go index 2babba22a..3b891ece9 100644 --- a/x/amm/types/query.pb.gw.go +++ b/x/amm/types/query.pb.gw.go @@ -20,6 +20,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -30,6 +31,7 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage +var _ = metadata.Join func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryParamsRequest @@ -232,12 +234,14 @@ func local_request_Query_DenomLiquidityAll_0(ctx context.Context, marshaler runt // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -245,6 +249,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -258,6 +263,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_Pool_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -265,6 +272,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Pool_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -278,6 +286,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_PoolAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -285,6 +295,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_PoolAll_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -298,6 +309,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_DenomLiquidity_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -305,6 +318,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_DenomLiquidity_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -318,6 +332,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_DenomLiquidityAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -325,6 +341,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_DenomLiquidityAll_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) diff --git a/x/commitment/client/cli/tx.go b/x/commitment/client/cli/tx.go index 3632e9422..c45a7356b 100644 --- a/x/commitment/client/cli/tx.go +++ b/x/commitment/client/cli/tx.go @@ -31,13 +31,14 @@ func GetTxCmd() *cobra.Command { } cmd.AddCommand(CmdCommitTokens()) + cmd.AddCommand(CmdCommitLiquidTokens()) cmd.AddCommand(CmdUncommitTokens()) cmd.AddCommand(CmdWithdrawTokens()) - cmd.AddCommand(CmdDepositTokens()) cmd.AddCommand(CmdVest()) cmd.AddCommand(CmdCancelVest()) cmd.AddCommand(CmdVestNow()) cmd.AddCommand(CmdUpdateVestingInfo()) + cmd.AddCommand(CmdVestLiquid()) // this line is used by starport scaffolding # 1 return cmd diff --git a/x/commitment/client/cli/tx_commit_liquid_tokens.go b/x/commitment/client/cli/tx_commit_liquid_tokens.go new file mode 100644 index 000000000..c78297439 --- /dev/null +++ b/x/commitment/client/cli/tx_commit_liquid_tokens.go @@ -0,0 +1,50 @@ +package cli + +import ( + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/elys-network/elys/x/commitment/types" + "github.com/spf13/cobra" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +var _ = strconv.Itoa(0) + +func CmdCommitLiquidTokens() *cobra.Command { + cmd := &cobra.Command{ + Use: "commit-liquid-tokens [amount] [denom]", + Short: "Broadcast message commit-liquid-tokens", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argAmount, found := sdk.NewIntFromString(args[0]) + if !found { + return sdkerrors.Wrap(sdkerrors.ErrInvalidType, "cannot convert string to int") + } + argDenom := args[1] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgCommitLiquidTokens( + clientCtx.GetFromAddress().String(), + argAmount, + argDenom, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/commitment/client/cli/tx_deposit_tokens.go b/x/commitment/client/cli/tx_vest_liquid.go similarity index 85% rename from x/commitment/client/cli/tx_deposit_tokens.go rename to x/commitment/client/cli/tx_vest_liquid.go index ae70edde7..c54babf5d 100644 --- a/x/commitment/client/cli/tx_deposit_tokens.go +++ b/x/commitment/client/cli/tx_vest_liquid.go @@ -6,19 +6,18 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" - "github.com/elys-network/elys/x/commitment/types" - "github.com/spf13/cobra" - sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/elys-network/elys/x/commitment/types" + "github.com/spf13/cobra" ) var _ = strconv.Itoa(0) -func CmdDepositTokens() *cobra.Command { +func CmdVestLiquid() *cobra.Command { cmd := &cobra.Command{ - Use: "deposit-tokens [amount] [denom]", - Short: "Broadcast message deposit-tokens", + Use: "vest-liquid [amount] [denom]", + Short: "Broadcast message vest-liquid", Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) (err error) { argAmount, found := sdk.NewIntFromString(args[0]) @@ -32,7 +31,7 @@ func CmdDepositTokens() *cobra.Command { return err } - msg := types.NewMsgDepositTokens( + msg := types.NewMsgVestLiquid( clientCtx.GetFromAddress().String(), argAmount, argDenom, diff --git a/x/commitment/keeper/commitments.go b/x/commitment/keeper/commitments.go index 02601a869..caf72a9bb 100644 --- a/x/commitment/keeper/commitments.go +++ b/x/commitment/keeper/commitments.go @@ -74,10 +74,15 @@ func (k Keeper) DeductCommitments(ctx sdk.Context, creator string, denom string, return types.Commitments{}, sdkerrors.Wrapf(types.ErrCommitmentsNotFound, "creator: %s", creator) } + // if deduction amount is zero + if amount.Equal(sdk.ZeroInt()) { + return commitments, nil + } + // Get user's uncommitted balance uncommittedToken, found := commitments.GetUncommittedTokensForDenom(denom) if !found { - return types.Commitments{}, sdkerrors.Wrapf(types.ErrCommitmentsNotFound, "creator: %s", creator) + uncommittedToken = &types.UncommittedTokens{Denom: denom, Amount: sdk.ZeroInt()} } requestedAmount := amount diff --git a/x/commitment/keeper/deposit_liquid_tokens.go b/x/commitment/keeper/deposit_liquid_tokens.go new file mode 100644 index 000000000..0afcb317d --- /dev/null +++ b/x/commitment/keeper/deposit_liquid_tokens.go @@ -0,0 +1,69 @@ +package keeper + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + aptypes "github.com/elys-network/elys/x/assetprofile/types" + "github.com/elys-network/elys/x/commitment/types" +) + +// accounting the liquid token as a uncommitted token in commitment module. +func (k Keeper) DepositLiquidTokensUncommitted(ctx sdk.Context, denom string, amount sdk.Int, creator string) error { + assetProfile, found := k.apKeeper.GetEntry(ctx, denom) + if !found { + return sdkerrors.Wrapf(aptypes.ErrAssetProfileNotFound, "denom: %s", denom) + } + + if !assetProfile.CommitEnabled { + return sdkerrors.Wrapf(types.ErrCommitDisabled, "denom: %s", denom) + } + + depositCoins := sdk.NewCoins(sdk.NewCoin(denom, amount)) + + addr, err := sdk.AccAddressFromBech32(creator) + if err != nil { + return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "unable to convert address from bech32") + } + + // send the deposited coins to the module + err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, addr, types.ModuleName, depositCoins) + if err != nil { + return sdkerrors.Wrap(sdkerrors.ErrInsufficientFunds, fmt.Sprintf("unable to send deposit tokens: %v", depositCoins)) + } + // burn the deposited coins + err = k.bankKeeper.BurnCoins(ctx, types.ModuleName, depositCoins) + if err != nil { + return sdkerrors.Wrap(sdkerrors.ErrInsufficientFunds, "unable to burn deposit tokens") + } + + // Get the Commitments for the creator + commitments, found := k.GetCommitments(ctx, creator) + if !found { + commitments = types.Commitments{ + Creator: creator, + CommittedTokens: []*types.CommittedTokens{}, + UncommittedTokens: []*types.UncommittedTokens{}, + } + } + // Get the uncommitted tokens for the creator + uncommittedToken, found := commitments.GetUncommittedTokensForDenom(denom) + if !found { + uncommittedTokens := commitments.GetUncommittedTokens() + uncommittedToken = &types.UncommittedTokens{ + Denom: denom, + Amount: sdk.ZeroInt(), + } + uncommittedTokens = append(uncommittedTokens, uncommittedToken) + commitments.UncommittedTokens = uncommittedTokens + } + + // Update the uncommitted tokens amount + uncommittedToken.Amount = uncommittedToken.Amount.Add(amount) + + // Update the commitments + k.SetCommitments(ctx, commitments) + + return nil +} diff --git a/x/commitment/keeper/deposit_liquid_tokens_test.go b/x/commitment/keeper/deposit_liquid_tokens_test.go new file mode 100644 index 000000000..443a57bd7 --- /dev/null +++ b/x/commitment/keeper/deposit_liquid_tokens_test.go @@ -0,0 +1,73 @@ +package keeper_test + +import ( + "testing" + + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + + sdk "github.com/cosmos/cosmos-sdk/types" + simapp "github.com/elys-network/elys/app" + aptypes "github.com/elys-network/elys/x/assetprofile/types" + "github.com/elys-network/elys/x/commitment/types" + ptypes "github.com/elys-network/elys/x/parameter/types" + "github.com/stretchr/testify/require" +) + +func TestDepositLiquidTokens(t *testing.T) { + app := simapp.InitElysTestApp(true) + + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + // Create a test context and keeper + keeper := app.CommitmentKeeper + + addr := simapp.AddTestAddrs(app, ctx, 1, sdk.NewInt(1000000)) + + // Mint 100ueden + edenToken := sdk.NewCoins(sdk.NewCoin(ptypes.Eden, sdk.NewInt(100))) + + err := app.BankKeeper.MintCoins(ctx, types.ModuleName, edenToken) + require.NoError(t, err) + err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, addr[0], edenToken) + require.NoError(t, err) + + creator := addr[0] + + // Set assetprofile entry for denom + app.AssetprofileKeeper.SetEntry(ctx, aptypes.Entry{BaseDenom: ptypes.Eden, CommitEnabled: true}) + + // Set up the commitments for the creator + commitments := types.Commitments{ + Creator: creator.String(), + CommittedTokens: []*types.CommittedTokens{ + { + Denom: ptypes.Eden, + Amount: sdk.NewInt(50), + }, + }, + UncommittedTokens: []*types.UncommittedTokens{ + { + Denom: ptypes.Eden, + Amount: sdk.NewInt(150), + }, + }, + } + keeper.SetCommitments(ctx, commitments) + + // Deposit liquid eden to become uncommitted state + keeper.DepositLiquidTokensUncommitted(ctx, ptypes.Eden, sdk.NewInt(100), creator.String()) + + // Check if the deposit tokens were added to commitments + newCommitments, found := keeper.GetCommitments(ctx, creator.String()) + require.True(t, found, "commitments not found") + + // Check if the uncommitted tokens were updated correctly + uncommittedToken := newCommitments.GetUncommittedAmountForDenom(ptypes.Eden) + require.Equal(t, sdk.NewInt(250), uncommittedToken, "uncommitted tokens were not updated correctly") + + // Check if the committed tokens were updated correctly + committedToken := newCommitments.GetCommittedAmountForDenom(ptypes.Eden) + require.Equal(t, sdk.NewInt(50), committedToken, "committed tokens were not updated correctly") + + edenCoin := app.BankKeeper.GetBalance(ctx, addr[0], ptypes.Eden) + require.Equal(t, edenCoin.Amount, sdk.ZeroInt()) +} diff --git a/x/commitment/keeper/keeper.go b/x/commitment/keeper/keeper.go index a68421ac7..1f19b175b 100644 --- a/x/commitment/keeper/keeper.go +++ b/x/commitment/keeper/keeper.go @@ -348,3 +348,58 @@ func (k Keeper) ProcessWithdrawUSDC(ctx sdk.Context, creator string, denom strin return nil } + +// Vesting token +// Check if vesting entity count is not exceeding the maximum and if it is fine, creates a new vesting entity +// Deduct from uncommitted bucket. If it is insufficent, deduct from committed bucket as well. +func (k Keeper) ProcessTokenVesting(ctx sdk.Context, denom string, amount sdk.Int, creator string) error { + vestingInfo, _ := k.GetVestingInfo(ctx, denom) + + if vestingInfo == nil { + return sdkerrors.Wrapf(types.ErrInvalidDenom, "denom: %s", denom) + } + + commitments, found := k.GetCommitments(ctx, creator) + if !found { + return sdkerrors.Wrapf(types.ErrCommitmentsNotFound, "creator: %s", creator) + } + + // Create vesting tokens entry and add to commitments + vestingTokens := commitments.GetVestingTokens() + if vestingInfo.NumMaxVestings <= (int64)(len(vestingTokens)) { + return sdkerrors.Wrapf(types.ErrExceedMaxVestings, "creator: %s", creator) + } + + commitments, err := k.DeductCommitments(ctx, creator, denom, amount) + if err != nil { + return err + } + + vestingTokens = append(vestingTokens, &types.VestingTokens{ + Denom: vestingInfo.VestingDenom, + TotalAmount: amount, + UnvestedAmount: amount, + EpochIdentifier: vestingInfo.EpochIdentifier, + NumEpochs: vestingInfo.NumEpochs, + CurrentEpoch: 0, + }) + commitments.VestingTokens = vestingTokens + + // Update the commitments + k.SetCommitments(ctx, commitments) + + // Emit Hook commitment changed + k.AfterCommitmentChange(ctx, creator, sdk.NewCoin(denom, amount)) + + // Emit blockchain event + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeCommitmentChanged, + sdk.NewAttribute(types.AttributeCreator, creator), + sdk.NewAttribute(types.AttributeAmount, amount.String()), + sdk.NewAttribute(types.AttributeDenom, denom), + ), + ) + + return nil +} diff --git a/x/commitment/keeper/msg_server_deposit_tokens.go b/x/commitment/keeper/msg_server_commit_liquid_tokens.go similarity index 77% rename from x/commitment/keeper/msg_server_deposit_tokens.go rename to x/commitment/keeper/msg_server_commit_liquid_tokens.go index d60aafa43..9fc9921a5 100644 --- a/x/commitment/keeper/msg_server_deposit_tokens.go +++ b/x/commitment/keeper/msg_server_commit_liquid_tokens.go @@ -10,7 +10,7 @@ import ( "github.com/elys-network/elys/x/commitment/types" ) -func (k msgServer) DepositTokens(goCtx context.Context, msg *types.MsgDepositTokens) (*types.MsgDepositTokensResponse, error) { +func (k msgServer) CommitLiquidTokens(goCtx context.Context, msg *types.MsgCommitLiquidTokens) (*types.MsgCommitLiquidTokensResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) assetProfile, found := k.apKeeper.GetEntry(ctx, msg.Denom) @@ -49,20 +49,20 @@ func (k msgServer) DepositTokens(goCtx context.Context, msg *types.MsgDepositTok UncommittedTokens: []*types.UncommittedTokens{}, } } - // Get the uncommitted tokens for the creator - uncommittedToken, found := commitments.GetUncommittedTokensForDenom(msg.Denom) + // Get the committed tokens for the creator + committedToken, found := commitments.GetCommittedTokensForDenom(msg.Denom) if !found { - uncommittedTokens := commitments.GetUncommittedTokens() - uncommittedToken = &types.UncommittedTokens{ + committedTokens := commitments.GetCommittedTokens() + committedToken = &types.CommittedTokens{ Denom: msg.Denom, Amount: sdk.ZeroInt(), } - uncommittedTokens = append(uncommittedTokens, uncommittedToken) - commitments.UncommittedTokens = uncommittedTokens + committedTokens = append(committedTokens, committedToken) + commitments.CommittedTokens = committedTokens } - // Update the uncommitted tokens amount - uncommittedToken.Amount = uncommittedToken.Amount.Add(msg.Amount) + // Update the committed tokens amount + committedToken.Amount = committedToken.Amount.Add(msg.Amount) // Update the commitments k.SetCommitments(ctx, commitments) @@ -80,5 +80,5 @@ func (k msgServer) DepositTokens(goCtx context.Context, msg *types.MsgDepositTok ), ) - return &types.MsgDepositTokensResponse{}, nil + return &types.MsgCommitLiquidTokensResponse{}, nil } diff --git a/x/commitment/keeper/msg_server_deposit_tokens_test.go b/x/commitment/keeper/msg_server_commit_liquid_tokens_test.go similarity index 74% rename from x/commitment/keeper/msg_server_deposit_tokens_test.go rename to x/commitment/keeper/msg_server_commit_liquid_tokens_test.go index 5f5f27cb2..81b7fa0ed 100644 --- a/x/commitment/keeper/msg_server_deposit_tokens_test.go +++ b/x/commitment/keeper/msg_server_commit_liquid_tokens_test.go @@ -14,7 +14,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestDepositTokens(t *testing.T) { +func TestCommitLiquidTokens(t *testing.T) { app := app.InitElysTestApp(true) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) @@ -27,14 +27,14 @@ func TestDepositTokens(t *testing.T) { creator, _ := sdk.AccAddressFromBech32("cosmos1xv9tklw7d82sezh9haa573wufgy59vmwe6xxe5") // Create a deposit message - depositMsg := &types.MsgDepositTokens{ + commitMsg := &types.MsgCommitLiquidTokens{ Creator: creator.String(), Denom: ptypes.Eden, Amount: sdk.NewInt(100), } // Set assetprofile entry for denom - app.AssetprofileKeeper.SetEntry(ctx, aptypes.Entry{BaseDenom: depositMsg.Denom, CommitEnabled: true}) + app.AssetprofileKeeper.SetEntry(ctx, aptypes.Entry{BaseDenom: commitMsg.Denom, CommitEnabled: true}) // Add initial funds to creator's account coins := sdk.NewCoins(sdk.NewCoin(ptypes.Eden, sdk.NewInt(200))) @@ -42,27 +42,27 @@ func TestDepositTokens(t *testing.T) { require.NoError(t, err) err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, creator, coins) require.NoError(t, err) - balance := app.BankKeeper.GetBalance(ctx, creator, depositMsg.Denom) + balance := app.BankKeeper.GetBalance(ctx, creator, commitMsg.Denom) require.Equal(t, coins.AmountOf(ptypes.Eden), balance.Amount, "creator balance did not initialize") require.NoError(t, err) // Execute the DepositTokens function - _, err = msgServer.DepositTokens(ctx, depositMsg) + _, err = msgServer.CommitLiquidTokens(ctx, commitMsg) require.NoError(t, err) // Check if the tokens were deposited and uncommitted balance was updated - commitments, found := keeper.GetCommitments(ctx, depositMsg.Creator) + commitments, found := keeper.GetCommitments(ctx, commitMsg.Creator) require.True(t, found, "commitments not found") - uncommittedBalance := commitments.GetUncommittedAmountForDenom(depositMsg.Denom) - require.Equal(t, depositMsg.Amount, uncommittedBalance, "uncommitted balance did not update correctly") + committedBalance := commitments.GetCommittedAmountForDenom(commitMsg.Denom) + require.Equal(t, commitMsg.Amount, committedBalance, "committed balance did not update correctly") // Check if the deposited tokens were deducted from creator balance - remainingCoins := app.BankKeeper.GetBalance(ctx, creator, depositMsg.Denom) + remainingCoins := app.BankKeeper.GetBalance(ctx, creator, commitMsg.Denom) require.Equal(t, sdk.NewInt(100), remainingCoins.Amount, "tokens were not deducted correctly") // Check if the deposited tokens were burned - remainingCoins = app.BankKeeper.GetBalance(ctx, app.AccountKeeper.GetModuleAddress(types.ModuleName), depositMsg.Denom) + remainingCoins = app.BankKeeper.GetBalance(ctx, app.AccountKeeper.GetModuleAddress(types.ModuleName), commitMsg.Denom) require.Equal(t, sdk.NewInt(0), remainingCoins.Amount, "tokens were not burned correctly") } diff --git a/x/commitment/keeper/msg_server_commit_tokens.go b/x/commitment/keeper/msg_server_commit_tokens.go index 56e0642ec..b88c4b1ef 100644 --- a/x/commitment/keeper/msg_server_commit_tokens.go +++ b/x/commitment/keeper/msg_server_commit_tokens.go @@ -28,7 +28,10 @@ func (k msgServer) CommitTokens(goCtx context.Context, msg *types.MsgCommitToken } // Check if the uncommitted tokens have enough amount to be committed - uncommittedToken, _ := commitments.GetUncommittedTokensForDenom(msg.Denom) + uncommittedToken, found := commitments.GetUncommittedTokensForDenom(msg.Denom) + if !found { + return nil, sdkerrors.Wrapf(types.ErrInsufficientUncommittedTokens, "creator: %s", msg.Creator) + } if uncommittedToken.Amount.LT(msg.Amount) { return nil, sdkerrors.Wrapf(types.ErrInsufficientUncommittedTokens, "creator: %s, denom: %s", msg.Creator, msg.Denom) diff --git a/x/commitment/keeper/msg_server_uncommit_tokens.go b/x/commitment/keeper/msg_server_uncommit_tokens.go index f10a1238b..3cbb6e72a 100644 --- a/x/commitment/keeper/msg_server_uncommit_tokens.go +++ b/x/commitment/keeper/msg_server_uncommit_tokens.go @@ -10,6 +10,7 @@ import ( ptypes "github.com/elys-network/elys/x/parameter/types" ) +// uncommit the committed one and make it liquid immediately. func (k msgServer) UncommitTokens(goCtx context.Context, msg *types.MsgUncommitTokens) (*types.MsgUncommitTokensResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) @@ -30,8 +31,6 @@ func (k msgServer) UncommitTokens(goCtx context.Context, msg *types.MsgUncommitT // Check if the committed tokens have enough amount to be uncommitted committedToken, _ := commitments.GetCommittedTokensForDenom(msg.Denom) - // committedAmount := commitments.GetCommittedAmountForDenom(msg.Denom) - if committedToken.Amount.LT(msg.Amount) { return nil, sdkerrors.Wrapf(types.ErrInsufficientCommittedTokens, "creator: %s, denom: %s", msg.Creator, msg.Denom) } @@ -39,23 +38,28 @@ func (k msgServer) UncommitTokens(goCtx context.Context, msg *types.MsgUncommitT // Update the committed tokens amount committedToken.Amount = committedToken.Amount.Sub(msg.Amount) - // Update the uncommitted tokens amount - uncommittedToken, found := commitments.GetUncommittedTokensForDenom(msg.Denom) - - if found { - uncommittedToken.Amount = uncommittedToken.Amount.Add(msg.Amount) - } else { - uncommittedTokens := commitments.GetUncommittedTokens() - uncommittedTokens = append(uncommittedTokens, &types.UncommittedTokens{ - Denom: msg.Denom, - Amount: msg.Amount, - }) - commitments.UncommittedTokens = uncommittedTokens - } - // Update the commitments k.SetCommitments(ctx, commitments) + liquidCoins := sdk.NewCoins(sdk.NewCoin(msg.Denom, msg.Amount)) + + // Mint the withdrawn tokens to the module account + err := k.bankKeeper.MintCoins(ctx, types.ModuleName, liquidCoins) + if err != nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrInsufficientFunds, "unable to mint liquid tokens") + } + + addr, err := sdk.AccAddressFromBech32(commitments.Creator) + if err != nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "unable to convert address from bech32") + } + + // Send the minted coins to the user's account + err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, addr, liquidCoins) + if err != nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrInsufficientFunds, "unable to send liquid tokens") + } + // Emit Hook commitment changed k.AfterCommitmentChange(ctx, msg.Creator, sdk.NewCoin(msg.Denom, msg.Amount)) diff --git a/x/commitment/keeper/msg_server_uncommit_tokens_test.go b/x/commitment/keeper/msg_server_uncommit_tokens_test.go index 1026f55f6..b2be8ffa1 100644 --- a/x/commitment/keeper/msg_server_uncommit_tokens_test.go +++ b/x/commitment/keeper/msg_server_uncommit_tokens_test.go @@ -6,7 +6,8 @@ import ( tmproto "github.com/cometbft/cometbft/proto/tendermint/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/elys-network/elys/app" + simapp "github.com/elys-network/elys/app" + aptypes "github.com/elys-network/elys/x/assetprofile/types" commitmentkeeper "github.com/elys-network/elys/x/commitment/keeper" "github.com/elys-network/elys/x/commitment/types" @@ -15,15 +16,18 @@ import ( ) func TestUncommitTokens(t *testing.T) { - app := app.InitElysTestApp(true) + app := simapp.InitElysTestApp(true) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) // Create a test context and keeper keeper := app.CommitmentKeeper msgServer := commitmentkeeper.NewMsgServerImpl(keeper) + // Generate 1 random account with 1000000uelys balanced + addr := simapp.AddTestAddrs(app, ctx, 1, sdk.NewInt(1000000)) + // Define the test data - creator := "test_creator" + creator := addr[0].String() denom := "test_denom" initialUncommitted := sdk.NewInt(400) initialCommitted := sdk.NewInt(100) @@ -68,6 +72,10 @@ func TestUncommitTokens(t *testing.T) { assert.Equal(t, creator, commitments.Creator, "Incorrect creator") assert.Len(t, commitments.CommittedTokens, 1, "Incorrect number of committed tokens") assert.Equal(t, denom, commitments.CommittedTokens[0].Denom, "Incorrect denom") - assert.Equal(t, uncommitAmount.Add(initialUncommitted), commitments.UncommittedTokens[0].Amount, "Incorrect amount") assert.Equal(t, sdk.ZeroInt(), commitments.CommittedTokens[0].Amount, "Incorrect amount") + + uncommittedToken := sdk.NewCoins(sdk.NewCoin(denom, uncommitAmount)) + + edenCoin := app.BankKeeper.GetBalance(ctx, addr[0], denom) + require.Equal(t, sdk.Coins{edenCoin}, uncommittedToken) } diff --git a/x/commitment/keeper/msg_server_vest.go b/x/commitment/keeper/msg_server_vest.go index 327ab46b7..00c0eda49 100644 --- a/x/commitment/keeper/msg_server_vest.go +++ b/x/commitment/keeper/msg_server_vest.go @@ -4,61 +4,15 @@ import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/elys-network/elys/x/commitment/types" ) func (k msgServer) Vest(goCtx context.Context, msg *types.MsgVest) (*types.MsgVestResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - - vestingInfo, _ := k.GetVestingInfo(ctx, msg.Denom) - - if vestingInfo == nil { - return nil, sdkerrors.Wrapf(types.ErrInvalidDenom, "denom: %s", msg.Denom) - } - - commitments, found := k.GetCommitments(ctx, msg.Creator) - if !found { - return nil, sdkerrors.Wrapf(types.ErrCommitmentsNotFound, "creator: %s", msg.Creator) - } - - // Create vesting tokens entry and add to commitments - vestingTokens := commitments.GetVestingTokens() - if vestingInfo.NumMaxVestings <= (int64)(len(vestingTokens)) { - return nil, sdkerrors.Wrapf(types.ErrExceedMaxVestings, "creator: %s", msg.Creator) + if err := k.ProcessTokenVesting(ctx, msg.Denom, msg.Amount, msg.Creator); err != nil { + return &types.MsgVestResponse{}, err } - commitments, err := k.DeductCommitments(ctx, msg.Creator, msg.Denom, msg.Amount) - if err != nil { - return nil, err - } - - vestingTokens = append(vestingTokens, &types.VestingTokens{ - Denom: vestingInfo.VestingDenom, - TotalAmount: msg.Amount, - UnvestedAmount: msg.Amount, - EpochIdentifier: vestingInfo.EpochIdentifier, - NumEpochs: vestingInfo.NumEpochs, - CurrentEpoch: 0, - }) - commitments.VestingTokens = vestingTokens - - // Update the commitments - k.SetCommitments(ctx, commitments) - - // Emit Hook commitment changed - k.AfterCommitmentChange(ctx, msg.Creator, sdk.NewCoin(msg.Denom, msg.Amount)) - - // Emit blockchain event - ctx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventTypeCommitmentChanged, - sdk.NewAttribute(types.AttributeCreator, msg.Creator), - sdk.NewAttribute(types.AttributeAmount, msg.Amount.String()), - sdk.NewAttribute(types.AttributeDenom, msg.Denom), - ), - ) - return &types.MsgVestResponse{}, nil } diff --git a/x/commitment/keeper/msg_server_vest_liquid.go b/x/commitment/keeper/msg_server_vest_liquid.go new file mode 100644 index 000000000..65f7e4a64 --- /dev/null +++ b/x/commitment/keeper/msg_server_vest_liquid.go @@ -0,0 +1,21 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/elys-network/elys/x/commitment/types" +) + +func (k msgServer) VestLiquid(goCtx context.Context, msg *types.MsgVestLiquid) (*types.MsgVestLiquidResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + if err := k.DepositLiquidTokensUncommitted(ctx, msg.Denom, msg.Amount, msg.Creator); err != nil { + return &types.MsgVestLiquidResponse{}, err + } + + if err := k.ProcessTokenVesting(ctx, msg.Denom, msg.Amount, msg.Creator); err != nil { + return &types.MsgVestLiquidResponse{}, err + } + + return &types.MsgVestLiquidResponse{}, nil +} diff --git a/x/commitment/keeper/msg_server_vest_liquid_test.go b/x/commitment/keeper/msg_server_vest_liquid_test.go new file mode 100644 index 000000000..c5f819ffd --- /dev/null +++ b/x/commitment/keeper/msg_server_vest_liquid_test.go @@ -0,0 +1,105 @@ +package keeper_test + +import ( + "fmt" + "testing" + + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + simapp "github.com/elys-network/elys/app" + aptypes "github.com/elys-network/elys/x/assetprofile/types" + commitmentkeeper "github.com/elys-network/elys/x/commitment/keeper" + "github.com/elys-network/elys/x/commitment/types" + ptypes "github.com/elys-network/elys/x/parameter/types" + "github.com/stretchr/testify/require" +) + +func TestLiquidVestWithExceed(t *testing.T) { + app := simapp.InitElysTestApp(true) + + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + // Create a test context and keeper + keeper := app.CommitmentKeeper + + addr := simapp.AddTestAddrs(app, ctx, 1, sdk.NewInt(1000000)) + + // Mint 100ueden + edenToken := sdk.NewCoins(sdk.NewCoin(ptypes.Eden, sdk.NewInt(100))) + + err := app.BankKeeper.MintCoins(ctx, types.ModuleName, edenToken) + require.NoError(t, err) + err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, addr[0], edenToken) + require.NoError(t, err) + + creator := addr[0] + msgServer := commitmentkeeper.NewMsgServerImpl(keeper) + vestingInfos := []*types.VestingInfo{ + { + BaseDenom: ptypes.Eden, + VestingDenom: ptypes.Elys, + EpochIdentifier: "tenseconds", + NumEpochs: 10, + VestNowFactor: sdk.NewInt(90), + NumMaxVestings: 10, + }, + } + + params := types.Params{ + VestingInfos: vestingInfos, + } + + keeper.SetParams(ctx, params) + + // Create a vesting message + vestMsg := &types.MsgVestLiquid{ + Creator: creator.String(), + Denom: ptypes.Eden, + Amount: sdk.NewInt(100), + } + + // Set up the commitments for the creator + commitments := types.Commitments{ + Creator: creator.String(), + CommittedTokens: []*types.CommittedTokens{ + { + Denom: ptypes.Eden, + Amount: sdk.NewInt(50), + }, + }, + UncommittedTokens: []*types.UncommittedTokens{ + { + Denom: ptypes.Eden, + Amount: sdk.NewInt(150), + }, + }, + } + keeper.SetCommitments(ctx, commitments) + + // Set assetprofile entry for denom + app.AssetprofileKeeper.SetEntry(ctx, aptypes.Entry{BaseDenom: ptypes.Eden, CommitEnabled: true}) + + // Execute the Vest function + _, err = msgServer.VestLiquid(ctx, vestMsg) + require.NoError(t, err) + + // Check if the vesting tokens were added to commitments + newCommitments, found := keeper.GetCommitments(ctx, vestMsg.Creator) + require.True(t, found, "commitments not found") + require.Len(t, newCommitments.VestingTokens, 1, "vesting tokens were not added") + + // Check if the uncommitted tokens were updated correctly + uncommittedToken := newCommitments.GetUncommittedAmountForDenom(vestMsg.Denom) + require.Equal(t, sdk.NewInt(150), uncommittedToken, "uncommitted tokens were not updated correctly") + + // Check if the committed tokens were updated correctly + committedToken := newCommitments.GetCommittedAmountForDenom(vestMsg.Denom) + require.Equal(t, sdk.NewInt(50), committedToken, "committed tokens were not updated correctly") + + edenCoin := app.BankKeeper.GetBalance(ctx, addr[0], ptypes.Eden) + require.Equal(t, edenCoin.Amount, sdk.ZeroInt()) + + _, err = msgServer.VestLiquid(ctx, vestMsg) + require.Equal(t, err.Error(), sdkerrors.Wrap(sdkerrors.ErrInsufficientFunds, fmt.Sprintf("unable to send deposit tokens: %v", edenToken)).Error()) +} diff --git a/x/commitment/module_simulation.go b/x/commitment/module_simulation.go index e5832ad02..91b9ae45c 100644 --- a/x/commitment/module_simulation.go +++ b/x/commitment/module_simulation.go @@ -34,9 +34,9 @@ const ( // TODO: Determine the simulation weight value defaultWeightMsgWithdrawTokens int = 100 - opWeightMsgDepositTokens = "op_weight_msg_deposit_tokens" + opWeightMsgCommitLiquidTokens = "op_weight_msg_commit_liquid_tokens" // TODO: Determine the simulation weight value - defaultWeightMsgDepositTokens int = 100 + defaultWeightMsgCommitLiquidTokens int = 100 opWeightMsgVest = "op_weight_msg_vest" // TODO: Determine the simulation weight value @@ -54,6 +54,10 @@ const ( // TODO: Determine the simulation weight value defaultWeightMsgUpdateVestingInfo int = 100 + opWeightMsgVestLiquid = "op_weight_msg_vest_liquid" + // TODO: Determine the simulation weight value + defaultWeightMsgVestLiquid int = 100 + // this line is used by starport scaffolding # simapp/module/const ) @@ -115,15 +119,15 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp commitmentsimulation.SimulateMsgWithdrawTokens(am.accountKeeper, am.bankKeeper, am.keeper), )) - var weightMsgDepositTokens int - simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgDepositTokens, &weightMsgDepositTokens, nil, + var weightMsgCommitLiquidTokens int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgCommitLiquidTokens, &weightMsgCommitLiquidTokens, nil, func(_ *rand.Rand) { - weightMsgDepositTokens = defaultWeightMsgDepositTokens + weightMsgCommitLiquidTokens = defaultWeightMsgCommitLiquidTokens }, ) operations = append(operations, simulation.NewWeightedOperation( - weightMsgDepositTokens, - commitmentsimulation.SimulateMsgDepositTokens(am.accountKeeper, am.bankKeeper, am.keeper), + weightMsgCommitLiquidTokens, + commitmentsimulation.SimulateMsgCommitLiquidTokens(am.accountKeeper, am.bankKeeper, am.keeper), )) var weightMsgVest int @@ -170,6 +174,17 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp commitmentsimulation.SimulateMsgUpdateVestingInfo(am.accountKeeper, am.bankKeeper, am.keeper), )) + var weightMsgVestLiquid int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgVestLiquid, &weightMsgVestLiquid, nil, + func(_ *rand.Rand) { + weightMsgVestLiquid = defaultWeightMsgVestLiquid + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgVestLiquid, + commitmentsimulation.SimulateMsgVestLiquid(am.accountKeeper, am.bankKeeper, am.keeper), + )) + // this line is used by starport scaffolding # simapp/module/operation return operations diff --git a/x/commitment/simulation/deposit_tokens.go b/x/commitment/simulation/commit_liquid_tokens.go similarity index 91% rename from x/commitment/simulation/deposit_tokens.go rename to x/commitment/simulation/commit_liquid_tokens.go index 0c940ba6c..4242537ac 100644 --- a/x/commitment/simulation/deposit_tokens.go +++ b/x/commitment/simulation/commit_liquid_tokens.go @@ -10,7 +10,7 @@ import ( "github.com/elys-network/elys/x/commitment/types" ) -func SimulateMsgDepositTokens( +func SimulateMsgCommitLiquidTokens( ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper, @@ -18,7 +18,7 @@ func SimulateMsgDepositTokens( return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { simAccount, _ := simtypes.RandomAcc(r, accs) - msg := &types.MsgDepositTokens{ + msg := &types.MsgCommitLiquidTokens{ Creator: simAccount.Address.String(), } diff --git a/x/commitment/simulation/vest_liquid.go b/x/commitment/simulation/vest_liquid.go new file mode 100644 index 000000000..59f39d14c --- /dev/null +++ b/x/commitment/simulation/vest_liquid.go @@ -0,0 +1,29 @@ +package simulation + +import ( + "math/rand" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/elys-network/elys/x/commitment/keeper" + "github.com/elys-network/elys/x/commitment/types" +) + +func SimulateMsgVestLiquid( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgVestLiquid{ + Creator: simAccount.Address.String(), + } + + // TODO: Handling the VestLiquid simulation + + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "VestLiquid simulation not implemented"), nil, nil + } +} diff --git a/x/commitment/types/codec.go b/x/commitment/types/codec.go index 13146e693..9dff8c061 100644 --- a/x/commitment/types/codec.go +++ b/x/commitment/types/codec.go @@ -11,11 +11,12 @@ func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgCommitTokens{}, "commitment/CommitTokens", nil) cdc.RegisterConcrete(&MsgUncommitTokens{}, "commitment/UncommitTokens", nil) cdc.RegisterConcrete(&MsgWithdrawTokens{}, "commitment/WithdrawTokens", nil) - cdc.RegisterConcrete(&MsgDepositTokens{}, "commitment/DepositTokens", nil) + cdc.RegisterConcrete(&MsgCommitLiquidTokens{}, "commitment/CommitLiquidTokens", nil) cdc.RegisterConcrete(&MsgVest{}, "commitment/Vest", nil) cdc.RegisterConcrete(&MsgCancelVest{}, "commitment/CancelVest", nil) cdc.RegisterConcrete(&MsgVestNow{}, "commitment/VestNow", nil) cdc.RegisterConcrete(&MsgUpdateVestingInfo{}, "commitment/UpdateVestingInfo", nil) + cdc.RegisterConcrete(&MsgVestLiquid{}, "commitment/VestLiquid", nil) // this line is used by starport scaffolding # 2 } @@ -30,7 +31,7 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { &MsgWithdrawTokens{}, ) registry.RegisterImplementations((*sdk.Msg)(nil), - &MsgDepositTokens{}, + &MsgCommitLiquidTokens{}, ) registry.RegisterImplementations((*sdk.Msg)(nil), &MsgVest{}, @@ -44,6 +45,9 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgUpdateVestingInfo{}, ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgVestLiquid{}, + ) // this line is used by starport scaffolding # 3 msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/commitment/types/message_deposit_tokens.go b/x/commitment/types/message_commit_liquid_tokens.go similarity index 58% rename from x/commitment/types/message_deposit_tokens.go rename to x/commitment/types/message_commit_liquid_tokens.go index b6bfaf278..1ccf5f5e1 100644 --- a/x/commitment/types/message_deposit_tokens.go +++ b/x/commitment/types/message_commit_liquid_tokens.go @@ -5,27 +5,27 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -const TypeMsgDepositTokens = "deposit_tokens" +const TypeMsgDepositTokens = "commit_liquid_tokens" -var _ sdk.Msg = &MsgDepositTokens{} +var _ sdk.Msg = &MsgCommitLiquidTokens{} -func NewMsgDepositTokens(creator string, amount sdk.Int, denom string) *MsgDepositTokens { - return &MsgDepositTokens{ +func NewMsgCommitLiquidTokens(creator string, amount sdk.Int, denom string) *MsgCommitLiquidTokens { + return &MsgCommitLiquidTokens{ Creator: creator, Amount: amount, Denom: denom, } } -func (msg *MsgDepositTokens) Route() string { +func (msg *MsgCommitLiquidTokens) Route() string { return RouterKey } -func (msg *MsgDepositTokens) Type() string { +func (msg *MsgCommitLiquidTokens) Type() string { return TypeMsgDepositTokens } -func (msg *MsgDepositTokens) GetSigners() []sdk.AccAddress { +func (msg *MsgCommitLiquidTokens) GetSigners() []sdk.AccAddress { creator, err := sdk.AccAddressFromBech32(msg.Creator) if err != nil { panic(err) @@ -33,12 +33,12 @@ func (msg *MsgDepositTokens) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{creator} } -func (msg *MsgDepositTokens) GetSignBytes() []byte { +func (msg *MsgCommitLiquidTokens) GetSignBytes() []byte { bz := ModuleCdc.MustMarshalJSON(msg) return sdk.MustSortJSON(bz) } -func (msg *MsgDepositTokens) ValidateBasic() error { +func (msg *MsgCommitLiquidTokens) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(msg.Creator) if err != nil { return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid creator address: %v", err) diff --git a/x/commitment/types/message_deposit_tokens_test.go b/x/commitment/types/message_commit_liquid_tokens_test.go similarity index 82% rename from x/commitment/types/message_deposit_tokens_test.go rename to x/commitment/types/message_commit_liquid_tokens_test.go index 2988912d0..c69a5c826 100644 --- a/x/commitment/types/message_deposit_tokens_test.go +++ b/x/commitment/types/message_commit_liquid_tokens_test.go @@ -9,22 +9,22 @@ import ( "github.com/stretchr/testify/require" ) -func TestMsgDepositTokens_ValidateBasic(t *testing.T) { +func TestMsgCommitLiquidTokens_ValidateBasic(t *testing.T) { tests := []struct { name string - msg MsgDepositTokens + msg MsgCommitLiquidTokens err error }{ { name: "invalid address", - msg: MsgDepositTokens{ + msg: MsgCommitLiquidTokens{ Creator: "invalid_address", Amount: sdk.ZeroInt(), }, err: sdkerrors.ErrInvalidAddress, }, { name: "valid address", - msg: MsgDepositTokens{ + msg: MsgCommitLiquidTokens{ Creator: sample.AccAddress(), Amount: sdk.ZeroInt(), }, diff --git a/x/commitment/types/message_vest_liquid.go b/x/commitment/types/message_vest_liquid.go new file mode 100644 index 000000000..2a316b6e1 --- /dev/null +++ b/x/commitment/types/message_vest_liquid.go @@ -0,0 +1,47 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgVestLiquid = "vest_liquid" + +var _ sdk.Msg = &MsgVestLiquid{} + +func NewMsgVestLiquid(creator string, amount sdk.Int, denom string) *MsgVestLiquid { + return &MsgVestLiquid{ + Creator: creator, + Amount: amount, + Denom: denom, + } +} + +func (msg *MsgVestLiquid) Route() string { + return RouterKey +} + +func (msg *MsgVestLiquid) Type() string { + return TypeMsgVestLiquid +} + +func (msg *MsgVestLiquid) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgVestLiquid) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgVestLiquid) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + return nil +} diff --git a/x/commitment/types/message_vest_liquid_test.go b/x/commitment/types/message_vest_liquid_test.go new file mode 100644 index 000000000..1bddd38c3 --- /dev/null +++ b/x/commitment/types/message_vest_liquid_test.go @@ -0,0 +1,40 @@ +package types + +import ( + "testing" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/elys-network/elys/testutil/sample" + "github.com/stretchr/testify/require" +) + +func TestMsgVestLiquid_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgVestLiquid + err error + }{ + { + name: "invalid address", + msg: MsgVestLiquid{ + Creator: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "valid address", + msg: MsgVestLiquid{ + Creator: sample.AccAddress(), + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/commitment/types/tx.pb.go b/x/commitment/types/tx.pb.go index 165985d8d..116453226 100644 --- a/x/commitment/types/tx.pb.go +++ b/x/commitment/types/tx.pb.go @@ -296,24 +296,24 @@ func (m *MsgWithdrawTokensResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgWithdrawTokensResponse proto.InternalMessageInfo -type MsgDepositTokens struct { +type MsgCommitLiquidTokens struct { Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount"` Denom string `protobuf:"bytes,3,opt,name=denom,proto3" json:"denom,omitempty"` } -func (m *MsgDepositTokens) Reset() { *m = MsgDepositTokens{} } -func (m *MsgDepositTokens) String() string { return proto.CompactTextString(m) } -func (*MsgDepositTokens) ProtoMessage() {} -func (*MsgDepositTokens) Descriptor() ([]byte, []int) { +func (m *MsgCommitLiquidTokens) Reset() { *m = MsgCommitLiquidTokens{} } +func (m *MsgCommitLiquidTokens) String() string { return proto.CompactTextString(m) } +func (*MsgCommitLiquidTokens) ProtoMessage() {} +func (*MsgCommitLiquidTokens) Descriptor() ([]byte, []int) { return fileDescriptor_eda78aafe7eb119c, []int{6} } -func (m *MsgDepositTokens) XXX_Unmarshal(b []byte) error { +func (m *MsgCommitLiquidTokens) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgDepositTokens) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgCommitLiquidTokens) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgDepositTokens.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgCommitLiquidTokens.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -323,47 +323,47 @@ func (m *MsgDepositTokens) XXX_Marshal(b []byte, deterministic bool) ([]byte, er return b[:n], nil } } -func (m *MsgDepositTokens) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgDepositTokens.Merge(m, src) +func (m *MsgCommitLiquidTokens) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCommitLiquidTokens.Merge(m, src) } -func (m *MsgDepositTokens) XXX_Size() int { +func (m *MsgCommitLiquidTokens) XXX_Size() int { return m.Size() } -func (m *MsgDepositTokens) XXX_DiscardUnknown() { - xxx_messageInfo_MsgDepositTokens.DiscardUnknown(m) +func (m *MsgCommitLiquidTokens) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCommitLiquidTokens.DiscardUnknown(m) } -var xxx_messageInfo_MsgDepositTokens proto.InternalMessageInfo +var xxx_messageInfo_MsgCommitLiquidTokens proto.InternalMessageInfo -func (m *MsgDepositTokens) GetCreator() string { +func (m *MsgCommitLiquidTokens) GetCreator() string { if m != nil { return m.Creator } return "" } -func (m *MsgDepositTokens) GetDenom() string { +func (m *MsgCommitLiquidTokens) GetDenom() string { if m != nil { return m.Denom } return "" } -type MsgDepositTokensResponse struct { +type MsgCommitLiquidTokensResponse struct { } -func (m *MsgDepositTokensResponse) Reset() { *m = MsgDepositTokensResponse{} } -func (m *MsgDepositTokensResponse) String() string { return proto.CompactTextString(m) } -func (*MsgDepositTokensResponse) ProtoMessage() {} -func (*MsgDepositTokensResponse) Descriptor() ([]byte, []int) { +func (m *MsgCommitLiquidTokensResponse) Reset() { *m = MsgCommitLiquidTokensResponse{} } +func (m *MsgCommitLiquidTokensResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCommitLiquidTokensResponse) ProtoMessage() {} +func (*MsgCommitLiquidTokensResponse) Descriptor() ([]byte, []int) { return fileDescriptor_eda78aafe7eb119c, []int{7} } -func (m *MsgDepositTokensResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgCommitLiquidTokensResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgDepositTokensResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgCommitLiquidTokensResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgDepositTokensResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgCommitLiquidTokensResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -373,17 +373,17 @@ func (m *MsgDepositTokensResponse) XXX_Marshal(b []byte, deterministic bool) ([] return b[:n], nil } } -func (m *MsgDepositTokensResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgDepositTokensResponse.Merge(m, src) +func (m *MsgCommitLiquidTokensResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCommitLiquidTokensResponse.Merge(m, src) } -func (m *MsgDepositTokensResponse) XXX_Size() int { +func (m *MsgCommitLiquidTokensResponse) XXX_Size() int { return m.Size() } -func (m *MsgDepositTokensResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgDepositTokensResponse.DiscardUnknown(m) +func (m *MsgCommitLiquidTokensResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCommitLiquidTokensResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgDepositTokensResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgCommitLiquidTokensResponse proto.InternalMessageInfo type MsgVest struct { Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` @@ -780,6 +780,95 @@ func (m *MsgUpdateVestingInfoResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateVestingInfoResponse proto.InternalMessageInfo +type MsgVestLiquid struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount"` + Denom string `protobuf:"bytes,3,opt,name=denom,proto3" json:"denom,omitempty"` +} + +func (m *MsgVestLiquid) Reset() { *m = MsgVestLiquid{} } +func (m *MsgVestLiquid) String() string { return proto.CompactTextString(m) } +func (*MsgVestLiquid) ProtoMessage() {} +func (*MsgVestLiquid) Descriptor() ([]byte, []int) { + return fileDescriptor_eda78aafe7eb119c, []int{16} +} +func (m *MsgVestLiquid) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgVestLiquid) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgVestLiquid.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgVestLiquid) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgVestLiquid.Merge(m, src) +} +func (m *MsgVestLiquid) XXX_Size() int { + return m.Size() +} +func (m *MsgVestLiquid) XXX_DiscardUnknown() { + xxx_messageInfo_MsgVestLiquid.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgVestLiquid proto.InternalMessageInfo + +func (m *MsgVestLiquid) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgVestLiquid) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +type MsgVestLiquidResponse struct { +} + +func (m *MsgVestLiquidResponse) Reset() { *m = MsgVestLiquidResponse{} } +func (m *MsgVestLiquidResponse) String() string { return proto.CompactTextString(m) } +func (*MsgVestLiquidResponse) ProtoMessage() {} +func (*MsgVestLiquidResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_eda78aafe7eb119c, []int{17} +} +func (m *MsgVestLiquidResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgVestLiquidResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgVestLiquidResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgVestLiquidResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgVestLiquidResponse.Merge(m, src) +} +func (m *MsgVestLiquidResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgVestLiquidResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgVestLiquidResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgVestLiquidResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgCommitTokens)(nil), "elys.commitment.MsgCommitTokens") proto.RegisterType((*MsgCommitTokensResponse)(nil), "elys.commitment.MsgCommitTokensResponse") @@ -787,8 +876,8 @@ func init() { proto.RegisterType((*MsgUncommitTokensResponse)(nil), "elys.commitment.MsgUncommitTokensResponse") proto.RegisterType((*MsgWithdrawTokens)(nil), "elys.commitment.MsgWithdrawTokens") proto.RegisterType((*MsgWithdrawTokensResponse)(nil), "elys.commitment.MsgWithdrawTokensResponse") - proto.RegisterType((*MsgDepositTokens)(nil), "elys.commitment.MsgDepositTokens") - proto.RegisterType((*MsgDepositTokensResponse)(nil), "elys.commitment.MsgDepositTokensResponse") + proto.RegisterType((*MsgCommitLiquidTokens)(nil), "elys.commitment.MsgCommitLiquidTokens") + proto.RegisterType((*MsgCommitLiquidTokensResponse)(nil), "elys.commitment.MsgCommitLiquidTokensResponse") proto.RegisterType((*MsgVest)(nil), "elys.commitment.MsgVest") proto.RegisterType((*MsgVestResponse)(nil), "elys.commitment.MsgVestResponse") proto.RegisterType((*MsgCancelVest)(nil), "elys.commitment.MsgCancelVest") @@ -797,52 +886,56 @@ func init() { proto.RegisterType((*MsgVestNowResponse)(nil), "elys.commitment.MsgVestNowResponse") proto.RegisterType((*MsgUpdateVestingInfo)(nil), "elys.commitment.MsgUpdateVestingInfo") proto.RegisterType((*MsgUpdateVestingInfoResponse)(nil), "elys.commitment.MsgUpdateVestingInfoResponse") + proto.RegisterType((*MsgVestLiquid)(nil), "elys.commitment.MsgVestLiquid") + proto.RegisterType((*MsgVestLiquidResponse)(nil), "elys.commitment.MsgVestLiquidResponse") } func init() { proto.RegisterFile("elys/commitment/tx.proto", fileDescriptor_eda78aafe7eb119c) } var fileDescriptor_eda78aafe7eb119c = []byte{ - // 639 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x96, 0xcb, 0x6a, 0xdb, 0x40, - 0x14, 0x86, 0x3d, 0xb9, 0x99, 0x1c, 0x72, 0x69, 0x06, 0x97, 0x28, 0x4a, 0x50, 0x5c, 0xb5, 0x0d, - 0x6e, 0x21, 0x12, 0xb4, 0x6f, 0x90, 0xa6, 0x01, 0x53, 0x94, 0x85, 0x49, 0x5b, 0x08, 0x14, 0x2a, - 0xcb, 0x13, 0x59, 0x38, 0x9a, 0x11, 0x9a, 0x71, 0x6c, 0x2f, 0x0b, 0x85, 0xd2, 0xcb, 0xa2, 0x8f, - 0x95, 0x65, 0x56, 0xa5, 0x74, 0x11, 0x8a, 0xfd, 0x22, 0x65, 0x24, 0x5b, 0xb6, 0x14, 0x25, 0xee, - 0xce, 0x59, 0x25, 0x73, 0xfe, 0x7f, 0xce, 0xf9, 0x34, 0xf2, 0xfc, 0x08, 0x14, 0x72, 0xde, 0xe3, - 0xa6, 0xc3, 0x7c, 0xdf, 0x13, 0x3e, 0xa1, 0xc2, 0x14, 0x5d, 0x23, 0x08, 0x99, 0x60, 0x78, 0x5d, - 0x2a, 0xc6, 0x58, 0x51, 0x4b, 0x2e, 0x73, 0x59, 0xa4, 0x99, 0xf2, 0xbf, 0xd8, 0xa6, 0x7f, 0x45, - 0xb0, 0x6e, 0x71, 0xf7, 0x55, 0xe4, 0x3b, 0x61, 0x2d, 0x42, 0x39, 0x56, 0xa0, 0xe8, 0x84, 0xc4, - 0x16, 0x2c, 0x54, 0x50, 0x19, 0x55, 0x96, 0x6b, 0xa3, 0x25, 0x3e, 0x82, 0x25, 0xdb, 0x67, 0x6d, - 0x2a, 0x94, 0x39, 0x29, 0x1c, 0x18, 0x97, 0xd7, 0xbb, 0x85, 0x3f, 0xd7, 0xbb, 0x7b, 0xae, 0x27, - 0x9a, 0xed, 0xba, 0x1c, 0x67, 0x3a, 0x8c, 0xfb, 0x8c, 0x0f, 0xff, 0xec, 0xf3, 0x46, 0xcb, 0x14, - 0xbd, 0x80, 0x70, 0xa3, 0x4a, 0x45, 0x6d, 0xb8, 0x1b, 0x97, 0x60, 0xb1, 0x41, 0x28, 0xf3, 0x95, - 0xf9, 0xa8, 0x7f, 0xbc, 0xd0, 0xb7, 0x60, 0x33, 0x83, 0x52, 0x23, 0x3c, 0x60, 0x94, 0x13, 0xfd, - 0x3b, 0x82, 0x0d, 0x8b, 0xbb, 0x6f, 0xa9, 0x73, 0x1f, 0x40, 0xb7, 0x61, 0xeb, 0x06, 0x4c, 0x16, - 0xf5, 0xbd, 0x27, 0x9a, 0x8d, 0xd0, 0xee, 0xdc, 0x0b, 0xd4, 0x34, 0x4c, 0x82, 0xfa, 0x0d, 0xc1, - 0x03, 0x8b, 0xbb, 0x87, 0x24, 0x60, 0x7c, 0xe6, 0x87, 0xaa, 0x82, 0x92, 0x65, 0x49, 0x40, 0x3f, - 0x21, 0x28, 0x5a, 0xdc, 0x7d, 0x47, 0xb8, 0x98, 0x19, 0xdf, 0x46, 0x74, 0x51, 0x24, 0x42, 0x82, - 0xf5, 0x05, 0xc1, 0xaa, 0xfc, 0xc5, 0xda, 0xd4, 0x21, 0xe7, 0x33, 0x85, 0xdb, 0x84, 0x87, 0x29, - 0x90, 0x04, 0xf1, 0x33, 0x02, 0x18, 0x62, 0x1f, 0xb3, 0xce, 0xcc, 0xf8, 0x4a, 0x80, 0xc7, 0x14, - 0x09, 0xdc, 0x8f, 0x39, 0x28, 0xc9, 0x8b, 0x14, 0x34, 0x6c, 0x41, 0xa4, 0xe8, 0x51, 0xb7, 0x4a, - 0xcf, 0x18, 0xde, 0x81, 0x65, 0xbb, 0x2d, 0x9a, 0x2c, 0xf4, 0x44, 0x6f, 0x08, 0x3a, 0x2e, 0x48, - 0xb5, 0x6e, 0x73, 0x72, 0x18, 0x8d, 0x99, 0x8b, 0xd5, 0xa4, 0x80, 0x75, 0x58, 0xb9, 0x88, 0x5b, - 0x1d, 0x4e, 0x70, 0xa4, 0x6a, 0xb8, 0x02, 0xeb, 0x24, 0x60, 0x4e, 0xb3, 0xda, 0x20, 0x54, 0x78, - 0x67, 0x1e, 0x09, 0x95, 0x85, 0xc8, 0x96, 0x2d, 0xcb, 0x59, 0xb4, 0xed, 0xbf, 0x96, 0x55, 0xae, - 0x2c, 0x96, 0x51, 0x65, 0xbe, 0x36, 0x2e, 0xe0, 0x27, 0xb0, 0x7a, 0x11, 0x3f, 0xd3, 0x91, 0xed, - 0xc8, 0x43, 0x5d, 0x8a, 0x1c, 0xe9, 0x22, 0xde, 0x83, 0x35, 0xda, 0xf6, 0x2d, 0xbb, 0x3b, 0x7c, - 0x44, 0xae, 0x14, 0x23, 0x5b, 0xa6, 0xaa, 0x6b, 0xb0, 0x93, 0x77, 0x1a, 0xa3, 0xe3, 0x7a, 0xf1, - 0x6b, 0x11, 0xe6, 0x2d, 0xee, 0xe2, 0x53, 0x58, 0x49, 0xe5, 0x75, 0xd9, 0xc8, 0x64, 0xbd, 0x91, - 0x89, 0x51, 0xb5, 0x32, 0xcd, 0x31, 0x9a, 0x81, 0x3f, 0xc2, 0x5a, 0x26, 0x64, 0xf5, 0xbc, 0xbd, - 0x69, 0x8f, 0xfa, 0x7c, 0xba, 0x67, 0x72, 0x42, 0x26, 0x1b, 0x73, 0x27, 0xa4, 0x3d, 0xf9, 0x13, - 0xf2, 0x63, 0x0d, 0x7f, 0x80, 0xd5, 0x74, 0xa4, 0x3d, 0xca, 0xdb, 0x9c, 0xb2, 0xa8, 0xcf, 0xa6, - 0x5a, 0x92, 0xf6, 0x07, 0xb0, 0x10, 0xdf, 0xf5, 0xbc, 0x2d, 0x52, 0x51, 0xcb, 0xb7, 0x29, 0x49, - 0x8f, 0x13, 0x80, 0x89, 0xd4, 0xd0, 0x72, 0x5f, 0x4f, 0xa2, 0xab, 0x7b, 0x77, 0xeb, 0x49, 0xd7, - 0x37, 0x50, 0x1c, 0x5d, 0xf4, 0xed, 0xdb, 0x10, 0x8e, 0x59, 0x47, 0x7d, 0x7c, 0x87, 0x98, 0x34, - 0xf3, 0x60, 0xe3, 0xe6, 0xc5, 0x7c, 0x9a, 0xfb, 0xa2, 0xb3, 0x36, 0x75, 0xff, 0xbf, 0x6c, 0xa3, - 0x51, 0x07, 0xd5, 0xcb, 0xbe, 0x86, 0xae, 0xfa, 0x1a, 0xfa, 0xdb, 0xd7, 0xd0, 0xcf, 0x81, 0x56, - 0xb8, 0x1a, 0x68, 0x85, 0xdf, 0x03, 0xad, 0x70, 0x6a, 0x4e, 0xa4, 0x8f, 0x6c, 0xb9, 0x4f, 0x89, - 0xe8, 0xb0, 0xb0, 0x15, 0x2d, 0xcc, 0x6e, 0xea, 0xcb, 0x47, 0x46, 0x51, 0x7d, 0x29, 0xfa, 0xac, - 0x79, 0xf9, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x9a, 0x11, 0xd0, 0x5d, 0x19, 0x09, 0x00, 0x00, + // 665 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x96, 0xcd, 0x4e, 0xdb, 0x40, + 0x10, 0xc7, 0xb3, 0x7c, 0x24, 0x62, 0xc4, 0x87, 0x58, 0xa5, 0xc2, 0x18, 0x6a, 0xa2, 0xb4, 0x8d, + 0xa2, 0x4a, 0xd8, 0x52, 0xfb, 0x06, 0x94, 0x22, 0x45, 0x6d, 0x38, 0x44, 0xb4, 0x95, 0x38, 0xd5, + 0xd8, 0x8b, 0x63, 0x81, 0x77, 0x53, 0xef, 0x9a, 0xc0, 0xb1, 0x52, 0xa5, 0xaa, 0x6a, 0xa5, 0xf6, + 0x7d, 0xfa, 0x02, 0x1c, 0x39, 0x56, 0x3d, 0xa0, 0x0a, 0x5e, 0xa4, 0x5a, 0x3b, 0xd9, 0xd8, 0xc6, + 0x01, 0x6e, 0xe1, 0x94, 0x78, 0xfe, 0x7f, 0xcf, 0xfc, 0x3c, 0xf6, 0x8c, 0x0d, 0x1a, 0x39, 0x3e, + 0xe3, 0x96, 0xc3, 0x82, 0xc0, 0x17, 0x01, 0xa1, 0xc2, 0x12, 0xa7, 0x66, 0x2f, 0x64, 0x82, 0xe1, + 0x25, 0xa9, 0x98, 0x23, 0x45, 0xaf, 0x7a, 0xcc, 0x63, 0xb1, 0x66, 0xc9, 0x7f, 0x89, 0xad, 0xfe, + 0x0d, 0xc1, 0x52, 0x9b, 0x7b, 0xaf, 0x62, 0xdf, 0x1e, 0x3b, 0x22, 0x94, 0x63, 0x0d, 0x2a, 0x4e, + 0x48, 0x6c, 0xc1, 0x42, 0x0d, 0xd5, 0x50, 0x73, 0xae, 0x33, 0x3c, 0xc4, 0x3b, 0x50, 0xb6, 0x03, + 0x16, 0x51, 0xa1, 0x4d, 0x49, 0x61, 0xcb, 0x3c, 0xbf, 0xdc, 0x28, 0xfd, 0xbd, 0xdc, 0x68, 0x78, + 0xbe, 0xe8, 0x46, 0x07, 0xb2, 0x9c, 0xe5, 0x30, 0x1e, 0x30, 0x3e, 0xf8, 0xd9, 0xe4, 0xee, 0x91, + 0x25, 0xce, 0x7a, 0x84, 0x9b, 0x2d, 0x2a, 0x3a, 0x83, 0xb3, 0x71, 0x15, 0x66, 0x5d, 0x42, 0x59, + 0xa0, 0x4d, 0xc7, 0xf9, 0x93, 0x83, 0xfa, 0x2a, 0xac, 0xe4, 0x50, 0x3a, 0x84, 0xf7, 0x18, 0xe5, + 0xa4, 0xfe, 0x1d, 0xc1, 0x72, 0x9b, 0x7b, 0xef, 0xa8, 0xf3, 0x10, 0x40, 0xd7, 0x60, 0xf5, 0x06, + 0x4c, 0x1e, 0xf5, 0x83, 0x2f, 0xba, 0x6e, 0x68, 0xf7, 0x1f, 0x04, 0x6a, 0x16, 0x46, 0xa1, 0xfe, + 0x44, 0xf0, 0x48, 0x75, 0xfc, 0xad, 0xff, 0x29, 0xf2, 0xdd, 0x09, 0xe3, 0x6e, 0xc0, 0xe3, 0x42, + 0x20, 0x85, 0xfc, 0x19, 0x41, 0xa5, 0xcd, 0xbd, 0xf7, 0x84, 0x8b, 0x89, 0x41, 0x2e, 0xc7, 0x23, + 0x23, 0x11, 0x14, 0xd6, 0x57, 0x04, 0x0b, 0x12, 0xdc, 0xa6, 0x0e, 0x39, 0x9e, 0x28, 0xdc, 0x4a, + 0x72, 0x4b, 0x15, 0x88, 0x42, 0xfc, 0x82, 0x00, 0x06, 0xd8, 0xbb, 0xac, 0x3f, 0x31, 0xbe, 0x2a, + 0xe0, 0x11, 0x85, 0x82, 0xfb, 0x31, 0x05, 0x55, 0x39, 0x52, 0x3d, 0xd7, 0x16, 0x44, 0x8a, 0x3e, + 0xf5, 0x5a, 0xf4, 0x90, 0xe1, 0x75, 0x98, 0xb3, 0x23, 0xd1, 0x65, 0xa1, 0x2f, 0xce, 0x06, 0xa0, + 0xa3, 0x80, 0x54, 0x0f, 0x6c, 0x4e, 0xb6, 0xe3, 0x32, 0x53, 0x89, 0xaa, 0x02, 0xb8, 0x0e, 0xf3, + 0x27, 0x49, 0xaa, 0xed, 0x14, 0x47, 0x26, 0x86, 0x9b, 0xb0, 0x44, 0x7a, 0xcc, 0xe9, 0xb6, 0x5c, + 0x42, 0x85, 0x7f, 0xe8, 0x93, 0x50, 0x9b, 0x89, 0x6d, 0xf9, 0xb0, 0xac, 0x45, 0xa3, 0xe0, 0xb5, + 0x8c, 0x72, 0x6d, 0xb6, 0x86, 0x9a, 0xd3, 0x9d, 0x51, 0x00, 0x3f, 0x85, 0x85, 0x93, 0xe4, 0x9a, + 0x76, 0x6c, 0x47, 0x36, 0xb5, 0x1c, 0x3b, 0xb2, 0x41, 0xdc, 0x80, 0x45, 0x1a, 0x05, 0x6d, 0xfb, + 0x74, 0x70, 0x89, 0x5c, 0xab, 0xc4, 0xb6, 0x5c, 0xb4, 0x6e, 0xc0, 0x7a, 0x51, 0x37, 0xf2, 0x8f, + 0x9b, 0x94, 0x92, 0x29, 0x99, 0xf0, 0xe3, 0x36, 0x02, 0x19, 0x22, 0xbe, 0xf8, 0x5d, 0x86, 0xe9, + 0x36, 0xf7, 0xf0, 0x3e, 0xcc, 0x67, 0x5e, 0x2e, 0x35, 0x33, 0xf7, 0x62, 0x32, 0x73, 0x3b, 0x5f, + 0x6f, 0xde, 0xe5, 0x18, 0xd6, 0xc0, 0x1f, 0x61, 0x31, 0xf7, 0x46, 0xa8, 0x17, 0x9d, 0x9b, 0xf5, + 0xe8, 0xcf, 0xef, 0xf6, 0xa4, 0x2b, 0xe4, 0x16, 0x79, 0x61, 0x85, 0xac, 0xa7, 0xb8, 0x42, 0xf1, + 0x0e, 0xc6, 0xc7, 0x80, 0x0b, 0xf6, 0x6f, 0x63, 0x7c, 0x0f, 0xd2, 0x3e, 0xdd, 0xbc, 0x9f, 0x4f, + 0x55, 0xdb, 0x82, 0x99, 0x64, 0x3b, 0x15, 0x9d, 0x27, 0x15, 0xbd, 0x36, 0x4e, 0x51, 0x39, 0xf6, + 0x00, 0x52, 0x7b, 0xce, 0x28, 0x24, 0x50, 0xba, 0xde, 0xb8, 0x5d, 0x57, 0x59, 0xdf, 0x40, 0x65, + 0xb8, 0x9a, 0xd6, 0xc6, 0x21, 0xec, 0xb2, 0xbe, 0xfe, 0xe4, 0x16, 0x51, 0x25, 0xf3, 0x61, 0xf9, + 0xe6, 0x2a, 0x79, 0x56, 0x78, 0xdf, 0xf3, 0x36, 0x7d, 0xf3, 0x5e, 0xb6, 0x74, 0x37, 0x52, 0x63, + 0x68, 0x8c, 0xa3, 0x4b, 0xf4, 0xe2, 0x6e, 0xdc, 0x9c, 0x9e, 0xad, 0xd6, 0xf9, 0x95, 0x81, 0x2e, + 0xae, 0x0c, 0xf4, 0xef, 0xca, 0x40, 0xbf, 0xae, 0x8d, 0xd2, 0xc5, 0xb5, 0x51, 0xfa, 0x73, 0x6d, + 0x94, 0xf6, 0xad, 0xd4, 0xd8, 0xca, 0x5c, 0x9b, 0x94, 0x88, 0x3e, 0x0b, 0x8f, 0xe2, 0x03, 0xeb, + 0x34, 0xf3, 0x2d, 0x28, 0x67, 0xf8, 0xa0, 0x1c, 0x7f, 0xe8, 0xbd, 0xfc, 0x1f, 0x00, 0x00, 0xff, + 0xff, 0x1a, 0xe4, 0xe1, 0x03, 0x2b, 0x0a, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -860,11 +953,12 @@ type MsgClient interface { CommitTokens(ctx context.Context, in *MsgCommitTokens, opts ...grpc.CallOption) (*MsgCommitTokensResponse, error) UncommitTokens(ctx context.Context, in *MsgUncommitTokens, opts ...grpc.CallOption) (*MsgUncommitTokensResponse, error) WithdrawTokens(ctx context.Context, in *MsgWithdrawTokens, opts ...grpc.CallOption) (*MsgWithdrawTokensResponse, error) - DepositTokens(ctx context.Context, in *MsgDepositTokens, opts ...grpc.CallOption) (*MsgDepositTokensResponse, error) + CommitLiquidTokens(ctx context.Context, in *MsgCommitLiquidTokens, opts ...grpc.CallOption) (*MsgCommitLiquidTokensResponse, error) Vest(ctx context.Context, in *MsgVest, opts ...grpc.CallOption) (*MsgVestResponse, error) CancelVest(ctx context.Context, in *MsgCancelVest, opts ...grpc.CallOption) (*MsgCancelVestResponse, error) VestNow(ctx context.Context, in *MsgVestNow, opts ...grpc.CallOption) (*MsgVestNowResponse, error) UpdateVestingInfo(ctx context.Context, in *MsgUpdateVestingInfo, opts ...grpc.CallOption) (*MsgUpdateVestingInfoResponse, error) + VestLiquid(ctx context.Context, in *MsgVestLiquid, opts ...grpc.CallOption) (*MsgVestLiquidResponse, error) } type msgClient struct { @@ -902,9 +996,9 @@ func (c *msgClient) WithdrawTokens(ctx context.Context, in *MsgWithdrawTokens, o return out, nil } -func (c *msgClient) DepositTokens(ctx context.Context, in *MsgDepositTokens, opts ...grpc.CallOption) (*MsgDepositTokensResponse, error) { - out := new(MsgDepositTokensResponse) - err := c.cc.Invoke(ctx, "/elys.commitment.Msg/DepositTokens", in, out, opts...) +func (c *msgClient) CommitLiquidTokens(ctx context.Context, in *MsgCommitLiquidTokens, opts ...grpc.CallOption) (*MsgCommitLiquidTokensResponse, error) { + out := new(MsgCommitLiquidTokensResponse) + err := c.cc.Invoke(ctx, "/elys.commitment.Msg/CommitLiquidTokens", in, out, opts...) if err != nil { return nil, err } @@ -947,16 +1041,26 @@ func (c *msgClient) UpdateVestingInfo(ctx context.Context, in *MsgUpdateVestingI return out, nil } +func (c *msgClient) VestLiquid(ctx context.Context, in *MsgVestLiquid, opts ...grpc.CallOption) (*MsgVestLiquidResponse, error) { + out := new(MsgVestLiquidResponse) + err := c.cc.Invoke(ctx, "/elys.commitment.Msg/VestLiquid", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { CommitTokens(context.Context, *MsgCommitTokens) (*MsgCommitTokensResponse, error) UncommitTokens(context.Context, *MsgUncommitTokens) (*MsgUncommitTokensResponse, error) WithdrawTokens(context.Context, *MsgWithdrawTokens) (*MsgWithdrawTokensResponse, error) - DepositTokens(context.Context, *MsgDepositTokens) (*MsgDepositTokensResponse, error) + CommitLiquidTokens(context.Context, *MsgCommitLiquidTokens) (*MsgCommitLiquidTokensResponse, error) Vest(context.Context, *MsgVest) (*MsgVestResponse, error) CancelVest(context.Context, *MsgCancelVest) (*MsgCancelVestResponse, error) VestNow(context.Context, *MsgVestNow) (*MsgVestNowResponse, error) UpdateVestingInfo(context.Context, *MsgUpdateVestingInfo) (*MsgUpdateVestingInfoResponse, error) + VestLiquid(context.Context, *MsgVestLiquid) (*MsgVestLiquidResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -972,8 +1076,8 @@ func (*UnimplementedMsgServer) UncommitTokens(ctx context.Context, req *MsgUncom func (*UnimplementedMsgServer) WithdrawTokens(ctx context.Context, req *MsgWithdrawTokens) (*MsgWithdrawTokensResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method WithdrawTokens not implemented") } -func (*UnimplementedMsgServer) DepositTokens(ctx context.Context, req *MsgDepositTokens) (*MsgDepositTokensResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method DepositTokens not implemented") +func (*UnimplementedMsgServer) CommitLiquidTokens(ctx context.Context, req *MsgCommitLiquidTokens) (*MsgCommitLiquidTokensResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CommitLiquidTokens not implemented") } func (*UnimplementedMsgServer) Vest(ctx context.Context, req *MsgVest) (*MsgVestResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Vest not implemented") @@ -987,6 +1091,9 @@ func (*UnimplementedMsgServer) VestNow(ctx context.Context, req *MsgVestNow) (*M func (*UnimplementedMsgServer) UpdateVestingInfo(ctx context.Context, req *MsgUpdateVestingInfo) (*MsgUpdateVestingInfoResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateVestingInfo not implemented") } +func (*UnimplementedMsgServer) VestLiquid(ctx context.Context, req *MsgVestLiquid) (*MsgVestLiquidResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method VestLiquid not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -1046,20 +1153,20 @@ func _Msg_WithdrawTokens_Handler(srv interface{}, ctx context.Context, dec func( return interceptor(ctx, in, info, handler) } -func _Msg_DepositTokens_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgDepositTokens) +func _Msg_CommitLiquidTokens_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCommitLiquidTokens) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).DepositTokens(ctx, in) + return srv.(MsgServer).CommitLiquidTokens(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/elys.commitment.Msg/DepositTokens", + FullMethod: "/elys.commitment.Msg/CommitLiquidTokens", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).DepositTokens(ctx, req.(*MsgDepositTokens)) + return srv.(MsgServer).CommitLiquidTokens(ctx, req.(*MsgCommitLiquidTokens)) } return interceptor(ctx, in, info, handler) } @@ -1136,6 +1243,24 @@ func _Msg_UpdateVestingInfo_Handler(srv interface{}, ctx context.Context, dec fu return interceptor(ctx, in, info, handler) } +func _Msg_VestLiquid_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgVestLiquid) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).VestLiquid(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/elys.commitment.Msg/VestLiquid", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).VestLiquid(ctx, req.(*MsgVestLiquid)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "elys.commitment.Msg", HandlerType: (*MsgServer)(nil), @@ -1153,8 +1278,8 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Handler: _Msg_WithdrawTokens_Handler, }, { - MethodName: "DepositTokens", - Handler: _Msg_DepositTokens_Handler, + MethodName: "CommitLiquidTokens", + Handler: _Msg_CommitLiquidTokens_Handler, }, { MethodName: "Vest", @@ -1172,6 +1297,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "UpdateVestingInfo", Handler: _Msg_UpdateVestingInfo_Handler, }, + { + MethodName: "VestLiquid", + Handler: _Msg_VestLiquid_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "elys/commitment/tx.proto", @@ -1387,7 +1516,7 @@ func (m *MsgWithdrawTokensResponse) MarshalToSizedBuffer(dAtA []byte) (int, erro return len(dAtA) - i, nil } -func (m *MsgDepositTokens) Marshal() (dAtA []byte, err error) { +func (m *MsgCommitLiquidTokens) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1397,12 +1526,12 @@ func (m *MsgDepositTokens) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgDepositTokens) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgCommitLiquidTokens) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgDepositTokens) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgCommitLiquidTokens) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1434,7 +1563,7 @@ func (m *MsgDepositTokens) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgDepositTokensResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgCommitLiquidTokensResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1444,12 +1573,12 @@ func (m *MsgDepositTokensResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgDepositTokensResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgCommitLiquidTokensResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgDepositTokensResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgCommitLiquidTokensResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1756,6 +1885,76 @@ func (m *MsgUpdateVestingInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, e return len(dAtA) - i, nil } +func (m *MsgVestLiquid) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgVestLiquid) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgVestLiquid) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintTx(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0x1a + } + { + size := m.Amount.Size() + i -= size + if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgVestLiquidResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgVestLiquidResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgVestLiquidResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -1851,7 +2050,7 @@ func (m *MsgWithdrawTokensResponse) Size() (n int) { return n } -func (m *MsgDepositTokens) Size() (n int) { +func (m *MsgCommitLiquidTokens) Size() (n int) { if m == nil { return 0 } @@ -1870,7 +2069,7 @@ func (m *MsgDepositTokens) Size() (n int) { return n } -func (m *MsgDepositTokensResponse) Size() (n int) { +func (m *MsgCommitLiquidTokensResponse) Size() (n int) { if m == nil { return 0 } @@ -2006,6 +2205,34 @@ func (m *MsgUpdateVestingInfoResponse) Size() (n int) { return n } +func (m *MsgVestLiquid) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Amount.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgVestLiquidResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2606,7 +2833,7 @@ func (m *MsgWithdrawTokensResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgDepositTokens) Unmarshal(dAtA []byte) error { +func (m *MsgCommitLiquidTokens) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2629,10 +2856,10 @@ func (m *MsgDepositTokens) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgDepositTokens: wiretype end group for non-group") + return fmt.Errorf("proto: MsgCommitLiquidTokens: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgDepositTokens: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgCommitLiquidTokens: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2754,7 +2981,7 @@ func (m *MsgDepositTokens) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgDepositTokensResponse) Unmarshal(dAtA []byte) error { +func (m *MsgCommitLiquidTokensResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2777,10 +3004,10 @@ func (m *MsgDepositTokensResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgDepositTokensResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgCommitLiquidTokensResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgDepositTokensResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgCommitLiquidTokensResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -3683,6 +3910,204 @@ func (m *MsgUpdateVestingInfoResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgVestLiquid) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgVestLiquid: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgVestLiquid: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgVestLiquidResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgVestLiquidResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgVestLiquidResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/leveragelp/types/query.pb.gw.go b/x/leveragelp/types/query.pb.gw.go index 50bdd6320..4fee639c7 100644 --- a/x/leveragelp/types/query.pb.gw.go +++ b/x/leveragelp/types/query.pb.gw.go @@ -20,6 +20,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -30,6 +31,7 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage +var _ = metadata.Join func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq ParamsRequest @@ -640,12 +642,14 @@ func local_request_Query_MTP_0(ctx context.Context, marshaler runtime.Marshaler, // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -653,6 +657,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -666,6 +671,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_GetPositions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -673,6 +680,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_GetPositions_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -686,6 +694,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_GetPositionsByPool_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -693,6 +703,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_GetPositionsByPool_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -706,6 +717,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_GetStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -713,6 +726,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_GetStatus_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -726,6 +740,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_GetPositionsForAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -733,6 +749,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_GetPositionsForAddress_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -746,6 +763,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_GetWhitelist_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -753,6 +772,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_GetWhitelist_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -766,6 +786,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_IsWhitelisted_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -773,6 +795,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_IsWhitelisted_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -786,6 +809,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_Pool_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -793,6 +818,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Pool_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -806,6 +832,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_Pools_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -813,6 +841,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Pools_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -826,6 +855,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_MTP_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -833,6 +864,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_MTP_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) diff --git a/x/stablestake/types/query.pb.gw.go b/x/stablestake/types/query.pb.gw.go index 483a2d4fc..2517c62cf 100644 --- a/x/stablestake/types/query.pb.gw.go +++ b/x/stablestake/types/query.pb.gw.go @@ -20,6 +20,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -30,6 +31,7 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage +var _ = metadata.Join func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryParamsRequest @@ -52,12 +54,14 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -65,6 +69,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) diff --git a/x/tokenomics/types/query.pb.gw.go b/x/tokenomics/types/query.pb.gw.go index 43ca1c0ec..4bb565e48 100644 --- a/x/tokenomics/types/query.pb.gw.go +++ b/x/tokenomics/types/query.pb.gw.go @@ -20,6 +20,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -30,6 +31,7 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage +var _ = metadata.Join func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryParamsRequest @@ -272,12 +274,14 @@ func local_request_Query_TimeBasedInflationAll_0(ctx context.Context, marshaler // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -285,6 +289,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -298,6 +303,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_Airdrop_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -305,6 +312,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Airdrop_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -318,6 +326,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_AirdropAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -325,6 +335,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_AirdropAll_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -338,6 +349,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_GenesisInflation_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -345,6 +358,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_GenesisInflation_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -358,6 +372,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_TimeBasedInflation_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -365,6 +381,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_TimeBasedInflation_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -378,6 +395,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_TimeBasedInflationAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -385,6 +404,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_TimeBasedInflationAll_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) diff --git a/x/transferhook/types/query.pb.gw.go b/x/transferhook/types/query.pb.gw.go index d0791f7e3..ab4f8cf6e 100644 --- a/x/transferhook/types/query.pb.gw.go +++ b/x/transferhook/types/query.pb.gw.go @@ -20,6 +20,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -30,6 +31,7 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage +var _ = metadata.Join func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryParamsRequest @@ -52,12 +54,14 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -65,6 +69,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)