From dc296bcffa27aefa5a6d8c762657777fec2d7dda Mon Sep 17 00:00:00 2001 From: 170210 Date: Tue, 9 Apr 2024 19:41:35 +0900 Subject: [PATCH 01/17] feat: initial fswap module Signed-off-by: 170210 --- x/fswap/client/cli/query.go | 31 ++ x/fswap/client/cli/query_params.go | 34 ++ x/fswap/client/cli/tx.go | 36 ++ x/fswap/genesis.go | 24 + x/fswap/genesis_test.go | 29 ++ x/fswap/handler.go | 26 ++ x/fswap/keeper/grpc_query.go | 7 + x/fswap/keeper/grpc_query_params.go | 19 + x/fswap/keeper/grpc_query_params_test.go | 21 + x/fswap/keeper/keeper.go | 46 ++ x/fswap/keeper/msg_server.go | 17 + x/fswap/keeper/msg_server_test.go | 16 + x/fswap/keeper/params.go | 16 + x/fswap/keeper/params_test.go | 18 + x/fswap/module.go | 175 ++++++++ x/fswap/module_simulation.go | 64 +++ x/fswap/simulation/simap.go | 15 + x/fswap/types/codec.go | 23 + x/fswap/types/errors.go | 12 + x/fswap/types/expected_keepers.go | 18 + x/fswap/types/genesis.go | 24 + x/fswap/types/genesis.pb.go | 319 ++++++++++++++ x/fswap/types/genesis_test.go | 40 ++ x/fswap/types/keys.go | 22 + x/fswap/types/params.go | 39 ++ x/fswap/types/params.pb.go | 262 +++++++++++ x/fswap/types/query.pb.go | 536 +++++++++++++++++++++++ x/fswap/types/query.pb.gw.go | 153 +++++++ x/fswap/types/tx.pb.go | 79 ++++ x/fswap/types/types.go | 1 + 30 files changed, 2122 insertions(+) create mode 100644 x/fswap/client/cli/query.go create mode 100644 x/fswap/client/cli/query_params.go create mode 100644 x/fswap/client/cli/tx.go create mode 100644 x/fswap/genesis.go create mode 100644 x/fswap/genesis_test.go create mode 100644 x/fswap/handler.go create mode 100644 x/fswap/keeper/grpc_query.go create mode 100644 x/fswap/keeper/grpc_query_params.go create mode 100644 x/fswap/keeper/grpc_query_params_test.go create mode 100644 x/fswap/keeper/keeper.go create mode 100644 x/fswap/keeper/msg_server.go create mode 100644 x/fswap/keeper/msg_server_test.go create mode 100644 x/fswap/keeper/params.go create mode 100644 x/fswap/keeper/params_test.go create mode 100644 x/fswap/module.go create mode 100644 x/fswap/module_simulation.go create mode 100644 x/fswap/simulation/simap.go create mode 100644 x/fswap/types/codec.go create mode 100644 x/fswap/types/errors.go create mode 100644 x/fswap/types/expected_keepers.go create mode 100644 x/fswap/types/genesis.go create mode 100644 x/fswap/types/genesis.pb.go create mode 100644 x/fswap/types/genesis_test.go create mode 100644 x/fswap/types/keys.go create mode 100644 x/fswap/types/params.go create mode 100644 x/fswap/types/params.pb.go create mode 100644 x/fswap/types/query.pb.go create mode 100644 x/fswap/types/query.pb.gw.go create mode 100644 x/fswap/types/tx.pb.go create mode 100644 x/fswap/types/types.go diff --git a/x/fswap/client/cli/query.go b/x/fswap/client/cli/query.go new file mode 100644 index 0000000000..b0229db9b7 --- /dev/null +++ b/x/fswap/client/cli/query.go @@ -0,0 +1,31 @@ +package cli + +import ( + "fmt" + // "strings" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + // "github.com/cosmos/cosmos-sdk/client/flags" + // sdk "github.com/cosmos/cosmos-sdk/types" + + "fswap/x/fswap/types" +) + +// GetQueryCmd returns the cli query commands for this module +func GetQueryCmd(queryRoute string) *cobra.Command { + // Group fswap queries under a subcommand + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand(CmdQueryParams()) + // this line is used by starport scaffolding # 1 + + return cmd +} diff --git a/x/fswap/client/cli/query_params.go b/x/fswap/client/cli/query_params.go new file mode 100644 index 0000000000..bb00a2825d --- /dev/null +++ b/x/fswap/client/cli/query_params.go @@ -0,0 +1,34 @@ +package cli + +import ( + "context" + + "fswap/x/fswap/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" +) + +func CmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "shows the parameters of the module", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/fswap/client/cli/tx.go b/x/fswap/client/cli/tx.go new file mode 100644 index 0000000000..70674b4038 --- /dev/null +++ b/x/fswap/client/cli/tx.go @@ -0,0 +1,36 @@ +package cli + +import ( + "fmt" + "time" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + // "github.com/cosmos/cosmos-sdk/client/flags" + "fswap/x/fswap/types" +) + +var ( + DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds()) +) + +const ( + flagPacketTimeoutTimestamp = "packet-timeout-timestamp" + listSeparator = "," +) + +// GetTxCmd returns the transaction commands for this module +func GetTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + // this line is used by starport scaffolding # 1 + + return cmd +} diff --git a/x/fswap/genesis.go b/x/fswap/genesis.go new file mode 100644 index 0000000000..8714bf3669 --- /dev/null +++ b/x/fswap/genesis.go @@ -0,0 +1,24 @@ +package fswap + +import ( + "fswap/x/fswap/keeper" + "fswap/x/fswap/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// InitGenesis initializes the capability module's state from a provided genesis +// state. +func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + // this line is used by starport scaffolding # genesis/module/init + k.SetParams(ctx, genState.Params) +} + +// ExportGenesis returns the capability module's exported genesis. +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { + genesis := types.DefaultGenesis() + genesis.Params = k.GetParams(ctx) + + // this line is used by starport scaffolding # genesis/module/export + + return genesis +} diff --git a/x/fswap/genesis_test.go b/x/fswap/genesis_test.go new file mode 100644 index 0000000000..d7bc05b209 --- /dev/null +++ b/x/fswap/genesis_test.go @@ -0,0 +1,29 @@ +package fswap_test + +import ( + "testing" + + keepertest "fswap/testutil/keeper" + "fswap/testutil/nullify" + "fswap/x/fswap" + "fswap/x/fswap/types" + "github.com/stretchr/testify/require" +) + +func TestGenesis(t *testing.T) { + genesisState := types.GenesisState{ + Params: types.DefaultParams(), + + // this line is used by starport scaffolding # genesis/test/state + } + + k, ctx := keepertest.FswapKeeper(t) + fswap.InitGenesis(ctx, *k, genesisState) + got := fswap.ExportGenesis(ctx, *k) + require.NotNil(t, got) + + nullify.Fill(&genesisState) + nullify.Fill(got) + + // this line is used by starport scaffolding # genesis/test/assert +} diff --git a/x/fswap/handler.go b/x/fswap/handler.go new file mode 100644 index 0000000000..59ab995f07 --- /dev/null +++ b/x/fswap/handler.go @@ -0,0 +1,26 @@ +package fswap + +import ( + "fmt" + + "fswap/x/fswap/keeper" + "fswap/x/fswap/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// NewHandler ... +func NewHandler(k keeper.Keeper) sdk.Handler { + // this line is used by starport scaffolding # handler/msgServer + + return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { + ctx = ctx.WithEventManager(sdk.NewEventManager()) + + switch msg := msg.(type) { + // this line is used by starport scaffolding # 1 + default: + errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) + return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) + } + } +} diff --git a/x/fswap/keeper/grpc_query.go b/x/fswap/keeper/grpc_query.go new file mode 100644 index 0000000000..e9a7a672d7 --- /dev/null +++ b/x/fswap/keeper/grpc_query.go @@ -0,0 +1,7 @@ +package keeper + +import ( + "fswap/x/fswap/types" +) + +var _ types.QueryServer = Keeper{} diff --git a/x/fswap/keeper/grpc_query_params.go b/x/fswap/keeper/grpc_query_params.go new file mode 100644 index 0000000000..c347634d01 --- /dev/null +++ b/x/fswap/keeper/grpc_query_params.go @@ -0,0 +1,19 @@ +package keeper + +import ( + "context" + + "fswap/x/fswap/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(c) + + return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil +} diff --git a/x/fswap/keeper/grpc_query_params_test.go b/x/fswap/keeper/grpc_query_params_test.go new file mode 100644 index 0000000000..4f3bd4b7d5 --- /dev/null +++ b/x/fswap/keeper/grpc_query_params_test.go @@ -0,0 +1,21 @@ +package keeper_test + +import ( + "testing" + + testkeeper "fswap/testutil/keeper" + "fswap/x/fswap/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" +) + +func TestParamsQuery(t *testing.T) { + keeper, ctx := testkeeper.FswapKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + params := types.DefaultParams() + keeper.SetParams(ctx, params) + + response, err := keeper.Params(wctx, &types.QueryParamsRequest{}) + require.NoError(t, err) + require.Equal(t, &types.QueryParamsResponse{Params: params}, response) +} diff --git a/x/fswap/keeper/keeper.go b/x/fswap/keeper/keeper.go new file mode 100644 index 0000000000..af02247575 --- /dev/null +++ b/x/fswap/keeper/keeper.go @@ -0,0 +1,46 @@ +package keeper + +import ( + "fmt" + + "github.com/tendermint/tendermint/libs/log" + + "fswap/x/fswap/types" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +type ( + Keeper struct { + cdc codec.BinaryCodec + storeKey sdk.StoreKey + memKey sdk.StoreKey + paramstore paramtypes.Subspace + } +) + +func NewKeeper( + cdc codec.BinaryCodec, + storeKey, + memKey sdk.StoreKey, + ps paramtypes.Subspace, + +) *Keeper { + // set KeyTable if it has not already been set + if !ps.HasKeyTable() { + ps = ps.WithKeyTable(types.ParamKeyTable()) + } + + return &Keeper{ + + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + paramstore: ps, + } +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} diff --git a/x/fswap/keeper/msg_server.go b/x/fswap/keeper/msg_server.go new file mode 100644 index 0000000000..a02d098916 --- /dev/null +++ b/x/fswap/keeper/msg_server.go @@ -0,0 +1,17 @@ +package keeper + +import ( + "fswap/x/fswap/types" +) + +type msgServer struct { + Keeper +} + +// NewMsgServerImpl returns an implementation of the MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +var _ types.MsgServer = msgServer{} diff --git a/x/fswap/keeper/msg_server_test.go b/x/fswap/keeper/msg_server_test.go new file mode 100644 index 0000000000..cde82fc3a3 --- /dev/null +++ b/x/fswap/keeper/msg_server_test.go @@ -0,0 +1,16 @@ +package keeper_test + +import ( + "context" + "testing" + + keepertest "fswap/testutil/keeper" + "fswap/x/fswap/keeper" + "fswap/x/fswap/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { + k, ctx := keepertest.FswapKeeper(t) + return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx) +} diff --git a/x/fswap/keeper/params.go b/x/fswap/keeper/params.go new file mode 100644 index 0000000000..cb34d9f0f4 --- /dev/null +++ b/x/fswap/keeper/params.go @@ -0,0 +1,16 @@ +package keeper + +import ( + "fswap/x/fswap/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// GetParams get all parameters as types.Params +func (k Keeper) GetParams(ctx sdk.Context) types.Params { + return types.NewParams() +} + +// SetParams set the params +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + k.paramstore.SetParamSet(ctx, ¶ms) +} diff --git a/x/fswap/keeper/params_test.go b/x/fswap/keeper/params_test.go new file mode 100644 index 0000000000..413e84c71b --- /dev/null +++ b/x/fswap/keeper/params_test.go @@ -0,0 +1,18 @@ +package keeper_test + +import ( + "testing" + + testkeeper "fswap/testutil/keeper" + "fswap/x/fswap/types" + "github.com/stretchr/testify/require" +) + +func TestGetParams(t *testing.T) { + k, ctx := testkeeper.FswapKeeper(t) + params := types.DefaultParams() + + k.SetParams(ctx, params) + + require.EqualValues(t, params, k.GetParams(ctx)) +} diff --git a/x/fswap/module.go b/x/fswap/module.go new file mode 100644 index 0000000000..483624049f --- /dev/null +++ b/x/fswap/module.go @@ -0,0 +1,175 @@ +package fswap + +import ( + "encoding/json" + "fmt" + // this line is used by starport scaffolding # 1 + + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + abci "github.com/tendermint/tendermint/abci/types" + + "fswap/x/fswap/client/cli" + "fswap/x/fswap/keeper" + "fswap/x/fswap/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface for the capability module. +type AppModuleBasic struct { + cdc codec.BinaryCodec +} + +func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the capability module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) { + types.RegisterCodec(cdc) +} + +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterCodec(cdc) +} + +// RegisterInterfaces registers the module's interface types +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns the capability module's default genesis state. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis performs genesis state validation for the capability module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + return genState.Validate() +} + +// RegisterRESTRoutes registers the capability module's REST service handlers. +func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + // this line is used by starport scaffolding # 2 +} + +// GetTxCmd returns the capability module's root tx command. +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns the capability module's root query command. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd(types.StoreKey) +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface for the capability module. +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper + accountKeeper types.AccountKeeper + bankKeeper types.BankKeeper +} + +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, + accountKeeper types.AccountKeeper, + bankKeeper types.BankKeeper, +) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + accountKeeper: accountKeeper, + bankKeeper: bankKeeper, + } +} + +// Name returns the capability module's name. +func (am AppModule) Name() string { + return am.AppModuleBasic.Name() +} + +// Route returns the capability module's message routing key. +func (am AppModule) Route() sdk.Route { + return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper)) +} + +// QuerierRoute returns the capability module's query routing key. +func (AppModule) QuerierRoute() string { return types.QuerierRoute } + +// LegacyQuerierHandler returns the capability module's Querier. +func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { + return nil +} + +// RegisterServices registers a GRPC query service to respond to the +// module-specific GRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +// RegisterInvariants registers the capability module's invariants. +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the capability module's genesis initialization It returns +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { + var genState types.GenesisState + // Initialize global index to index in genesis state + cdc.MustUnmarshalJSON(gs, &genState) + + InitGenesis(ctx, am.keeper, genState) + + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the capability module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(genState) +} + +// ConsensusVersion implements ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return 2 } + +// BeginBlock executes all ABCI BeginBlock logic respective to the capability module. +func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} + +// EndBlock executes all ABCI EndBlock logic respective to the capability module. It +// returns no validator updates. +func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} diff --git a/x/fswap/module_simulation.go b/x/fswap/module_simulation.go new file mode 100644 index 0000000000..ddc328b113 --- /dev/null +++ b/x/fswap/module_simulation.go @@ -0,0 +1,64 @@ +package fswap + +import ( + "math/rand" + + "fswap/testutil/sample" + fswapsimulation "fswap/x/fswap/simulation" + "fswap/x/fswap/types" + "github.com/cosmos/cosmos-sdk/baseapp" + simappparams "github.com/cosmos/cosmos-sdk/simapp/params" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/simulation" +) + +// avoid unused import issue +var ( + _ = sample.AccAddress + _ = fswapsimulation.FindAccount + _ = simappparams.StakePerAccount + _ = simulation.MsgEntryKind + _ = baseapp.Paramspace +) + +const ( +// this line is used by starport scaffolding # simapp/module/const +) + +// GenerateGenesisState creates a randomized GenState of the module +func (AppModule) GenerateGenesisState(simState *module.SimulationState) { + accs := make([]string, len(simState.Accounts)) + for i, acc := range simState.Accounts { + accs[i] = acc.Address.String() + } + fswapGenesis := types.GenesisState{ + Params: types.DefaultParams(), + // this line is used by starport scaffolding # simapp/module/genesisState + } + simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&fswapGenesis) +} + +// ProposalContents doesn't return any content functions for governance proposals +func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { + return nil +} + +// RandomizedParams creates randomized param changes for the simulator +func (am AppModule) RandomizedParams(_ *rand.Rand) []simtypes.ParamChange { + + return []simtypes.ParamChange{} +} + +// RegisterStoreDecoder registers a decoder +func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {} + +// WeightedOperations returns the all the gov module operations with their respective weights. +func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { + operations := make([]simtypes.WeightedOperation, 0) + + // this line is used by starport scaffolding # simapp/module/operation + + return operations +} diff --git a/x/fswap/simulation/simap.go b/x/fswap/simulation/simap.go new file mode 100644 index 0000000000..92c437c0d1 --- /dev/null +++ b/x/fswap/simulation/simap.go @@ -0,0 +1,15 @@ +package simulation + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" +) + +// FindAccount find a specific address from an account list +func FindAccount(accs []simtypes.Account, address string) (simtypes.Account, bool) { + creator, err := sdk.AccAddressFromBech32(address) + if err != nil { + panic(err) + } + return simtypes.FindAccount(accs, creator) +} diff --git a/x/fswap/types/codec.go b/x/fswap/types/codec.go new file mode 100644 index 0000000000..844157a87f --- /dev/null +++ b/x/fswap/types/codec.go @@ -0,0 +1,23 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + // this line is used by starport scaffolding # 1 + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +func RegisterCodec(cdc *codec.LegacyAmino) { + // this line is used by starport scaffolding # 2 +} + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + // this line is used by starport scaffolding # 3 + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + Amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) +) diff --git a/x/fswap/types/errors.go b/x/fswap/types/errors.go new file mode 100644 index 0000000000..c01b82f5b3 --- /dev/null +++ b/x/fswap/types/errors.go @@ -0,0 +1,12 @@ +package types + +// DONTCOVER + +import ( + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// x/fswap module sentinel errors +var ( + ErrSample = sdkerrors.Register(ModuleName, 1100, "sample error") +) diff --git a/x/fswap/types/expected_keepers.go b/x/fswap/types/expected_keepers.go new file mode 100644 index 0000000000..6aa6e97781 --- /dev/null +++ b/x/fswap/types/expected_keepers.go @@ -0,0 +1,18 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/types" +) + +// AccountKeeper defines the expected account keeper used for simulations (noalias) +type AccountKeeper interface { + GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI + // Methods imported from account should be defined here +} + +// BankKeeper defines the expected interface needed to retrieve account balances. +type BankKeeper interface { + SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + // Methods imported from bank should be defined here +} diff --git a/x/fswap/types/genesis.go b/x/fswap/types/genesis.go new file mode 100644 index 0000000000..8df94bae23 --- /dev/null +++ b/x/fswap/types/genesis.go @@ -0,0 +1,24 @@ +package types + +import ( +// this line is used by starport scaffolding # genesis/types/import +) + +// DefaultIndex is the default capability global index +const DefaultIndex uint64 = 1 + +// DefaultGenesis returns the default Capability genesis state +func DefaultGenesis() *GenesisState { + return &GenesisState{ + // this line is used by starport scaffolding # genesis/types/default + Params: DefaultParams(), + } +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + // this line is used by starport scaffolding # genesis/types/validate + + return gs.Params.Validate() +} diff --git a/x/fswap/types/genesis.pb.go b/x/fswap/types/genesis.pb.go new file mode 100644 index 0000000000..b2f01d29c7 --- /dev/null +++ b/x/fswap/types/genesis.pb.go @@ -0,0 +1,319 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: fswap/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines the fswap module's genesis state. +type GenesisState struct { + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_12b6cdf66abb1efc, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "fswap.fswap.GenesisState") +} + +func init() { proto.RegisterFile("fswap/genesis.proto", fileDescriptor_12b6cdf66abb1efc) } + +var fileDescriptor_12b6cdf66abb1efc = []byte{ + // 162 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4e, 0x2b, 0x2e, 0x4f, + 0x2c, 0xd0, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, + 0xe2, 0x06, 0x0b, 0xea, 0x81, 0x49, 0x29, 0x91, 0xf4, 0xfc, 0xf4, 0x7c, 0xb0, 0xb8, 0x3e, 0x88, + 0x05, 0x51, 0x22, 0x25, 0x04, 0xd1, 0x57, 0x90, 0x58, 0x94, 0x98, 0x0b, 0xd5, 0xa6, 0xe4, 0xc8, + 0xc5, 0xe3, 0x0e, 0x31, 0x27, 0xb8, 0x24, 0xb1, 0x24, 0x55, 0xc8, 0x90, 0x8b, 0x0d, 0x22, 0x2f, + 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xac, 0x87, 0x64, 0xae, 0x5e, 0x00, 0x58, 0xca, 0x89, + 0xe5, 0xc4, 0x3d, 0x79, 0x86, 0x20, 0xa8, 0x42, 0x27, 0xdd, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, + 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, + 0x3c, 0x96, 0x63, 0x88, 0x82, 0x3a, 0xb4, 0x42, 0x1f, 0x42, 0x97, 0x54, 0x16, 0xa4, 0x16, 0x27, + 0xb1, 0x81, 0x2d, 0x36, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xc2, 0xe2, 0xad, 0xa6, 0xc6, 0x00, + 0x00, 0x00, +} + +func (m *GenesisState) 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 *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) 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 ErrIntOverflowGenesis + } + 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: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/fswap/types/genesis_test.go b/x/fswap/types/genesis_test.go new file mode 100644 index 0000000000..58341f8560 --- /dev/null +++ b/x/fswap/types/genesis_test.go @@ -0,0 +1,40 @@ +package types_test + +import ( + "testing" + + "fswap/x/fswap/types" + "github.com/stretchr/testify/require" +) + +func TestGenesisState_Validate(t *testing.T) { + for _, tc := range []struct { + desc string + genState *types.GenesisState + valid bool + }{ + { + desc: "default is valid", + genState: types.DefaultGenesis(), + valid: true, + }, + { + desc: "valid genesis state", + genState: &types.GenesisState{ + + // this line is used by starport scaffolding # types/genesis/validField + }, + valid: true, + }, + // this line is used by starport scaffolding # types/genesis/testcase + } { + t.Run(tc.desc, func(t *testing.T) { + err := tc.genState.Validate() + if tc.valid { + require.NoError(t, err) + } else { + require.Error(t, err) + } + }) + } +} diff --git a/x/fswap/types/keys.go b/x/fswap/types/keys.go new file mode 100644 index 0000000000..18047ccfb2 --- /dev/null +++ b/x/fswap/types/keys.go @@ -0,0 +1,22 @@ +package types + +const ( + // ModuleName defines the module name + ModuleName = "fswap" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey is the message route for slashing + RouterKey = ModuleName + + // QuerierRoute defines the module's query routing key + QuerierRoute = ModuleName + + // MemStoreKey defines the in-memory store key + MemStoreKey = "mem_fswap" +) + +func KeyPrefix(p string) []byte { + return []byte(p) +} diff --git a/x/fswap/types/params.go b/x/fswap/types/params.go new file mode 100644 index 0000000000..357196ad6a --- /dev/null +++ b/x/fswap/types/params.go @@ -0,0 +1,39 @@ +package types + +import ( + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "gopkg.in/yaml.v2" +) + +var _ paramtypes.ParamSet = (*Params)(nil) + +// ParamKeyTable the param key table for launch module +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +// NewParams creates a new Params instance +func NewParams() Params { + return Params{} +} + +// DefaultParams returns a default set of parameters +func DefaultParams() Params { + return NewParams() +} + +// ParamSetPairs get the params.ParamSet +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{} +} + +// Validate validates the set of params +func (p Params) Validate() error { + return nil +} + +// String implements the Stringer interface. +func (p Params) String() string { + out, _ := yaml.Marshal(p) + return string(out) +} diff --git a/x/fswap/types/params.pb.go b/x/fswap/types/params.pb.go new file mode 100644 index 0000000000..2542e6e13c --- /dev/null +++ b/x/fswap/types/params.pb.go @@ -0,0 +1,262 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: fswap/params.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Params defines the parameters for the module. +type Params struct { +} + +func (m *Params) Reset() { *m = Params{} } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_f82e84990da21041, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.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 *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func init() { + proto.RegisterType((*Params)(nil), "fswap.fswap.Params") +} + +func init() { proto.RegisterFile("fswap/params.proto", fileDescriptor_f82e84990da21041) } + +var fileDescriptor_f82e84990da21041 = []byte{ + // 122 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4a, 0x2b, 0x2e, 0x4f, + 0x2c, 0xd0, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, + 0x06, 0x8b, 0xe9, 0x81, 0x49, 0x29, 0x91, 0xf4, 0xfc, 0xf4, 0x7c, 0xb0, 0xb8, 0x3e, 0x88, 0x05, + 0x51, 0xa2, 0xc4, 0xc7, 0xc5, 0x16, 0x00, 0xd6, 0x62, 0xc5, 0x32, 0x63, 0x81, 0x3c, 0x83, 0x93, + 0xee, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, + 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x09, 0x43, 0x2c, 0xa8, 0xd0, + 0x87, 0xd0, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0x53, 0x8c, 0x01, 0x01, 0x00, 0x00, + 0xff, 0xff, 0x1f, 0xa9, 0xea, 0x49, 0x7e, 0x00, 0x00, 0x00, +} + +func (m *Params) 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 *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintParams(dAtA []byte, offset int, v uint64) int { + offset -= sovParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozParams(x uint64) (n int) { + return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) 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 ErrIntOverflowParams + } + 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: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipParams(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/fswap/types/query.pb.go b/x/fswap/types/query.pb.go new file mode 100644 index 0000000000..a0695ca73f --- /dev/null +++ b/x/fswap/types/query.pb.go @@ -0,0 +1,536 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: fswap/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryParamsRequest is request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_4b0a2b30d5573837, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.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 *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is response type for the Query/Params RPC method. +type QueryParamsResponse struct { + // params holds all the parameters of this module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4b0a2b30d5573837, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.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 *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "fswap.fswap.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "fswap.fswap.QueryParamsResponse") +} + +func init() { proto.RegisterFile("fswap/query.proto", fileDescriptor_4b0a2b30d5573837) } + +var fileDescriptor_4b0a2b30d5573837 = []byte{ + // 274 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x90, 0x4f, 0x4b, 0xc3, 0x30, + 0x18, 0x87, 0x5b, 0xd1, 0x1e, 0xb2, 0x93, 0xe9, 0x04, 0xa9, 0x92, 0x8d, 0x9e, 0x44, 0xb0, 0xa1, + 0xf3, 0x1b, 0xec, 0xe4, 0x51, 0x77, 0xf4, 0x96, 0x4a, 0x8c, 0x05, 0x97, 0x37, 0x6d, 0x32, 0x75, + 0x57, 0x3f, 0x81, 0xe0, 0x97, 0xda, 0x71, 0xe0, 0xc5, 0x93, 0x48, 0xeb, 0x07, 0x91, 0xe5, 0xcd, + 0x61, 0x43, 0xbc, 0x84, 0xf0, 0xcb, 0xf3, 0xbc, 0x7f, 0x42, 0x0e, 0xef, 0xed, 0xb3, 0x30, 0xbc, + 0x59, 0xc8, 0x76, 0x59, 0x98, 0x16, 0x1c, 0xd0, 0x81, 0x8f, 0x0a, 0x7f, 0x66, 0x43, 0x05, 0x0a, + 0x7c, 0xce, 0x37, 0x37, 0x44, 0xb2, 0x53, 0x05, 0xa0, 0x1e, 0x25, 0x17, 0xa6, 0xe6, 0x42, 0x6b, + 0x70, 0xc2, 0xd5, 0xa0, 0x6d, 0x78, 0x3d, 0xbf, 0x03, 0x3b, 0x07, 0xcb, 0x2b, 0x61, 0x25, 0x56, + 0xe6, 0x4f, 0x65, 0x25, 0x9d, 0x28, 0xb9, 0x11, 0xaa, 0xd6, 0x1e, 0x0e, 0x2c, 0xc5, 0xfe, 0x46, + 0xb4, 0x62, 0x1e, 0xfc, 0x7c, 0x48, 0xe8, 0xcd, 0xc6, 0xba, 0xf6, 0xe1, 0x4c, 0x36, 0x0b, 0x69, + 0x5d, 0x7e, 0x45, 0xd2, 0x9d, 0xd4, 0x1a, 0xd0, 0x56, 0xd2, 0x92, 0x24, 0x28, 0x1f, 0xc7, 0xe3, + 0xf8, 0x6c, 0x30, 0x49, 0x8b, 0xad, 0xf1, 0x0b, 0x84, 0xa7, 0xfb, 0xab, 0xaf, 0x51, 0x34, 0x0b, + 0xe0, 0xa4, 0x21, 0x07, 0xbe, 0x12, 0x7d, 0x20, 0x09, 0x02, 0x74, 0xb4, 0x63, 0xfd, 0xed, 0x9e, + 0x8d, 0xff, 0x07, 0x70, 0x90, 0xfc, 0xe4, 0xf5, 0xe3, 0xe7, 0x7d, 0xef, 0x88, 0xa6, 0x1c, 0x57, + 0xda, 0x5e, 0x6c, 0x7a, 0xb1, 0xea, 0x58, 0xbc, 0xee, 0x58, 0xfc, 0xdd, 0xb1, 0xf8, 0xad, 0x67, + 0xd1, 0xba, 0x67, 0xd1, 0x67, 0xcf, 0xa2, 0xdb, 0x14, 0xb9, 0x97, 0xc0, 0xbb, 0xa5, 0x91, 0xb6, + 0x4a, 0xfc, 0x47, 0x5c, 0xfe, 0x06, 0x00, 0x00, 0xff, 0xff, 0xea, 0x39, 0x81, 0xbe, 0x9e, 0x01, + 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Parameters queries the parameters of the module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/fswap.fswap.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Parameters queries the parameters of the module. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/fswap.fswap.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "fswap.fswap.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "fswap/query.proto", +} + +func (m *QueryParamsRequest) 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 *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) 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 *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) 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 ErrIntOverflowQuery + } + 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: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) 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 ErrIntOverflowQuery + } + 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: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/fswap/types/query.pb.gw.go b/x/fswap/types/query.pb.gw.go new file mode 100644 index 0000000000..018e3852ec --- /dev/null +++ b/x/fswap/types/query.pb.gw.go @@ -0,0 +1,153 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: fswap/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +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 + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +// 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 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 { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + 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) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) 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() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 0, 2, 1}, []string{"fswap", "params"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage +) diff --git a/x/fswap/types/tx.pb.go b/x/fswap/types/tx.pb.go new file mode 100644 index 0000000000..84085d0c71 --- /dev/null +++ b/x/fswap/types/tx.pb.go @@ -0,0 +1,79 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: fswap/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + grpc "google.golang.org/grpc" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +func init() { proto.RegisterFile("fswap/tx.proto", fileDescriptor_53fb6877925c5245) } + +var fileDescriptor_53fb6877925c5245 = []byte{ + // 98 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4b, 0x2b, 0x2e, 0x4f, + 0x2c, 0xd0, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x06, 0xf3, 0xf5, 0xc0, + 0xa4, 0x11, 0x2b, 0x17, 0xb3, 0x6f, 0x71, 0xba, 0x93, 0xee, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, + 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, + 0x1e, 0xcb, 0x31, 0x44, 0x09, 0x43, 0x74, 0x57, 0xe8, 0x43, 0x4d, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, + 0x62, 0x03, 0x9b, 0x64, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x2c, 0xe5, 0xc3, 0x35, 0x5b, 0x00, + 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "fswap.fswap.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{}, + Metadata: "fswap/tx.proto", +} diff --git a/x/fswap/types/types.go b/x/fswap/types/types.go new file mode 100644 index 0000000000..ab1254f4c2 --- /dev/null +++ b/x/fswap/types/types.go @@ -0,0 +1 @@ +package types From a1fec2acf4af5244c9476d4ad0732153da772c31 Mon Sep 17 00:00:00 2001 From: 170210 Date: Tue, 9 Apr 2024 19:54:30 +0900 Subject: [PATCH 02/17] chore: correct dependencies Signed-off-by: 170210 --- x/fswap/client/cli/query.go | 8 +- x/fswap/client/cli/query_params.go | 7 +- x/fswap/client/cli/tx.go | 6 +- x/fswap/genesis.go | 7 +- x/fswap/genesis_test.go | 45 +++++----- x/fswap/handler.go | 9 +- x/fswap/keeper/grpc_query.go | 2 +- x/fswap/keeper/grpc_query_params.go | 5 +- x/fswap/keeper/grpc_query_params_test.go | 35 ++++---- x/fswap/keeper/keeper.go | 9 +- x/fswap/keeper/msg_server.go | 2 +- x/fswap/keeper/msg_server_test.go | 17 +++- x/fswap/keeper/params.go | 5 +- x/fswap/keeper/params_test.go | 5 +- x/fswap/keeper/query_params_test.go | 23 +++++ x/fswap/module.go | 18 ++-- x/fswap/module_simulation.go | 106 ++++++++++++----------- x/fswap/simulation/simap.go | 4 +- x/fswap/types/codec.go | 7 +- x/fswap/types/errors.go | 2 +- x/fswap/types/expected_keepers.go | 4 +- x/fswap/types/genesis_test.go | 2 +- x/fswap/types/params.go | 2 +- x/fswap/types/query.pb.go | 2 +- 24 files changed, 189 insertions(+), 143 deletions(-) create mode 100644 x/fswap/keeper/query_params_test.go diff --git a/x/fswap/client/cli/query.go b/x/fswap/client/cli/query.go index b0229db9b7..eb3ba21181 100644 --- a/x/fswap/client/cli/query.go +++ b/x/fswap/client/cli/query.go @@ -6,11 +6,11 @@ import ( "github.com/spf13/cobra" - "github.com/cosmos/cosmos-sdk/client" - // "github.com/cosmos/cosmos-sdk/client/flags" - // sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/Finschia/finschia-sdk/client" + // "github.com/Finschia/finschia-sdk/client/flags" + // sdk "github.com/Finschia/finschia-sdk/types" - "fswap/x/fswap/types" + "github.com/Finschia/finschia-sdk/x/fswap/types" ) // GetQueryCmd returns the cli query commands for this module diff --git a/x/fswap/client/cli/query_params.go b/x/fswap/client/cli/query_params.go index bb00a2825d..208aff3327 100644 --- a/x/fswap/client/cli/query_params.go +++ b/x/fswap/client/cli/query_params.go @@ -3,9 +3,10 @@ package cli import ( "context" - "fswap/x/fswap/types" - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/Finschia/finschia-sdk/x/fswap/types" + + "github.com/Finschia/finschia-sdk/client" + "github.com/Finschia/finschia-sdk/client/flags" "github.com/spf13/cobra" ) diff --git a/x/fswap/client/cli/tx.go b/x/fswap/client/cli/tx.go index 70674b4038..87e9ced900 100644 --- a/x/fswap/client/cli/tx.go +++ b/x/fswap/client/cli/tx.go @@ -6,9 +6,9 @@ import ( "github.com/spf13/cobra" - "github.com/cosmos/cosmos-sdk/client" - // "github.com/cosmos/cosmos-sdk/client/flags" - "fswap/x/fswap/types" + "github.com/Finschia/finschia-sdk/client" + // "github.com/Finschia/finschia-sdk/client/flags" + "github.com/Finschia/finschia-sdk/x/fswap/types" ) var ( diff --git a/x/fswap/genesis.go b/x/fswap/genesis.go index 8714bf3669..728b0e8d3c 100644 --- a/x/fswap/genesis.go +++ b/x/fswap/genesis.go @@ -1,9 +1,10 @@ package fswap import ( - "fswap/x/fswap/keeper" - "fswap/x/fswap/types" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/Finschia/finschia-sdk/x/fswap/keeper" + "github.com/Finschia/finschia-sdk/x/fswap/types" + + sdk "github.com/Finschia/finschia-sdk/types" ) // InitGenesis initializes the capability module's state from a provided genesis diff --git a/x/fswap/genesis_test.go b/x/fswap/genesis_test.go index d7bc05b209..0178a1f0e3 100644 --- a/x/fswap/genesis_test.go +++ b/x/fswap/genesis_test.go @@ -1,29 +1,30 @@ -package fswap_test +// package fswap_test -import ( - "testing" +// import ( +// "testing" - keepertest "fswap/testutil/keeper" - "fswap/testutil/nullify" - "fswap/x/fswap" - "fswap/x/fswap/types" - "github.com/stretchr/testify/require" -) +// keepertest "github.com/Finschia/finschia-sdk/testutil/keeper" +// "github.com/Finschia/finschia-sdk/testutil/nullify" -func TestGenesis(t *testing.T) { - genesisState := types.GenesisState{ - Params: types.DefaultParams(), +// "github.com/Finschia/finschia-sdk/x/fswap" +// "github.com/Finschia/finschia-sdk/x/fswap/types" +// "github.com/stretchr/testify/require" +// ) - // this line is used by starport scaffolding # genesis/test/state - } +// func TestGenesis(t *testing.T) { +// genesisState := types.GenesisState{ +// Params: types.DefaultParams(), - k, ctx := keepertest.FswapKeeper(t) - fswap.InitGenesis(ctx, *k, genesisState) - got := fswap.ExportGenesis(ctx, *k) - require.NotNil(t, got) +// // this line is used by starport scaffolding # genesis/test/state +// } - nullify.Fill(&genesisState) - nullify.Fill(got) +// k, ctx := keepertest.FswapKeeper(t) +// fswap.InitGenesis(ctx, *k, genesisState) +// got := fswap.ExportGenesis(ctx, *k) +// require.NotNil(t, got) - // this line is used by starport scaffolding # genesis/test/assert -} +// nullify.Fill(&genesisState) +// nullify.Fill(got) + +// // this line is used by starport scaffolding # genesis/test/assert +// } diff --git a/x/fswap/handler.go b/x/fswap/handler.go index 59ab995f07..8a1ab99713 100644 --- a/x/fswap/handler.go +++ b/x/fswap/handler.go @@ -3,10 +3,11 @@ package fswap import ( "fmt" - "fswap/x/fswap/keeper" - "fswap/x/fswap/types" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/Finschia/finschia-sdk/x/fswap/keeper" + "github.com/Finschia/finschia-sdk/x/fswap/types" + + sdk "github.com/Finschia/finschia-sdk/types" + sdkerrors "github.com/Finschia/finschia-sdk/types/errors" ) // NewHandler ... diff --git a/x/fswap/keeper/grpc_query.go b/x/fswap/keeper/grpc_query.go index e9a7a672d7..5f6ce68ab3 100644 --- a/x/fswap/keeper/grpc_query.go +++ b/x/fswap/keeper/grpc_query.go @@ -1,7 +1,7 @@ package keeper import ( - "fswap/x/fswap/types" + "github.com/Finschia/finschia-sdk/x/fswap/types" ) var _ types.QueryServer = Keeper{} diff --git a/x/fswap/keeper/grpc_query_params.go b/x/fswap/keeper/grpc_query_params.go index c347634d01..c3f9a1f7af 100644 --- a/x/fswap/keeper/grpc_query_params.go +++ b/x/fswap/keeper/grpc_query_params.go @@ -3,8 +3,9 @@ package keeper import ( "context" - "fswap/x/fswap/types" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/Finschia/finschia-sdk/x/fswap/types" + + sdk "github.com/Finschia/finschia-sdk/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) diff --git a/x/fswap/keeper/grpc_query_params_test.go b/x/fswap/keeper/grpc_query_params_test.go index 4f3bd4b7d5..6deca9b7c1 100644 --- a/x/fswap/keeper/grpc_query_params_test.go +++ b/x/fswap/keeper/grpc_query_params_test.go @@ -1,21 +1,22 @@ -package keeper_test +// package keeper_test -import ( - "testing" +// import ( +// "testing" - testkeeper "fswap/testutil/keeper" - "fswap/x/fswap/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" -) +// "github.com/Finschia/finschia-sdk/x/fswap/types" -func TestParamsQuery(t *testing.T) { - keeper, ctx := testkeeper.FswapKeeper(t) - wctx := sdk.WrapSDKContext(ctx) - params := types.DefaultParams() - keeper.SetParams(ctx, params) +// testkeeper "github.com/Finschia/finschia-sdk/testutil/keeper" +// sdk "github.com/Finschia/finschia-sdk/types" +// "github.com/stretchr/testify/require" +// ) - response, err := keeper.Params(wctx, &types.QueryParamsRequest{}) - require.NoError(t, err) - require.Equal(t, &types.QueryParamsResponse{Params: params}, response) -} +// func TestParamsQuery(t *testing.T) { +// keeper, ctx := testkeeper.FswapKeeper(t) +// wctx := sdk.WrapSDKContext(ctx) +// params := types.DefaultParams() +// keeper.SetParams(ctx, params) + +// response, err := keeper.Params(wctx, &types.QueryParamsRequest{}) +// require.NoError(t, err) +// require.Equal(t, &types.QueryParamsResponse{Params: params}, response) +// } diff --git a/x/fswap/keeper/keeper.go b/x/fswap/keeper/keeper.go index af02247575..5c6799bd3e 100644 --- a/x/fswap/keeper/keeper.go +++ b/x/fswap/keeper/keeper.go @@ -5,10 +5,11 @@ import ( "github.com/tendermint/tendermint/libs/log" - "fswap/x/fswap/types" - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/Finschia/finschia-sdk/x/fswap/types" + + "github.com/Finschia/finschia-sdk/codec" + sdk "github.com/Finschia/finschia-sdk/types" + paramtypes "github.com/Finschia/finschia-sdk/x/params/types" ) type ( diff --git a/x/fswap/keeper/msg_server.go b/x/fswap/keeper/msg_server.go index a02d098916..b9b4b1fa6c 100644 --- a/x/fswap/keeper/msg_server.go +++ b/x/fswap/keeper/msg_server.go @@ -1,7 +1,7 @@ package keeper import ( - "fswap/x/fswap/types" + "github.com/Finschia/finschia-sdk/x/fswap/types" ) type msgServer struct { diff --git a/x/fswap/keeper/msg_server_test.go b/x/fswap/keeper/msg_server_test.go index cde82fc3a3..5d36b52dae 100644 --- a/x/fswap/keeper/msg_server_test.go +++ b/x/fswap/keeper/msg_server_test.go @@ -4,13 +4,22 @@ import ( "context" "testing" - keepertest "fswap/testutil/keeper" - "fswap/x/fswap/keeper" - "fswap/x/fswap/types" - sdk "github.com/cosmos/cosmos-sdk/types" + keepertest "github.com/Finschia/finschia-sdk/testutil/keeper" + + "github.com/Finschia/finschia-sdk/x/fswap/keeper" + "github.com/Finschia/finschia-sdk/x/fswap/types" + + sdk "github.com/Finschia/finschia-sdk/types" + "github.com/stretchr/testify/require" ) func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { k, ctx := keepertest.FswapKeeper(t) return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx) } + +func TestMsgServer(t *testing.T) { + ms, ctx := setupMsgServer(t) + require.NotNil(t, ms) + require.NotNil(t, ctx) +} diff --git a/x/fswap/keeper/params.go b/x/fswap/keeper/params.go index cb34d9f0f4..829e69c5cc 100644 --- a/x/fswap/keeper/params.go +++ b/x/fswap/keeper/params.go @@ -1,8 +1,9 @@ package keeper import ( - "fswap/x/fswap/types" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/Finschia/finschia-sdk/x/fswap/types" + + sdk "github.com/Finschia/finschia-sdk/types" ) // GetParams get all parameters as types.Params diff --git a/x/fswap/keeper/params_test.go b/x/fswap/keeper/params_test.go index 413e84c71b..7d12962e16 100644 --- a/x/fswap/keeper/params_test.go +++ b/x/fswap/keeper/params_test.go @@ -3,8 +3,9 @@ package keeper_test import ( "testing" - testkeeper "fswap/testutil/keeper" - "fswap/x/fswap/types" + testkeeper "github.com/Finschia/finschia-sdk/testutil/keeper" + + "github.com/Finschia/finschia-sdk/x/fswap/types" "github.com/stretchr/testify/require" ) diff --git a/x/fswap/keeper/query_params_test.go b/x/fswap/keeper/query_params_test.go new file mode 100644 index 0000000000..db33ad7bbd --- /dev/null +++ b/x/fswap/keeper/query_params_test.go @@ -0,0 +1,23 @@ +// package keeper_test + +// import ( +// "testing" + +// testkeeper "github.com/Finschia/finschia-sdk/testutil/keeper" + +// "github.com/Finschia/finschia-sdk/x/fswap/types" + +// sdk "github.com/Finschia/finschia-sdk/types" +// "github.com/stretchr/testify/require" +// ) + +// func TestParamsQuery(t *testing.T) { +// keeper, ctx := testkeeper.FswapKeeper(t) +// wctx := sdk.WrapSDKContext(ctx) +// params := types.DefaultParams() +// keeper.SetParams(ctx, params) + +// response, err := keeper.Params(wctx, &types.QueryParamsRequest{}) +// require.NoError(t, err) +// require.Equal(t, &types.QueryParamsResponse{Params: params}, response) +// } diff --git a/x/fswap/module.go b/x/fswap/module.go index 483624049f..2ef4018b20 100644 --- a/x/fswap/module.go +++ b/x/fswap/module.go @@ -3,6 +3,7 @@ package fswap import ( "encoding/json" "fmt" + // this line is used by starport scaffolding # 1 "github.com/gorilla/mux" @@ -11,14 +12,15 @@ import ( abci "github.com/tendermint/tendermint/abci/types" - "fswap/x/fswap/client/cli" - "fswap/x/fswap/keeper" - "fswap/x/fswap/types" - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" - cdctypes "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" + "github.com/Finschia/finschia-sdk/x/fswap/client/cli" + "github.com/Finschia/finschia-sdk/x/fswap/keeper" + "github.com/Finschia/finschia-sdk/x/fswap/types" + + "github.com/Finschia/finschia-sdk/client" + "github.com/Finschia/finschia-sdk/codec" + cdctypes "github.com/Finschia/finschia-sdk/codec/types" + sdk "github.com/Finschia/finschia-sdk/types" + "github.com/Finschia/finschia-sdk/types/module" ) var ( diff --git a/x/fswap/module_simulation.go b/x/fswap/module_simulation.go index ddc328b113..098b0c432d 100644 --- a/x/fswap/module_simulation.go +++ b/x/fswap/module_simulation.go @@ -1,64 +1,66 @@ -package fswap +// package fswap -import ( - "math/rand" +// import ( +// "math/rand" - "fswap/testutil/sample" - fswapsimulation "fswap/x/fswap/simulation" - "fswap/x/fswap/types" - "github.com/cosmos/cosmos-sdk/baseapp" - simappparams "github.com/cosmos/cosmos-sdk/simapp/params" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/simulation" -) +// "github.com/Finschia/finschia-sdk/testutil/sample" -// avoid unused import issue -var ( - _ = sample.AccAddress - _ = fswapsimulation.FindAccount - _ = simappparams.StakePerAccount - _ = simulation.MsgEntryKind - _ = baseapp.Paramspace -) +// fswapsimulation "github.com/Finschia/finschia-sdk/x/fswap/simulation" +// "github.com/Finschia/finschia-sdk/x/fswap/types" -const ( -// this line is used by starport scaffolding # simapp/module/const -) +// "github.com/Finschia/finschia-sdk/baseapp" +// sdk "github.com/Finschia/finschia-sdk/types" +// "github.com/Finschia/finschia-sdk/types/module" +// simtypes "github.com/Finschia/finschia-sdk/types/simulation" +// "github.com/Finschia/finschia-sdk/x/simulation" +// ) -// GenerateGenesisState creates a randomized GenState of the module -func (AppModule) GenerateGenesisState(simState *module.SimulationState) { - accs := make([]string, len(simState.Accounts)) - for i, acc := range simState.Accounts { - accs[i] = acc.Address.String() - } - fswapGenesis := types.GenesisState{ - Params: types.DefaultParams(), - // this line is used by starport scaffolding # simapp/module/genesisState - } - simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&fswapGenesis) -} +// // avoid unused import issue +// var ( +// _ = sample.AccAddress +// _ = fswapsimulation.FindAccount +// _ = simulation.MsgEntryKind +// _ = baseapp.Paramspace +// _ = rand.Rand{} +// ) -// ProposalContents doesn't return any content functions for governance proposals -func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { - return nil -} +// const ( +// // this line is used by starport scaffolding # simapp/module/const +// ) -// RandomizedParams creates randomized param changes for the simulator -func (am AppModule) RandomizedParams(_ *rand.Rand) []simtypes.ParamChange { +// // GenerateGenesisState creates a randomized GenState of the module. +// func (AppModule) GenerateGenesisState(simState *module.SimulationState) { +// accs := make([]string, len(simState.Accounts)) +// for i, acc := range simState.Accounts { +// accs[i] = acc.Address.String() +// } +// fswapGenesis := types.GenesisState{ +// Params: types.DefaultParams(), +// // this line is used by starport scaffolding # simapp/module/genesisState +// } +// simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&fswapGenesis) +// } - return []simtypes.ParamChange{} -} +// // RegisterStoreDecoder registers a decoder. +// func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {} -// RegisterStoreDecoder registers a decoder -func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {} +// // ProposalContents doesn't return any content functions for governance proposals. +// func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { +// return nil +// } -// WeightedOperations returns the all the gov module operations with their respective weights. -func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { - operations := make([]simtypes.WeightedOperation, 0) +// // WeightedOperations returns the all the gov module operations with their respective weights. +// func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { +// operations := make([]simtypes.WeightedOperation, 0) - // this line is used by starport scaffolding # simapp/module/operation +// // this line is used by starport scaffolding # simapp/module/operation - return operations -} +// return operations +// } + +// // ProposalMsgs returns msgs used for governance proposals for simulations. +// func (am AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.WeightedProposalMsg { +// return []simtypes.WeightedProposalMsg{ +// // this line is used by starport scaffolding # simapp/module/OpMsg +// } +// } diff --git a/x/fswap/simulation/simap.go b/x/fswap/simulation/simap.go index 92c437c0d1..1b74bcd04c 100644 --- a/x/fswap/simulation/simap.go +++ b/x/fswap/simulation/simap.go @@ -1,8 +1,8 @@ package simulation import ( - sdk "github.com/cosmos/cosmos-sdk/types" - simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + sdk "github.com/Finschia/finschia-sdk/types" + simtypes "github.com/Finschia/finschia-sdk/types/simulation" ) // FindAccount find a specific address from an account list diff --git a/x/fswap/types/codec.go b/x/fswap/types/codec.go index 844157a87f..3d8bc224d0 100644 --- a/x/fswap/types/codec.go +++ b/x/fswap/types/codec.go @@ -1,10 +1,11 @@ package types import ( - "github.com/cosmos/cosmos-sdk/codec" - cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/Finschia/finschia-sdk/codec" + cdctypes "github.com/Finschia/finschia-sdk/codec/types" + // this line is used by starport scaffolding # 1 - "github.com/cosmos/cosmos-sdk/types/msgservice" + "github.com/Finschia/finschia-sdk/types/msgservice" ) func RegisterCodec(cdc *codec.LegacyAmino) { diff --git a/x/fswap/types/errors.go b/x/fswap/types/errors.go index c01b82f5b3..c0b627de88 100644 --- a/x/fswap/types/errors.go +++ b/x/fswap/types/errors.go @@ -3,7 +3,7 @@ package types // DONTCOVER import ( - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + sdkerrors "github.com/Finschia/finschia-sdk/types/errors" ) // x/fswap module sentinel errors diff --git a/x/fswap/types/expected_keepers.go b/x/fswap/types/expected_keepers.go index 6aa6e97781..6134a117d7 100644 --- a/x/fswap/types/expected_keepers.go +++ b/x/fswap/types/expected_keepers.go @@ -1,8 +1,8 @@ package types import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth/types" + sdk "github.com/Finschia/finschia-sdk/types" + "github.com/Finschia/finschia-sdk/x/auth/types" ) // AccountKeeper defines the expected account keeper used for simulations (noalias) diff --git a/x/fswap/types/genesis_test.go b/x/fswap/types/genesis_test.go index 58341f8560..16db637933 100644 --- a/x/fswap/types/genesis_test.go +++ b/x/fswap/types/genesis_test.go @@ -3,7 +3,7 @@ package types_test import ( "testing" - "fswap/x/fswap/types" + "github.com/Finschia/finschia-sdk/x/fswap/types" "github.com/stretchr/testify/require" ) diff --git a/x/fswap/types/params.go b/x/fswap/types/params.go index 357196ad6a..81bb8ee1cc 100644 --- a/x/fswap/types/params.go +++ b/x/fswap/types/params.go @@ -1,7 +1,7 @@ package types import ( - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + paramtypes "github.com/Finschia/finschia-sdk/x/params/types" "gopkg.in/yaml.v2" ) diff --git a/x/fswap/types/query.pb.go b/x/fswap/types/query.pb.go index a0695ca73f..58f3c5c5bb 100644 --- a/x/fswap/types/query.pb.go +++ b/x/fswap/types/query.pb.go @@ -6,7 +6,7 @@ package types import ( context "context" fmt "fmt" - _ "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/Finschia/finschia-sdk/types/query" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" From fbea8d78022ac746d4e6e21bc7273af9d93f9398 Mon Sep 17 00:00:00 2001 From: 170210 Date: Thu, 11 Apr 2024 14:29:06 +0900 Subject: [PATCH 03/17] chore: remove unuse files Signed-off-by: 170210 --- x/fswap/genesis_test.go | 31 +---------- x/fswap/keeper/grpc_query_params_test.go | 23 +------- x/fswap/keeper/msg_server_test.go | 24 --------- x/fswap/keeper/params_test.go | 18 ------- x/fswap/keeper/query_params_test.go | 24 +-------- x/fswap/module_simulation.go | 67 +----------------------- 6 files changed, 4 insertions(+), 183 deletions(-) diff --git a/x/fswap/genesis_test.go b/x/fswap/genesis_test.go index 0178a1f0e3..43bc7afc7c 100644 --- a/x/fswap/genesis_test.go +++ b/x/fswap/genesis_test.go @@ -1,30 +1 @@ -// package fswap_test - -// import ( -// "testing" - -// keepertest "github.com/Finschia/finschia-sdk/testutil/keeper" -// "github.com/Finschia/finschia-sdk/testutil/nullify" - -// "github.com/Finschia/finschia-sdk/x/fswap" -// "github.com/Finschia/finschia-sdk/x/fswap/types" -// "github.com/stretchr/testify/require" -// ) - -// func TestGenesis(t *testing.T) { -// genesisState := types.GenesisState{ -// Params: types.DefaultParams(), - -// // this line is used by starport scaffolding # genesis/test/state -// } - -// k, ctx := keepertest.FswapKeeper(t) -// fswap.InitGenesis(ctx, *k, genesisState) -// got := fswap.ExportGenesis(ctx, *k) -// require.NotNil(t, got) - -// nullify.Fill(&genesisState) -// nullify.Fill(got) - -// // this line is used by starport scaffolding # genesis/test/assert -// } +package fswap_test diff --git a/x/fswap/keeper/grpc_query_params_test.go b/x/fswap/keeper/grpc_query_params_test.go index 6deca9b7c1..9429264902 100644 --- a/x/fswap/keeper/grpc_query_params_test.go +++ b/x/fswap/keeper/grpc_query_params_test.go @@ -1,22 +1 @@ -// package keeper_test - -// import ( -// "testing" - -// "github.com/Finschia/finschia-sdk/x/fswap/types" - -// testkeeper "github.com/Finschia/finschia-sdk/testutil/keeper" -// sdk "github.com/Finschia/finschia-sdk/types" -// "github.com/stretchr/testify/require" -// ) - -// func TestParamsQuery(t *testing.T) { -// keeper, ctx := testkeeper.FswapKeeper(t) -// wctx := sdk.WrapSDKContext(ctx) -// params := types.DefaultParams() -// keeper.SetParams(ctx, params) - -// response, err := keeper.Params(wctx, &types.QueryParamsRequest{}) -// require.NoError(t, err) -// require.Equal(t, &types.QueryParamsResponse{Params: params}, response) -// } +package keeper_test diff --git a/x/fswap/keeper/msg_server_test.go b/x/fswap/keeper/msg_server_test.go index 5d36b52dae..9429264902 100644 --- a/x/fswap/keeper/msg_server_test.go +++ b/x/fswap/keeper/msg_server_test.go @@ -1,25 +1 @@ package keeper_test - -import ( - "context" - "testing" - - keepertest "github.com/Finschia/finschia-sdk/testutil/keeper" - - "github.com/Finschia/finschia-sdk/x/fswap/keeper" - "github.com/Finschia/finschia-sdk/x/fswap/types" - - sdk "github.com/Finschia/finschia-sdk/types" - "github.com/stretchr/testify/require" -) - -func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { - k, ctx := keepertest.FswapKeeper(t) - return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx) -} - -func TestMsgServer(t *testing.T) { - ms, ctx := setupMsgServer(t) - require.NotNil(t, ms) - require.NotNil(t, ctx) -} diff --git a/x/fswap/keeper/params_test.go b/x/fswap/keeper/params_test.go index 7d12962e16..9429264902 100644 --- a/x/fswap/keeper/params_test.go +++ b/x/fswap/keeper/params_test.go @@ -1,19 +1 @@ package keeper_test - -import ( - "testing" - - testkeeper "github.com/Finschia/finschia-sdk/testutil/keeper" - - "github.com/Finschia/finschia-sdk/x/fswap/types" - "github.com/stretchr/testify/require" -) - -func TestGetParams(t *testing.T) { - k, ctx := testkeeper.FswapKeeper(t) - params := types.DefaultParams() - - k.SetParams(ctx, params) - - require.EqualValues(t, params, k.GetParams(ctx)) -} diff --git a/x/fswap/keeper/query_params_test.go b/x/fswap/keeper/query_params_test.go index db33ad7bbd..9429264902 100644 --- a/x/fswap/keeper/query_params_test.go +++ b/x/fswap/keeper/query_params_test.go @@ -1,23 +1 @@ -// package keeper_test - -// import ( -// "testing" - -// testkeeper "github.com/Finschia/finschia-sdk/testutil/keeper" - -// "github.com/Finschia/finschia-sdk/x/fswap/types" - -// sdk "github.com/Finschia/finschia-sdk/types" -// "github.com/stretchr/testify/require" -// ) - -// func TestParamsQuery(t *testing.T) { -// keeper, ctx := testkeeper.FswapKeeper(t) -// wctx := sdk.WrapSDKContext(ctx) -// params := types.DefaultParams() -// keeper.SetParams(ctx, params) - -// response, err := keeper.Params(wctx, &types.QueryParamsRequest{}) -// require.NoError(t, err) -// require.Equal(t, &types.QueryParamsResponse{Params: params}, response) -// } +package keeper_test diff --git a/x/fswap/module_simulation.go b/x/fswap/module_simulation.go index 098b0c432d..48b26e84a0 100644 --- a/x/fswap/module_simulation.go +++ b/x/fswap/module_simulation.go @@ -1,66 +1 @@ -// package fswap - -// import ( -// "math/rand" - -// "github.com/Finschia/finschia-sdk/testutil/sample" - -// fswapsimulation "github.com/Finschia/finschia-sdk/x/fswap/simulation" -// "github.com/Finschia/finschia-sdk/x/fswap/types" - -// "github.com/Finschia/finschia-sdk/baseapp" -// sdk "github.com/Finschia/finschia-sdk/types" -// "github.com/Finschia/finschia-sdk/types/module" -// simtypes "github.com/Finschia/finschia-sdk/types/simulation" -// "github.com/Finschia/finschia-sdk/x/simulation" -// ) - -// // avoid unused import issue -// var ( -// _ = sample.AccAddress -// _ = fswapsimulation.FindAccount -// _ = simulation.MsgEntryKind -// _ = baseapp.Paramspace -// _ = rand.Rand{} -// ) - -// const ( -// // this line is used by starport scaffolding # simapp/module/const -// ) - -// // GenerateGenesisState creates a randomized GenState of the module. -// func (AppModule) GenerateGenesisState(simState *module.SimulationState) { -// accs := make([]string, len(simState.Accounts)) -// for i, acc := range simState.Accounts { -// accs[i] = acc.Address.String() -// } -// fswapGenesis := types.GenesisState{ -// Params: types.DefaultParams(), -// // this line is used by starport scaffolding # simapp/module/genesisState -// } -// simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&fswapGenesis) -// } - -// // RegisterStoreDecoder registers a decoder. -// func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {} - -// // ProposalContents doesn't return any content functions for governance proposals. -// func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { -// return nil -// } - -// // WeightedOperations returns the all the gov module operations with their respective weights. -// func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { -// operations := make([]simtypes.WeightedOperation, 0) - -// // this line is used by starport scaffolding # simapp/module/operation - -// return operations -// } - -// // ProposalMsgs returns msgs used for governance proposals for simulations. -// func (am AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.WeightedProposalMsg { -// return []simtypes.WeightedProposalMsg{ -// // this line is used by starport scaffolding # simapp/module/OpMsg -// } -// } +package fswap From 19ff1d871192a28f456e0c3e71899ac42ff77a65 Mon Sep 17 00:00:00 2001 From: 170210 Date: Thu, 11 Apr 2024 17:04:18 +0900 Subject: [PATCH 04/17] feat: add proto files Signed-off-by: 170210 --- proto/lbm/fswap/v1/event.proto | 18 +++++++++++++++++ proto/lbm/fswap/v1/genesis.proto | 12 ++++++++++++ proto/lbm/fswap/v1/params.proto | 20 +++++++++++++++++++ proto/lbm/fswap/v1/query.proto | 31 ++++++++++++++++++++++++++++++ proto/lbm/fswap/v1/tx.proto | 33 ++++++++++++++++++++++++++++++++ 5 files changed, 114 insertions(+) create mode 100644 proto/lbm/fswap/v1/event.proto create mode 100644 proto/lbm/fswap/v1/genesis.proto create mode 100644 proto/lbm/fswap/v1/params.proto create mode 100644 proto/lbm/fswap/v1/query.proto create mode 100644 proto/lbm/fswap/v1/tx.proto diff --git a/proto/lbm/fswap/v1/event.proto b/proto/lbm/fswap/v1/event.proto new file mode 100644 index 0000000000..374447f7c3 --- /dev/null +++ b/proto/lbm/fswap/v1/event.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; +package lbm.fswap.v1; + +option go_package = "github.com/Finschia/finschia-sdk/x/fswap/types"; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +message EventSwapCoins { + // holder's address + string address = 1; + // amount of the old currency + cosmos.base.v1beta1.Coin old_coin_amount = 2 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/Finschia/finschia-sdk/types.Coin"]; + // amount of the new currency + cosmos.base.v1beta1.Coin new_coin_amount = 3 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/Finschia/finschia-sdk/types.Coin"]; +} diff --git a/proto/lbm/fswap/v1/genesis.proto b/proto/lbm/fswap/v1/genesis.proto new file mode 100644 index 0000000000..4b055874ef --- /dev/null +++ b/proto/lbm/fswap/v1/genesis.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; +package lbm.fswap.v1; + +option go_package = "github.com/Finschia/finschia-sdk/x/fswap/types"; + +import "gogoproto/gogo.proto"; +import "lbm/fswap/v1/params.proto"; + +// GenesisState defines the fswap module's genesis state. +message GenesisState { + Params params = 1 [(gogoproto.nullable) = false]; +} diff --git a/proto/lbm/fswap/v1/params.proto b/proto/lbm/fswap/v1/params.proto new file mode 100644 index 0000000000..03dbcf9c22 --- /dev/null +++ b/proto/lbm/fswap/v1/params.proto @@ -0,0 +1,20 @@ + +syntax = "proto3"; +package lbm.fswap.v1; + +option go_package = "github.com/Finschia/finschia-sdk/x/fswap/types"; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +// Params defines the parameters for the module. +message Params { + option (gogoproto.goproto_stringer) = false; + // upper limit in new coin that this module can swap + cosmos.base.v1beta1.Coin new_coin_swap_total_limit = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/Finschia/finschia-sdk/types.Coin"]; + // constant value for swap rate, 148.079656 + double swap_rate = 2; + // new denomination for new coin after swap + string new_coin_denom = 3; +} \ No newline at end of file diff --git a/proto/lbm/fswap/v1/query.proto b/proto/lbm/fswap/v1/query.proto new file mode 100644 index 0000000000..1d7041dd32 --- /dev/null +++ b/proto/lbm/fswap/v1/query.proto @@ -0,0 +1,31 @@ +syntax = "proto3"; +package lbm.fswap.v1; + +option go_package = "github.com/Finschia/finschia-sdk/x/fswap/types"; + +import "google/api/annotations.proto"; +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +service Query { + rpc Swapped(QuerySwappedRequest) returns (QuerySwappedResponse) { + option (google.api.http).get = "/lbm/fswap/v1/swapped"; + } + rpc TotalNewCurrencySwapLimit(QueryTotalSwappableAmountRequest) returns (QueryTotalSwappableAmountResponse) { + option (google.api.http).get = "/lbm/fswap/v1/swappable_new_coin_amount"; + } +} + +message QuerySwappedRequest {} +message QuerySwappedResponse { + cosmos.base.v1beta1.Coin old_coin_amount = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/Finschia/finschia-sdk/types.Coin"]; + cosmos.base.v1beta1.Coin new_coin_amount = 2 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/Finschia/finschia-sdk/types.Coin"]; +} + +message QueryTotalSwappableAmountRequest {} +message QueryTotalSwappableAmountResponse { + cosmos.base.v1beta1.Coin swappable_new_coin_amount = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/Finschia/finschia-sdk/types.Coin"]; +} diff --git a/proto/lbm/fswap/v1/tx.proto b/proto/lbm/fswap/v1/tx.proto new file mode 100644 index 0000000000..6942bb7d80 --- /dev/null +++ b/proto/lbm/fswap/v1/tx.proto @@ -0,0 +1,33 @@ +syntax = "proto3"; +package lbm.fswap.v1; + +option go_package = "github.com/Finschia/finschia-sdk/x/fswap/types"; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +service Msg { + rpc Swap(MsgSwapRequest) returns (MsgSwapResponse); + rpc SwapAll(MsgSwapAllRequest) returns (MsgSwapAllResponse); +} + +message MsgSwapRequest { + // holder's address + string from_address = 1; + // amount of old currency + cosmos.base.v1beta1.Coin amount = 2 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/Finschia/finschia-sdk/types.Coin"]; +} + +message MsgSwapResponse {} + +message MsgSwapAllRequest { + // holder's address + string from_address = 1; +} + +message MsgSwapAllResponse { + // amount of swapped in new currency + cosmos.base.v1beta1.Coin amount = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/Finschia/finschia-sdk/types.Coin"]; +} From 8194e855260f93e28ac648e87e3e93209a68a192 Mon Sep 17 00:00:00 2001 From: 170210 Date: Thu, 11 Apr 2024 17:04:42 +0900 Subject: [PATCH 05/17] chore: make proto-gen Signed-off-by: 170210 --- docs/core/proto-docs.md | 283 +++++++++++ go.sum | 2 - x/fswap/types/event.pb.go | 433 +++++++++++++++++ x/fswap/types/genesis.pb.go | 36 +- x/fswap/types/params.pb.go | 177 ++++++- x/fswap/types/query.pb.go | 587 ++++++++++++++++++---- x/fswap/types/query.pb.gw.go | 99 +++- x/fswap/types/tx.pb.go | 919 ++++++++++++++++++++++++++++++++++- 8 files changed, 2366 insertions(+), 170 deletions(-) create mode 100644 x/fswap/types/event.pb.go diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index a01f8940c0..c1574b55ab 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -856,6 +856,31 @@ - [Msg](#lbm.foundation.v1.Msg) +- [lbm/fswap/v1/event.proto](#lbm/fswap/v1/event.proto) + - [EventSwapCoins](#lbm.fswap.v1.EventSwapCoins) + +- [lbm/fswap/v1/params.proto](#lbm/fswap/v1/params.proto) + - [Params](#lbm.fswap.v1.Params) + +- [lbm/fswap/v1/genesis.proto](#lbm/fswap/v1/genesis.proto) + - [GenesisState](#lbm.fswap.v1.GenesisState) + +- [lbm/fswap/v1/query.proto](#lbm/fswap/v1/query.proto) + - [QuerySwappedRequest](#lbm.fswap.v1.QuerySwappedRequest) + - [QuerySwappedResponse](#lbm.fswap.v1.QuerySwappedResponse) + - [QueryTotalSwappableAmountRequest](#lbm.fswap.v1.QueryTotalSwappableAmountRequest) + - [QueryTotalSwappableAmountResponse](#lbm.fswap.v1.QueryTotalSwappableAmountResponse) + + - [Query](#lbm.fswap.v1.Query) + +- [lbm/fswap/v1/tx.proto](#lbm/fswap/v1/tx.proto) + - [MsgSwapAllRequest](#lbm.fswap.v1.MsgSwapAllRequest) + - [MsgSwapAllResponse](#lbm.fswap.v1.MsgSwapAllResponse) + - [MsgSwapRequest](#lbm.fswap.v1.MsgSwapRequest) + - [MsgSwapResponse](#lbm.fswap.v1.MsgSwapResponse) + + - [Msg](#lbm.fswap.v1.Msg) + - [lbm/stakingplus/v1/authz.proto](#lbm/stakingplus/v1/authz.proto) - [CreateValidatorAuthorization](#lbm.stakingplus.v1.CreateValidatorAuthorization) @@ -12683,6 +12708,264 @@ Msg defines the foundation Msg service. + +

Top

+ +## lbm/fswap/v1/event.proto + + + + + +### EventSwapCoins + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `address` | [string](#string) | | holder's address | +| `old_coin_amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | amount of the old currency | +| `new_coin_amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | amount of the new currency | + + + + + + + + + + + + + + + + +

Top

+ +## lbm/fswap/v1/params.proto + + + + + +### Params +Params defines the parameters for the module. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `new_coin_swap_total_limit` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | upper limit in new coin that this module can swap | +| `swap_rate` | [double](#double) | | constant value for swap rate, 148.079656 | +| `new_coin_denom` | [string](#string) | | new denomination for new coin after swap | + + + + + + + + + + + + + + + + +

Top

+ +## lbm/fswap/v1/genesis.proto + + + + + +### GenesisState +GenesisState defines the fswap module's genesis state. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `params` | [Params](#lbm.fswap.v1.Params) | | | + + + + + + + + + + + + + + + + +

Top

+ +## lbm/fswap/v1/query.proto + + + + + +### QuerySwappedRequest + + + + + + + + + +### QuerySwappedResponse + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `old_coin_amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | | +| `new_coin_amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | | + + + + + + + + +### QueryTotalSwappableAmountRequest + + + + + + + + + +### QueryTotalSwappableAmountResponse + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `swappable_new_coin_amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | | + + + + + + + + + + + + + + +### Query + + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `Swapped` | [QuerySwappedRequest](#lbm.fswap.v1.QuerySwappedRequest) | [QuerySwappedResponse](#lbm.fswap.v1.QuerySwappedResponse) | | GET|/lbm/fswap/v1/swapped| +| `TotalNewCurrencySwapLimit` | [QueryTotalSwappableAmountRequest](#lbm.fswap.v1.QueryTotalSwappableAmountRequest) | [QueryTotalSwappableAmountResponse](#lbm.fswap.v1.QueryTotalSwappableAmountResponse) | | GET|/lbm/fswap/v1/swappable_new_coin_amount| + + + + + + +

Top

+ +## lbm/fswap/v1/tx.proto + + + + + +### MsgSwapAllRequest + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `from_address` | [string](#string) | | holder's address | + + + + + + + + +### MsgSwapAllResponse + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | amount of swapped in new currency | + + + + + + + + +### MsgSwapRequest + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `from_address` | [string](#string) | | holder's address | +| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | amount of old currency | + + + + + + + + +### MsgSwapResponse + + + + + + + + + + + + + + + +### Msg + + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `Swap` | [MsgSwapRequest](#lbm.fswap.v1.MsgSwapRequest) | [MsgSwapResponse](#lbm.fswap.v1.MsgSwapResponse) | | | +| `SwapAll` | [MsgSwapAllRequest](#lbm.fswap.v1.MsgSwapAllRequest) | [MsgSwapAllResponse](#lbm.fswap.v1.MsgSwapAllResponse) | | | + + + + +

Top

diff --git a/go.sum b/go.sum index 33e2a0281b..6d880b970e 100644 --- a/go.sum +++ b/go.sum @@ -134,8 +134,6 @@ github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4Y= github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw= -github.com/cosmos/iavl v0.19.0 h1:sgyrjqOkycXiN7Tuupuo4QAldKFg7Sipyfeg/IL7cps= -github.com/cosmos/iavl v0.19.0/go.mod h1:l5h9pAB3m5fihB3pXVgwYqdY8aBsMagqz7T0MUjxZeA= github.com/cosmos/iavl v0.19.4 h1:t82sN+Y0WeqxDLJRSpNd8YFX5URIrT+p8n6oJbJ2Dok= github.com/cosmos/iavl v0.19.4/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw= github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 h1:DdzS1m6o/pCqeZ8VOAit/gyATedRgjvkVI+UCrLpyuU= diff --git a/x/fswap/types/event.pb.go b/x/fswap/types/event.pb.go new file mode 100644 index 0000000000..5808cc6e7f --- /dev/null +++ b/x/fswap/types/event.pb.go @@ -0,0 +1,433 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: lbm/fswap/v1/event.proto + +package types + +import ( + fmt "fmt" + types "github.com/Finschia/finschia-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type EventSwapCoins struct { + // holder's address + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // amount of the old currency + OldCoinAmount types.Coin `protobuf:"bytes,2,opt,name=old_coin_amount,json=oldCoinAmount,proto3,castrepeated=github.com/Finschia/finschia-sdk/types.Coin" json:"old_coin_amount"` + // amount of the new currency + NewCoinAmount types.Coin `protobuf:"bytes,3,opt,name=new_coin_amount,json=newCoinAmount,proto3,castrepeated=github.com/Finschia/finschia-sdk/types.Coin" json:"new_coin_amount"` +} + +func (m *EventSwapCoins) Reset() { *m = EventSwapCoins{} } +func (m *EventSwapCoins) String() string { return proto.CompactTextString(m) } +func (*EventSwapCoins) ProtoMessage() {} +func (*EventSwapCoins) Descriptor() ([]byte, []int) { + return fileDescriptor_92d5edbd64a725af, []int{0} +} +func (m *EventSwapCoins) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventSwapCoins) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventSwapCoins.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 *EventSwapCoins) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventSwapCoins.Merge(m, src) +} +func (m *EventSwapCoins) XXX_Size() int { + return m.Size() +} +func (m *EventSwapCoins) XXX_DiscardUnknown() { + xxx_messageInfo_EventSwapCoins.DiscardUnknown(m) +} + +var xxx_messageInfo_EventSwapCoins proto.InternalMessageInfo + +func (m *EventSwapCoins) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *EventSwapCoins) GetOldCoinAmount() types.Coin { + if m != nil { + return m.OldCoinAmount + } + return types.Coin{} +} + +func (m *EventSwapCoins) GetNewCoinAmount() types.Coin { + if m != nil { + return m.NewCoinAmount + } + return types.Coin{} +} + +func init() { + proto.RegisterType((*EventSwapCoins)(nil), "lbm.fswap.v1.EventSwapCoins") +} + +func init() { proto.RegisterFile("lbm/fswap/v1/event.proto", fileDescriptor_92d5edbd64a725af) } + +var fileDescriptor_92d5edbd64a725af = []byte{ + // 288 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x91, 0x3f, 0x4e, 0xc3, 0x30, + 0x1c, 0x85, 0xe3, 0x22, 0x81, 0x08, 0xff, 0xa4, 0x88, 0x21, 0x74, 0x70, 0x2b, 0xa6, 0x4a, 0x08, + 0x5b, 0xa1, 0x27, 0xa0, 0x08, 0xc4, 0x5c, 0x36, 0x96, 0xca, 0x4e, 0xdc, 0x34, 0x22, 0xf1, 0x2f, + 0xaa, 0x5d, 0x07, 0x6e, 0xc1, 0xcc, 0x11, 0x38, 0x49, 0xc7, 0x8e, 0x4c, 0x80, 0x92, 0x8b, 0x20, + 0x3b, 0x41, 0x88, 0x89, 0x89, 0xed, 0x59, 0xcf, 0xef, 0xfb, 0x24, 0xdb, 0x0f, 0x73, 0x5e, 0xd0, + 0xb9, 0xaa, 0x58, 0x49, 0x4d, 0x44, 0x85, 0x11, 0x52, 0x93, 0x72, 0x09, 0x1a, 0x82, 0xfd, 0x9c, + 0x17, 0xc4, 0x35, 0xc4, 0x44, 0xfd, 0xe3, 0x14, 0x52, 0x70, 0x05, 0xb5, 0xa9, 0xbd, 0xd3, 0xc7, + 0x31, 0xa8, 0x02, 0x14, 0xe5, 0x4c, 0x09, 0x6a, 0x22, 0x2e, 0x34, 0x8b, 0x68, 0x0c, 0x99, 0x6c, + 0xfb, 0xd3, 0x97, 0x9e, 0x7f, 0x78, 0x6d, 0x99, 0x77, 0x15, 0x2b, 0xaf, 0x20, 0x93, 0x2a, 0x08, + 0xfd, 0x1d, 0x96, 0x24, 0x4b, 0xa1, 0x54, 0x88, 0x86, 0x68, 0xb4, 0x3b, 0xfd, 0x3e, 0x06, 0xc6, + 0x3f, 0x82, 0x3c, 0x99, 0xd9, 0xf9, 0x8c, 0x15, 0xb0, 0x92, 0x3a, 0xec, 0x0d, 0xd1, 0x68, 0xef, + 0xe2, 0x84, 0xb4, 0x1a, 0x62, 0x35, 0xa4, 0xd3, 0x10, 0x8b, 0x9b, 0x8c, 0xd7, 0xef, 0x03, 0xef, + 0xf5, 0x63, 0x70, 0x96, 0x66, 0x7a, 0xb1, 0xe2, 0x24, 0x86, 0x82, 0xde, 0x64, 0x52, 0xc5, 0x8b, + 0x8c, 0xd1, 0x79, 0x17, 0xce, 0x55, 0xf2, 0x40, 0xf5, 0x53, 0x29, 0x94, 0x1b, 0x4d, 0x0f, 0x20, + 0x4f, 0x6c, 0xb8, 0x74, 0x12, 0xeb, 0x95, 0xa2, 0xfa, 0xe5, 0xdd, 0xfa, 0x1f, 0xaf, 0x14, 0xd5, + 0x8f, 0x77, 0x72, 0xbb, 0xae, 0x31, 0xda, 0xd4, 0x18, 0x7d, 0xd6, 0x18, 0x3d, 0x37, 0xd8, 0xdb, + 0x34, 0xd8, 0x7b, 0x6b, 0xb0, 0x77, 0x4f, 0xfe, 0xa4, 0x3e, 0x76, 0x7f, 0xe6, 0xe8, 0x7c, 0xdb, + 0xbd, 0xf6, 0xf8, 0x2b, 0x00, 0x00, 0xff, 0xff, 0x2b, 0x08, 0x6b, 0x7c, 0xcd, 0x01, 0x00, 0x00, +} + +func (m *EventSwapCoins) 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 *EventSwapCoins) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventSwapCoins) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.NewCoinAmount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvent(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size, err := m.OldCoinAmount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvent(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintEvent(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintEvent(dAtA []byte, offset int, v uint64) int { + offset -= sovEvent(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *EventSwapCoins) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovEvent(uint64(l)) + } + l = m.OldCoinAmount.Size() + n += 1 + l + sovEvent(uint64(l)) + l = m.NewCoinAmount.Size() + n += 1 + l + sovEvent(uint64(l)) + return n +} + +func sovEvent(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozEvent(x uint64) (n int) { + return sovEvent(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *EventSwapCoins) 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 ErrIntOverflowEvent + } + 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: EventSwapCoins: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventSwapCoins: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + 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 ErrInvalidLengthEvent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OldCoinAmount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.OldCoinAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewCoinAmount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvent + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.NewCoinAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvent(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipEvent(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowEvent + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowEvent + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowEvent + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthEvent + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupEvent + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthEvent + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthEvent = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowEvent = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupEvent = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/fswap/types/genesis.pb.go b/x/fswap/types/genesis.pb.go index b2f01d29c7..a56d510e68 100644 --- a/x/fswap/types/genesis.pb.go +++ b/x/fswap/types/genesis.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: fswap/genesis.proto +// source: lbm/fswap/v1/genesis.proto package types @@ -32,7 +32,7 @@ func (m *GenesisState) Reset() { *m = GenesisState{} } func (m *GenesisState) String() string { return proto.CompactTextString(m) } func (*GenesisState) ProtoMessage() {} func (*GenesisState) Descriptor() ([]byte, []int) { - return fileDescriptor_12b6cdf66abb1efc, []int{0} + return fileDescriptor_94e309cb1db27661, []int{0} } func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -69,24 +69,26 @@ func (m *GenesisState) GetParams() Params { } func init() { - proto.RegisterType((*GenesisState)(nil), "fswap.fswap.GenesisState") + proto.RegisterType((*GenesisState)(nil), "lbm.fswap.v1.GenesisState") } -func init() { proto.RegisterFile("fswap/genesis.proto", fileDescriptor_12b6cdf66abb1efc) } +func init() { proto.RegisterFile("lbm/fswap/v1/genesis.proto", fileDescriptor_94e309cb1db27661) } -var fileDescriptor_12b6cdf66abb1efc = []byte{ - // 162 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4e, 0x2b, 0x2e, 0x4f, - 0x2c, 0xd0, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, - 0xe2, 0x06, 0x0b, 0xea, 0x81, 0x49, 0x29, 0x91, 0xf4, 0xfc, 0xf4, 0x7c, 0xb0, 0xb8, 0x3e, 0x88, - 0x05, 0x51, 0x22, 0x25, 0x04, 0xd1, 0x57, 0x90, 0x58, 0x94, 0x98, 0x0b, 0xd5, 0xa6, 0xe4, 0xc8, - 0xc5, 0xe3, 0x0e, 0x31, 0x27, 0xb8, 0x24, 0xb1, 0x24, 0x55, 0xc8, 0x90, 0x8b, 0x0d, 0x22, 0x2f, - 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xac, 0x87, 0x64, 0xae, 0x5e, 0x00, 0x58, 0xca, 0x89, - 0xe5, 0xc4, 0x3d, 0x79, 0x86, 0x20, 0xa8, 0x42, 0x27, 0xdd, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, - 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, - 0x3c, 0x96, 0x63, 0x88, 0x82, 0x3a, 0xb4, 0x42, 0x1f, 0x42, 0x97, 0x54, 0x16, 0xa4, 0x16, 0x27, - 0xb1, 0x81, 0x2d, 0x36, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xc2, 0xe2, 0xad, 0xa6, 0xc6, 0x00, - 0x00, 0x00, +var fileDescriptor_94e309cb1db27661 = []byte{ + // 200 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xca, 0x49, 0xca, 0xd5, + 0x4f, 0x2b, 0x2e, 0x4f, 0x2c, 0xd0, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, + 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0xc9, 0x49, 0xca, 0xd5, 0x03, 0xcb, 0xe9, 0x95, + 0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x25, 0xf4, 0x41, 0x2c, 0x88, 0x1a, 0x29, 0x49, + 0x14, 0xfd, 0x05, 0x89, 0x45, 0x89, 0xb9, 0x50, 0xed, 0x4a, 0x4e, 0x5c, 0x3c, 0xee, 0x10, 0xf3, + 0x82, 0x4b, 0x12, 0x4b, 0x52, 0x85, 0x8c, 0xb8, 0xd8, 0x20, 0xf2, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, + 0xdc, 0x46, 0x22, 0x7a, 0xc8, 0xe6, 0xeb, 0x05, 0x80, 0xe5, 0x9c, 0x58, 0x4e, 0xdc, 0x93, 0x67, + 0x08, 0x82, 0xaa, 0x74, 0xf2, 0x38, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, + 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, + 0xbd, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0xb7, 0xcc, 0xbc, 0xe2, + 0xe4, 0x8c, 0xcc, 0x44, 0xfd, 0x34, 0x28, 0x43, 0xb7, 0x38, 0x25, 0x5b, 0xbf, 0x02, 0xea, 0xae, + 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0xa3, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, + 0xa6, 0x7e, 0x83, 0x5e, 0xf1, 0x00, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/fswap/types/params.pb.go b/x/fswap/types/params.pb.go index 2542e6e13c..ecc820e3fa 100644 --- a/x/fswap/types/params.pb.go +++ b/x/fswap/types/params.pb.go @@ -1,10 +1,12 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: fswap/params.proto +// source: lbm/fswap/v1/params.proto package types import ( + encoding_binary "encoding/binary" fmt "fmt" + types "github.com/Finschia/finschia-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" @@ -25,12 +27,18 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the module. type Params struct { + // upper limit in new coin that this module can swap + NewCoinSwapTotalLimit types.Coin `protobuf:"bytes,1,opt,name=new_coin_swap_total_limit,json=newCoinSwapTotalLimit,proto3,castrepeated=github.com/Finschia/finschia-sdk/types.Coin" json:"new_coin_swap_total_limit"` + // constant value for swap rate, 148.079656 + SwapRate float64 `protobuf:"fixed64,2,opt,name=swap_rate,json=swapRate,proto3" json:"swap_rate,omitempty"` + // new denomination for new coin after swap + NewCoinDenom string `protobuf:"bytes,3,opt,name=new_coin_denom,json=newCoinDenom,proto3" json:"new_coin_denom,omitempty"` } func (m *Params) Reset() { *m = Params{} } func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_f82e84990da21041, []int{0} + return fileDescriptor_15e620b81032c44d, []int{0} } func (m *Params) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -59,22 +67,55 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo +func (m *Params) GetNewCoinSwapTotalLimit() types.Coin { + if m != nil { + return m.NewCoinSwapTotalLimit + } + return types.Coin{} +} + +func (m *Params) GetSwapRate() float64 { + if m != nil { + return m.SwapRate + } + return 0 +} + +func (m *Params) GetNewCoinDenom() string { + if m != nil { + return m.NewCoinDenom + } + return "" +} + func init() { - proto.RegisterType((*Params)(nil), "fswap.fswap.Params") + proto.RegisterType((*Params)(nil), "lbm.fswap.v1.Params") } -func init() { proto.RegisterFile("fswap/params.proto", fileDescriptor_f82e84990da21041) } +func init() { proto.RegisterFile("lbm/fswap/v1/params.proto", fileDescriptor_15e620b81032c44d) } -var fileDescriptor_f82e84990da21041 = []byte{ - // 122 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4a, 0x2b, 0x2e, 0x4f, - 0x2c, 0xd0, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, - 0x06, 0x8b, 0xe9, 0x81, 0x49, 0x29, 0x91, 0xf4, 0xfc, 0xf4, 0x7c, 0xb0, 0xb8, 0x3e, 0x88, 0x05, - 0x51, 0xa2, 0xc4, 0xc7, 0xc5, 0x16, 0x00, 0xd6, 0x62, 0xc5, 0x32, 0x63, 0x81, 0x3c, 0x83, 0x93, - 0xee, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, - 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x09, 0x43, 0x2c, 0xa8, 0xd0, - 0x87, 0xd0, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0x53, 0x8c, 0x01, 0x01, 0x00, 0x00, - 0xff, 0xff, 0x1f, 0xa9, 0xea, 0x49, 0x7e, 0x00, 0x00, 0x00, +var fileDescriptor_15e620b81032c44d = []byte{ + // 317 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x90, 0xb1, 0x4e, 0xeb, 0x30, + 0x14, 0x86, 0xe3, 0x7b, 0x51, 0x45, 0x43, 0xc5, 0x10, 0x81, 0xd4, 0x16, 0xc9, 0xad, 0x10, 0x43, + 0x25, 0x84, 0xad, 0xd0, 0x8d, 0xb1, 0x20, 0xc4, 0xc0, 0x80, 0x02, 0x13, 0x4b, 0x64, 0xa7, 0x6e, + 0x6b, 0x11, 0xdb, 0x51, 0x6d, 0x12, 0x78, 0x03, 0x46, 0x46, 0x46, 0x66, 0x9e, 0xa4, 0x63, 0x47, + 0x06, 0x04, 0x28, 0x79, 0x11, 0x64, 0x27, 0x62, 0x65, 0xfb, 0x75, 0x7e, 0xfb, 0x3b, 0x9f, 0x8e, + 0xdf, 0x4b, 0xa9, 0xc0, 0x33, 0x5d, 0x90, 0x0c, 0xe7, 0x21, 0xce, 0xc8, 0x92, 0x08, 0x8d, 0xb2, + 0xa5, 0x32, 0x2a, 0xe8, 0xa4, 0x54, 0x20, 0x57, 0xa1, 0x3c, 0xec, 0xef, 0xcc, 0xd5, 0x5c, 0xb9, + 0x02, 0xdb, 0x54, 0xbf, 0xe9, 0xc3, 0x44, 0x69, 0xa1, 0x34, 0xa6, 0x44, 0x33, 0x9c, 0x87, 0x94, + 0x19, 0x12, 0xe2, 0x44, 0x71, 0x59, 0xf7, 0xfb, 0x1f, 0xc0, 0x6f, 0x5d, 0x39, 0x68, 0xf0, 0x04, + 0xfc, 0x9e, 0x64, 0x45, 0x6c, 0xdb, 0xd8, 0x52, 0x63, 0xa3, 0x0c, 0x49, 0xe3, 0x94, 0x0b, 0x6e, + 0xba, 0x60, 0x08, 0x46, 0x5b, 0xc7, 0x3d, 0x54, 0xf3, 0x90, 0xe5, 0xa1, 0x86, 0x87, 0x4e, 0x15, + 0x97, 0x93, 0xf1, 0xea, 0x73, 0xe0, 0xbd, 0x7d, 0x0d, 0x0e, 0xe7, 0xdc, 0x2c, 0xee, 0x29, 0x4a, + 0x94, 0xc0, 0xe7, 0x5c, 0xea, 0x64, 0xc1, 0x09, 0x9e, 0x35, 0xe1, 0x48, 0x4f, 0xef, 0xb0, 0x79, + 0xcc, 0x98, 0x76, 0x9f, 0xa2, 0x5d, 0xc9, 0x0a, 0x1b, 0xae, 0x0b, 0x92, 0xdd, 0xd8, 0x6d, 0x97, + 0x76, 0x59, 0xb0, 0xe7, 0xb7, 0x9d, 0xc0, 0x92, 0x18, 0xd6, 0xfd, 0x37, 0x04, 0x23, 0x10, 0x6d, + 0xda, 0x41, 0x44, 0x0c, 0x0b, 0x0e, 0xfc, 0xed, 0x5f, 0xcd, 0x29, 0x93, 0x4a, 0x74, 0xff, 0x0f, + 0xc1, 0xa8, 0x1d, 0x75, 0x1a, 0xd6, 0x99, 0x9d, 0x9d, 0x6c, 0xbc, 0xbc, 0x0e, 0xbc, 0xc9, 0xc5, + 0xaa, 0x84, 0x60, 0x5d, 0x42, 0xf0, 0x5d, 0x42, 0xf0, 0x5c, 0x41, 0x6f, 0x5d, 0x41, 0xef, 0xbd, + 0x82, 0xde, 0x2d, 0xfa, 0x53, 0xf3, 0xa1, 0x39, 0xbb, 0xd3, 0xa5, 0x2d, 0x77, 0xaf, 0xf1, 0x4f, + 0x00, 0x00, 0x00, 0xff, 0xff, 0xfc, 0x06, 0x39, 0x42, 0x90, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -97,6 +138,29 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.NewCoinDenom) > 0 { + i -= len(m.NewCoinDenom) + copy(dAtA[i:], m.NewCoinDenom) + i = encodeVarintParams(dAtA, i, uint64(len(m.NewCoinDenom))) + i-- + dAtA[i] = 0x1a + } + if m.SwapRate != 0 { + i -= 8 + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.SwapRate)))) + i-- + dAtA[i] = 0x11 + } + { + size, err := m.NewCoinSwapTotalLimit.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -117,6 +181,15 @@ func (m *Params) Size() (n int) { } var l int _ = l + l = m.NewCoinSwapTotalLimit.Size() + n += 1 + l + sovParams(uint64(l)) + if m.SwapRate != 0 { + n += 9 + } + l = len(m.NewCoinDenom) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } return n } @@ -155,6 +228,82 @@ func (m *Params) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewCoinSwapTotalLimit", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.NewCoinSwapTotalLimit.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field SwapRate", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.SwapRate = float64(math.Float64frombits(v)) + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewCoinDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NewCoinDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/fswap/types/query.pb.go b/x/fswap/types/query.pb.go index 58f3c5c5bb..49b4e5ae0d 100644 --- a/x/fswap/types/query.pb.go +++ b/x/fswap/types/query.pb.go @@ -1,12 +1,12 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: fswap/query.proto +// source: lbm/fswap/v1/query.proto package types import ( context "context" fmt "fmt" - _ "github.com/Finschia/finschia-sdk/types/query" + types "github.com/Finschia/finschia-sdk/types" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" @@ -30,22 +30,21 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// QueryParamsRequest is request type for the Query/Params RPC method. -type QueryParamsRequest struct { +type QuerySwappedRequest struct { } -func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } -func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryParamsRequest) ProtoMessage() {} -func (*QueryParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_4b0a2b30d5573837, []int{0} +func (m *QuerySwappedRequest) Reset() { *m = QuerySwappedRequest{} } +func (m *QuerySwappedRequest) String() string { return proto.CompactTextString(m) } +func (*QuerySwappedRequest) ProtoMessage() {} +func (*QuerySwappedRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_01deae9da7816d6a, []int{0} } -func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { +func (m *QuerySwappedRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QuerySwappedRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QuerySwappedRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -55,36 +54,35 @@ func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryParamsRequest.Merge(m, src) +func (m *QuerySwappedRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySwappedRequest.Merge(m, src) } -func (m *QueryParamsRequest) XXX_Size() int { +func (m *QuerySwappedRequest) XXX_Size() int { return m.Size() } -func (m *QueryParamsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +func (m *QuerySwappedRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySwappedRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo +var xxx_messageInfo_QuerySwappedRequest proto.InternalMessageInfo -// QueryParamsResponse is response type for the Query/Params RPC method. -type QueryParamsResponse struct { - // params holds all the parameters of this module. - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +type QuerySwappedResponse struct { + OldCoinAmount types.Coin `protobuf:"bytes,1,opt,name=old_coin_amount,json=oldCoinAmount,proto3,castrepeated=github.com/Finschia/finschia-sdk/types.Coin" json:"old_coin_amount"` + NewCoinAmount types.Coin `protobuf:"bytes,2,opt,name=new_coin_amount,json=newCoinAmount,proto3,castrepeated=github.com/Finschia/finschia-sdk/types.Coin" json:"new_coin_amount"` } -func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } -func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryParamsResponse) ProtoMessage() {} -func (*QueryParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_4b0a2b30d5573837, []int{1} +func (m *QuerySwappedResponse) Reset() { *m = QuerySwappedResponse{} } +func (m *QuerySwappedResponse) String() string { return proto.CompactTextString(m) } +func (*QuerySwappedResponse) ProtoMessage() {} +func (*QuerySwappedResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_01deae9da7816d6a, []int{1} } -func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { +func (m *QuerySwappedResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QuerySwappedResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QuerySwappedResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -94,52 +92,151 @@ func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryParamsResponse.Merge(m, src) +func (m *QuerySwappedResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySwappedResponse.Merge(m, src) } -func (m *QueryParamsResponse) XXX_Size() int { +func (m *QuerySwappedResponse) XXX_Size() int { return m.Size() } -func (m *QueryParamsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +func (m *QuerySwappedResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySwappedResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo +var xxx_messageInfo_QuerySwappedResponse proto.InternalMessageInfo -func (m *QueryParamsResponse) GetParams() Params { +func (m *QuerySwappedResponse) GetOldCoinAmount() types.Coin { if m != nil { - return m.Params + return m.OldCoinAmount } - return Params{} + return types.Coin{} +} + +func (m *QuerySwappedResponse) GetNewCoinAmount() types.Coin { + if m != nil { + return m.NewCoinAmount + } + return types.Coin{} +} + +type QueryTotalSwappableAmountRequest struct { +} + +func (m *QueryTotalSwappableAmountRequest) Reset() { *m = QueryTotalSwappableAmountRequest{} } +func (m *QueryTotalSwappableAmountRequest) String() string { return proto.CompactTextString(m) } +func (*QueryTotalSwappableAmountRequest) ProtoMessage() {} +func (*QueryTotalSwappableAmountRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_01deae9da7816d6a, []int{2} +} +func (m *QueryTotalSwappableAmountRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTotalSwappableAmountRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTotalSwappableAmountRequest.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 *QueryTotalSwappableAmountRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTotalSwappableAmountRequest.Merge(m, src) +} +func (m *QueryTotalSwappableAmountRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryTotalSwappableAmountRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTotalSwappableAmountRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTotalSwappableAmountRequest proto.InternalMessageInfo + +type QueryTotalSwappableAmountResponse struct { + SwappableNewCoinAmount types.Coin `protobuf:"bytes,1,opt,name=swappable_new_coin_amount,json=swappableNewCoinAmount,proto3,castrepeated=github.com/Finschia/finschia-sdk/types.Coin" json:"swappable_new_coin_amount"` +} + +func (m *QueryTotalSwappableAmountResponse) Reset() { *m = QueryTotalSwappableAmountResponse{} } +func (m *QueryTotalSwappableAmountResponse) String() string { return proto.CompactTextString(m) } +func (*QueryTotalSwappableAmountResponse) ProtoMessage() {} +func (*QueryTotalSwappableAmountResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_01deae9da7816d6a, []int{3} +} +func (m *QueryTotalSwappableAmountResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTotalSwappableAmountResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTotalSwappableAmountResponse.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 *QueryTotalSwappableAmountResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTotalSwappableAmountResponse.Merge(m, src) +} +func (m *QueryTotalSwappableAmountResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryTotalSwappableAmountResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTotalSwappableAmountResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTotalSwappableAmountResponse proto.InternalMessageInfo + +func (m *QueryTotalSwappableAmountResponse) GetSwappableNewCoinAmount() types.Coin { + if m != nil { + return m.SwappableNewCoinAmount + } + return types.Coin{} } func init() { - proto.RegisterType((*QueryParamsRequest)(nil), "fswap.fswap.QueryParamsRequest") - proto.RegisterType((*QueryParamsResponse)(nil), "fswap.fswap.QueryParamsResponse") -} - -func init() { proto.RegisterFile("fswap/query.proto", fileDescriptor_4b0a2b30d5573837) } - -var fileDescriptor_4b0a2b30d5573837 = []byte{ - // 274 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x90, 0x4f, 0x4b, 0xc3, 0x30, - 0x18, 0x87, 0x5b, 0xd1, 0x1e, 0xb2, 0x93, 0xe9, 0x04, 0xa9, 0x92, 0x8d, 0x9e, 0x44, 0xb0, 0xa1, - 0xf3, 0x1b, 0xec, 0xe4, 0x51, 0x77, 0xf4, 0x96, 0x4a, 0x8c, 0x05, 0x97, 0x37, 0x6d, 0x32, 0x75, - 0x57, 0x3f, 0x81, 0xe0, 0x97, 0xda, 0x71, 0xe0, 0xc5, 0x93, 0x48, 0xeb, 0x07, 0x91, 0xe5, 0xcd, - 0x61, 0x43, 0xbc, 0x84, 0xf0, 0xcb, 0xf3, 0xbc, 0x7f, 0x42, 0x0e, 0xef, 0xed, 0xb3, 0x30, 0xbc, - 0x59, 0xc8, 0x76, 0x59, 0x98, 0x16, 0x1c, 0xd0, 0x81, 0x8f, 0x0a, 0x7f, 0x66, 0x43, 0x05, 0x0a, - 0x7c, 0xce, 0x37, 0x37, 0x44, 0xb2, 0x53, 0x05, 0xa0, 0x1e, 0x25, 0x17, 0xa6, 0xe6, 0x42, 0x6b, - 0x70, 0xc2, 0xd5, 0xa0, 0x6d, 0x78, 0x3d, 0xbf, 0x03, 0x3b, 0x07, 0xcb, 0x2b, 0x61, 0x25, 0x56, - 0xe6, 0x4f, 0x65, 0x25, 0x9d, 0x28, 0xb9, 0x11, 0xaa, 0xd6, 0x1e, 0x0e, 0x2c, 0xc5, 0xfe, 0x46, - 0xb4, 0x62, 0x1e, 0xfc, 0x7c, 0x48, 0xe8, 0xcd, 0xc6, 0xba, 0xf6, 0xe1, 0x4c, 0x36, 0x0b, 0x69, - 0x5d, 0x7e, 0x45, 0xd2, 0x9d, 0xd4, 0x1a, 0xd0, 0x56, 0xd2, 0x92, 0x24, 0x28, 0x1f, 0xc7, 0xe3, - 0xf8, 0x6c, 0x30, 0x49, 0x8b, 0xad, 0xf1, 0x0b, 0x84, 0xa7, 0xfb, 0xab, 0xaf, 0x51, 0x34, 0x0b, - 0xe0, 0xa4, 0x21, 0x07, 0xbe, 0x12, 0x7d, 0x20, 0x09, 0x02, 0x74, 0xb4, 0x63, 0xfd, 0xed, 0x9e, - 0x8d, 0xff, 0x07, 0x70, 0x90, 0xfc, 0xe4, 0xf5, 0xe3, 0xe7, 0x7d, 0xef, 0x88, 0xa6, 0x1c, 0x57, - 0xda, 0x5e, 0x6c, 0x7a, 0xb1, 0xea, 0x58, 0xbc, 0xee, 0x58, 0xfc, 0xdd, 0xb1, 0xf8, 0xad, 0x67, - 0xd1, 0xba, 0x67, 0xd1, 0x67, 0xcf, 0xa2, 0xdb, 0x14, 0xb9, 0x97, 0xc0, 0xbb, 0xa5, 0x91, 0xb6, - 0x4a, 0xfc, 0x47, 0x5c, 0xfe, 0x06, 0x00, 0x00, 0xff, 0xff, 0xea, 0x39, 0x81, 0xbe, 0x9e, 0x01, - 0x00, 0x00, + proto.RegisterType((*QuerySwappedRequest)(nil), "lbm.fswap.v1.QuerySwappedRequest") + proto.RegisterType((*QuerySwappedResponse)(nil), "lbm.fswap.v1.QuerySwappedResponse") + proto.RegisterType((*QueryTotalSwappableAmountRequest)(nil), "lbm.fswap.v1.QueryTotalSwappableAmountRequest") + proto.RegisterType((*QueryTotalSwappableAmountResponse)(nil), "lbm.fswap.v1.QueryTotalSwappableAmountResponse") +} + +func init() { proto.RegisterFile("lbm/fswap/v1/query.proto", fileDescriptor_01deae9da7816d6a) } + +var fileDescriptor_01deae9da7816d6a = []byte{ + // 447 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x93, 0x41, 0x6b, 0xd4, 0x40, + 0x14, 0xc7, 0x33, 0x01, 0x15, 0x46, 0x45, 0x88, 0xad, 0x76, 0x83, 0xa6, 0x6d, 0x2e, 0x2a, 0xe2, + 0x0c, 0x69, 0x3f, 0x81, 0x15, 0xc4, 0x83, 0x08, 0x56, 0x4f, 0x5e, 0x96, 0x49, 0x32, 0x4d, 0x07, + 0x93, 0x79, 0x69, 0x66, 0x92, 0xd8, 0xab, 0x07, 0xc1, 0x9b, 0xe0, 0x97, 0x10, 0x41, 0xfc, 0x1a, + 0x3d, 0x2e, 0x78, 0xf1, 0xa4, 0xb2, 0xeb, 0x07, 0x91, 0x4c, 0x66, 0x75, 0x57, 0xc2, 0xea, 0x65, + 0x6f, 0x8f, 0x79, 0x2f, 0xef, 0xf7, 0x7f, 0xff, 0xf7, 0x82, 0xb7, 0xf2, 0xb8, 0xa0, 0x47, 0xaa, + 0x65, 0x25, 0x6d, 0x22, 0x7a, 0x52, 0xf3, 0xea, 0x94, 0x94, 0x15, 0x68, 0xf0, 0x2e, 0xe5, 0x71, + 0x41, 0x4c, 0x86, 0x34, 0x91, 0x7f, 0x23, 0x03, 0xc8, 0x72, 0x4e, 0x59, 0x29, 0x28, 0x93, 0x12, + 0x34, 0xd3, 0x02, 0xa4, 0xea, 0x6b, 0xfd, 0x8d, 0x0c, 0x32, 0x30, 0x21, 0xed, 0x22, 0xfb, 0x1a, + 0x24, 0xa0, 0x0a, 0x50, 0x34, 0x66, 0x8a, 0xd3, 0x26, 0x8a, 0xb9, 0x66, 0x11, 0x4d, 0x40, 0xc8, + 0x3e, 0x1f, 0x6e, 0xe2, 0xab, 0x4f, 0x3b, 0xe0, 0xb3, 0x96, 0x95, 0x25, 0x4f, 0x0f, 0xf9, 0x49, + 0xcd, 0x95, 0x0e, 0xdf, 0xb8, 0x78, 0x63, 0xf9, 0x5d, 0x95, 0x20, 0x15, 0xf7, 0x1a, 0x7c, 0x05, + 0xf2, 0x74, 0xdc, 0x75, 0x18, 0xb3, 0x02, 0x6a, 0xa9, 0xb7, 0xd0, 0x0e, 0xba, 0x7d, 0x71, 0x6f, + 0x44, 0x7a, 0x12, 0xe9, 0x48, 0xc4, 0x92, 0xc8, 0x03, 0x10, 0xf2, 0x60, 0xff, 0xec, 0xdb, 0xb6, + 0xf3, 0xf1, 0xfb, 0xf6, 0xdd, 0x4c, 0xe8, 0xe3, 0x3a, 0x26, 0x09, 0x14, 0xf4, 0xa1, 0x90, 0x2a, + 0x39, 0x16, 0x8c, 0x1e, 0xd9, 0xe0, 0x9e, 0x4a, 0x5f, 0x52, 0x7d, 0x5a, 0x72, 0x65, 0x3e, 0x3a, + 0xbc, 0x0c, 0x79, 0xda, 0x05, 0xf7, 0x0d, 0xa4, 0xe3, 0x4a, 0xde, 0x2e, 0x71, 0xdd, 0xf5, 0x70, + 0x25, 0x6f, 0xff, 0x70, 0xc3, 0x10, 0xef, 0x18, 0x1f, 0x9e, 0x83, 0x66, 0xb9, 0x31, 0x83, 0xc5, + 0x39, 0xef, 0x93, 0x73, 0xb3, 0x3e, 0x23, 0xbc, 0xbb, 0xa2, 0xc8, 0x3a, 0xf7, 0x16, 0xe1, 0x91, + 0x9a, 0xe7, 0xc6, 0x7f, 0x0f, 0xb3, 0x1e, 0x13, 0xaf, 0xfd, 0x06, 0x3e, 0x59, 0x9c, 0x6a, 0xef, + 0x83, 0x8b, 0xcf, 0x19, 0xc5, 0x1e, 0xe0, 0x0b, 0x76, 0xc5, 0xde, 0x2e, 0x59, 0xbc, 0x36, 0x32, + 0x70, 0x16, 0x7e, 0xb8, 0xaa, 0xa4, 0x9f, 0x33, 0xbc, 0xf9, 0xfa, 0xcb, 0xcf, 0xf7, 0xee, 0x75, + 0x6f, 0x93, 0x2e, 0x9d, 0xb5, 0xb2, 0x94, 0x4f, 0x08, 0x8f, 0x8c, 0x4f, 0x9d, 0xa2, 0xba, 0xaa, + 0xb8, 0x4c, 0x4c, 0x8b, 0xc7, 0xa2, 0x10, 0xda, 0x23, 0x03, 0x80, 0x15, 0xd6, 0xfb, 0xf4, 0xbf, + 0xeb, 0xad, 0x3a, 0x6a, 0xd4, 0xdd, 0xf1, 0x6e, 0x0d, 0xa8, 0x1b, 0x5a, 0xcc, 0xc1, 0xa3, 0xb3, + 0x69, 0x80, 0x26, 0xd3, 0x00, 0xfd, 0x98, 0x06, 0xe8, 0xdd, 0x2c, 0x70, 0x26, 0xb3, 0xc0, 0xf9, + 0x3a, 0x0b, 0x9c, 0x17, 0xe4, 0x9f, 0x9b, 0x78, 0x65, 0x01, 0x66, 0x23, 0xf1, 0x79, 0xf3, 0xc7, + 0xed, 0xff, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x07, 0x01, 0xc3, 0x43, 0xef, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -154,8 +251,8 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type QueryClient interface { - // Parameters queries the parameters of the module. - Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + Swapped(ctx context.Context, in *QuerySwappedRequest, opts ...grpc.CallOption) (*QuerySwappedResponse, error) + TotalNewCurrencySwapLimit(ctx context.Context, in *QueryTotalSwappableAmountRequest, opts ...grpc.CallOption) (*QueryTotalSwappableAmountResponse, error) } type queryClient struct { @@ -166,9 +263,18 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { return &queryClient{cc} } -func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { - out := new(QueryParamsResponse) - err := c.cc.Invoke(ctx, "/fswap.fswap.Query/Params", in, out, opts...) +func (c *queryClient) Swapped(ctx context.Context, in *QuerySwappedRequest, opts ...grpc.CallOption) (*QuerySwappedResponse, error) { + out := new(QuerySwappedResponse) + err := c.cc.Invoke(ctx, "/lbm.fswap.v1.Query/Swapped", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) TotalNewCurrencySwapLimit(ctx context.Context, in *QueryTotalSwappableAmountRequest, opts ...grpc.CallOption) (*QueryTotalSwappableAmountResponse, error) { + out := new(QueryTotalSwappableAmountResponse) + err := c.cc.Invoke(ctx, "/lbm.fswap.v1.Query/TotalNewCurrencySwapLimit", in, out, opts...) if err != nil { return nil, err } @@ -177,54 +283,145 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . // QueryServer is the server API for Query service. type QueryServer interface { - // Parameters queries the parameters of the module. - Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + Swapped(context.Context, *QuerySwappedRequest) (*QuerySwappedResponse, error) + TotalNewCurrencySwapLimit(context.Context, *QueryTotalSwappableAmountRequest) (*QueryTotalSwappableAmountResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. type UnimplementedQueryServer struct { } -func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +func (*UnimplementedQueryServer) Swapped(ctx context.Context, req *QuerySwappedRequest) (*QuerySwappedResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Swapped not implemented") +} +func (*UnimplementedQueryServer) TotalNewCurrencySwapLimit(ctx context.Context, req *QueryTotalSwappableAmountRequest) (*QueryTotalSwappableAmountResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method TotalNewCurrencySwapLimit not implemented") } func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } -func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryParamsRequest) +func _Query_Swapped_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QuerySwappedRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).Params(ctx, in) + return srv.(QueryServer).Swapped(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/fswap.fswap.Query/Params", + FullMethod: "/lbm.fswap.v1.Query/Swapped", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + return srv.(QueryServer).Swapped(ctx, req.(*QuerySwappedRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_TotalNewCurrencySwapLimit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryTotalSwappableAmountRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).TotalNewCurrencySwapLimit(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lbm.fswap.v1.Query/TotalNewCurrencySwapLimit", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).TotalNewCurrencySwapLimit(ctx, req.(*QueryTotalSwappableAmountRequest)) } return interceptor(ctx, in, info, handler) } var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "fswap.fswap.Query", + ServiceName: "lbm.fswap.v1.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "Params", - Handler: _Query_Params_Handler, + MethodName: "Swapped", + Handler: _Query_Swapped_Handler, + }, + { + MethodName: "TotalNewCurrencySwapLimit", + Handler: _Query_TotalNewCurrencySwapLimit_Handler, }, }, Streams: []grpc.StreamDesc{}, - Metadata: "fswap/query.proto", + Metadata: "lbm/fswap/v1/query.proto", +} + +func (m *QuerySwappedRequest) 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 *QuerySwappedRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySwappedRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QuerySwappedResponse) 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 *QuerySwappedResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySwappedResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.NewCoinAmount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.OldCoinAmount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil } -func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryTotalSwappableAmountRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -234,12 +431,12 @@ func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryTotalSwappableAmountRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryTotalSwappableAmountRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -247,7 +444,7 @@ func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryTotalSwappableAmountResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -257,18 +454,18 @@ func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryTotalSwappableAmountResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryTotalSwappableAmountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.SwappableNewCoinAmount.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -291,22 +488,44 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *QueryParamsRequest) Size() (n int) { +func (m *QuerySwappedRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QuerySwappedResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l + l = m.OldCoinAmount.Size() + n += 1 + l + sovQuery(uint64(l)) + l = m.NewCoinAmount.Size() + n += 1 + l + sovQuery(uint64(l)) return n } -func (m *QueryParamsResponse) Size() (n int) { +func (m *QueryTotalSwappableAmountRequest) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = m.Params.Size() + return n +} + +func (m *QueryTotalSwappableAmountResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.SwappableNewCoinAmount.Size() n += 1 + l + sovQuery(uint64(l)) return n } @@ -317,7 +536,173 @@ func sovQuery(x uint64) (n int) { func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { +func (m *QuerySwappedRequest) 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 ErrIntOverflowQuery + } + 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: QuerySwappedRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QuerySwappedRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QuerySwappedResponse) 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 ErrIntOverflowQuery + } + 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: QuerySwappedResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QuerySwappedResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OldCoinAmount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.OldCoinAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewCoinAmount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.NewCoinAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryTotalSwappableAmountRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -340,10 +725,10 @@ func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryTotalSwappableAmountRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryTotalSwappableAmountRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -367,7 +752,7 @@ func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { +func (m *QueryTotalSwappableAmountResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -390,15 +775,15 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryTotalSwappableAmountResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryTotalSwappableAmountResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SwappableNewCoinAmount", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -425,7 +810,7 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.SwappableNewCoinAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/fswap/types/query.pb.gw.go b/x/fswap/types/query.pb.gw.go index 018e3852ec..5a63817f6a 100644 --- a/x/fswap/types/query.pb.gw.go +++ b/x/fswap/types/query.pb.gw.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: fswap/query.proto +// source: lbm/fswap/v1/query.proto /* Package types is a reverse proxy. @@ -20,7 +20,6 @@ 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" ) @@ -31,22 +30,39 @@ 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 +func request_Query_Swapped_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySwappedRequest var metadata runtime.ServerMetadata - msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.Swapped(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryParamsRequest +func local_request_Query_Swapped_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySwappedRequest var metadata runtime.ServerMetadata - msg, err := server.Params(ctx, &protoReq) + msg, err := server.Swapped(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_TotalNewCurrencySwapLimit_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTotalSwappableAmountRequest + var metadata runtime.ServerMetadata + + msg, err := client.TotalNewCurrencySwapLimit(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_TotalNewCurrencySwapLimit_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTotalSwappableAmountRequest + var metadata runtime.ServerMetadata + + msg, err := server.TotalNewCurrencySwapLimit(ctx, &protoReq) return msg, metadata, err } @@ -54,29 +70,46 @@ 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 to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) 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) { + mux.Handle("GET", pattern_Query_Swapped_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Swapped_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Swapped_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_TotalNewCurrencySwapLimit_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 { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) 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()) + resp, md, err := local_request_Query_TotalNewCurrencySwapLimit_0(rctx, inboundMarshaler, server, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_TotalNewCurrencySwapLimit_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -121,7 +154,27 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // "QueryClient" to call the correct interceptors. func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_Swapped_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Swapped_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Swapped_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_TotalNewCurrencySwapLimit_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -130,14 +183,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_TotalNewCurrencySwapLimit_0(rctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_TotalNewCurrencySwapLimit_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -145,9 +198,13 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 0, 2, 1}, []string{"fswap", "params"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Swapped_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"lbm", "fswap", "v1", "swapped"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_TotalNewCurrencySwapLimit_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"lbm", "fswap", "v1", "swappable_new_coin_amount"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( - forward_Query_Params_0 = runtime.ForwardResponseMessage + forward_Query_Swapped_0 = runtime.ForwardResponseMessage + + forward_Query_TotalNewCurrencySwapLimit_0 = runtime.ForwardResponseMessage ) diff --git a/x/fswap/types/tx.pb.go b/x/fswap/types/tx.pb.go index 84085d0c71..9a93f8566f 100644 --- a/x/fswap/types/tx.pb.go +++ b/x/fswap/types/tx.pb.go @@ -1,15 +1,21 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: fswap/tx.proto +// source: lbm/fswap/v1/tx.proto package types import ( context "context" fmt "fmt" + types "github.com/Finschia/finschia-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" math "math" + math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. @@ -23,17 +29,220 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -func init() { proto.RegisterFile("fswap/tx.proto", fileDescriptor_53fb6877925c5245) } +type MsgSwapRequest struct { + // holder's address + FromAddress string `protobuf:"bytes,1,opt,name=from_address,json=fromAddress,proto3" json:"from_address,omitempty"` + // amount of old currency + Amount types.Coin `protobuf:"bytes,2,opt,name=amount,proto3,castrepeated=github.com/Finschia/finschia-sdk/types.Coin" json:"amount"` +} + +func (m *MsgSwapRequest) Reset() { *m = MsgSwapRequest{} } +func (m *MsgSwapRequest) String() string { return proto.CompactTextString(m) } +func (*MsgSwapRequest) ProtoMessage() {} +func (*MsgSwapRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_65c77cf1d9b67323, []int{0} +} +func (m *MsgSwapRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSwapRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSwapRequest.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 *MsgSwapRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSwapRequest.Merge(m, src) +} +func (m *MsgSwapRequest) XXX_Size() int { + return m.Size() +} +func (m *MsgSwapRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSwapRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSwapRequest proto.InternalMessageInfo + +func (m *MsgSwapRequest) GetFromAddress() string { + if m != nil { + return m.FromAddress + } + return "" +} + +func (m *MsgSwapRequest) GetAmount() types.Coin { + if m != nil { + return m.Amount + } + return types.Coin{} +} + +type MsgSwapResponse struct { +} + +func (m *MsgSwapResponse) Reset() { *m = MsgSwapResponse{} } +func (m *MsgSwapResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSwapResponse) ProtoMessage() {} +func (*MsgSwapResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_65c77cf1d9b67323, []int{1} +} +func (m *MsgSwapResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSwapResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSwapResponse.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 *MsgSwapResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSwapResponse.Merge(m, src) +} +func (m *MsgSwapResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSwapResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSwapResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSwapResponse proto.InternalMessageInfo + +type MsgSwapAllRequest struct { + // holder's address + FromAddress string `protobuf:"bytes,1,opt,name=from_address,json=fromAddress,proto3" json:"from_address,omitempty"` +} + +func (m *MsgSwapAllRequest) Reset() { *m = MsgSwapAllRequest{} } +func (m *MsgSwapAllRequest) String() string { return proto.CompactTextString(m) } +func (*MsgSwapAllRequest) ProtoMessage() {} +func (*MsgSwapAllRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_65c77cf1d9b67323, []int{2} +} +func (m *MsgSwapAllRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSwapAllRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSwapAllRequest.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 *MsgSwapAllRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSwapAllRequest.Merge(m, src) +} +func (m *MsgSwapAllRequest) XXX_Size() int { + return m.Size() +} +func (m *MsgSwapAllRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSwapAllRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSwapAllRequest proto.InternalMessageInfo + +func (m *MsgSwapAllRequest) GetFromAddress() string { + if m != nil { + return m.FromAddress + } + return "" +} -var fileDescriptor_53fb6877925c5245 = []byte{ - // 98 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4b, 0x2b, 0x2e, 0x4f, - 0x2c, 0xd0, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x06, 0xf3, 0xf5, 0xc0, - 0xa4, 0x11, 0x2b, 0x17, 0xb3, 0x6f, 0x71, 0xba, 0x93, 0xee, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, - 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, - 0x1e, 0xcb, 0x31, 0x44, 0x09, 0x43, 0x74, 0x57, 0xe8, 0x43, 0x4d, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, - 0x62, 0x03, 0x9b, 0x64, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x2c, 0xe5, 0xc3, 0x35, 0x5b, 0x00, - 0x00, 0x00, +type MsgSwapAllResponse struct { + // amount of swapped in new currency + Amount types.Coin `protobuf:"bytes,1,opt,name=amount,proto3,castrepeated=github.com/Finschia/finschia-sdk/types.Coin" json:"amount"` +} + +func (m *MsgSwapAllResponse) Reset() { *m = MsgSwapAllResponse{} } +func (m *MsgSwapAllResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSwapAllResponse) ProtoMessage() {} +func (*MsgSwapAllResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_65c77cf1d9b67323, []int{3} +} +func (m *MsgSwapAllResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSwapAllResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSwapAllResponse.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 *MsgSwapAllResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSwapAllResponse.Merge(m, src) +} +func (m *MsgSwapAllResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSwapAllResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSwapAllResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSwapAllResponse proto.InternalMessageInfo + +func (m *MsgSwapAllResponse) GetAmount() types.Coin { + if m != nil { + return m.Amount + } + return types.Coin{} +} + +func init() { + proto.RegisterType((*MsgSwapRequest)(nil), "lbm.fswap.v1.MsgSwapRequest") + proto.RegisterType((*MsgSwapResponse)(nil), "lbm.fswap.v1.MsgSwapResponse") + proto.RegisterType((*MsgSwapAllRequest)(nil), "lbm.fswap.v1.MsgSwapAllRequest") + proto.RegisterType((*MsgSwapAllResponse)(nil), "lbm.fswap.v1.MsgSwapAllResponse") +} + +func init() { proto.RegisterFile("lbm/fswap/v1/tx.proto", fileDescriptor_65c77cf1d9b67323) } + +var fileDescriptor_65c77cf1d9b67323 = []byte{ + // 356 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xcd, 0x49, 0xca, 0xd5, + 0x4f, 0x2b, 0x2e, 0x4f, 0x2c, 0xd0, 0x2f, 0x33, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, + 0xc9, 0x17, 0xe2, 0xc9, 0x49, 0xca, 0xd5, 0x03, 0x0b, 0xeb, 0x95, 0x19, 0x4a, 0x89, 0xa4, 0xe7, + 0xa7, 0xe7, 0x83, 0x25, 0xf4, 0x41, 0x2c, 0x88, 0x1a, 0x29, 0xb9, 0xe4, 0xfc, 0xe2, 0xdc, 0xfc, + 0x62, 0xfd, 0xa4, 0xc4, 0xe2, 0x54, 0xfd, 0x32, 0xc3, 0xa4, 0xd4, 0x92, 0x44, 0x43, 0xfd, 0xe4, + 0xfc, 0xcc, 0x3c, 0x88, 0xbc, 0xd2, 0x6c, 0x46, 0x2e, 0x3e, 0xdf, 0xe2, 0xf4, 0xe0, 0xf2, 0xc4, + 0x82, 0xa0, 0xd4, 0xc2, 0xd2, 0xd4, 0xe2, 0x12, 0x21, 0x45, 0x2e, 0x9e, 0xb4, 0xa2, 0xfc, 0xdc, + 0xf8, 0xc4, 0x94, 0x94, 0xa2, 0xd4, 0xe2, 0x62, 0x09, 0x46, 0x05, 0x46, 0x0d, 0xce, 0x20, 0x6e, + 0x90, 0x98, 0x23, 0x44, 0x48, 0x28, 0x8d, 0x8b, 0x2d, 0x31, 0x37, 0xbf, 0x34, 0xaf, 0x44, 0x82, + 0x49, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x52, 0x0f, 0x62, 0x8d, 0x1e, 0xc8, 0x1a, 0x3d, 0xa8, 0x35, + 0x7a, 0xce, 0xf9, 0x99, 0x79, 0x4e, 0xc6, 0x27, 0xee, 0xc9, 0x33, 0xac, 0xba, 0x2f, 0xaf, 0x9d, + 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0xef, 0x96, 0x99, 0x57, 0x9c, 0x9c, + 0x91, 0x99, 0xa8, 0x9f, 0x06, 0x65, 0xe8, 0x16, 0xa7, 0x64, 0xeb, 0x97, 0x54, 0x16, 0xa4, 0x16, + 0x83, 0x35, 0x05, 0x41, 0x4d, 0x57, 0x12, 0xe4, 0xe2, 0x87, 0x3b, 0xae, 0xb8, 0x20, 0x3f, 0xaf, + 0x38, 0x55, 0xc9, 0x8c, 0x4b, 0x10, 0x2a, 0xe4, 0x98, 0x93, 0x43, 0xbc, 0x93, 0x95, 0x6a, 0xb8, + 0x84, 0x90, 0xf5, 0x41, 0x4c, 0x43, 0xf2, 0x08, 0x23, 0x2d, 0x3d, 0x62, 0x34, 0x83, 0x91, 0x8b, + 0xd9, 0xb7, 0x38, 0x5d, 0xc8, 0x99, 0x8b, 0x05, 0xe4, 0x04, 0x21, 0x19, 0x3d, 0xe4, 0xb8, 0xd3, + 0x43, 0x8d, 0x01, 0x29, 0x59, 0x1c, 0xb2, 0x50, 0x47, 0xfb, 0x70, 0xb1, 0x43, 0xfd, 0x21, 0x24, + 0x8f, 0x55, 0x25, 0x22, 0x64, 0xa4, 0x14, 0x70, 0x2b, 0x80, 0x98, 0xe6, 0xe4, 0x71, 0xe2, 0x91, + 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, + 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x7a, 0x04, 0x7d, 0x5a, 0x01, 0x4d, 0x95, 0x60, + 0x1f, 0x27, 0xb1, 0x81, 0x93, 0x94, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x66, 0x25, 0x56, 0x7f, + 0xaf, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -48,6 +257,8 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { + Swap(ctx context.Context, in *MsgSwapRequest, opts ...grpc.CallOption) (*MsgSwapResponse, error) + SwapAll(ctx context.Context, in *MsgSwapAllRequest, opts ...grpc.CallOption) (*MsgSwapAllResponse, error) } type msgClient struct { @@ -58,22 +269,700 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } +func (c *msgClient) Swap(ctx context.Context, in *MsgSwapRequest, opts ...grpc.CallOption) (*MsgSwapResponse, error) { + out := new(MsgSwapResponse) + err := c.cc.Invoke(ctx, "/lbm.fswap.v1.Msg/Swap", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) SwapAll(ctx context.Context, in *MsgSwapAllRequest, opts ...grpc.CallOption) (*MsgSwapAllResponse, error) { + out := new(MsgSwapAllResponse) + err := c.cc.Invoke(ctx, "/lbm.fswap.v1.Msg/SwapAll", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { + Swap(context.Context, *MsgSwapRequest) (*MsgSwapResponse, error) + SwapAll(context.Context, *MsgSwapAllRequest) (*MsgSwapAllResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. type UnimplementedMsgServer struct { } +func (*UnimplementedMsgServer) Swap(ctx context.Context, req *MsgSwapRequest) (*MsgSwapResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Swap not implemented") +} +func (*UnimplementedMsgServer) SwapAll(ctx context.Context, req *MsgSwapAllRequest) (*MsgSwapAllResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SwapAll not implemented") +} + func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } +func _Msg_Swap_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSwapRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Swap(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lbm.fswap.v1.Msg/Swap", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Swap(ctx, req.(*MsgSwapRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_SwapAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSwapAllRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SwapAll(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lbm.fswap.v1.Msg/SwapAll", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SwapAll(ctx, req.(*MsgSwapAllRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "fswap.fswap.Msg", + ServiceName: "lbm.fswap.v1.Msg", HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{}, - Metadata: "fswap/tx.proto", + Methods: []grpc.MethodDesc{ + { + MethodName: "Swap", + Handler: _Msg_Swap_Handler, + }, + { + MethodName: "SwapAll", + Handler: _Msg_SwapAll_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "lbm/fswap/v1/tx.proto", +} + +func (m *MsgSwapRequest) 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 *MsgSwapRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSwapRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.FromAddress) > 0 { + i -= len(m.FromAddress) + copy(dAtA[i:], m.FromAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.FromAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSwapResponse) 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 *MsgSwapResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSwapResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgSwapAllRequest) 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 *MsgSwapAllRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSwapAllRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.FromAddress) > 0 { + i -= len(m.FromAddress) + copy(dAtA[i:], m.FromAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.FromAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSwapAllResponse) 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 *MsgSwapAllResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSwapAllResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgSwapRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FromAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Amount.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgSwapResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgSwapAllRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FromAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgSwapAllResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Amount.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgSwapRequest) 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: MsgSwapRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSwapRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FromAddress", 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.FromAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + 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 + 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 *MsgSwapResponse) 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: MsgSwapResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSwapResponse: 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 (m *MsgSwapAllRequest) 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: MsgSwapAllRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSwapAllRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FromAddress", 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.FromAddress = 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 *MsgSwapAllResponse) 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: MsgSwapAllResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSwapAllResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + 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 + 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 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) From f3ef7eedbffc924651d9faff76c1e631ceb1869e Mon Sep 17 00:00:00 2001 From: 170210 Date: Thu, 11 Apr 2024 17:04:54 +0900 Subject: [PATCH 06/17] chore: fix compile error Signed-off-by: 170210 --- x/fswap/client/cli/query.go | 2 +- x/fswap/client/cli/query_params.go | 35 ----------------------------- x/fswap/keeper/grpc_query.go | 12 ++++++++++ x/fswap/keeper/grpc_query_params.go | 20 ----------------- x/fswap/keeper/msg_server.go | 12 ++++++++++ 5 files changed, 25 insertions(+), 56 deletions(-) delete mode 100644 x/fswap/client/cli/query_params.go delete mode 100644 x/fswap/keeper/grpc_query_params.go diff --git a/x/fswap/client/cli/query.go b/x/fswap/client/cli/query.go index eb3ba21181..f9e460613b 100644 --- a/x/fswap/client/cli/query.go +++ b/x/fswap/client/cli/query.go @@ -24,7 +24,7 @@ func GetQueryCmd(queryRoute string) *cobra.Command { RunE: client.ValidateCmd, } - cmd.AddCommand(CmdQueryParams()) + cmd.AddCommand() // this line is used by starport scaffolding # 1 return cmd diff --git a/x/fswap/client/cli/query_params.go b/x/fswap/client/cli/query_params.go deleted file mode 100644 index 208aff3327..0000000000 --- a/x/fswap/client/cli/query_params.go +++ /dev/null @@ -1,35 +0,0 @@ -package cli - -import ( - "context" - - "github.com/Finschia/finschia-sdk/x/fswap/types" - - "github.com/Finschia/finschia-sdk/client" - "github.com/Finschia/finschia-sdk/client/flags" - "github.com/spf13/cobra" -) - -func CmdQueryParams() *cobra.Command { - cmd := &cobra.Command{ - Use: "params", - Short: "shows the parameters of the module", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) - - queryClient := types.NewQueryClient(clientCtx) - - res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{}) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} diff --git a/x/fswap/keeper/grpc_query.go b/x/fswap/keeper/grpc_query.go index 5f6ce68ab3..b55b7c1155 100644 --- a/x/fswap/keeper/grpc_query.go +++ b/x/fswap/keeper/grpc_query.go @@ -1,7 +1,19 @@ package keeper import ( + "context" + "github.com/Finschia/finschia-sdk/x/fswap/types" ) var _ types.QueryServer = Keeper{} + +// Swapped implements types.QueryServer. +func (k Keeper) Swapped(context.Context, *types.QuerySwappedRequest) (*types.QuerySwappedResponse, error) { + panic("unimplemented") +} + +// TotalNewCurrencySwapLimit implements types.QueryServer. +func (k Keeper) TotalNewCurrencySwapLimit(context.Context, *types.QueryTotalSwappableAmountRequest) (*types.QueryTotalSwappableAmountResponse, error) { + panic("unimplemented") +} diff --git a/x/fswap/keeper/grpc_query_params.go b/x/fswap/keeper/grpc_query_params.go deleted file mode 100644 index c3f9a1f7af..0000000000 --- a/x/fswap/keeper/grpc_query_params.go +++ /dev/null @@ -1,20 +0,0 @@ -package keeper - -import ( - "context" - - "github.com/Finschia/finschia-sdk/x/fswap/types" - - sdk "github.com/Finschia/finschia-sdk/types" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" -) - -func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - ctx := sdk.UnwrapSDKContext(c) - - return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil -} diff --git a/x/fswap/keeper/msg_server.go b/x/fswap/keeper/msg_server.go index b9b4b1fa6c..41b76b832a 100644 --- a/x/fswap/keeper/msg_server.go +++ b/x/fswap/keeper/msg_server.go @@ -1,6 +1,8 @@ package keeper import ( + "context" + "github.com/Finschia/finschia-sdk/x/fswap/types" ) @@ -15,3 +17,13 @@ func NewMsgServerImpl(keeper Keeper) types.MsgServer { } var _ types.MsgServer = msgServer{} + +// Swap implements types.MsgServer. +func (m msgServer) Swap(context.Context, *types.MsgSwapRequest) (*types.MsgSwapResponse, error) { + panic("unimplemented") +} + +// SwapAll implements types.MsgServer. +func (m msgServer) SwapAll(context.Context, *types.MsgSwapAllRequest) (*types.MsgSwapAllResponse, error) { + panic("unimplemented") +} From 41f65700dccc1c813644eec4eb6fb3309a945c66 Mon Sep 17 00:00:00 2001 From: 170210 Date: Thu, 11 Apr 2024 19:18:08 +0900 Subject: [PATCH 07/17] chore: add new field in params proto Signed-off-by: 170210 --- docs/core/proto-docs.md | 3 +- proto/lbm/fswap/v1/params.proto | 8 ++- x/fswap/types/params.pb.go | 120 ++++++++++++++++++++++---------- 3 files changed, 89 insertions(+), 42 deletions(-) diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index c1574b55ab..03a5427a91 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -12757,7 +12757,8 @@ Params defines the parameters for the module. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `new_coin_swap_total_limit` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | upper limit in new coin that this module can swap | -| `swap_rate` | [double](#double) | | constant value for swap rate, 148.079656 | +| `swap_rate` | [uint64](#uint64) | | constant value representing the exchange rate, without decimal (148079656) | +| `swap_rate_decimals` | [int32](#int32) | | The number shows how to get the true exchange rate by dividing swap_rate by 10 to the power | | `new_coin_denom` | [string](#string) | | new denomination for new coin after swap | diff --git a/proto/lbm/fswap/v1/params.proto b/proto/lbm/fswap/v1/params.proto index 03dbcf9c22..c0a6030da9 100644 --- a/proto/lbm/fswap/v1/params.proto +++ b/proto/lbm/fswap/v1/params.proto @@ -13,8 +13,10 @@ message Params { // upper limit in new coin that this module can swap cosmos.base.v1beta1.Coin new_coin_swap_total_limit = 1 [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/Finschia/finschia-sdk/types.Coin"]; - // constant value for swap rate, 148.079656 - double swap_rate = 2; + // constant value representing the exchange rate, without decimal (148079656) + uint64 swap_rate = 2; + // The number shows how to get the true exchange rate by dividing swap_rate by 10 to the power + int32 swap_rate_decimals = 3; // new denomination for new coin after swap - string new_coin_denom = 3; + string new_coin_denom = 4; } \ No newline at end of file diff --git a/x/fswap/types/params.pb.go b/x/fswap/types/params.pb.go index ecc820e3fa..9298bdc283 100644 --- a/x/fswap/types/params.pb.go +++ b/x/fswap/types/params.pb.go @@ -4,7 +4,6 @@ package types import ( - encoding_binary "encoding/binary" fmt "fmt" types "github.com/Finschia/finschia-sdk/types" _ "github.com/gogo/protobuf/gogoproto" @@ -29,10 +28,12 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Params struct { // upper limit in new coin that this module can swap NewCoinSwapTotalLimit types.Coin `protobuf:"bytes,1,opt,name=new_coin_swap_total_limit,json=newCoinSwapTotalLimit,proto3,castrepeated=github.com/Finschia/finschia-sdk/types.Coin" json:"new_coin_swap_total_limit"` - // constant value for swap rate, 148.079656 - SwapRate float64 `protobuf:"fixed64,2,opt,name=swap_rate,json=swapRate,proto3" json:"swap_rate,omitempty"` + // constant value representing the exchange rate, without decimal (148079656) + SwapRate uint64 `protobuf:"varint,2,opt,name=swap_rate,json=swapRate,proto3" json:"swap_rate,omitempty"` + // The number shows how to get the true exchange rate by dividing swap_rate by 10 to the power + SwapRateDecimals int32 `protobuf:"varint,3,opt,name=swap_rate_decimals,json=swapRateDecimals,proto3" json:"swap_rate_decimals,omitempty"` // new denomination for new coin after swap - NewCoinDenom string `protobuf:"bytes,3,opt,name=new_coin_denom,json=newCoinDenom,proto3" json:"new_coin_denom,omitempty"` + NewCoinDenom string `protobuf:"bytes,4,opt,name=new_coin_denom,json=newCoinDenom,proto3" json:"new_coin_denom,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -74,13 +75,20 @@ func (m *Params) GetNewCoinSwapTotalLimit() types.Coin { return types.Coin{} } -func (m *Params) GetSwapRate() float64 { +func (m *Params) GetSwapRate() uint64 { if m != nil { return m.SwapRate } return 0 } +func (m *Params) GetSwapRateDecimals() int32 { + if m != nil { + return m.SwapRateDecimals + } + return 0 +} + func (m *Params) GetNewCoinDenom() string { if m != nil { return m.NewCoinDenom @@ -95,27 +103,29 @@ func init() { func init() { proto.RegisterFile("lbm/fswap/v1/params.proto", fileDescriptor_15e620b81032c44d) } var fileDescriptor_15e620b81032c44d = []byte{ - // 317 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x90, 0xb1, 0x4e, 0xeb, 0x30, - 0x14, 0x86, 0xe3, 0x7b, 0x51, 0x45, 0x43, 0xc5, 0x10, 0x81, 0xd4, 0x16, 0xc9, 0xad, 0x10, 0x43, - 0x25, 0x84, 0xad, 0xd0, 0x8d, 0xb1, 0x20, 0xc4, 0xc0, 0x80, 0x02, 0x13, 0x4b, 0x64, 0xa7, 0x6e, - 0x6b, 0x11, 0xdb, 0x51, 0x6d, 0x12, 0x78, 0x03, 0x46, 0x46, 0x46, 0x66, 0x9e, 0xa4, 0x63, 0x47, - 0x06, 0x04, 0x28, 0x79, 0x11, 0x64, 0x27, 0x62, 0x65, 0xfb, 0x75, 0x7e, 0xfb, 0x3b, 0x9f, 0x8e, - 0xdf, 0x4b, 0xa9, 0xc0, 0x33, 0x5d, 0x90, 0x0c, 0xe7, 0x21, 0xce, 0xc8, 0x92, 0x08, 0x8d, 0xb2, - 0xa5, 0x32, 0x2a, 0xe8, 0xa4, 0x54, 0x20, 0x57, 0xa1, 0x3c, 0xec, 0xef, 0xcc, 0xd5, 0x5c, 0xb9, - 0x02, 0xdb, 0x54, 0xbf, 0xe9, 0xc3, 0x44, 0x69, 0xa1, 0x34, 0xa6, 0x44, 0x33, 0x9c, 0x87, 0x94, - 0x19, 0x12, 0xe2, 0x44, 0x71, 0x59, 0xf7, 0xfb, 0x1f, 0xc0, 0x6f, 0x5d, 0x39, 0x68, 0xf0, 0x04, - 0xfc, 0x9e, 0x64, 0x45, 0x6c, 0xdb, 0xd8, 0x52, 0x63, 0xa3, 0x0c, 0x49, 0xe3, 0x94, 0x0b, 0x6e, - 0xba, 0x60, 0x08, 0x46, 0x5b, 0xc7, 0x3d, 0x54, 0xf3, 0x90, 0xe5, 0xa1, 0x86, 0x87, 0x4e, 0x15, - 0x97, 0x93, 0xf1, 0xea, 0x73, 0xe0, 0xbd, 0x7d, 0x0d, 0x0e, 0xe7, 0xdc, 0x2c, 0xee, 0x29, 0x4a, - 0x94, 0xc0, 0xe7, 0x5c, 0xea, 0x64, 0xc1, 0x09, 0x9e, 0x35, 0xe1, 0x48, 0x4f, 0xef, 0xb0, 0x79, - 0xcc, 0x98, 0x76, 0x9f, 0xa2, 0x5d, 0xc9, 0x0a, 0x1b, 0xae, 0x0b, 0x92, 0xdd, 0xd8, 0x6d, 0x97, - 0x76, 0x59, 0xb0, 0xe7, 0xb7, 0x9d, 0xc0, 0x92, 0x18, 0xd6, 0xfd, 0x37, 0x04, 0x23, 0x10, 0x6d, - 0xda, 0x41, 0x44, 0x0c, 0x0b, 0x0e, 0xfc, 0xed, 0x5f, 0xcd, 0x29, 0x93, 0x4a, 0x74, 0xff, 0x0f, - 0xc1, 0xa8, 0x1d, 0x75, 0x1a, 0xd6, 0x99, 0x9d, 0x9d, 0x6c, 0xbc, 0xbc, 0x0e, 0xbc, 0xc9, 0xc5, - 0xaa, 0x84, 0x60, 0x5d, 0x42, 0xf0, 0x5d, 0x42, 0xf0, 0x5c, 0x41, 0x6f, 0x5d, 0x41, 0xef, 0xbd, - 0x82, 0xde, 0x2d, 0xfa, 0x53, 0xf3, 0xa1, 0x39, 0xbb, 0xd3, 0xa5, 0x2d, 0x77, 0xaf, 0xf1, 0x4f, - 0x00, 0x00, 0x00, 0xff, 0xff, 0xfc, 0x06, 0x39, 0x42, 0x90, 0x01, 0x00, 0x00, + // 342 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0xb1, 0x4e, 0xeb, 0x30, + 0x18, 0x85, 0xe3, 0xde, 0xde, 0x8a, 0x86, 0x0a, 0xa1, 0x08, 0xa4, 0xb4, 0x48, 0x6e, 0x84, 0x18, + 0x22, 0x01, 0xb6, 0x42, 0x37, 0xc6, 0x52, 0x21, 0x06, 0x06, 0x14, 0x98, 0x58, 0x22, 0x27, 0x75, + 0x5b, 0x8b, 0x38, 0x8e, 0x6a, 0xd3, 0xc0, 0x1b, 0x20, 0x26, 0x46, 0x46, 0x66, 0x9e, 0xa4, 0x63, + 0x47, 0x26, 0x40, 0xed, 0x8b, 0x20, 0x3b, 0xa1, 0x2b, 0xdb, 0xaf, 0x73, 0x7e, 0x7f, 0xc7, 0xc7, + 0xb6, 0xdb, 0x69, 0xcc, 0xf1, 0x48, 0x16, 0x24, 0xc7, 0xb3, 0x00, 0xe7, 0x64, 0x4a, 0xb8, 0x44, + 0xf9, 0x54, 0x28, 0xe1, 0xb4, 0xd2, 0x98, 0x23, 0x63, 0xa1, 0x59, 0xd0, 0xd9, 0x19, 0x8b, 0xb1, + 0x30, 0x06, 0xd6, 0x53, 0xb9, 0xd3, 0x81, 0x89, 0x90, 0x5c, 0x48, 0x1c, 0x13, 0x49, 0xf1, 0x2c, + 0x88, 0xa9, 0x22, 0x01, 0x4e, 0x04, 0xcb, 0x4a, 0x7f, 0xff, 0xb9, 0x66, 0x37, 0xae, 0x0c, 0xd4, + 0x79, 0x02, 0x76, 0x3b, 0xa3, 0x45, 0xa4, 0xdd, 0x48, 0x53, 0x23, 0x25, 0x14, 0x49, 0xa3, 0x94, + 0x71, 0xa6, 0x5c, 0xe0, 0x01, 0x7f, 0xf3, 0xa4, 0x8d, 0x4a, 0x1e, 0xd2, 0x3c, 0x54, 0xf1, 0xd0, + 0x99, 0x60, 0x59, 0xbf, 0x37, 0xff, 0xec, 0x5a, 0xef, 0x5f, 0xdd, 0xc3, 0x31, 0x53, 0x93, 0xfb, + 0x18, 0x25, 0x82, 0xe3, 0x73, 0x96, 0xc9, 0x64, 0xc2, 0x08, 0x1e, 0x55, 0xc3, 0xb1, 0x1c, 0xde, + 0x61, 0xf5, 0x98, 0x53, 0x69, 0x0e, 0x85, 0xbb, 0x19, 0x2d, 0xf4, 0x70, 0x5d, 0x90, 0xfc, 0x46, + 0xa7, 0x5d, 0xea, 0x30, 0x67, 0xcf, 0x6e, 0x9a, 0x0b, 0x4c, 0x89, 0xa2, 0x6e, 0xcd, 0x03, 0x7e, + 0x3d, 0xdc, 0xd0, 0x42, 0x48, 0x14, 0x75, 0x8e, 0x6c, 0x67, 0x6d, 0x46, 0x43, 0x9a, 0x30, 0x4e, + 0x52, 0xe9, 0xfe, 0xf3, 0x80, 0xff, 0x3f, 0xdc, 0xfe, 0xdd, 0x1a, 0x54, 0xba, 0x73, 0x60, 0x6f, + 0xad, 0x4b, 0x0d, 0x69, 0x26, 0xb8, 0x5b, 0xf7, 0x80, 0xdf, 0x0c, 0x5b, 0x55, 0xf2, 0x40, 0x6b, + 0xa7, 0xf5, 0xd7, 0xb7, 0xae, 0xd5, 0xbf, 0x98, 0x2f, 0x21, 0x58, 0x2c, 0x21, 0xf8, 0x5e, 0x42, + 0xf0, 0xb2, 0x82, 0xd6, 0x62, 0x05, 0xad, 0x8f, 0x15, 0xb4, 0x6e, 0xd1, 0x9f, 0xa5, 0x1e, 0xaa, + 0x4f, 0x32, 0xe5, 0xe2, 0x86, 0x79, 0xdd, 0xde, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa9, 0x6c, + 0x55, 0x7a, 0xbe, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -143,13 +153,17 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.NewCoinDenom) i = encodeVarintParams(dAtA, i, uint64(len(m.NewCoinDenom))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 + } + if m.SwapRateDecimals != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.SwapRateDecimals)) + i-- + dAtA[i] = 0x18 } if m.SwapRate != 0 { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.SwapRate)))) + i = encodeVarintParams(dAtA, i, uint64(m.SwapRate)) i-- - dAtA[i] = 0x11 + dAtA[i] = 0x10 } { size, err := m.NewCoinSwapTotalLimit.MarshalToSizedBuffer(dAtA[:i]) @@ -184,7 +198,10 @@ func (m *Params) Size() (n int) { l = m.NewCoinSwapTotalLimit.Size() n += 1 + l + sovParams(uint64(l)) if m.SwapRate != 0 { - n += 9 + n += 1 + sovParams(uint64(m.SwapRate)) + } + if m.SwapRateDecimals != 0 { + n += 1 + sovParams(uint64(m.SwapRateDecimals)) } l = len(m.NewCoinDenom) if l > 0 { @@ -262,17 +279,44 @@ func (m *Params) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 2: - if wireType != 1 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field SwapRate", wireType) } - var v uint64 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF + m.SwapRate = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SwapRate |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } } - v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - m.SwapRate = float64(math.Float64frombits(v)) case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SwapRateDecimals", wireType) + } + m.SwapRateDecimals = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SwapRateDecimals |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field NewCoinDenom", wireType) } From 78e1d4fe31825ff7914befc5e36fde5351359170 Mon Sep 17 00:00:00 2001 From: 170210 Date: Fri, 12 Apr 2024 13:36:53 +0900 Subject: [PATCH 08/17] fix: fix lint Signed-off-by: 170210 --- x/fswap/client/cli/query.go | 4 ---- x/fswap/client/cli/tx.go | 12 +++++------- x/fswap/genesis.go | 3 +-- x/fswap/handler.go | 17 ++++++++--------- x/fswap/keeper/keeper.go | 5 +---- x/fswap/keeper/params.go | 3 +-- x/fswap/module.go | 10 +++------- x/fswap/types/codec.go | 1 - x/fswap/types/genesis_test.go | 3 ++- x/fswap/types/params.go | 3 ++- 10 files changed, 23 insertions(+), 38 deletions(-) diff --git a/x/fswap/client/cli/query.go b/x/fswap/client/cli/query.go index f9e460613b..8432be5d3e 100644 --- a/x/fswap/client/cli/query.go +++ b/x/fswap/client/cli/query.go @@ -2,14 +2,10 @@ package cli import ( "fmt" - // "strings" "github.com/spf13/cobra" "github.com/Finschia/finschia-sdk/client" - // "github.com/Finschia/finschia-sdk/client/flags" - // sdk "github.com/Finschia/finschia-sdk/types" - "github.com/Finschia/finschia-sdk/x/fswap/types" ) diff --git a/x/fswap/client/cli/tx.go b/x/fswap/client/cli/tx.go index 87e9ced900..603f3c2125 100644 --- a/x/fswap/client/cli/tx.go +++ b/x/fswap/client/cli/tx.go @@ -11,14 +11,12 @@ import ( "github.com/Finschia/finschia-sdk/x/fswap/types" ) -var ( - DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds()) -) +var DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds()) -const ( - flagPacketTimeoutTimestamp = "packet-timeout-timestamp" - listSeparator = "," -) +// const ( +// flagPacketTimeoutTimestamp = "packet-timeout-timestamp" +// listSeparator = "," +// ) // GetTxCmd returns the transaction commands for this module func GetTxCmd() *cobra.Command { diff --git a/x/fswap/genesis.go b/x/fswap/genesis.go index 728b0e8d3c..af232aad36 100644 --- a/x/fswap/genesis.go +++ b/x/fswap/genesis.go @@ -1,10 +1,9 @@ package fswap import ( + sdk "github.com/Finschia/finschia-sdk/types" "github.com/Finschia/finschia-sdk/x/fswap/keeper" "github.com/Finschia/finschia-sdk/x/fswap/types" - - sdk "github.com/Finschia/finschia-sdk/types" ) // InitGenesis initializes the capability module's state from a provided genesis diff --git a/x/fswap/handler.go b/x/fswap/handler.go index 8a1ab99713..2e3dae3f45 100644 --- a/x/fswap/handler.go +++ b/x/fswap/handler.go @@ -3,11 +3,10 @@ package fswap import ( "fmt" - "github.com/Finschia/finschia-sdk/x/fswap/keeper" - "github.com/Finschia/finschia-sdk/x/fswap/types" - sdk "github.com/Finschia/finschia-sdk/types" sdkerrors "github.com/Finschia/finschia-sdk/types/errors" + "github.com/Finschia/finschia-sdk/x/fswap/keeper" + "github.com/Finschia/finschia-sdk/x/fswap/types" ) // NewHandler ... @@ -15,13 +14,13 @@ func NewHandler(k keeper.Keeper) sdk.Handler { // this line is used by starport scaffolding # handler/msgServer return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { - ctx = ctx.WithEventManager(sdk.NewEventManager()) + // ctx = ctx.WithEventManager(sdk.NewEventManager()) - switch msg := msg.(type) { + // switch msg := msg.(type) { // this line is used by starport scaffolding # 1 - default: - errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) - return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) - } + // default: + errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) + return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) + // } } } diff --git a/x/fswap/keeper/keeper.go b/x/fswap/keeper/keeper.go index 5c6799bd3e..e81236cf43 100644 --- a/x/fswap/keeper/keeper.go +++ b/x/fswap/keeper/keeper.go @@ -5,10 +5,9 @@ import ( "github.com/tendermint/tendermint/libs/log" - "github.com/Finschia/finschia-sdk/x/fswap/types" - "github.com/Finschia/finschia-sdk/codec" sdk "github.com/Finschia/finschia-sdk/types" + "github.com/Finschia/finschia-sdk/x/fswap/types" paramtypes "github.com/Finschia/finschia-sdk/x/params/types" ) @@ -26,7 +25,6 @@ func NewKeeper( storeKey, memKey sdk.StoreKey, ps paramtypes.Subspace, - ) *Keeper { // set KeyTable if it has not already been set if !ps.HasKeyTable() { @@ -34,7 +32,6 @@ func NewKeeper( } return &Keeper{ - cdc: cdc, storeKey: storeKey, memKey: memKey, diff --git a/x/fswap/keeper/params.go b/x/fswap/keeper/params.go index 829e69c5cc..77d2823f2e 100644 --- a/x/fswap/keeper/params.go +++ b/x/fswap/keeper/params.go @@ -1,9 +1,8 @@ package keeper import ( - "github.com/Finschia/finschia-sdk/x/fswap/types" - sdk "github.com/Finschia/finschia-sdk/types" + "github.com/Finschia/finschia-sdk/x/fswap/types" ) // GetParams get all parameters as types.Params diff --git a/x/fswap/module.go b/x/fswap/module.go index 2ef4018b20..669eea4734 100644 --- a/x/fswap/module.go +++ b/x/fswap/module.go @@ -4,23 +4,19 @@ import ( "encoding/json" "fmt" - // this line is used by starport scaffolding # 1 - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" - abci "github.com/tendermint/tendermint/abci/types" - "github.com/Finschia/finschia-sdk/x/fswap/client/cli" - "github.com/Finschia/finschia-sdk/x/fswap/keeper" - "github.com/Finschia/finschia-sdk/x/fswap/types" - "github.com/Finschia/finschia-sdk/client" "github.com/Finschia/finschia-sdk/codec" cdctypes "github.com/Finschia/finschia-sdk/codec/types" sdk "github.com/Finschia/finschia-sdk/types" "github.com/Finschia/finschia-sdk/types/module" + "github.com/Finschia/finschia-sdk/x/fswap/client/cli" + "github.com/Finschia/finschia-sdk/x/fswap/keeper" + "github.com/Finschia/finschia-sdk/x/fswap/types" ) var ( diff --git a/x/fswap/types/codec.go b/x/fswap/types/codec.go index 3d8bc224d0..72003233c5 100644 --- a/x/fswap/types/codec.go +++ b/x/fswap/types/codec.go @@ -3,7 +3,6 @@ package types import ( "github.com/Finschia/finschia-sdk/codec" cdctypes "github.com/Finschia/finschia-sdk/codec/types" - // this line is used by starport scaffolding # 1 "github.com/Finschia/finschia-sdk/types/msgservice" ) diff --git a/x/fswap/types/genesis_test.go b/x/fswap/types/genesis_test.go index 16db637933..e4fa429dc8 100644 --- a/x/fswap/types/genesis_test.go +++ b/x/fswap/types/genesis_test.go @@ -3,8 +3,9 @@ package types_test import ( "testing" - "github.com/Finschia/finschia-sdk/x/fswap/types" "github.com/stretchr/testify/require" + + "github.com/Finschia/finschia-sdk/x/fswap/types" ) func TestGenesisState_Validate(t *testing.T) { diff --git a/x/fswap/types/params.go b/x/fswap/types/params.go index 81bb8ee1cc..f3d55e7f9e 100644 --- a/x/fswap/types/params.go +++ b/x/fswap/types/params.go @@ -1,8 +1,9 @@ package types import ( - paramtypes "github.com/Finschia/finschia-sdk/x/params/types" "gopkg.in/yaml.v2" + + paramtypes "github.com/Finschia/finschia-sdk/x/params/types" ) var _ paramtypes.ParamSet = (*Params)(nil) From d26da8481e6bd06e8c95bdf315fc2eeb5da1a6e3 Mon Sep 17 00:00:00 2001 From: 170210 Date: Fri, 12 Apr 2024 17:45:56 +0900 Subject: [PATCH 09/17] feat: add query&tx commands of fswap module Signed-off-by: 170210 --- x/fswap/client/cli/query.go | 56 +++++++++++++++++++++- x/fswap/client/cli/tx.go | 75 +++++++++++++++++++++++++++--- x/fswap/types/msgs.go | 92 +++++++++++++++++++++++++++++++++++++ 3 files changed, 214 insertions(+), 9 deletions(-) create mode 100644 x/fswap/types/msgs.go diff --git a/x/fswap/client/cli/query.go b/x/fswap/client/cli/query.go index 8432be5d3e..55ec1d2bd1 100644 --- a/x/fswap/client/cli/query.go +++ b/x/fswap/client/cli/query.go @@ -6,6 +6,7 @@ import ( "github.com/spf13/cobra" "github.com/Finschia/finschia-sdk/client" + "github.com/Finschia/finschia-sdk/client/flags" "github.com/Finschia/finschia-sdk/x/fswap/types" ) @@ -20,8 +21,59 @@ func GetQueryCmd(queryRoute string) *cobra.Command { RunE: client.ValidateCmd, } - cmd.AddCommand() - // this line is used by starport scaffolding # 1 + cmd.AddCommand( + CmdQuerySwapped(), + CmdQueryTotalSwappableAmount(), + ) + return cmd +} + +func CmdQuerySwapped() *cobra.Command { + cmd := &cobra.Command{ + Use: "fswap swapped", + Short: "shows the current swap status, including both old and new coin amount", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.Swapped(cmd.Context(), &types.QuerySwappedRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + return cmd +} + +func CmdQueryTotalSwappableAmount() *cobra.Command { + cmd := &cobra.Command{ + Use: "fswap total-swappable-amount", + Short: "shows the current total amount of new coin that're swappable", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.TotalNewCurrencySwapLimit(cmd.Context(), &types.QueryTotalSwappableAmountRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + flags.AddQueryFlagsToCmd(cmd) return cmd } diff --git a/x/fswap/client/cli/tx.go b/x/fswap/client/cli/tx.go index 603f3c2125..9b2f915ab7 100644 --- a/x/fswap/client/cli/tx.go +++ b/x/fswap/client/cli/tx.go @@ -7,17 +7,14 @@ import ( "github.com/spf13/cobra" "github.com/Finschia/finschia-sdk/client" - // "github.com/Finschia/finschia-sdk/client/flags" + "github.com/Finschia/finschia-sdk/client/flags" + "github.com/Finschia/finschia-sdk/client/tx" + sdk "github.com/Finschia/finschia-sdk/types" "github.com/Finschia/finschia-sdk/x/fswap/types" ) var DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds()) -// const ( -// flagPacketTimeoutTimestamp = "packet-timeout-timestamp" -// listSeparator = "," -// ) - // GetTxCmd returns the transaction commands for this module func GetTxCmd() *cobra.Command { cmd := &cobra.Command{ @@ -27,8 +24,72 @@ func GetTxCmd() *cobra.Command { SuggestionsMinimumDistance: 2, RunE: client.ValidateCmd, } + cmd.AddCommand( + CmdTxMsgSwap(), + CmdTxMsgSwapAll(), + ) + + return cmd +} - // this line is used by starport scaffolding # 1 +func CmdTxMsgSwap() *cobra.Command { + cmd := &cobra.Command{ + Use: "fswap swap [address] [fnsa_amount]", + Short: "swap amounts of old coin to new coin. Note, the'--from' flag is ignored as it is implied from [address].", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + if err := cmd.Flags().Set(flags.FlagFrom, args[0]); err != nil { + return err + } + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + coin, err := sdk.ParseCoinNormalized(args[2]) + if err != nil { + return err + } + + msg := &types.MsgSwapRequest{ + FromAddress: clientCtx.GetFromAddress().String(), + Amount: coin, + } + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} + +func CmdTxMsgSwapAll() *cobra.Command { + cmd := &cobra.Command{ + Use: "fswap swap-all [address]", + Short: "swap all the old coins. Note, the'--from' flag is ignored as it is implied from [address].", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + if err := cmd.Flags().Set(flags.FlagFrom, args[0]); err != nil { + return err + } + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := &types.MsgSwapAllRequest{ + FromAddress: clientCtx.GetFromAddress().String(), + } + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + flags.AddTxFlagsToCmd(cmd) return cmd } diff --git a/x/fswap/types/msgs.go b/x/fswap/types/msgs.go new file mode 100644 index 0000000000..dabae8d74c --- /dev/null +++ b/x/fswap/types/msgs.go @@ -0,0 +1,92 @@ +package types + +import ( + sdk "github.com/Finschia/finschia-sdk/types" + sdkerrors "github.com/Finschia/finschia-sdk/types/errors" +) + +var _ sdk.Msg = &MsgSwapRequest{} + +// NewMsgSwapRequest - construct a msg to swap amounts of old coin to new coin +// +//nolint:interfacer +func NewMsgSwapRequest(fromAddr, toAddr sdk.AccAddress, amount sdk.Coin) *MsgSwapRequest { + return &MsgSwapRequest{FromAddress: fromAddr.String(), Amount: amount} +} + +// Route Implements Msg. +func (msg MsgSwapRequest) Route() string { return RouterKey } + +// Type Implements Msg. +func (msg MsgSwapRequest) Type() string { return sdk.MsgTypeURL(&msg) } + +// ValidateBasic Implements Msg. +func (msg MsgSwapRequest) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.FromAddress) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid address (%s)", err) + } + + if !msg.Amount.IsValid() { + return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, msg.Amount.String()) + } + + if !msg.Amount.IsPositive() { + return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, msg.Amount.String()) + } + + return nil +} + +// GetSignBytes Implements Msg. +func (msg MsgSwapRequest) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +// GetSigners Implements Msg. +func (msg MsgSwapRequest) GetSigners() []sdk.AccAddress { + from, err := sdk.AccAddressFromBech32(msg.FromAddress) + if err != nil { + panic(err) + } + return []sdk.AccAddress{from} +} + +var _ sdk.Msg = &MsgSwapAllRequest{} + +// NewMsgSwapRequest - construct a msg to swap all old coin to new coin +// +//nolint:interfacer +func NewMsgSwapAllRequest(fromAddr, toAddr sdk.AccAddress) *MsgSwapAllRequest { + return &MsgSwapAllRequest{FromAddress: fromAddr.String()} +} + +// Route Implements Msg. +func (msg MsgSwapAllRequest) Route() string { return RouterKey } + +// Type Implements Msg. +func (msg MsgSwapAllRequest) Type() string { return sdk.MsgTypeURL(&msg) } + +// ValidateBasic Implements Msg. +func (msg MsgSwapAllRequest) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.FromAddress) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid address (%s)", err) + } + + return nil +} + +// GetSignBytes Implements Msg. +func (msg MsgSwapAllRequest) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +// GetSigners Implements Msg. +func (msg MsgSwapAllRequest) GetSigners() []sdk.AccAddress { + from, err := sdk.AccAddressFromBech32(msg.FromAddress) + if err != nil { + panic(err) + } + return []sdk.AccAddress{from} +} From 42f19302658fc631cc58715d7e64e111331b76e0 Mon Sep 17 00:00:00 2001 From: 170210 Date: Mon, 15 Apr 2024 14:44:22 +0900 Subject: [PATCH 10/17] fix: fix for comment Signed-off-by: 170210 --- docs/core/proto-docs.md | 5 -- proto/lbm/fswap/v1/params.proto | 2 +- proto/lbm/fswap/v1/tx.proto | 6 +- x/fswap/types/tx.pb.go | 101 ++++++++------------------------ 4 files changed, 25 insertions(+), 89 deletions(-) diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index 03a5427a91..423eff0da4 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -12912,11 +12912,6 @@ GenesisState defines the fswap module's genesis state. -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | amount of swapped in new currency | - - diff --git a/proto/lbm/fswap/v1/params.proto b/proto/lbm/fswap/v1/params.proto index c0a6030da9..3507c72b91 100644 --- a/proto/lbm/fswap/v1/params.proto +++ b/proto/lbm/fswap/v1/params.proto @@ -19,4 +19,4 @@ message Params { int32 swap_rate_decimals = 3; // new denomination for new coin after swap string new_coin_denom = 4; -} \ No newline at end of file +} diff --git a/proto/lbm/fswap/v1/tx.proto b/proto/lbm/fswap/v1/tx.proto index 6942bb7d80..c9b3c171bc 100644 --- a/proto/lbm/fswap/v1/tx.proto +++ b/proto/lbm/fswap/v1/tx.proto @@ -26,8 +26,4 @@ message MsgSwapAllRequest { string from_address = 1; } -message MsgSwapAllResponse { - // amount of swapped in new currency - cosmos.base.v1beta1.Coin amount = 1 - [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/Finschia/finschia-sdk/types.Coin"]; -} +message MsgSwapAllResponse {} diff --git a/x/fswap/types/tx.pb.go b/x/fswap/types/tx.pb.go index 9a93f8566f..682ec7260b 100644 --- a/x/fswap/types/tx.pb.go +++ b/x/fswap/types/tx.pb.go @@ -165,8 +165,6 @@ func (m *MsgSwapAllRequest) GetFromAddress() string { } type MsgSwapAllResponse struct { - // amount of swapped in new currency - Amount types.Coin `protobuf:"bytes,1,opt,name=amount,proto3,castrepeated=github.com/Finschia/finschia-sdk/types.Coin" json:"amount"` } func (m *MsgSwapAllResponse) Reset() { *m = MsgSwapAllResponse{} } @@ -202,13 +200,6 @@ func (m *MsgSwapAllResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSwapAllResponse proto.InternalMessageInfo -func (m *MsgSwapAllResponse) GetAmount() types.Coin { - if m != nil { - return m.Amount - } - return types.Coin{} -} - func init() { proto.RegisterType((*MsgSwapRequest)(nil), "lbm.fswap.v1.MsgSwapRequest") proto.RegisterType((*MsgSwapResponse)(nil), "lbm.fswap.v1.MsgSwapResponse") @@ -219,30 +210,29 @@ func init() { func init() { proto.RegisterFile("lbm/fswap/v1/tx.proto", fileDescriptor_65c77cf1d9b67323) } var fileDescriptor_65c77cf1d9b67323 = []byte{ - // 356 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xcd, 0x49, 0xca, 0xd5, - 0x4f, 0x2b, 0x2e, 0x4f, 0x2c, 0xd0, 0x2f, 0x33, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, - 0xc9, 0x17, 0xe2, 0xc9, 0x49, 0xca, 0xd5, 0x03, 0x0b, 0xeb, 0x95, 0x19, 0x4a, 0x89, 0xa4, 0xe7, - 0xa7, 0xe7, 0x83, 0x25, 0xf4, 0x41, 0x2c, 0x88, 0x1a, 0x29, 0xb9, 0xe4, 0xfc, 0xe2, 0xdc, 0xfc, - 0x62, 0xfd, 0xa4, 0xc4, 0xe2, 0x54, 0xfd, 0x32, 0xc3, 0xa4, 0xd4, 0x92, 0x44, 0x43, 0xfd, 0xe4, - 0xfc, 0xcc, 0x3c, 0x88, 0xbc, 0xd2, 0x6c, 0x46, 0x2e, 0x3e, 0xdf, 0xe2, 0xf4, 0xe0, 0xf2, 0xc4, - 0x82, 0xa0, 0xd4, 0xc2, 0xd2, 0xd4, 0xe2, 0x12, 0x21, 0x45, 0x2e, 0x9e, 0xb4, 0xa2, 0xfc, 0xdc, - 0xf8, 0xc4, 0x94, 0x94, 0xa2, 0xd4, 0xe2, 0x62, 0x09, 0x46, 0x05, 0x46, 0x0d, 0xce, 0x20, 0x6e, - 0x90, 0x98, 0x23, 0x44, 0x48, 0x28, 0x8d, 0x8b, 0x2d, 0x31, 0x37, 0xbf, 0x34, 0xaf, 0x44, 0x82, - 0x49, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x52, 0x0f, 0x62, 0x8d, 0x1e, 0xc8, 0x1a, 0x3d, 0xa8, 0x35, - 0x7a, 0xce, 0xf9, 0x99, 0x79, 0x4e, 0xc6, 0x27, 0xee, 0xc9, 0x33, 0xac, 0xba, 0x2f, 0xaf, 0x9d, - 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0xef, 0x96, 0x99, 0x57, 0x9c, 0x9c, - 0x91, 0x99, 0xa8, 0x9f, 0x06, 0x65, 0xe8, 0x16, 0xa7, 0x64, 0xeb, 0x97, 0x54, 0x16, 0xa4, 0x16, - 0x83, 0x35, 0x05, 0x41, 0x4d, 0x57, 0x12, 0xe4, 0xe2, 0x87, 0x3b, 0xae, 0xb8, 0x20, 0x3f, 0xaf, - 0x38, 0x55, 0xc9, 0x8c, 0x4b, 0x10, 0x2a, 0xe4, 0x98, 0x93, 0x43, 0xbc, 0x93, 0x95, 0x6a, 0xb8, - 0x84, 0x90, 0xf5, 0x41, 0x4c, 0x43, 0xf2, 0x08, 0x23, 0x2d, 0x3d, 0x62, 0x34, 0x83, 0x91, 0x8b, - 0xd9, 0xb7, 0x38, 0x5d, 0xc8, 0x99, 0x8b, 0x05, 0xe4, 0x04, 0x21, 0x19, 0x3d, 0xe4, 0xb8, 0xd3, - 0x43, 0x8d, 0x01, 0x29, 0x59, 0x1c, 0xb2, 0x50, 0x47, 0xfb, 0x70, 0xb1, 0x43, 0xfd, 0x21, 0x24, - 0x8f, 0x55, 0x25, 0x22, 0x64, 0xa4, 0x14, 0x70, 0x2b, 0x80, 0x98, 0xe6, 0xe4, 0x71, 0xe2, 0x91, - 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, - 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x7a, 0x04, 0x7d, 0x5a, 0x01, 0x4d, 0x95, 0x60, - 0x1f, 0x27, 0xb1, 0x81, 0x93, 0x94, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x66, 0x25, 0x56, 0x7f, - 0xaf, 0x02, 0x00, 0x00, + // 348 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0xcd, 0x4a, 0xf3, 0x40, + 0x14, 0xcd, 0x7c, 0x9f, 0x54, 0x9c, 0x16, 0xa5, 0x43, 0x85, 0x1a, 0x34, 0xad, 0x59, 0x15, 0xc4, + 0x19, 0xd2, 0x82, 0xfb, 0xb6, 0x20, 0x2e, 0xec, 0xa6, 0xee, 0xdc, 0x48, 0x92, 0x4e, 0xd2, 0x60, + 0x92, 0x89, 0xbd, 0xd3, 0x1f, 0xdf, 0xc2, 0xa5, 0xe0, 0x1b, 0xf8, 0x24, 0x5d, 0x76, 0xe9, 0x4a, + 0xa5, 0x7d, 0x11, 0x49, 0x26, 0x68, 0x05, 0x8b, 0xee, 0x2e, 0xe7, 0xdc, 0x7b, 0xce, 0xe1, 0xcc, + 0xe0, 0xfd, 0xd0, 0x89, 0x98, 0x07, 0x53, 0x3b, 0x61, 0x13, 0x8b, 0xc9, 0x19, 0x4d, 0x46, 0x42, + 0x0a, 0x52, 0x0a, 0x9d, 0x88, 0x66, 0x30, 0x9d, 0x58, 0x7a, 0xc5, 0x17, 0xbe, 0xc8, 0x08, 0x96, + 0x4e, 0x6a, 0x47, 0x37, 0x5c, 0x01, 0x91, 0x00, 0xe6, 0xd8, 0xc0, 0xd9, 0xc4, 0x72, 0xb8, 0xb4, + 0x2d, 0xe6, 0x8a, 0x20, 0x56, 0xbc, 0xf9, 0x84, 0xf0, 0x6e, 0x0f, 0xfc, 0xab, 0xa9, 0x9d, 0xf4, + 0xf9, 0xdd, 0x98, 0x83, 0x24, 0xc7, 0xb8, 0xe4, 0x8d, 0x44, 0x74, 0x63, 0x0f, 0x06, 0x23, 0x0e, + 0x50, 0x45, 0x75, 0xd4, 0xd8, 0xe9, 0x17, 0x53, 0xac, 0xad, 0x20, 0xe2, 0xe1, 0x82, 0x1d, 0x89, + 0x71, 0x2c, 0xab, 0xff, 0xea, 0xa8, 0x51, 0x6c, 0x1e, 0x50, 0x65, 0x43, 0x53, 0x1b, 0x9a, 0xdb, + 0xd0, 0xae, 0x08, 0xe2, 0x4e, 0x6b, 0xfe, 0x5a, 0xd3, 0x9e, 0xdf, 0x6a, 0x27, 0x7e, 0x20, 0x87, + 0x63, 0x87, 0xba, 0x22, 0x62, 0xe7, 0x41, 0x0c, 0xee, 0x30, 0xb0, 0x99, 0x97, 0x0f, 0xa7, 0x30, + 0xb8, 0x65, 0xf2, 0x3e, 0xe1, 0x90, 0x1d, 0xf5, 0x73, 0x75, 0xb3, 0x8c, 0xf7, 0x3e, 0xc3, 0x41, + 0x22, 0x62, 0xe0, 0xe6, 0x19, 0x2e, 0xe7, 0x50, 0x3b, 0x0c, 0xff, 0x1e, 0xd9, 0xac, 0x60, 0xb2, + 0x7e, 0xa7, 0xd4, 0x9a, 0x8f, 0x08, 0xff, 0xef, 0x81, 0x4f, 0xba, 0x78, 0x2b, 0xa5, 0xc8, 0x21, + 0x5d, 0xef, 0x94, 0x7e, 0x6f, 0x46, 0x3f, 0xda, 0xc0, 0x2a, 0x31, 0x72, 0x89, 0xb7, 0x73, 0x7d, + 0x52, 0xfb, 0x71, 0xf3, 0x2b, 0xb1, 0x5e, 0xdf, 0xbc, 0xa0, 0xd4, 0x3a, 0x17, 0xf3, 0xa5, 0x81, + 0x16, 0x4b, 0x03, 0xbd, 0x2f, 0x0d, 0xf4, 0xb0, 0x32, 0xb4, 0xc5, 0xca, 0xd0, 0x5e, 0x56, 0x86, + 0x76, 0x4d, 0x7f, 0xad, 0x72, 0x96, 0xff, 0x96, 0xac, 0x52, 0xa7, 0x90, 0x3d, 0x75, 0xeb, 0x23, + 0x00, 0x00, 0xff, 0xff, 0xf1, 0x37, 0x1c, 0xc2, 0x47, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -474,16 +464,6 @@ func (m *MsgSwapAllResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - { - size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -541,8 +521,6 @@ func (m *MsgSwapAllResponse) Size() (n int) { } var l int _ = l - l = m.Amount.Size() - n += 1 + l + sovTx(uint64(l)) return n } @@ -828,39 +806,6 @@ func (m *MsgSwapAllResponse) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: MsgSwapAllResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - 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 default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) From ee0348355957e02e10cc3d8e568ec362cfc4dada Mon Sep 17 00:00:00 2001 From: 170210 Date: Mon, 15 Apr 2024 14:47:51 +0900 Subject: [PATCH 11/17] docs: update CHANGLOG.md Signed-off-by: 170210 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4479669cfc..a88a6c5ca3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Features * (consensus) [\#1178](https://github.com/Finschia/finschia-sdk/pull/1178) change the consensus from Ostracon to Tendermint v0.34.24 +* (x/fswap) [\#1336](https://github.com/Finschia/finschia-sdk/pull/1336) Initialize fswap module ### Improvements * (docs) [\#1120](https://github.com/Finschia/finschia-sdk/pull/1120) Update links in x/foundation README.md From 65b25b869458fdded81229ee43b42dcfc30bf083 Mon Sep 17 00:00:00 2001 From: 170210 Date: Mon, 15 Apr 2024 14:50:33 +0900 Subject: [PATCH 12/17] docs: fix error docs Signed-off-by: 170210 --- x/ERRORS.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/x/ERRORS.md b/x/ERRORS.md index 32ed9ca1b2..c324c8315c 100644 --- a/x/ERRORS.md +++ b/x/ERRORS.md @@ -9,6 +9,7 @@ * [Evidence](#evidence) * [Feegrant](#feegrant) * [Foundation](#foundation) + * [Fswap](#fswap) * [Gov](#gov) * [Params](#params) * [Slashing](#slashing) @@ -172,6 +173,15 @@ >You can also find detailed information in the following Errors.go files: * [foundation/errors.go](foundation/errors.go) +## Fswap + +|Error Name|Codespace|Code|Description| +|:-|:-|:-|:-| +|ErrSample|fswap|1100|sample error| + +>You can also find detailed information in the following Errors.go files: + * [fswap/types/errors.go](fswap/types/errors.go) + ## Gov |Error Name|Codespace|Code|Description| From f43563d7333bc71ad7eb2860976813682474771b Mon Sep 17 00:00:00 2001 From: 170210 Date: Mon, 15 Apr 2024 18:49:00 +0900 Subject: [PATCH 13/17] fix: fix consensusversion Signed-off-by: 170210 --- x/fswap/module.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/fswap/module.go b/x/fswap/module.go index 669eea4734..4992b043fe 100644 --- a/x/fswap/module.go +++ b/x/fswap/module.go @@ -161,7 +161,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion implements ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 2 } +func (AppModule) ConsensusVersion() uint64 { return 1 } // BeginBlock executes all ABCI BeginBlock logic respective to the capability module. func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} From 0b2cab7f012eb39c16ff5f84f6bbc4dce4d72f50 Mon Sep 17 00:00:00 2001 From: 170210 Date: Mon, 15 Apr 2024 18:49:30 +0900 Subject: [PATCH 14/17] fix: remove route,type&getSignBytes in msgs.go Signed-off-by: 170210 --- x/fswap/types/msgs.go | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/x/fswap/types/msgs.go b/x/fswap/types/msgs.go index dabae8d74c..4f4ad81cb5 100644 --- a/x/fswap/types/msgs.go +++ b/x/fswap/types/msgs.go @@ -14,12 +14,6 @@ func NewMsgSwapRequest(fromAddr, toAddr sdk.AccAddress, amount sdk.Coin) *MsgSwa return &MsgSwapRequest{FromAddress: fromAddr.String(), Amount: amount} } -// Route Implements Msg. -func (msg MsgSwapRequest) Route() string { return RouterKey } - -// Type Implements Msg. -func (msg MsgSwapRequest) Type() string { return sdk.MsgTypeURL(&msg) } - // ValidateBasic Implements Msg. func (msg MsgSwapRequest) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(msg.FromAddress) @@ -38,11 +32,6 @@ func (msg MsgSwapRequest) ValidateBasic() error { return nil } -// GetSignBytes Implements Msg. -func (msg MsgSwapRequest) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - // GetSigners Implements Msg. func (msg MsgSwapRequest) GetSigners() []sdk.AccAddress { from, err := sdk.AccAddressFromBech32(msg.FromAddress) @@ -61,12 +50,6 @@ func NewMsgSwapAllRequest(fromAddr, toAddr sdk.AccAddress) *MsgSwapAllRequest { return &MsgSwapAllRequest{FromAddress: fromAddr.String()} } -// Route Implements Msg. -func (msg MsgSwapAllRequest) Route() string { return RouterKey } - -// Type Implements Msg. -func (msg MsgSwapAllRequest) Type() string { return sdk.MsgTypeURL(&msg) } - // ValidateBasic Implements Msg. func (msg MsgSwapAllRequest) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(msg.FromAddress) @@ -77,11 +60,6 @@ func (msg MsgSwapAllRequest) ValidateBasic() error { return nil } -// GetSignBytes Implements Msg. -func (msg MsgSwapAllRequest) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) -} - // GetSigners Implements Msg. func (msg MsgSwapAllRequest) GetSigners() []sdk.AccAddress { from, err := sdk.AccAddressFromBech32(msg.FromAddress) From 4e0771a4be1e438ca31c2647976d2d6ed76f8b16 Mon Sep 17 00:00:00 2001 From: 170210 Date: Mon, 15 Apr 2024 19:35:49 +0900 Subject: [PATCH 15/17] fix: update proto files Signed-off-by: 170210 --- docs/core/proto-docs.md | 42 +++- proto/lbm/fswap/v1/fswap.proto | 14 ++ proto/lbm/fswap/v1/genesis.proto | 2 + proto/lbm/fswap/v1/params.proto | 11 +- proto/lbm/fswap/v1/query.proto | 6 +- x/fswap/types/fswap.pb.go | 378 +++++++++++++++++++++++++++++++ x/fswap/types/genesis.pb.go | 77 ++++++- x/fswap/types/params.pb.go | 168 ++------------ x/fswap/types/query.pb.go | 127 +++-------- 9 files changed, 553 insertions(+), 272 deletions(-) create mode 100644 proto/lbm/fswap/v1/fswap.proto create mode 100644 x/fswap/types/fswap.pb.go diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index 423eff0da4..e9718495d8 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -859,6 +859,9 @@ - [lbm/fswap/v1/event.proto](#lbm/fswap/v1/event.proto) - [EventSwapCoins](#lbm.fswap.v1.EventSwapCoins) +- [lbm/fswap/v1/fswap.proto](#lbm/fswap/v1/fswap.proto) + - [Swapped](#lbm.fswap.v1.Swapped) + - [lbm/fswap/v1/params.proto](#lbm/fswap/v1/params.proto) - [Params](#lbm.fswap.v1.Params) @@ -12731,6 +12734,38 @@ Msg defines the foundation Msg service. + + + + + + + + + + + +

Top

+ +## lbm/fswap/v1/fswap.proto + + + + + +### Swapped + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `old_coin_amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | | +| `new_coin_amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | | + + + + + @@ -12756,9 +12791,6 @@ Params defines the parameters for the module. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `new_coin_swap_total_limit` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | upper limit in new coin that this module can swap | -| `swap_rate` | [uint64](#uint64) | | constant value representing the exchange rate, without decimal (148079656) | -| `swap_rate_decimals` | [int32](#int32) | | The number shows how to get the true exchange rate by dividing swap_rate by 10 to the power | | `new_coin_denom` | [string](#string) | | new denomination for new coin after swap | @@ -12791,6 +12823,7 @@ GenesisState defines the fswap module's genesis state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `params` | [Params](#lbm.fswap.v1.Params) | | | +| `swapped` | [Swapped](#lbm.fswap.v1.Swapped) | | | @@ -12831,8 +12864,7 @@ GenesisState defines the fswap module's genesis state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `old_coin_amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | | -| `new_coin_amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | | +| `swapped` | [Swapped](#lbm.fswap.v1.Swapped) | | | diff --git a/proto/lbm/fswap/v1/fswap.proto b/proto/lbm/fswap/v1/fswap.proto new file mode 100644 index 0000000000..827f5f3e32 --- /dev/null +++ b/proto/lbm/fswap/v1/fswap.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; +package lbm.fswap.v1; + +option go_package = "github.com/Finschia/finschia-sdk/x/fswap/types"; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +message Swapped{ + cosmos.base.v1beta1.Coin old_coin_amount = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/Finschia/finschia-sdk/types.Coin"]; + cosmos.base.v1beta1.Coin new_coin_amount = 2 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/Finschia/finschia-sdk/types.Coin"]; +} diff --git a/proto/lbm/fswap/v1/genesis.proto b/proto/lbm/fswap/v1/genesis.proto index 4b055874ef..ae0a9ade75 100644 --- a/proto/lbm/fswap/v1/genesis.proto +++ b/proto/lbm/fswap/v1/genesis.proto @@ -5,8 +5,10 @@ option go_package = "github.com/Finschia/finschia-sdk/x/fswap/types"; import "gogoproto/gogo.proto"; import "lbm/fswap/v1/params.proto"; +import "lbm/fswap/v1/fswap.proto"; // GenesisState defines the fswap module's genesis state. message GenesisState { Params params = 1 [(gogoproto.nullable) = false]; + Swapped swapped =2 [(gogoproto.nullable) = false]; } diff --git a/proto/lbm/fswap/v1/params.proto b/proto/lbm/fswap/v1/params.proto index 3507c72b91..da236c9373 100644 --- a/proto/lbm/fswap/v1/params.proto +++ b/proto/lbm/fswap/v1/params.proto @@ -1,22 +1,13 @@ - syntax = "proto3"; package lbm.fswap.v1; option go_package = "github.com/Finschia/finschia-sdk/x/fswap/types"; import "gogoproto/gogo.proto"; -import "cosmos/base/v1beta1/coin.proto"; // Params defines the parameters for the module. message Params { option (gogoproto.goproto_stringer) = false; - // upper limit in new coin that this module can swap - cosmos.base.v1beta1.Coin new_coin_swap_total_limit = 1 - [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/Finschia/finschia-sdk/types.Coin"]; - // constant value representing the exchange rate, without decimal (148079656) - uint64 swap_rate = 2; - // The number shows how to get the true exchange rate by dividing swap_rate by 10 to the power - int32 swap_rate_decimals = 3; // new denomination for new coin after swap - string new_coin_denom = 4; + string new_coin_denom = 1; } diff --git a/proto/lbm/fswap/v1/query.proto b/proto/lbm/fswap/v1/query.proto index 1d7041dd32..f5d92c7bfc 100644 --- a/proto/lbm/fswap/v1/query.proto +++ b/proto/lbm/fswap/v1/query.proto @@ -6,6 +6,7 @@ option go_package = "github.com/Finschia/finschia-sdk/x/fswap/types"; import "google/api/annotations.proto"; import "gogoproto/gogo.proto"; import "cosmos/base/v1beta1/coin.proto"; +import "lbm/fswap/v1/fswap.proto"; service Query { rpc Swapped(QuerySwappedRequest) returns (QuerySwappedResponse) { @@ -18,10 +19,7 @@ service Query { message QuerySwappedRequest {} message QuerySwappedResponse { - cosmos.base.v1beta1.Coin old_coin_amount = 1 - [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/Finschia/finschia-sdk/types.Coin"]; - cosmos.base.v1beta1.Coin new_coin_amount = 2 - [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/Finschia/finschia-sdk/types.Coin"]; + Swapped swapped = 1 [(gogoproto.nullable) = false]; } message QueryTotalSwappableAmountRequest {} diff --git a/x/fswap/types/fswap.pb.go b/x/fswap/types/fswap.pb.go new file mode 100644 index 0000000000..f53d058797 --- /dev/null +++ b/x/fswap/types/fswap.pb.go @@ -0,0 +1,378 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: lbm/fswap/v1/fswap.proto + +package types + +import ( + fmt "fmt" + types "github.com/Finschia/finschia-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type Swapped struct { + OldCoinAmount types.Coin `protobuf:"bytes,1,opt,name=old_coin_amount,json=oldCoinAmount,proto3,castrepeated=github.com/Finschia/finschia-sdk/types.Coin" json:"old_coin_amount"` + NewCoinAmount types.Coin `protobuf:"bytes,2,opt,name=new_coin_amount,json=newCoinAmount,proto3,castrepeated=github.com/Finschia/finschia-sdk/types.Coin" json:"new_coin_amount"` +} + +func (m *Swapped) Reset() { *m = Swapped{} } +func (m *Swapped) String() string { return proto.CompactTextString(m) } +func (*Swapped) ProtoMessage() {} +func (*Swapped) Descriptor() ([]byte, []int) { + return fileDescriptor_42ca60eaf37a2b67, []int{0} +} +func (m *Swapped) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Swapped) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Swapped.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 *Swapped) XXX_Merge(src proto.Message) { + xxx_messageInfo_Swapped.Merge(m, src) +} +func (m *Swapped) XXX_Size() int { + return m.Size() +} +func (m *Swapped) XXX_DiscardUnknown() { + xxx_messageInfo_Swapped.DiscardUnknown(m) +} + +var xxx_messageInfo_Swapped proto.InternalMessageInfo + +func (m *Swapped) GetOldCoinAmount() types.Coin { + if m != nil { + return m.OldCoinAmount + } + return types.Coin{} +} + +func (m *Swapped) GetNewCoinAmount() types.Coin { + if m != nil { + return m.NewCoinAmount + } + return types.Coin{} +} + +func init() { + proto.RegisterType((*Swapped)(nil), "lbm.fswap.v1.Swapped") +} + +func init() { proto.RegisterFile("lbm/fswap/v1/fswap.proto", fileDescriptor_42ca60eaf37a2b67) } + +var fileDescriptor_42ca60eaf37a2b67 = []byte{ + // 262 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xc8, 0x49, 0xca, 0xd5, + 0x4f, 0x2b, 0x2e, 0x4f, 0x2c, 0xd0, 0x2f, 0x33, 0x84, 0x30, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, + 0x85, 0x78, 0x72, 0x92, 0x72, 0xf5, 0x20, 0x02, 0x65, 0x86, 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, + 0x60, 0x09, 0x7d, 0x10, 0x0b, 0xa2, 0x46, 0x4a, 0x2e, 0x39, 0xbf, 0x38, 0x37, 0xbf, 0x58, 0x3f, + 0x29, 0xb1, 0x38, 0x55, 0xbf, 0xcc, 0x30, 0x29, 0xb5, 0x24, 0xd1, 0x50, 0x3f, 0x39, 0x3f, 0x33, + 0x0f, 0x22, 0xaf, 0xf4, 0x93, 0x91, 0x8b, 0x3d, 0xb8, 0x3c, 0xb1, 0xa0, 0x20, 0x35, 0x45, 0xa8, + 0x8c, 0x8b, 0x3f, 0x3f, 0x27, 0x25, 0x1e, 0x24, 0x1b, 0x9f, 0x98, 0x9b, 0x5f, 0x9a, 0x57, 0x22, + 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xa9, 0x07, 0x31, 0x45, 0x0f, 0x64, 0x8a, 0x1e, 0xd4, + 0x14, 0x3d, 0xe7, 0xfc, 0xcc, 0x3c, 0x27, 0xe3, 0x13, 0xf7, 0xe4, 0x19, 0x56, 0xdd, 0x97, 0xd7, + 0x4e, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x77, 0xcb, 0xcc, 0x2b, 0x4e, + 0xce, 0xc8, 0x4c, 0xd4, 0x4f, 0x83, 0x32, 0x74, 0x8b, 0x53, 0xb2, 0xf5, 0x4b, 0x2a, 0x0b, 0x52, + 0x8b, 0xc1, 0x9a, 0x82, 0x78, 0xf3, 0x73, 0x52, 0x40, 0x0c, 0x47, 0xb0, 0x25, 0x20, 0x7b, 0xf3, + 0x52, 0xcb, 0x51, 0xec, 0x65, 0xa2, 0x8d, 0xbd, 0x79, 0xa9, 0xe5, 0x08, 0x7b, 0x9d, 0x3c, 0x4e, + 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, + 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x8f, 0xa0, 0xa9, 0x15, 0xd0, 0x28, + 0x01, 0x9b, 0x9e, 0xc4, 0x06, 0x0e, 0x4c, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x5c, 0x78, + 0x6f, 0xce, 0xac, 0x01, 0x00, 0x00, +} + +func (m *Swapped) 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 *Swapped) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Swapped) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.NewCoinAmount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFswap(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.OldCoinAmount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFswap(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintFswap(dAtA []byte, offset int, v uint64) int { + offset -= sovFswap(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Swapped) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.OldCoinAmount.Size() + n += 1 + l + sovFswap(uint64(l)) + l = m.NewCoinAmount.Size() + n += 1 + l + sovFswap(uint64(l)) + return n +} + +func sovFswap(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozFswap(x uint64) (n int) { + return sovFswap(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Swapped) 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 ErrIntOverflowFswap + } + 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: Swapped: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Swapped: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OldCoinAmount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFswap + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFswap + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFswap + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.OldCoinAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewCoinAmount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFswap + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFswap + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFswap + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.NewCoinAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipFswap(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFswap + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipFswap(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowFswap + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowFswap + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowFswap + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthFswap + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupFswap + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthFswap + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthFswap = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowFswap = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupFswap = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/fswap/types/genesis.pb.go b/x/fswap/types/genesis.pb.go index a56d510e68..af2475beea 100644 --- a/x/fswap/types/genesis.pb.go +++ b/x/fswap/types/genesis.pb.go @@ -25,7 +25,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the fswap module's genesis state. type GenesisState struct { - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + Swapped Swapped `protobuf:"bytes,2,opt,name=swapped,proto3" json:"swapped"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -68,6 +69,13 @@ func (m *GenesisState) GetParams() Params { return Params{} } +func (m *GenesisState) GetSwapped() Swapped { + if m != nil { + return m.Swapped + } + return Swapped{} +} + func init() { proto.RegisterType((*GenesisState)(nil), "lbm.fswap.v1.GenesisState") } @@ -75,20 +83,22 @@ func init() { func init() { proto.RegisterFile("lbm/fswap/v1/genesis.proto", fileDescriptor_94e309cb1db27661) } var fileDescriptor_94e309cb1db27661 = []byte{ - // 200 bytes of a gzipped FileDescriptorProto + // 231 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xca, 0x49, 0xca, 0xd5, 0x4f, 0x2b, 0x2e, 0x4f, 0x2c, 0xd0, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0xc9, 0x49, 0xca, 0xd5, 0x03, 0xcb, 0xe9, 0x95, 0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x25, 0xf4, 0x41, 0x2c, 0x88, 0x1a, 0x29, 0x49, - 0x14, 0xfd, 0x05, 0x89, 0x45, 0x89, 0xb9, 0x50, 0xed, 0x4a, 0x4e, 0x5c, 0x3c, 0xee, 0x10, 0xf3, - 0x82, 0x4b, 0x12, 0x4b, 0x52, 0x85, 0x8c, 0xb8, 0xd8, 0x20, 0xf2, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, - 0xdc, 0x46, 0x22, 0x7a, 0xc8, 0xe6, 0xeb, 0x05, 0x80, 0xe5, 0x9c, 0x58, 0x4e, 0xdc, 0x93, 0x67, - 0x08, 0x82, 0xaa, 0x74, 0xf2, 0x38, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, - 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, - 0xbd, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0xb7, 0xcc, 0xbc, 0xe2, - 0xe4, 0x8c, 0xcc, 0x44, 0xfd, 0x34, 0x28, 0x43, 0xb7, 0x38, 0x25, 0x5b, 0xbf, 0x02, 0xea, 0xae, - 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0xa3, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, - 0xa6, 0x7e, 0x83, 0x5e, 0xf1, 0x00, 0x00, 0x00, + 0x14, 0xfd, 0x05, 0x89, 0x45, 0x89, 0xb9, 0x50, 0xed, 0x52, 0x12, 0x28, 0x52, 0x10, 0x73, 0xc0, + 0x32, 0x4a, 0x95, 0x5c, 0x3c, 0xee, 0x10, 0x9b, 0x82, 0x4b, 0x12, 0x4b, 0x52, 0x85, 0x8c, 0xb8, + 0xd8, 0x20, 0x3a, 0x25, 0x18, 0x15, 0x18, 0x35, 0xb8, 0x8d, 0x44, 0xf4, 0x90, 0x6d, 0xd6, 0x0b, + 0x00, 0xcb, 0x39, 0xb1, 0x9c, 0xb8, 0x27, 0xcf, 0x10, 0x04, 0x55, 0x29, 0x64, 0xca, 0xc5, 0x0e, + 0x92, 0x2f, 0x48, 0x4d, 0x91, 0x60, 0x02, 0x6b, 0x12, 0x45, 0xd5, 0x14, 0x0c, 0x91, 0x84, 0xea, + 0x82, 0xa9, 0x75, 0xf2, 0x38, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, + 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xbd, + 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0xb7, 0xcc, 0xbc, 0xe2, 0xe4, + 0x8c, 0xcc, 0x44, 0xfd, 0x34, 0x28, 0x43, 0xb7, 0x38, 0x25, 0x5b, 0xbf, 0x02, 0xea, 0x9b, 0x92, + 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x5f, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x23, + 0x15, 0x87, 0x48, 0x42, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -111,6 +121,16 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size, err := m.Swapped.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 { size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -143,6 +163,8 @@ func (m *GenesisState) Size() (n int) { _ = l l = m.Params.Size() n += 1 + l + sovGenesis(uint64(l)) + l = m.Swapped.Size() + n += 1 + l + sovGenesis(uint64(l)) return n } @@ -214,6 +236,39 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Swapped", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Swapped.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/fswap/types/params.pb.go b/x/fswap/types/params.pb.go index 9298bdc283..fd779ed5a6 100644 --- a/x/fswap/types/params.pb.go +++ b/x/fswap/types/params.pb.go @@ -5,7 +5,6 @@ package types import ( fmt "fmt" - types "github.com/Finschia/finschia-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" @@ -26,14 +25,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the module. type Params struct { - // upper limit in new coin that this module can swap - NewCoinSwapTotalLimit types.Coin `protobuf:"bytes,1,opt,name=new_coin_swap_total_limit,json=newCoinSwapTotalLimit,proto3,castrepeated=github.com/Finschia/finschia-sdk/types.Coin" json:"new_coin_swap_total_limit"` - // constant value representing the exchange rate, without decimal (148079656) - SwapRate uint64 `protobuf:"varint,2,opt,name=swap_rate,json=swapRate,proto3" json:"swap_rate,omitempty"` - // The number shows how to get the true exchange rate by dividing swap_rate by 10 to the power - SwapRateDecimals int32 `protobuf:"varint,3,opt,name=swap_rate_decimals,json=swapRateDecimals,proto3" json:"swap_rate_decimals,omitempty"` // new denomination for new coin after swap - NewCoinDenom string `protobuf:"bytes,4,opt,name=new_coin_denom,json=newCoinDenom,proto3" json:"new_coin_denom,omitempty"` + NewCoinDenom string `protobuf:"bytes,1,opt,name=new_coin_denom,json=newCoinDenom,proto3" json:"new_coin_denom,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -68,27 +61,6 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo -func (m *Params) GetNewCoinSwapTotalLimit() types.Coin { - if m != nil { - return m.NewCoinSwapTotalLimit - } - return types.Coin{} -} - -func (m *Params) GetSwapRate() uint64 { - if m != nil { - return m.SwapRate - } - return 0 -} - -func (m *Params) GetSwapRateDecimals() int32 { - if m != nil { - return m.SwapRateDecimals - } - return 0 -} - func (m *Params) GetNewCoinDenom() string { if m != nil { return m.NewCoinDenom @@ -103,29 +75,20 @@ func init() { func init() { proto.RegisterFile("lbm/fswap/v1/params.proto", fileDescriptor_15e620b81032c44d) } var fileDescriptor_15e620b81032c44d = []byte{ - // 342 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0xb1, 0x4e, 0xeb, 0x30, - 0x18, 0x85, 0xe3, 0xde, 0xde, 0x8a, 0x86, 0x0a, 0xa1, 0x08, 0xa4, 0xb4, 0x48, 0x6e, 0x84, 0x18, - 0x22, 0x01, 0xb6, 0x42, 0x37, 0xc6, 0x52, 0x21, 0x06, 0x06, 0x14, 0x98, 0x58, 0x22, 0x27, 0x75, - 0x5b, 0x8b, 0x38, 0x8e, 0x6a, 0xd3, 0xc0, 0x1b, 0x20, 0x26, 0x46, 0x46, 0x66, 0x9e, 0xa4, 0x63, - 0x47, 0x26, 0x40, 0xed, 0x8b, 0x20, 0x3b, 0xa1, 0x2b, 0xdb, 0xaf, 0x73, 0x7e, 0x7f, 0xc7, 0xc7, - 0xb6, 0xdb, 0x69, 0xcc, 0xf1, 0x48, 0x16, 0x24, 0xc7, 0xb3, 0x00, 0xe7, 0x64, 0x4a, 0xb8, 0x44, - 0xf9, 0x54, 0x28, 0xe1, 0xb4, 0xd2, 0x98, 0x23, 0x63, 0xa1, 0x59, 0xd0, 0xd9, 0x19, 0x8b, 0xb1, - 0x30, 0x06, 0xd6, 0x53, 0xb9, 0xd3, 0x81, 0x89, 0x90, 0x5c, 0x48, 0x1c, 0x13, 0x49, 0xf1, 0x2c, - 0x88, 0xa9, 0x22, 0x01, 0x4e, 0x04, 0xcb, 0x4a, 0x7f, 0xff, 0xb9, 0x66, 0x37, 0xae, 0x0c, 0xd4, - 0x79, 0x02, 0x76, 0x3b, 0xa3, 0x45, 0xa4, 0xdd, 0x48, 0x53, 0x23, 0x25, 0x14, 0x49, 0xa3, 0x94, - 0x71, 0xa6, 0x5c, 0xe0, 0x01, 0x7f, 0xf3, 0xa4, 0x8d, 0x4a, 0x1e, 0xd2, 0x3c, 0x54, 0xf1, 0xd0, - 0x99, 0x60, 0x59, 0xbf, 0x37, 0xff, 0xec, 0x5a, 0xef, 0x5f, 0xdd, 0xc3, 0x31, 0x53, 0x93, 0xfb, - 0x18, 0x25, 0x82, 0xe3, 0x73, 0x96, 0xc9, 0x64, 0xc2, 0x08, 0x1e, 0x55, 0xc3, 0xb1, 0x1c, 0xde, - 0x61, 0xf5, 0x98, 0x53, 0x69, 0x0e, 0x85, 0xbb, 0x19, 0x2d, 0xf4, 0x70, 0x5d, 0x90, 0xfc, 0x46, - 0xa7, 0x5d, 0xea, 0x30, 0x67, 0xcf, 0x6e, 0x9a, 0x0b, 0x4c, 0x89, 0xa2, 0x6e, 0xcd, 0x03, 0x7e, - 0x3d, 0xdc, 0xd0, 0x42, 0x48, 0x14, 0x75, 0x8e, 0x6c, 0x67, 0x6d, 0x46, 0x43, 0x9a, 0x30, 0x4e, - 0x52, 0xe9, 0xfe, 0xf3, 0x80, 0xff, 0x3f, 0xdc, 0xfe, 0xdd, 0x1a, 0x54, 0xba, 0x73, 0x60, 0x6f, - 0xad, 0x4b, 0x0d, 0x69, 0x26, 0xb8, 0x5b, 0xf7, 0x80, 0xdf, 0x0c, 0x5b, 0x55, 0xf2, 0x40, 0x6b, - 0xa7, 0xf5, 0xd7, 0xb7, 0xae, 0xd5, 0xbf, 0x98, 0x2f, 0x21, 0x58, 0x2c, 0x21, 0xf8, 0x5e, 0x42, - 0xf0, 0xb2, 0x82, 0xd6, 0x62, 0x05, 0xad, 0x8f, 0x15, 0xb4, 0x6e, 0xd1, 0x9f, 0xa5, 0x1e, 0xaa, - 0x4f, 0x32, 0xe5, 0xe2, 0x86, 0x79, 0xdd, 0xde, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa9, 0x6c, - 0x55, 0x7a, 0xbe, 0x01, 0x00, 0x00, + // 194 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcc, 0x49, 0xca, 0xd5, + 0x4f, 0x2b, 0x2e, 0x4f, 0x2c, 0xd0, 0x2f, 0x33, 0xd4, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, + 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0xc9, 0x49, 0xca, 0xd5, 0x03, 0x4b, 0xe9, 0x95, 0x19, + 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x25, 0xf4, 0x41, 0x2c, 0x88, 0x1a, 0x25, 0x13, 0x2e, + 0xb6, 0x00, 0xb0, 0x1e, 0x21, 0x15, 0x2e, 0xbe, 0xbc, 0xd4, 0xf2, 0xf8, 0xe4, 0xfc, 0xcc, 0xbc, + 0xf8, 0x94, 0xd4, 0xbc, 0xfc, 0x5c, 0x09, 0x46, 0x05, 0x46, 0x0d, 0xce, 0x20, 0x9e, 0xbc, 0xd4, + 0x72, 0xe7, 0xfc, 0xcc, 0x3c, 0x17, 0x90, 0x98, 0x15, 0xcb, 0x8c, 0x05, 0xf2, 0x0c, 0x4e, 0x1e, + 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, + 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0xa5, 0x97, 0x9e, 0x59, 0x92, 0x51, + 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0xef, 0x96, 0x99, 0x57, 0x9c, 0x9c, 0x91, 0x99, 0xa8, 0x9f, + 0x06, 0x65, 0xe8, 0x16, 0xa7, 0x64, 0xeb, 0x57, 0x40, 0x5d, 0x5b, 0x52, 0x59, 0x90, 0x5a, 0x9c, + 0xc4, 0x06, 0x76, 0x86, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x90, 0xbf, 0xad, 0x40, 0xc7, 0x00, + 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -153,28 +116,8 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.NewCoinDenom) i = encodeVarintParams(dAtA, i, uint64(len(m.NewCoinDenom))) i-- - dAtA[i] = 0x22 - } - if m.SwapRateDecimals != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.SwapRateDecimals)) - i-- - dAtA[i] = 0x18 - } - if m.SwapRate != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.SwapRate)) - i-- - dAtA[i] = 0x10 + dAtA[i] = 0xa } - { - size, err := m.NewCoinSwapTotalLimit.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -195,14 +138,6 @@ func (m *Params) Size() (n int) { } var l int _ = l - l = m.NewCoinSwapTotalLimit.Size() - n += 1 + l + sovParams(uint64(l)) - if m.SwapRate != 0 { - n += 1 + sovParams(uint64(m.SwapRate)) - } - if m.SwapRateDecimals != 0 { - n += 1 + sovParams(uint64(m.SwapRateDecimals)) - } l = len(m.NewCoinDenom) if l > 0 { n += 1 + l + sovParams(uint64(l)) @@ -246,77 +181,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NewCoinSwapTotalLimit", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.NewCoinSwapTotalLimit.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SwapRate", wireType) - } - m.SwapRate = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.SwapRate |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SwapRateDecimals", wireType) - } - m.SwapRateDecimals = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.SwapRateDecimals |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field NewCoinDenom", wireType) } diff --git a/x/fswap/types/query.pb.go b/x/fswap/types/query.pb.go index 49b4e5ae0d..b3635cf9ad 100644 --- a/x/fswap/types/query.pb.go +++ b/x/fswap/types/query.pb.go @@ -67,8 +67,7 @@ func (m *QuerySwappedRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QuerySwappedRequest proto.InternalMessageInfo type QuerySwappedResponse struct { - OldCoinAmount types.Coin `protobuf:"bytes,1,opt,name=old_coin_amount,json=oldCoinAmount,proto3,castrepeated=github.com/Finschia/finschia-sdk/types.Coin" json:"old_coin_amount"` - NewCoinAmount types.Coin `protobuf:"bytes,2,opt,name=new_coin_amount,json=newCoinAmount,proto3,castrepeated=github.com/Finschia/finschia-sdk/types.Coin" json:"new_coin_amount"` + Swapped Swapped `protobuf:"bytes,1,opt,name=swapped,proto3" json:"swapped"` } func (m *QuerySwappedResponse) Reset() { *m = QuerySwappedResponse{} } @@ -104,18 +103,11 @@ func (m *QuerySwappedResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QuerySwappedResponse proto.InternalMessageInfo -func (m *QuerySwappedResponse) GetOldCoinAmount() types.Coin { +func (m *QuerySwappedResponse) GetSwapped() Swapped { if m != nil { - return m.OldCoinAmount + return m.Swapped } - return types.Coin{} -} - -func (m *QuerySwappedResponse) GetNewCoinAmount() types.Coin { - if m != nil { - return m.NewCoinAmount - } - return types.Coin{} + return Swapped{} } type QueryTotalSwappableAmountRequest struct { @@ -208,35 +200,35 @@ func init() { func init() { proto.RegisterFile("lbm/fswap/v1/query.proto", fileDescriptor_01deae9da7816d6a) } var fileDescriptor_01deae9da7816d6a = []byte{ - // 447 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x93, 0x41, 0x6b, 0xd4, 0x40, - 0x14, 0xc7, 0x33, 0x01, 0x15, 0x46, 0x45, 0x88, 0xad, 0x76, 0x83, 0xa6, 0x6d, 0x2e, 0x2a, 0xe2, - 0x0c, 0x69, 0x3f, 0x81, 0x15, 0xc4, 0x83, 0x08, 0x56, 0x4f, 0x5e, 0x96, 0x49, 0x32, 0x4d, 0x07, - 0x93, 0x79, 0x69, 0x66, 0x92, 0xd8, 0xab, 0x07, 0xc1, 0x9b, 0xe0, 0x97, 0x10, 0x41, 0xfc, 0x1a, - 0x3d, 0x2e, 0x78, 0xf1, 0xa4, 0xb2, 0xeb, 0x07, 0x91, 0x4c, 0x66, 0x75, 0x57, 0xc2, 0xea, 0x65, - 0x6f, 0x8f, 0x79, 0x2f, 0xef, 0xf7, 0x7f, 0xff, 0xf7, 0x82, 0xb7, 0xf2, 0xb8, 0xa0, 0x47, 0xaa, - 0x65, 0x25, 0x6d, 0x22, 0x7a, 0x52, 0xf3, 0xea, 0x94, 0x94, 0x15, 0x68, 0xf0, 0x2e, 0xe5, 0x71, - 0x41, 0x4c, 0x86, 0x34, 0x91, 0x7f, 0x23, 0x03, 0xc8, 0x72, 0x4e, 0x59, 0x29, 0x28, 0x93, 0x12, - 0x34, 0xd3, 0x02, 0xa4, 0xea, 0x6b, 0xfd, 0x8d, 0x0c, 0x32, 0x30, 0x21, 0xed, 0x22, 0xfb, 0x1a, - 0x24, 0xa0, 0x0a, 0x50, 0x34, 0x66, 0x8a, 0xd3, 0x26, 0x8a, 0xb9, 0x66, 0x11, 0x4d, 0x40, 0xc8, - 0x3e, 0x1f, 0x6e, 0xe2, 0xab, 0x4f, 0x3b, 0xe0, 0xb3, 0x96, 0x95, 0x25, 0x4f, 0x0f, 0xf9, 0x49, - 0xcd, 0x95, 0x0e, 0xdf, 0xb8, 0x78, 0x63, 0xf9, 0x5d, 0x95, 0x20, 0x15, 0xf7, 0x1a, 0x7c, 0x05, - 0xf2, 0x74, 0xdc, 0x75, 0x18, 0xb3, 0x02, 0x6a, 0xa9, 0xb7, 0xd0, 0x0e, 0xba, 0x7d, 0x71, 0x6f, - 0x44, 0x7a, 0x12, 0xe9, 0x48, 0xc4, 0x92, 0xc8, 0x03, 0x10, 0xf2, 0x60, 0xff, 0xec, 0xdb, 0xb6, - 0xf3, 0xf1, 0xfb, 0xf6, 0xdd, 0x4c, 0xe8, 0xe3, 0x3a, 0x26, 0x09, 0x14, 0xf4, 0xa1, 0x90, 0x2a, - 0x39, 0x16, 0x8c, 0x1e, 0xd9, 0xe0, 0x9e, 0x4a, 0x5f, 0x52, 0x7d, 0x5a, 0x72, 0x65, 0x3e, 0x3a, - 0xbc, 0x0c, 0x79, 0xda, 0x05, 0xf7, 0x0d, 0xa4, 0xe3, 0x4a, 0xde, 0x2e, 0x71, 0xdd, 0xf5, 0x70, - 0x25, 0x6f, 0xff, 0x70, 0xc3, 0x10, 0xef, 0x18, 0x1f, 0x9e, 0x83, 0x66, 0xb9, 0x31, 0x83, 0xc5, - 0x39, 0xef, 0x93, 0x73, 0xb3, 0x3e, 0x23, 0xbc, 0xbb, 0xa2, 0xc8, 0x3a, 0xf7, 0x16, 0xe1, 0x91, - 0x9a, 0xe7, 0xc6, 0x7f, 0x0f, 0xb3, 0x1e, 0x13, 0xaf, 0xfd, 0x06, 0x3e, 0x59, 0x9c, 0x6a, 0xef, - 0x83, 0x8b, 0xcf, 0x19, 0xc5, 0x1e, 0xe0, 0x0b, 0x76, 0xc5, 0xde, 0x2e, 0x59, 0xbc, 0x36, 0x32, - 0x70, 0x16, 0x7e, 0xb8, 0xaa, 0xa4, 0x9f, 0x33, 0xbc, 0xf9, 0xfa, 0xcb, 0xcf, 0xf7, 0xee, 0x75, - 0x6f, 0x93, 0x2e, 0x9d, 0xb5, 0xb2, 0x94, 0x4f, 0x08, 0x8f, 0x8c, 0x4f, 0x9d, 0xa2, 0xba, 0xaa, - 0xb8, 0x4c, 0x4c, 0x8b, 0xc7, 0xa2, 0x10, 0xda, 0x23, 0x03, 0x80, 0x15, 0xd6, 0xfb, 0xf4, 0xbf, - 0xeb, 0xad, 0x3a, 0x6a, 0xd4, 0xdd, 0xf1, 0x6e, 0x0d, 0xa8, 0x1b, 0x5a, 0xcc, 0xc1, 0xa3, 0xb3, - 0x69, 0x80, 0x26, 0xd3, 0x00, 0xfd, 0x98, 0x06, 0xe8, 0xdd, 0x2c, 0x70, 0x26, 0xb3, 0xc0, 0xf9, - 0x3a, 0x0b, 0x9c, 0x17, 0xe4, 0x9f, 0x9b, 0x78, 0x65, 0x01, 0x66, 0x23, 0xf1, 0x79, 0xf3, 0xc7, - 0xed, 0xff, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x07, 0x01, 0xc3, 0x43, 0xef, 0x03, 0x00, 0x00, + // 441 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x41, 0x8b, 0xd3, 0x40, + 0x14, 0xc7, 0x33, 0x8b, 0xba, 0x30, 0x7a, 0x1a, 0xb7, 0xba, 0x0d, 0x9a, 0xdd, 0xcd, 0x45, 0x45, + 0x9c, 0x21, 0xbb, 0xf8, 0x01, 0xac, 0x20, 0x1e, 0x54, 0xb0, 0x7a, 0xf2, 0x52, 0x26, 0xd9, 0xd9, + 0xec, 0x60, 0x32, 0x2f, 0xcd, 0x4c, 0x1a, 0x7b, 0xf5, 0xe6, 0x4d, 0xf0, 0x4b, 0x88, 0x20, 0x7e, + 0x8d, 0x1e, 0x0b, 0x5e, 0x3c, 0xa9, 0xb4, 0x7e, 0x10, 0xc9, 0x64, 0x2a, 0x06, 0x42, 0xf5, 0xf6, + 0x78, 0xef, 0x9f, 0xf9, 0xff, 0xde, 0xff, 0x05, 0xef, 0x67, 0x71, 0xce, 0xce, 0x74, 0xcd, 0x0b, + 0x36, 0x8b, 0xd8, 0xb4, 0x12, 0xe5, 0x9c, 0x16, 0x25, 0x18, 0x20, 0x57, 0xb2, 0x38, 0xa7, 0x76, + 0x42, 0x67, 0x91, 0x7f, 0x23, 0x05, 0x48, 0x33, 0xc1, 0x78, 0x21, 0x19, 0x57, 0x0a, 0x0c, 0x37, + 0x12, 0x94, 0x6e, 0xb5, 0xfe, 0x5e, 0x0a, 0x29, 0xd8, 0x92, 0x35, 0x95, 0xeb, 0x06, 0x09, 0xe8, + 0x1c, 0x34, 0x8b, 0xb9, 0x16, 0x6c, 0x16, 0xc5, 0xc2, 0xf0, 0x88, 0x25, 0x20, 0x95, 0x9b, 0x77, + 0xbd, 0x5b, 0x2b, 0x3b, 0x09, 0x07, 0xf8, 0xea, 0xf3, 0x06, 0xe5, 0x45, 0xcd, 0x8b, 0x42, 0x9c, + 0x8e, 0xc5, 0xb4, 0x12, 0xda, 0x84, 0x4f, 0xf1, 0x5e, 0xb7, 0xad, 0x0b, 0x50, 0x5a, 0x90, 0xfb, + 0x78, 0x57, 0xb7, 0xad, 0x7d, 0x74, 0x88, 0x6e, 0x5f, 0x3e, 0x1e, 0xd0, 0xbf, 0xe1, 0xa9, 0xd3, + 0x8f, 0x2e, 0x2c, 0xbe, 0x1f, 0x78, 0xe3, 0x8d, 0x36, 0x0c, 0xf1, 0xa1, 0x7d, 0xee, 0x25, 0x18, + 0x9e, 0x59, 0x0d, 0x8f, 0x33, 0xf1, 0x20, 0x87, 0x4a, 0x99, 0x8d, 0xe5, 0x17, 0x84, 0x8f, 0xb6, + 0x88, 0x1c, 0xc0, 0x3b, 0x84, 0x87, 0x7a, 0x33, 0x9b, 0x28, 0x51, 0x4f, 0x9a, 0x35, 0x27, 0xdc, + 0xaa, 0x1c, 0xd3, 0x90, 0xb6, 0x71, 0xd0, 0x26, 0x0e, 0xea, 0xe2, 0xa0, 0x0f, 0x41, 0xaa, 0xd1, + 0x49, 0xc3, 0xf5, 0xe9, 0xc7, 0xc1, 0xdd, 0x54, 0x9a, 0xf3, 0x2a, 0xa6, 0x09, 0xe4, 0xec, 0x91, + 0x54, 0x3a, 0x39, 0x97, 0x9c, 0x9d, 0xb9, 0xe2, 0x9e, 0x3e, 0x7d, 0xcd, 0xcc, 0xbc, 0x10, 0xda, + 0x7e, 0x34, 0xbe, 0xf6, 0xc7, 0xf0, 0x99, 0xa8, 0x9b, 0x4e, 0xcb, 0x74, 0xfc, 0x71, 0x07, 0x5f, + 0xb4, 0xc4, 0x04, 0xf0, 0xae, 0xdb, 0x9c, 0x1c, 0x75, 0x03, 0xe9, 0x09, 0xd7, 0x0f, 0xb7, 0x49, + 0xda, 0x3d, 0xc3, 0x9b, 0x6f, 0xbf, 0xfe, 0xfa, 0xb0, 0x73, 0x9d, 0x0c, 0x58, 0xe7, 0x74, 0x2e, + 0x50, 0xf2, 0x19, 0xe1, 0xa1, 0xcd, 0xa9, 0x21, 0xaa, 0xca, 0x52, 0xa8, 0xc4, 0x3e, 0xf1, 0x44, + 0xe6, 0xd2, 0x10, 0xda, 0x63, 0xb0, 0x25, 0x7a, 0x9f, 0xfd, 0xb7, 0xde, 0xd1, 0x31, 0x4b, 0x77, + 0x87, 0xdc, 0xea, 0xa1, 0xeb, 0x3b, 0xcc, 0xe8, 0xf1, 0x62, 0x15, 0xa0, 0xe5, 0x2a, 0x40, 0x3f, + 0x57, 0x01, 0x7a, 0xbf, 0x0e, 0xbc, 0xe5, 0x3a, 0xf0, 0xbe, 0xad, 0x03, 0xef, 0x15, 0xfd, 0xe7, + 0x25, 0xde, 0x38, 0x03, 0x7b, 0x91, 0xf8, 0x92, 0xfd, 0x6f, 0x4f, 0x7e, 0x07, 0x00, 0x00, 0xff, + 0xff, 0xb5, 0xb0, 0x8d, 0x67, 0x4f, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -399,17 +391,7 @@ func (m *QuerySwappedResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l { - size, err := m.NewCoinAmount.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size, err := m.OldCoinAmount.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Swapped.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -503,9 +485,7 @@ func (m *QuerySwappedResponse) Size() (n int) { } var l int _ = l - l = m.OldCoinAmount.Size() - n += 1 + l + sovQuery(uint64(l)) - l = m.NewCoinAmount.Size() + l = m.Swapped.Size() n += 1 + l + sovQuery(uint64(l)) return n } @@ -617,40 +597,7 @@ func (m *QuerySwappedResponse) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OldCoinAmount", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.OldCoinAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NewCoinAmount", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Swapped", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -677,7 +624,7 @@ func (m *QuerySwappedResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.NewCoinAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Swapped.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex From 4c1b61a9ce68164240d8537886726990ffa72869 Mon Sep 17 00:00:00 2001 From: 170210 Date: Wed, 17 Apr 2024 18:44:29 +0900 Subject: [PATCH 16/17] fix: fix NewKeeper Signed-off-by: 170210 --- x/fswap/keeper/keeper.go | 33 ++++++++++++++------------------- x/fswap/keeper/params.go | 2 +- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/x/fswap/keeper/keeper.go b/x/fswap/keeper/keeper.go index e81236cf43..329b87cf80 100644 --- a/x/fswap/keeper/keeper.go +++ b/x/fswap/keeper/keeper.go @@ -6,36 +6,31 @@ import ( "github.com/tendermint/tendermint/libs/log" "github.com/Finschia/finschia-sdk/codec" + storetypes "github.com/Finschia/finschia-sdk/store/types" sdk "github.com/Finschia/finschia-sdk/types" "github.com/Finschia/finschia-sdk/x/fswap/types" - paramtypes "github.com/Finschia/finschia-sdk/x/params/types" ) type ( Keeper struct { - cdc codec.BinaryCodec - storeKey sdk.StoreKey - memKey sdk.StoreKey - paramstore paramtypes.Subspace + cdc codec.BinaryCodec + accountKeeper types.AccountKeeper + bankKeeper types.BankKeeper + storeKey storetypes.StoreKey } ) func NewKeeper( cdc codec.BinaryCodec, - storeKey, - memKey sdk.StoreKey, - ps paramtypes.Subspace, -) *Keeper { - // set KeyTable if it has not already been set - if !ps.HasKeyTable() { - ps = ps.WithKeyTable(types.ParamKeyTable()) - } - - return &Keeper{ - cdc: cdc, - storeKey: storeKey, - memKey: memKey, - paramstore: ps, + ak types.AccountKeeper, + bk types.BankKeeper, + storeKey storetypes.StoreKey, +) Keeper { + return Keeper{ + cdc: cdc, + accountKeeper: ak, + bankKeeper: bk, + storeKey: storeKey, } } diff --git a/x/fswap/keeper/params.go b/x/fswap/keeper/params.go index 77d2823f2e..5a539d551a 100644 --- a/x/fswap/keeper/params.go +++ b/x/fswap/keeper/params.go @@ -12,5 +12,5 @@ func (k Keeper) GetParams(ctx sdk.Context) types.Params { // SetParams set the params func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { - k.paramstore.SetParamSet(ctx, ¶ms) + // k.paramstore.SetParamSet(ctx, ¶ms) } From fea7a938288d7b733370961e6c77a66f6b90fc3b Mon Sep 17 00:00:00 2001 From: 170210 Date: Thu, 18 Apr 2024 14:13:03 +0900 Subject: [PATCH 17/17] fix: fix for comment Signed-off-by: 170210 --- x/fswap/module.go | 5 ----- x/fswap/types/params.go | 14 -------------- 2 files changed, 19 deletions(-) diff --git a/x/fswap/module.go b/x/fswap/module.go index 4992b043fe..0e60e1d03d 100644 --- a/x/fswap/module.go +++ b/x/fswap/module.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -69,10 +68,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod return genState.Validate() } -// RegisterRESTRoutes registers the capability module's REST service handlers. -func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { -} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { // this line is used by starport scaffolding # 2 diff --git a/x/fswap/types/params.go b/x/fswap/types/params.go index f3d55e7f9e..f4b9ae24dc 100644 --- a/x/fswap/types/params.go +++ b/x/fswap/types/params.go @@ -2,17 +2,8 @@ package types import ( "gopkg.in/yaml.v2" - - paramtypes "github.com/Finschia/finschia-sdk/x/params/types" ) -var _ paramtypes.ParamSet = (*Params)(nil) - -// ParamKeyTable the param key table for launch module -func ParamKeyTable() paramtypes.KeyTable { - return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) -} - // NewParams creates a new Params instance func NewParams() Params { return Params{} @@ -23,11 +14,6 @@ func DefaultParams() Params { return NewParams() } -// ParamSetPairs get the params.ParamSet -func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{} -} - // Validate validates the set of params func (p Params) Validate() error { return nil